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 // Boolean parameter is used to run this test for webview (true) and for |
| 972 // iframe (false) GAIA sign in. |
| 973 class WizardControllerProxyAuthOnSigninTest |
| 974 : public WizardControllerTest, |
| 975 public testing::WithParamInterface<bool> { |
969 protected: | 976 protected: |
970 WizardControllerProxyAuthOnSigninTest() | 977 WizardControllerProxyAuthOnSigninTest() |
971 : proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, | 978 : proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, |
972 net::SpawnedTestServer::kLocalhost, | 979 net::SpawnedTestServer::kLocalhost, |
973 base::FilePath()) { | 980 base::FilePath()) { |
974 } | 981 } |
975 ~WizardControllerProxyAuthOnSigninTest() override {} | 982 ~WizardControllerProxyAuthOnSigninTest() override {} |
976 | 983 |
977 // Overridden from WizardControllerTest: | 984 // Overridden from WizardControllerTest: |
978 void SetUp() override { | 985 void SetUp() override { |
979 ASSERT_TRUE(proxy_server_.Start()); | 986 ASSERT_TRUE(proxy_server_.Start()); |
980 WizardControllerTest::SetUp(); | 987 WizardControllerTest::SetUp(); |
981 } | 988 } |
982 | 989 |
983 void SetUpOnMainThread() override { | 990 void SetUpOnMainThread() override { |
984 WizardControllerTest::SetUpOnMainThread(); | 991 WizardControllerTest::SetUpOnMainThread(); |
985 WizardController::default_controller()->AdvanceToScreen( | 992 WizardController::default_controller()->AdvanceToScreen( |
986 WizardController::kNetworkScreenName); | 993 WizardController::kNetworkScreenName); |
987 } | 994 } |
988 | 995 |
989 void SetUpCommandLine(base::CommandLine* command_line) override { | 996 void SetUpCommandLine(base::CommandLine* command_line) override { |
990 command_line->AppendSwitchASCII(::switches::kProxyServer, | 997 command_line->AppendSwitchASCII(::switches::kProxyServer, |
991 proxy_server_.host_port_pair().ToString()); | 998 proxy_server_.host_port_pair().ToString()); |
992 } | 999 } |
993 | 1000 |
| 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 |
994 net::SpawnedTestServer& proxy_server() { return proxy_server_; } | 1027 net::SpawnedTestServer& proxy_server() { return proxy_server_; } |
995 | 1028 |
996 private: | 1029 private: |
997 net::SpawnedTestServer proxy_server_; | 1030 net::SpawnedTestServer proxy_server_; |
998 | 1031 |
999 DISALLOW_COPY_AND_ASSIGN(WizardControllerProxyAuthOnSigninTest); | 1032 DISALLOW_COPY_AND_ASSIGN(WizardControllerProxyAuthOnSigninTest); |
1000 }; | 1033 }; |
1001 | 1034 |
1002 IN_PROC_BROWSER_TEST_F(WizardControllerProxyAuthOnSigninTest, | 1035 IN_PROC_BROWSER_TEST_P(WizardControllerProxyAuthOnSigninTest, |
1003 ProxyAuthDialogOnSigninScreen) { | 1036 ProxyAuthDialogOnSigninScreen) { |
1004 content::WindowedNotificationObserver auth_needed_waiter( | 1037 content::WindowedNotificationObserver auth_needed_waiter( |
1005 chrome::NOTIFICATION_AUTH_NEEDED, | 1038 chrome::NOTIFICATION_AUTH_NEEDED, |
1006 content::NotificationService::AllSources()); | 1039 content::NotificationService::AllSources()); |
1007 | 1040 |
1008 CheckCurrentScreen(WizardController::kNetworkScreenName); | 1041 CheckCurrentScreen(WizardController::kNetworkScreenName); |
1009 | 1042 |
1010 LoginDisplayHostImpl::default_host()->StartSignInScreen(LoginScreenContext()); | 1043 LoginDisplayHostImpl::default_host()->StartSignInScreen(LoginScreenContext()); |
1011 auth_needed_waiter.Wait(); | 1044 auth_needed_waiter.Wait(); |
1012 } | 1045 } |
1013 | 1046 |
| 1047 INSTANTIATE_TEST_CASE_P(WizardControllerProxyAuthOnSigninSuite, |
| 1048 WizardControllerProxyAuthOnSigninTest, |
| 1049 testing::Bool()); |
| 1050 |
1014 class WizardControllerKioskFlowTest : public WizardControllerFlowTest { | 1051 class WizardControllerKioskFlowTest : public WizardControllerFlowTest { |
1015 protected: | 1052 protected: |
1016 WizardControllerKioskFlowTest() {} | 1053 WizardControllerKioskFlowTest() {} |
1017 | 1054 |
1018 // Overridden from InProcessBrowserTest: | 1055 // Overridden from InProcessBrowserTest: |
1019 void SetUpCommandLine(base::CommandLine* command_line) override { | 1056 void SetUpCommandLine(base::CommandLine* command_line) override { |
1020 base::FilePath test_data_dir; | 1057 base::FilePath test_data_dir; |
1021 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath( | 1058 ASSERT_TRUE(chromeos::test_utils::GetTestDataPath( |
1022 "app_mode", "kiosk_manifest", &test_data_dir)); | 1059 "app_mode", "kiosk_manifest", &test_data_dir)); |
1023 command_line->AppendSwitchPath( | 1060 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 | 1266 // TODO(merkulova): Add tests for bluetooth HID detection screen variations when |
1230 // UI and logic is ready. http://crbug.com/127016 | 1267 // UI and logic is ready. http://crbug.com/127016 |
1231 | 1268 |
1232 // TODO(dzhioev): Add tests for controller/host pairing flow. | 1269 // TODO(dzhioev): Add tests for controller/host pairing flow. |
1233 // http://crbug.com/375191 | 1270 // http://crbug.com/375191 |
1234 | 1271 |
1235 static_assert(BaseScreenDelegate::EXIT_CODES_COUNT == 24, | 1272 static_assert(BaseScreenDelegate::EXIT_CODES_COUNT == 24, |
1236 "tests for new control flow are missing"); | 1273 "tests for new control flow are missing"); |
1237 | 1274 |
1238 } // namespace chromeos | 1275 } // namespace chromeos |
OLD | NEW |