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/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/chrome_notification_types.h" |
| 12 #include "chrome/browser/signin/account_tracker_service_factory.h" | |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/chrome_pages.h" | 15 #include "chrome/browser/ui/chrome_pages.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/browser/ui/webui/options/options_ui.h" | 17 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 17 #include "chrome/browser/ui/webui/uber/uber_ui.h" | 18 #include "chrome/browser/ui/webui/uber/uber_ui.h" |
| 18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "components/signin/core/browser/account_tracker_service.h" | |
| 21 #include "components/signin/core/browser/signin_manager.h" | 23 #include "components/signin/core/browser/signin_manager.h" |
| 22 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
| 26 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 28 | 30 |
| 29 #if !defined(OS_CHROMEOS) | 31 #if !defined(OS_CHROMEOS) |
| 30 #include <string> | 32 #include <string> |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 browser()->tab_strip_model()->GetActiveWebContents(), | 243 browser()->tab_strip_model()->GetActiveWebContents(), |
| 242 "$('disconnect-managed-profile-ok').click();")); | 244 "$('disconnect-managed-profile-ok').click();")); |
| 243 | 245 |
| 244 EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) == | 246 EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) == |
| 245 std::string::npos); | 247 std::string::npos); |
| 246 | 248 |
| 247 wait_for_browser_closed.Wait(); | 249 wait_for_browser_closed.Wait(); |
| 248 } | 250 } |
| 249 | 251 |
| 250 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) { | 252 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) { |
| 253 const std::string user = "test@example.com"; | |
| 254 std::string account_id = | |
| 255 AccountTrackerServiceFactory::GetForProfile(browser()->profile()) | |
| 256 ->SeedAccountInfo("12345", user); | |
| 251 SigninManager* signin = | 257 SigninManager* signin = |
| 252 SigninManagerFactory::GetForProfile(browser()->profile()); | 258 SigninManagerFactory::GetForProfile(browser()->profile()); |
| 253 const std::string user = "test@example.com"; | 259 signin->OnExternalSigninCompleted(account_id); |
| 254 signin->OnExternalSigninCompleted(user); | |
| 255 | 260 |
| 256 NavigateToSettingsFrame(); | 261 NavigateToSettingsFrame(); |
| 257 | 262 |
| 258 // This script simulates a click on the "Disconnect your Google Account" | 263 // This script simulates a click on the "Disconnect your Google Account" |
| 259 // button and returns true if the hidden flag of the appropriate dialog gets | 264 // button and returns true if the hidden flag of the appropriate dialog gets |
| 260 // flipped. | 265 // flipped. |
| 261 bool result = false; | 266 bool result = false; |
| 262 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 267 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 263 browser()->tab_strip_model()->GetActiveWebContents(), | 268 browser()->tab_strip_model()->GetActiveWebContents(), |
| 264 "var dialog = $('sync-setup-stop-syncing');" | 269 "var dialog = $('sync-setup-stop-syncing');" |
| 265 "var original_status = dialog.hidden;" | 270 "var original_status = dialog.hidden;" |
| 266 "$('start-stop-sync').click();" | 271 "$('start-stop-sync').click();" |
| 267 "domAutomationController.send(original_status && !dialog.hidden);", | 272 "domAutomationController.send(original_status && !dialog.hidden);", |
| 268 &result)); | 273 &result)); |
| 269 | 274 |
| 270 EXPECT_TRUE(result); | 275 EXPECT_TRUE(result); |
| 271 | 276 |
| 272 SignOutWaiter sign_out_waiter(signin); | 277 SignOutWaiter sign_out_waiter(signin); |
| 273 | 278 |
| 274 ASSERT_TRUE(content::ExecuteScript( | 279 ASSERT_TRUE(content::ExecuteScript( |
| 275 browser()->tab_strip_model()->GetActiveWebContents(), | 280 browser()->tab_strip_model()->GetActiveWebContents(), |
| 276 "$('stop-syncing-ok').click();")); | 281 "$('stop-syncing-ok').click();")); |
| 277 | 282 |
| 278 sign_out_waiter.Wait(); | 283 sign_out_waiter.Wait(); |
| 279 | 284 |
| 280 EXPECT_TRUE(browser()->profile()->GetProfileUserName() != user); | 285 EXPECT_TRUE(browser()->profile()->GetProfileUserName() != user); |
|
Evan Stade
2015/04/17 18:08:51
nit: EXPECT_NE
| |
| 281 EXPECT_FALSE(signin->IsAuthenticated()); | 286 EXPECT_FALSE(signin->IsAuthenticated()); |
| 282 } | 287 } |
| 283 | 288 |
| 284 // Regression test for http://crbug.com/301436, excluded on Chrome OS because | 289 // Regression test for http://crbug.com/301436, excluded on Chrome OS because |
| 285 // profile management in the settings UI exists on desktop platforms only. | 290 // profile management in the settings UI exists on desktop platforms only. |
| 286 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, NavigateBackFromOverlayDialog) { | 291 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, NavigateBackFromOverlayDialog) { |
| 287 NavigateToSettingsFrame(); | 292 NavigateToSettingsFrame(); |
| 288 | 293 |
| 289 // Click a button that opens an overlay dialog. | 294 // Click a button that opens an overlay dialog. |
| 290 content::WebContents* contents = | 295 content::WebContents* contents = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 run_loop.Run(); | 328 run_loop.Run(); |
| 324 | 329 |
| 325 // Verify that the settings page has updated and lists two profiles. | 330 // Verify that the settings page has updated and lists two profiles. |
| 326 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 331 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 327 contents, javascript, &profiles)); | 332 contents, javascript, &profiles)); |
| 328 EXPECT_EQ(2, profiles); | 333 EXPECT_EQ(2, profiles); |
| 329 } | 334 } |
| 330 #endif | 335 #endif |
| 331 | 336 |
| 332 } // namespace options | 337 } // namespace options |
| OLD | NEW |