Chromium Code Reviews| Index: chrome/browser/chromeos/login/oobe_browsertest.cc |
| diff --git a/chrome/browser/chromeos/login/oobe_browsertest.cc b/chrome/browser/chromeos/login/oobe_browsertest.cc |
| index da7e59675c29d921398277e7fc693866f518c852..e9f9e76a328a0e4b2907dcae337815677aa26643 100644 |
| --- a/chrome/browser/chromeos/login/oobe_browsertest.cc |
| +++ b/chrome/browser/chromeos/login/oobe_browsertest.cc |
| @@ -5,6 +5,7 @@ |
| #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/test/oobe_base_test.h" |
| #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| @@ -14,8 +15,8 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chromeos/chromeos_switches.h" |
| +#include "content/public/test/browser_test_utils.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" |
| @@ -27,28 +28,29 @@ using namespace net::test_server; |
| namespace chromeos { |
| -class OobeTest : public InProcessBrowserTest { |
| +namespace { |
| +const char kFakeUserEmail[] = "fake-email@gmail.com"; |
| +const char kFakeUserPassword[] = "fake-password"; |
| +const char kFakeSIDCookie[] = "fake-SID-cookie"; |
| +const char kFakeLSIDCookie[] = "fake-LSID-cookie"; |
|
dzhioev (left Google)
2015/04/15 17:36:25
What this cookies are needed for? I see that we se
Nikita (slow)
2015/04/15 18:35:42
Done.
|
| +} |
| + |
| +class OobeTest : public OobeBaseTest, public testing::WithParamInterface<bool> { |
| public: |
| - OobeTest() {} |
| + OobeTest() { use_webview_ = GetParam(); } |
| ~OobeTest() override {} |
| void SetUpCommandLine(base::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(); |
| + command_line->AppendSwitch(switches::kOobeSkipPostLogin); |
| + |
| + OobeBaseTest::SetUpCommandLine(command_line); |
| } |
| 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(); |
| + fake_gaia_->SetFakeMergeSessionParams(kFakeUserEmail, kFakeSIDCookie, |
| + kFakeLSIDCookie); |
| - base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| - ::switches::kGaiaUrl, embedded_test_server()->base_url().spec()); |
| + OobeBaseTest::SetUpOnMainThread(); |
| } |
| void TearDownOnMainThread() override { |
| @@ -58,6 +60,8 @@ class OobeTest : public InProcessBrowserTest { |
| base::Bind(&chrome::AttemptExit)); |
| content::RunMessageLoop(); |
| } |
| + |
| + OobeBaseTest::TearDownOnMainThread(); |
| } |
| chromeos::WebUILoginDisplay* GetLoginDisplay() { |
| @@ -75,40 +79,24 @@ class OobeTest : public InProcessBrowserTest { |
| } |
| private: |
| - FakeGaia fake_gaia_; |
| DISALLOW_COPY_AND_ASSIGN(OobeTest); |
| }; |
| -IN_PROC_BROWSER_TEST_F(OobeTest, NewUser) { |
| - chromeos::WizardController::SkipPostLoginScreensForTesting(); |
| - chromeos::WizardController* wizard_controller = |
| - chromeos::WizardController::default_controller(); |
| - CHECK(wizard_controller); |
| - wizard_controller->SkipToLoginForTesting(LoginScreenContext()); |
| +IN_PROC_BROWSER_TEST_P(OobeTest, NewUser) { |
| + WaitForGaiaPageLoad(); |
| - content::WindowedNotificationObserver( |
| - chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| - content::NotificationService::AllSources()).Wait(); |
| + content::WindowedNotificationObserver session_start_waiter( |
| + chrome::NOTIFICATION_SESSION_STARTED, |
| + content::NotificationService::AllSources()); |
| - // TODO(glotov): mock GAIA server (test_server()) should support |
| - // username/password configuration. |
| - GetLoginDisplay()->ShowSigninScreenForCreds("username", "password"); |
| + GetLoginDisplay()->ShowSigninScreenForCreds(kFakeUserEmail, |
| + kFakeUserPassword); |
| - content::WindowedNotificationObserver( |
| - chrome::NOTIFICATION_SESSION_STARTED, |
| - content::NotificationService::AllSources()).Wait(); |
| + session_start_waiter.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(); |
| +IN_PROC_BROWSER_TEST_P(OobeTest, Accelerator) { |
| + WaitForGaiaPageLoad(); |
| gfx::NativeWindow login_window = GetLoginWindowWidget()->GetNativeWindow(); |
| @@ -121,4 +109,6 @@ IN_PROC_BROWSER_TEST_F(OobeTest, Accelerator) { |
| OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_ENROLLMENT).Wait(); |
| } |
| +INSTANTIATE_TEST_CASE_P(OobeSuite, OobeTest, testing::Bool()); |
| + |
| } // namespace chromeos |