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