Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/chromeos/login/oobe_browsertest.cc

Issue 1079083002: [cros New-GAIA] Webview login and new GAIA endpoint enabled by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/chrome_notification_types.h" 6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/chromeos/login/existing_user_controller.h" 7 #include "chrome/browser/chromeos/login/existing_user_controller.h"
8 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
8 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" 9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
9 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 10 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
10 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" 11 #include "chrome/browser/chromeos/login/ui/webui_login_display.h"
11 #include "chrome/browser/chromeos/login/wizard_controller.h" 12 #include "chrome/browser/chromeos/login/wizard_controller.h"
12 #include "chrome/browser/lifetime/application_lifetime.h" 13 #include "chrome/browser/lifetime/application_lifetime.h"
13 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 14 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
15 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chromeos/chromeos_switches.h" 17 #include "chromeos/chromeos_switches.h"
18 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
18 #include "google_apis/gaia/fake_gaia.h"
19 #include "google_apis/gaia/gaia_switches.h" 20 #include "google_apis/gaia/gaia_switches.h"
20 #include "net/test/embedded_test_server/embedded_test_server.h" 21 #include "net/test/embedded_test_server/embedded_test_server.h"
21 #include "net/test/embedded_test_server/http_response.h" 22 #include "net/test/embedded_test_server/http_response.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 #include "ui/base/test/ui_controls.h" 24 #include "ui/base/test/ui_controls.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 26
26 using namespace net::test_server; 27 using namespace net::test_server;
27 28
28 namespace chromeos { 29 namespace chromeos {
29 30
30 class OobeTest : public InProcessBrowserTest { 31 namespace {
32 const char kFakeUserEmail[] = "fake-email@gmail.com";
33 const char kFakeUserPassword[] = "fake-password";
34 const char kFakeSIDCookie[] = "fake-SID-cookie";
35 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.
36 }
37
38 class OobeTest : public OobeBaseTest, public testing::WithParamInterface<bool> {
31 public: 39 public:
32 OobeTest() {} 40 OobeTest() { use_webview_ = GetParam(); }
33 ~OobeTest() override {} 41 ~OobeTest() override {}
34 42
35 void SetUpCommandLine(base::CommandLine* command_line) override { 43 void SetUpCommandLine(base::CommandLine* command_line) override {
36 command_line->AppendSwitch(chromeos::switches::kLoginManager); 44 command_line->AppendSwitch(switches::kOobeSkipPostLogin);
37 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); 45
38 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 46 OobeBaseTest::SetUpCommandLine(command_line);
39 command_line->AppendSwitchASCII(
40 ::switches::kAuthExtensionPath, "gaia_auth");
41 fake_gaia_.Initialize();
42 } 47 }
43 48
44 void SetUpOnMainThread() override { 49 void SetUpOnMainThread() override {
45 CHECK(embedded_test_server()->InitializeAndWaitUntilReady()); 50 fake_gaia_->SetFakeMergeSessionParams(kFakeUserEmail, kFakeSIDCookie,
46 embedded_test_server()->RegisterRequestHandler( 51 kFakeLSIDCookie);
47 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_)));
48 LOG(INFO) << "Set up http server at " << embedded_test_server()->base_url();
49 52
50 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 53 OobeBaseTest::SetUpOnMainThread();
51 ::switches::kGaiaUrl, embedded_test_server()->base_url().spec());
52 } 54 }
53 55
54 void TearDownOnMainThread() override { 56 void TearDownOnMainThread() override {
55 // If the login display is still showing, exit gracefully. 57 // If the login display is still showing, exit gracefully.
56 if (LoginDisplayHostImpl::default_host()) { 58 if (LoginDisplayHostImpl::default_host()) {
57 base::MessageLoop::current()->PostTask(FROM_HERE, 59 base::MessageLoop::current()->PostTask(FROM_HERE,
58 base::Bind(&chrome::AttemptExit)); 60 base::Bind(&chrome::AttemptExit));
59 content::RunMessageLoop(); 61 content::RunMessageLoop();
60 } 62 }
63
64 OobeBaseTest::TearDownOnMainThread();
61 } 65 }
62 66
63 chromeos::WebUILoginDisplay* GetLoginDisplay() { 67 chromeos::WebUILoginDisplay* GetLoginDisplay() {
64 chromeos::ExistingUserController* controller = 68 chromeos::ExistingUserController* controller =
65 chromeos::ExistingUserController::current_controller(); 69 chromeos::ExistingUserController::current_controller();
66 CHECK(controller); 70 CHECK(controller);
67 return static_cast<chromeos::WebUILoginDisplay*>( 71 return static_cast<chromeos::WebUILoginDisplay*>(
68 controller->login_display()); 72 controller->login_display());
69 } 73 }
70 74
71 views::Widget* GetLoginWindowWidget() { 75 views::Widget* GetLoginWindowWidget() {
72 return static_cast<chromeos::LoginDisplayHostImpl*>( 76 return static_cast<chromeos::LoginDisplayHostImpl*>(
73 chromeos::LoginDisplayHostImpl::default_host()) 77 chromeos::LoginDisplayHostImpl::default_host())
74 ->login_window_for_test(); 78 ->login_window_for_test();
75 } 79 }
76 80
77 private: 81 private:
78 FakeGaia fake_gaia_;
79 DISALLOW_COPY_AND_ASSIGN(OobeTest); 82 DISALLOW_COPY_AND_ASSIGN(OobeTest);
80 }; 83 };
81 84
82 IN_PROC_BROWSER_TEST_F(OobeTest, NewUser) { 85 IN_PROC_BROWSER_TEST_P(OobeTest, NewUser) {
83 chromeos::WizardController::SkipPostLoginScreensForTesting(); 86 WaitForGaiaPageLoad();
84 chromeos::WizardController* wizard_controller =
85 chromeos::WizardController::default_controller();
86 CHECK(wizard_controller);
87 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
88 87
89 content::WindowedNotificationObserver( 88 content::WindowedNotificationObserver session_start_waiter(
90 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 89 chrome::NOTIFICATION_SESSION_STARTED,
91 content::NotificationService::AllSources()).Wait(); 90 content::NotificationService::AllSources());
92 91
93 // TODO(glotov): mock GAIA server (test_server()) should support 92 GetLoginDisplay()->ShowSigninScreenForCreds(kFakeUserEmail,
94 // username/password configuration. 93 kFakeUserPassword);
95 GetLoginDisplay()->ShowSigninScreenForCreds("username", "password");
96 94
97 content::WindowedNotificationObserver( 95 session_start_waiter.Wait();
98 chrome::NOTIFICATION_SESSION_STARTED,
99 content::NotificationService::AllSources()).Wait();
100 } 96 }
101 97
102 IN_PROC_BROWSER_TEST_F(OobeTest, Accelerator) { 98 IN_PROC_BROWSER_TEST_P(OobeTest, Accelerator) {
103 chromeos::WizardController::SkipPostLoginScreensForTesting(); 99 WaitForGaiaPageLoad();
104 chromeos::WizardController* wizard_controller =
105 chromeos::WizardController::default_controller();
106 CHECK(wizard_controller);
107 wizard_controller->SkipToLoginForTesting(LoginScreenContext());
108
109 content::WindowedNotificationObserver(
110 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
111 content::NotificationService::AllSources()).Wait();
112 100
113 gfx::NativeWindow login_window = GetLoginWindowWidget()->GetNativeWindow(); 101 gfx::NativeWindow login_window = GetLoginWindowWidget()->GetNativeWindow();
114 102
115 ui_controls::SendKeyPress(login_window, 103 ui_controls::SendKeyPress(login_window,
116 ui::VKEY_E, 104 ui::VKEY_E,
117 true, // control 105 true, // control
118 false, // shift 106 false, // shift
119 true, // alt 107 true, // alt
120 false); // command 108 false); // command
121 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_ENROLLMENT).Wait(); 109 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_ENROLLMENT).Wait();
122 } 110 }
123 111
112 INSTANTIATE_TEST_CASE_P(OobeSuite, OobeTest, testing::Bool());
113
124 } // namespace chromeos 114 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698