Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/login/wizard_controller.h" | 5 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/json/json_file_value_serializer.h" | |
| 11 #include "base/path_service.h" | |
| 10 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 12 #include "base/prefs/pref_service_factory.h" | 14 #include "base/prefs/pref_service_factory.h" |
| 13 #include "base/prefs/testing_pref_store.h" | 15 #include "base/prefs/testing_pref_store.h" |
| 14 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/browser_shutdown.h" | 20 #include "chrome/browser/browser_shutdown.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 41 #include "chrome/browser/chromeos/login/test/wizard_in_process_browser_test.h" | 43 #include "chrome/browser/chromeos/login/test/wizard_in_process_browser_test.h" |
| 42 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 44 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 43 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 45 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 44 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | 46 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
| 45 #include "chrome/browser/chromeos/policy/enrollment_config.h" | 47 #include "chrome/browser/chromeos/policy/enrollment_config.h" |
| 46 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" | 48 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" |
| 47 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | 49 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" |
| 48 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 50 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 49 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 51 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 50 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 52 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 53 #include "chrome/common/chrome_constants.h" | |
| 51 #include "chrome/common/chrome_paths.h" | 54 #include "chrome/common/chrome_paths.h" |
| 52 #include "chrome/common/chrome_switches.h" | 55 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/pref_names.h" | 56 #include "chrome/common/pref_names.h" |
| 54 #include "chrome/grit/generated_resources.h" | 57 #include "chrome/grit/generated_resources.h" |
| 55 #include "chromeos/audio/cras_audio_handler.h" | 58 #include "chromeos/audio/cras_audio_handler.h" |
| 56 #include "chromeos/chromeos_switches.h" | 59 #include "chromeos/chromeos_switches.h" |
| 57 #include "chromeos/chromeos_test_utils.h" | 60 #include "chromeos/chromeos_test_utils.h" |
| 58 #include "chromeos/dbus/dbus_thread_manager.h" | 61 #include "chromeos/dbus/dbus_thread_manager.h" |
| 59 #include "chromeos/dbus/fake_session_manager_client.h" | 62 #include "chromeos/dbus/fake_session_manager_client.h" |
| 60 #include "chromeos/geolocation/simple_geolocation_provider.h" | 63 #include "chromeos/geolocation/simple_geolocation_provider.h" |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 ASSERT_TRUE(JSExecuteBooleanExpression("$('login-header-bar').hidden")); | 961 ASSERT_TRUE(JSExecuteBooleanExpression("$('login-header-bar').hidden")); |
| 959 | 962 |
| 960 // Emulates user click on the "Restart and Powerwash" button. | 963 // Emulates user click on the "Restart and Powerwash" button. |
| 961 ASSERT_EQ(0, fake_session_manager_client()->start_device_wipe_call_count()); | 964 ASSERT_EQ(0, fake_session_manager_client()->start_device_wipe_call_count()); |
| 962 ASSERT_TRUE(content::ExecuteScript( | 965 ASSERT_TRUE(content::ExecuteScript( |
| 963 GetWebContents(), | 966 GetWebContents(), |
| 964 "$('error-message-restart-and-powerwash-button').click();")); | 967 "$('error-message-restart-and-powerwash-button').click();")); |
| 965 ASSERT_EQ(1, fake_session_manager_client()->start_device_wipe_call_count()); | 968 ASSERT_EQ(1, fake_session_manager_client()->start_device_wipe_call_count()); |
| 966 } | 969 } |
| 967 | 970 |
| 968 class WizardControllerProxyAuthOnSigninTest : public WizardControllerTest { | 971 class WizardControllerProxyAuthOnSigninTest |
| 972 : public WizardControllerTest, | |
| 973 public testing::WithParamInterface<bool> { | |
|
dzhioev (left Google)
2015/04/15 17:36:25
nit: please put a comment here on the parameter me
Nikita (slow)
2015/04/15 18:35:42
Done.
| |
| 969 protected: | 974 protected: |
| 970 WizardControllerProxyAuthOnSigninTest() | 975 WizardControllerProxyAuthOnSigninTest() |
| 971 : proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, | 976 : proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, |
| 972 net::SpawnedTestServer::kLocalhost, | 977 net::SpawnedTestServer::kLocalhost, |
| 973 base::FilePath()) { | 978 base::FilePath()) { |
| 974 } | 979 } |
| 975 ~WizardControllerProxyAuthOnSigninTest() override {} | 980 ~WizardControllerProxyAuthOnSigninTest() override {} |
| 976 | 981 |
| 977 // Overridden from WizardControllerTest: | 982 // Overridden from WizardControllerTest: |
| 978 void SetUp() override { | 983 void SetUp() override { |
| 979 ASSERT_TRUE(proxy_server_.Start()); | 984 ASSERT_TRUE(proxy_server_.Start()); |
| 980 WizardControllerTest::SetUp(); | 985 WizardControllerTest::SetUp(); |
| 981 } | 986 } |
| 982 | 987 |
| 983 void SetUpOnMainThread() override { | 988 void SetUpOnMainThread() override { |
| 984 WizardControllerTest::SetUpOnMainThread(); | 989 WizardControllerTest::SetUpOnMainThread(); |
| 985 WizardController::default_controller()->AdvanceToScreen( | 990 WizardController::default_controller()->AdvanceToScreen( |
| 986 WizardController::kNetworkScreenName); | 991 WizardController::kNetworkScreenName); |
| 987 } | 992 } |
| 988 | 993 |
| 989 void SetUpCommandLine(base::CommandLine* command_line) override { | 994 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 990 command_line->AppendSwitchASCII(::switches::kProxyServer, | 995 command_line->AppendSwitchASCII(::switches::kProxyServer, |
| 991 proxy_server_.host_port_pair().ToString()); | 996 proxy_server_.host_port_pair().ToString()); |
| 992 } | 997 } |
| 993 | 998 |
| 999 bool SetUpUserDataDirectory() override { | |
| 1000 base::FilePath user_data_dir; | |
| 1001 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | |
| 1002 base::FilePath local_state_path = | |
| 1003 user_data_dir.Append(chrome::kLocalStateFilename); | |
| 1004 | |
| 1005 // Set webview disabled flag only when local state file does not exist. | |
| 1006 // Otherwise, we break PRE tests that leave state in it. | |
| 1007 if (!base::PathExists(local_state_path)) { | |
| 1008 base::DictionaryValue local_state_dict; | |
| 1009 | |
| 1010 if (!GetParam()) | |
| 1011 local_state_dict.SetBoolean(prefs::kWebviewSigninDisabled, true); | |
| 1012 | |
| 1013 // TODO(paulmeyer): Re-enable webview version of this test | |
| 1014 // (drop this condition) once http://crbug.com/452452 is fixed. | |
| 1015 if (GetParam()) | |
| 1016 local_state_dict.SetBoolean(prefs::kWebviewSigninDisabled, true); | |
| 1017 | |
| 1018 CHECK(JSONFileValueSerializer(local_state_path) | |
| 1019 .Serialize(local_state_dict)); | |
| 1020 } | |
| 1021 | |
| 1022 return WizardControllerTest::SetUpUserDataDirectory(); | |
| 1023 } | |
| 1024 | |
| 994 net::SpawnedTestServer& proxy_server() { return proxy_server_; } | 1025 net::SpawnedTestServer& proxy_server() { return proxy_server_; } |
| 995 | 1026 |
| 996 private: | 1027 private: |
| 997 net::SpawnedTestServer proxy_server_; | 1028 net::SpawnedTestServer proxy_server_; |
| 998 | 1029 |
| 999 DISALLOW_COPY_AND_ASSIGN(WizardControllerProxyAuthOnSigninTest); | 1030 DISALLOW_COPY_AND_ASSIGN(WizardControllerProxyAuthOnSigninTest); |
| 1000 }; | 1031 }; |
| 1001 | 1032 |
| 1002 IN_PROC_BROWSER_TEST_F(WizardControllerProxyAuthOnSigninTest, | 1033 IN_PROC_BROWSER_TEST_P(WizardControllerProxyAuthOnSigninTest, |
| 1003 ProxyAuthDialogOnSigninScreen) { | 1034 ProxyAuthDialogOnSigninScreen) { |
| 1004 content::WindowedNotificationObserver auth_needed_waiter( | 1035 content::WindowedNotificationObserver auth_needed_waiter( |
| 1005 chrome::NOTIFICATION_AUTH_NEEDED, | 1036 chrome::NOTIFICATION_AUTH_NEEDED, |
| 1006 content::NotificationService::AllSources()); | 1037 content::NotificationService::AllSources()); |
| 1007 | 1038 |
| 1008 CheckCurrentScreen(WizardController::kNetworkScreenName); | 1039 CheckCurrentScreen(WizardController::kNetworkScreenName); |
| 1009 | 1040 |
| 1010 LoginDisplayHostImpl::default_host()->StartSignInScreen(LoginScreenContext()); | 1041 LoginDisplayHostImpl::default_host()->StartSignInScreen(LoginScreenContext()); |
| 1011 auth_needed_waiter.Wait(); | 1042 auth_needed_waiter.Wait(); |
| 1012 } | 1043 } |
| 1013 | 1044 |
| 1045 INSTANTIATE_TEST_CASE_P(WizardControllerProxyAuthOnSigninSuite, | |
| 1046 WizardControllerProxyAuthOnSigninTest, | |
| 1047 testing::Bool()); | |
| 1048 | |
| 1014 class WizardControllerKioskFlowTest : public WizardControllerFlowTest { | 1049 class WizardControllerKioskFlowTest : public WizardControllerFlowTest { |
| 1015 protected: | 1050 protected: |
| 1016 WizardControllerKioskFlowTest() {} | 1051 WizardControllerKioskFlowTest() {} |
| 1017 | 1052 |
| 1018 // Overridden from InProcessBrowserTest: | 1053 // Overridden from InProcessBrowserTest: |
| 1019 void SetUpCommandLine(base::CommandLine* command_line) override { | 1054 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 1020 base::FilePath test_data_dir; | 1055 base::FilePath test_data_dir; |
| 1021 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath( | 1056 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath( |
| 1022 "app_mode", "kiosk_manifest", &test_data_dir)); | 1057 "app_mode", "kiosk_manifest", &test_data_dir)); |
| 1023 command_line->AppendSwitchPath( | 1058 command_line->AppendSwitchPath( |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1229 // TODO(merkulova): Add tests for bluetooth HID detection screen variations when | 1264 // TODO(merkulova): Add tests for bluetooth HID detection screen variations when |
| 1230 // UI and logic is ready. http://crbug.com/127016 | 1265 // UI and logic is ready. http://crbug.com/127016 |
| 1231 | 1266 |
| 1232 // TODO(dzhioev): Add tests for controller/host pairing flow. | 1267 // TODO(dzhioev): Add tests for controller/host pairing flow. |
| 1233 // http://crbug.com/375191 | 1268 // http://crbug.com/375191 |
| 1234 | 1269 |
| 1235 static_assert(BaseScreenDelegate::EXIT_CODES_COUNT == 24, | 1270 static_assert(BaseScreenDelegate::EXIT_CODES_COUNT == 24, |
| 1236 "tests for new control flow are missing"); | 1271 "tests for new control flow are missing"); |
| 1237 | 1272 |
| 1238 } // namespace chromeos | 1273 } // namespace chromeos |
| OLD | NEW |