This source file includes following definitions.
- SetUpCommandLine
- SetUpOnMainThread
- CleanUpOnMainThread
- GetLoginDisplay
- GetLoginWindowWidget
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "base/command_line.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
#include "chrome/browser/chromeos/login/webui_login_display.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/test/test_utils.h"
#include "google_apis/gaia/fake_gaia.h"
#include "google_apis/gaia/gaia_switches.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_response.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/test/ui_controls.h"
#include "ui/views/widget/widget.h"
using namespace net::test_server;
namespace chromeos {
class OobeTest : public InProcessBrowserTest {
public:
OobeTest() {}
virtual ~OobeTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(chromeos::switches::kLoginManager);
command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests);
command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
command_line->AppendSwitchASCII(
::switches::kAuthExtensionPath, "gaia_auth");
fake_gaia_.Initialize();
}
virtual void SetUpOnMainThread() OVERRIDE {
CHECK(embedded_test_server()->InitializeAndWaitUntilReady());
embedded_test_server()->RegisterRequestHandler(
base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_)));
LOG(INFO) << "Set up http server at " << embedded_test_server()->base_url();
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
::switches::kGaiaUrl, embedded_test_server()->base_url().spec());
}
virtual void CleanUpOnMainThread() OVERRIDE {
if (LoginDisplayHostImpl::default_host()) {
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&chrome::AttemptExit));
content::RunMessageLoop();
}
}
chromeos::WebUILoginDisplay* GetLoginDisplay() {
chromeos::ExistingUserController* controller =
chromeos::ExistingUserController::current_controller();
CHECK(controller);
return static_cast<chromeos::WebUILoginDisplay*>(
controller->login_display());
}
views::Widget* GetLoginWindowWidget() {
return static_cast<chromeos::LoginDisplayHostImpl*>(
chromeos::LoginDisplayHostImpl::default_host())
->login_window_for_test();
}
private:
FakeGaia fake_gaia_;
DISALLOW_COPY_AND_ASSIGN(OobeTest);
};
IN_PROC_BROWSER_TEST_F(OobeTest, DISABLED_NewUser) {
chromeos::WizardController::SkipPostLoginScreensForTesting();
chromeos::WizardController* wizard_controller =
chromeos::WizardController::default_controller();
CHECK(wizard_controller);
wizard_controller->SkipToLoginForTesting(LoginScreenContext());
content::WindowedNotificationObserver(
chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
content::NotificationService::AllSources()).Wait();
GetLoginDisplay()->ShowSigninScreenForCreds("username", "password");
content::WindowedNotificationObserver(
chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources()).Wait();
}
IN_PROC_BROWSER_TEST_F(OobeTest, Accelerator) {
chromeos::WizardController::SkipPostLoginScreensForTesting();
chromeos::WizardController* wizard_controller =
chromeos::WizardController::default_controller();
CHECK(wizard_controller);
wizard_controller->SkipToLoginForTesting(LoginScreenContext());
content::WindowedNotificationObserver(
chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
content::NotificationService::AllSources()).Wait();
gfx::NativeWindow login_window = GetLoginWindowWidget()->GetNativeWindow();
ui_controls::SendKeyPress(login_window,
ui::VKEY_E,
true,
false,
true,
false);
OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_ENROLLMENT).Wait();
}
}