Chromium Code Reviews| 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() { | |
| 66 // TODO(nkostylev): Fix this test for webview. http://crbug.com/477402 | |
| 67 set_use_webview(false); | |
|
Dmitry Polukhin
2015/04/22 06:47:07
nit, you can make it initialize it with GetParam()
Nikita (slow)
2015/04/22 09:01:44
Done.
| |
| 68 } | |
| 69 | |
| 62 void SetUpCommandLine(base::CommandLine* command_line) override { | 70 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 63 OobeBaseTest::SetUpCommandLine(command_line); | 71 OobeBaseTest::SetUpCommandLine(command_line); |
| 64 | 72 |
| 65 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 73 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 66 proximity_auth::switches::kForceLoadEasyUnlockAppInTests); | 74 proximity_auth::switches::kForceLoadEasyUnlockAppInTests); |
| 67 | 75 |
| 68 const GURL& server_url = embedded_test_server()->base_url(); | 76 const GURL& server_url = embedded_test_server()->base_url(); |
| 69 GURL::Replacements replace_host; | 77 GURL::Replacements replace_host; |
| 70 replace_host.SetHostStr("eafe"); | 78 replace_host.SetHostStr("eafe"); |
| 71 GURL eafe_url = server_url.ReplaceComponents(replace_host); | 79 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); | 130 EXPECT_TRUE(success); |
| 123 SetExpectedCredentials(user_context); | 131 SetExpectedCredentials(user_context); |
| 124 } | 132 } |
| 125 | 133 |
| 126 void EafeLogin() { | 134 void EafeLogin() { |
| 127 StartSignInScreen(); | 135 StartSignInScreen(); |
| 128 JsExecute("cr.ui.Oobe.handleAccelerator('toggle_easy_bootstrap');"); | 136 JsExecute("cr.ui.Oobe.handleAccelerator('toggle_easy_bootstrap');"); |
| 129 } | 137 } |
| 130 }; | 138 }; |
| 131 | 139 |
| 132 IN_PROC_BROWSER_TEST_F(BootstrapTest, Basic) { | 140 IN_PROC_BROWSER_TEST_P(BootstrapTest, Basic) { |
| 133 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( | 141 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( |
| 134 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); | 142 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); |
| 135 | 143 |
| 136 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_success"); | 144 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_success"); |
| 137 | 145 |
| 138 EafeLogin(); | 146 EafeLogin(); |
| 139 | 147 |
| 140 content::WindowedNotificationObserver( | 148 content::WindowedNotificationObserver( |
| 141 chrome::NOTIFICATION_SESSION_STARTED, | 149 chrome::NOTIFICATION_SESSION_STARTED, |
| 142 content::NotificationService::AllSources()).Wait(); | 150 content::NotificationService::AllSources()).Wait(); |
| 143 } | 151 } |
| 144 | 152 |
| 145 IN_PROC_BROWSER_TEST_F(BootstrapTest, PRE_CleanUpFailedUser) { | 153 IN_PROC_BROWSER_TEST_P(BootstrapTest, PRE_CleanUpFailedUser) { |
| 146 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( | 154 ScopedCompleteCallbackForTesting scoped_bootstrap_initialized(base::Bind( |
| 147 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); | 155 &BootstrapTest::OnBootstrapInitialized, base::Unretained(this))); |
| 148 | 156 |
| 149 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_failure"); | 157 SetTestEasyUnlockAppPath("login/easy_unlock/auto_pair_failure"); |
| 150 | 158 |
| 151 EafeLogin(); | 159 EafeLogin(); |
| 152 | 160 |
| 153 // Failed bootstrap should attempt exit and get out of this loop. | 161 // Failed bootstrap should attempt exit and get out of this loop. |
| 154 content::RunMessageLoop(); | 162 content::RunMessageLoop(); |
| 155 } | 163 } |
| 156 | 164 |
| 157 IN_PROC_BROWSER_TEST_F(BootstrapTest, CleanUpFailedUser) { | 165 IN_PROC_BROWSER_TEST_P(BootstrapTest, CleanUpFailedUser) { |
| 158 EXPECT_FALSE(user_manager::UserManager::Get()->IsKnownUser(kFakeUser)); | 166 EXPECT_FALSE(user_manager::UserManager::Get()->IsKnownUser(kFakeUser)); |
| 159 } | 167 } |
| 160 | 168 |
| 169 INSTANTIATE_TEST_CASE_P(BootstrapTestSuite, BootstrapTest, testing::Bool()); | |
| 170 | |
| 161 } // namespace chromeos | 171 } // namespace chromeos |
| OLD | NEW |