Index: chrome/browser/ui/webui/options/options_ui_browsertest.cc |
diff --git a/chrome/browser/ui/webui/options/options_ui_browsertest.cc b/chrome/browser/ui/webui/options/options_ui_browsertest.cc |
index 45e4841cd06dc9ea2bbbd6efc249c77d1fed41a2..f1cbd809ba1bfffbd06c254e7b91ec7a07055494 100644 |
--- a/chrome/browser/ui/webui/options/options_ui_browsertest.cc |
+++ b/chrome/browser/ui/webui/options/options_ui_browsertest.cc |
@@ -8,6 +8,7 @@ |
#include "base/scoped_observer.h" |
#include "base/strings/string16.h" |
#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
@@ -17,6 +18,7 @@ |
#include "chrome/common/url_constants.h" |
#include "chrome/test/base/ui_test_utils.h" |
#include "components/signin/core/browser/signin_manager.h" |
+#include "content/public/browser/notification_service.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/test/browser_test_utils.h" |
#include "content/public/test/test_utils.h" |
@@ -48,7 +50,7 @@ namespace { |
class SignOutWaiter : public SigninManagerBase::Observer { |
public: |
- SignOutWaiter(SigninManagerBase* signin_manager) |
+ explicit SignOutWaiter(SigninManagerBase* signin_manager) |
: seen_(false), running_(false), scoped_observer_(this) { |
scoped_observer_.Add(signin_manager); |
} |
@@ -146,7 +148,68 @@ IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, LoadOptionsByURL) { |
VerifyNavbar(); |
} |
+// Flaky on win_rel http://crbug.com/352546 |
Patrick Dubroy
2014/04/07 20:30:40
Do you know why the test is flaky? How do you know
|
+#if defined(OS_WIN) |
+#define MAYBE_VerifyManagedSignout DISABLED_VerifyManagedSignout |
+#else |
+#define MAYBE_VerifyManagedSignout VerifyManagedSignout |
+#endif |
+ |
#if !defined(OS_CHROMEOS) |
+IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, MAYBE_VerifyManagedSignout) { |
+ SigninManager* signin = |
+ SigninManagerFactory::GetForProfile(browser()->profile()); |
+ signin->OnExternalSigninCompleted("test@example.com"); |
+ signin->ProhibitSignout(true); |
+ |
+ NavigateToSettingsFrame(); |
+ |
+ // This script simulates a click on the "Disconnect your Google Account" |
+ // button and returns true if the hidden flag of the appropriate dialog gets |
+ // flipped. |
+ bool result = false; |
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
+ browser()->tab_strip_model()->GetActiveWebContents(), |
+ "var dialog = $('manage-profile-overlay-disconnect-managed');" |
+ "var original_status = dialog.hidden;" |
+ "$('start-stop-sync').click();" |
+ "domAutomationController.send(original_status && !dialog.hidden);", |
+ &result)); |
+ |
+ EXPECT_TRUE(result); |
+ |
+ base::FilePath profile_dir = browser()->profile()->GetPath(); |
+ ProfileInfoCache& profile_info_cache = |
+ g_browser_process->profile_manager()->GetProfileInfoCache(); |
+ |
+ EXPECT_TRUE(DirectoryExists(profile_dir)); |
+ EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) != |
+ std::string::npos); |
+ |
+ content::WindowedNotificationObserver wait_for_profile_deletion( |
+ chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
+ content::NotificationService::AllSources()); |
+ |
+ // TODO(kaliamoorthi): Get the macos problem fixed and remove this code. |
+ // Deleting the Profile also destroys all browser windows of that Profile. |
+ // Wait for the current browser to close before resuming, otherwise |
+ // the browser_tests shutdown code will be confused on the Mac. |
+ content::WindowedNotificationObserver wait_for_browser_closed( |
+ chrome::NOTIFICATION_BROWSER_CLOSED, |
+ content::NotificationService::AllSources()); |
+ |
+ ASSERT_TRUE(content::ExecuteScript( |
+ browser()->tab_strip_model()->GetActiveWebContents(), |
+ "$('disconnect-managed-profile-ok').click();")); |
+ |
+ wait_for_profile_deletion.Wait(); |
+ |
+ EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) == |
+ std::string::npos); |
+ |
+ wait_for_browser_closed.Wait(); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) { |
SigninManager* signin = |
SigninManagerFactory::GetForProfile(browser()->profile()); |