OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "chrome/browser/chromeos/login/easy_unlock/bootstrap_user_context_initi
alizer.h" | 8 #include "chrome/browser/chromeos/login/easy_unlock/bootstrap_user_context_initi
alizer.h" |
9 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 9 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
10 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" | 10 #include "chrome/browser/chromeos/login/session/user_session_manager_test_api.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 : callback_(callback) { | 50 : callback_(callback) { |
51 BootstrapUserContextInitializer::SetCompleteCallbackForTesting(&callback_); | 51 BootstrapUserContextInitializer::SetCompleteCallbackForTesting(&callback_); |
52 } | 52 } |
53 | 53 |
54 ScopedCompleteCallbackForTesting::~ScopedCompleteCallbackForTesting() { | 54 ScopedCompleteCallbackForTesting::~ScopedCompleteCallbackForTesting() { |
55 BootstrapUserContextInitializer::SetCompleteCallbackForTesting(NULL); | 55 BootstrapUserContextInitializer::SetCompleteCallbackForTesting(NULL); |
56 } | 56 } |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 class BootstrapTest : public OobeBaseTest { | 60 // Boolean parameter is used to run this test for webview (true) and for |
| 61 // iframe (false) GAIA sign in. |
| 62 class BootstrapTest : public OobeBaseTest, |
| 63 public testing::WithParamInterface<bool> { |
61 public: | 64 public: |
| 65 BootstrapTest() { set_use_webview(GetParam()); } |
| 66 |
62 void SetUpCommandLine(base::CommandLine* command_line) override { | 67 void SetUpCommandLine(base::CommandLine* command_line) override { |
63 OobeBaseTest::SetUpCommandLine(command_line); | 68 OobeBaseTest::SetUpCommandLine(command_line); |
64 | 69 |
65 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 70 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
66 proximity_auth::switches::kForceLoadEasyUnlockAppInTests); | 71 proximity_auth::switches::kForceLoadEasyUnlockAppInTests); |
67 | 72 |
68 const GURL& server_url = embedded_test_server()->base_url(); | 73 const GURL& server_url = embedded_test_server()->base_url(); |
69 GURL::Replacements replace_host; | 74 GURL::Replacements replace_host; |
70 replace_host.SetHostStr("eafe"); | 75 replace_host.SetHostStr("eafe"); |
71 GURL eafe_url = server_url.ReplaceComponents(replace_host); | 76 GURL eafe_url = server_url.ReplaceComponents(replace_host); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 EXPECT_TRUE(success); | 127 EXPECT_TRUE(success); |
123 SetExpectedCredentials(user_context); | 128 SetExpectedCredentials(user_context); |
124 } | 129 } |
125 | 130 |
126 void EafeLogin() { | 131 void EafeLogin() { |
127 StartSignInScreen(); | 132 StartSignInScreen(); |
128 JsExecute("cr.ui.Oobe.handleAccelerator('toggle_easy_bootstrap');"); | 133 JsExecute("cr.ui.Oobe.handleAccelerator('toggle_easy_bootstrap');"); |
129 } | 134 } |
130 }; | 135 }; |
131 | 136 |
132 IN_PROC_BROWSER_TEST_F(BootstrapTest, Basic) { | 137 IN_PROC_BROWSER_TEST_P(BootstrapTest, Basic) { |
133 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( | 138 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( |
134 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); | 139 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); |
135 | 140 |
136 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_success"); | 141 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_success"); |
137 | 142 |
138 EafeLogin(); | 143 EafeLogin(); |
139 | 144 |
140 content::WindowedNotificationObserver( | 145 content::WindowedNotificationObserver( |
141 chrome::NOTIFICATION_SESSION_STARTED, | 146 chrome::NOTIFICATION_SESSION_STARTED, |
142 content::NotificationService::AllSources()).Wait(); | 147 content::NotificationService::AllSources()).Wait(); |
143 } | 148 } |
144 | 149 |
145 IN_PROC_BROWSER_TEST_F(BootstrapTest, PRE_CleanUpFailedUser) { | 150 IN_PROC_BROWSER_TEST_P(BootstrapTest, PRE_CleanUpFailedUser) { |
146 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( | 151 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( |
147 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); | 152 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); |
148 | 153 |
149 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_failure"); | 154 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_failure"); |
150 | 155 |
151 EafeLogin(); | 156 EafeLogin(); |
152 | 157 |
153 // Failed bootstrap should attempt exit and get out of this loop. | 158 // Failed bootstrap should attempt exit and get out of this loop. |
154 content::RunMessageLoop(); | 159 content::RunMessageLoop(); |
155 } | 160 } |
156 | 161 |
157 IN_PROC_BROWSER_TEST_F(BootstrapTest, CleanUpFailedUser) { | 162 IN_PROC_BROWSER_TEST_P(BootstrapTest, CleanUpFailedUser) { |
158 EXPECT_FALSE(user_manager::UserManager::Get()->IsKnownUser(kFakeUser)); | 163 EXPECT_FALSE(user_manager::UserManager::Get()->IsKnownUser(kFakeUser)); |
159 } | 164 } |
160 | 165 |
| 166 // TODO(nkostylev): Fix this test for webview. http://crbug.com/477402 |
| 167 INSTANTIATE_TEST_CASE_P(BootstrapTestSuite, |
| 168 BootstrapTest, |
| 169 testing::Values(false)); |
| 170 |
161 } // namespace chromeos | 171 } // namespace chromeos |
OLD | NEW |