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/ui/webui/options/options_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/options/options_ui_browsertest.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/chrome_pages.h" | 14 #include "chrome/browser/ui/chrome_pages.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/browser/ui/webui/options/options_ui.h" | 16 #include "chrome/browser/ui/webui/options/options_ui.h" |
16 #include "chrome/browser/ui/webui/uber/uber_ui.h" | 17 #include "chrome/browser/ui/webui/uber/uber_ui.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "components/signin/core/browser/signin_manager.h" | 21 #include "components/signin/core/browser/signin_manager.h" |
| 22 #include "content/public/browser/notification_service.h" |
21 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
22 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
23 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
24 #include "content/public/test/test_utils.h" | 26 #include "content/public/test/test_utils.h" |
25 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
26 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
27 | 29 |
28 #if !defined(OS_CHROMEOS) | 30 #if !defined(OS_CHROMEOS) |
29 #include <string> | 31 #include <string> |
30 | 32 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 browser()->tab_strip_model()->GetActiveWebContents(), | 163 browser()->tab_strip_model()->GetActiveWebContents(), |
162 base::Bind(&FrameHasSettingsSourceHost)); | 164 base::Bind(&FrameHasSettingsSourceHost)); |
163 } | 165 } |
164 | 166 |
165 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, LoadOptionsByURL) { | 167 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, LoadOptionsByURL) { |
166 NavigateToSettings(); | 168 NavigateToSettings(); |
167 VerifyTitle(); | 169 VerifyTitle(); |
168 VerifyNavbar(); | 170 VerifyNavbar(); |
169 } | 171 } |
170 | 172 |
| 173 // Flaky on win_rel when the profile is deleted crbug.com/103355 |
| 174 // Also related to crbug.com/104851 |
| 175 #if defined(OS_WIN) |
| 176 #define MAYBE_VerifyManagedSignout DISABLED_VerifyManagedSignout |
| 177 #else |
| 178 #define MAYBE_VerifyManagedSignout VerifyManagedSignout |
| 179 #endif |
| 180 |
171 #if !defined(OS_CHROMEOS) | 181 #if !defined(OS_CHROMEOS) |
| 182 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, MAYBE_VerifyManagedSignout) { |
| 183 SigninManager* signin = |
| 184 SigninManagerFactory::GetForProfile(browser()->profile()); |
| 185 signin->OnExternalSigninCompleted("test@example.com"); |
| 186 signin->ProhibitSignout(true); |
| 187 |
| 188 NavigateToSettingsFrame(); |
| 189 |
| 190 // This script simulates a click on the "Disconnect your Google Account" |
| 191 // button and returns true if the hidden flag of the appropriate dialog gets |
| 192 // flipped. |
| 193 bool result = false; |
| 194 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 195 browser()->tab_strip_model()->GetActiveWebContents(), |
| 196 "var dialog = $('manage-profile-overlay-disconnect-managed');" |
| 197 "var original_status = dialog.hidden;" |
| 198 "$('start-stop-sync').click();" |
| 199 "domAutomationController.send(original_status && !dialog.hidden);", |
| 200 &result)); |
| 201 |
| 202 EXPECT_TRUE(result); |
| 203 |
| 204 base::FilePath profile_dir = browser()->profile()->GetPath(); |
| 205 ProfileInfoCache& profile_info_cache = |
| 206 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 207 |
| 208 EXPECT_TRUE(DirectoryExists(profile_dir)); |
| 209 EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) != |
| 210 std::string::npos); |
| 211 |
| 212 content::WindowedNotificationObserver wait_for_profile_deletion( |
| 213 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 214 content::NotificationService::AllSources()); |
| 215 |
| 216 // TODO(kaliamoorthi): Get the macos problem fixed and remove this code. |
| 217 // Deleting the Profile also destroys all browser windows of that Profile. |
| 218 // Wait for the current browser to close before resuming, otherwise |
| 219 // the browser_tests shutdown code will be confused on the Mac. |
| 220 content::WindowedNotificationObserver wait_for_browser_closed( |
| 221 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 222 content::NotificationService::AllSources()); |
| 223 |
| 224 ASSERT_TRUE(content::ExecuteScript( |
| 225 browser()->tab_strip_model()->GetActiveWebContents(), |
| 226 "$('disconnect-managed-profile-ok').click();")); |
| 227 |
| 228 wait_for_profile_deletion.Wait(); |
| 229 |
| 230 EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) == |
| 231 std::string::npos); |
| 232 |
| 233 wait_for_browser_closed.Wait(); |
| 234 } |
| 235 |
172 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) { | 236 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) { |
173 SigninManager* signin = | 237 SigninManager* signin = |
174 SigninManagerFactory::GetForProfile(browser()->profile()); | 238 SigninManagerFactory::GetForProfile(browser()->profile()); |
175 const std::string user = "test@example.com"; | 239 const std::string user = "test@example.com"; |
176 signin->OnExternalSigninCompleted(user); | 240 signin->OnExternalSigninCompleted(user); |
177 | 241 |
178 NavigateToSettingsFrame(); | 242 NavigateToSettingsFrame(); |
179 | 243 |
180 // This script simulates a click on the "Disconnect your Google Account" | 244 // This script simulates a click on the "Disconnect your Google Account" |
181 // button and returns true if the hidden flag of the appropriate dialog gets | 245 // button and returns true if the hidden flag of the appropriate dialog gets |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 run_loop.Run(); | 309 run_loop.Run(); |
246 | 310 |
247 // Verify that the settings page has updated and lists two profiles. | 311 // Verify that the settings page has updated and lists two profiles. |
248 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 312 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
249 contents, javascript, &profiles)); | 313 contents, javascript, &profiles)); |
250 EXPECT_EQ(2, profiles); | 314 EXPECT_EQ(2, profiles); |
251 } | 315 } |
252 #endif | 316 #endif |
253 | 317 |
254 } // namespace options | 318 } // namespace options |
OLD | NEW |