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/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/browser/ui/webui/options/options_ui.h" | 15 #include "chrome/browser/ui/webui/options/options_ui.h" |
15 #include "chrome/browser/ui/webui/uber/uber_ui.h" | 16 #include "chrome/browser/ui/webui/uber/uber_ui.h" |
16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
19 #include "components/signin/core/browser/signin_manager.h" | 20 #include "components/signin/core/browser/signin_manager.h" |
21 #include "content/public/browser/notification_service.h" | |
20 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
21 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
23 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
24 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
25 | 27 |
26 #if !defined(OS_CHROMEOS) | 28 #if !defined(OS_CHROMEOS) |
27 #include <string> | 29 #include <string> |
28 | 30 |
29 #include "base/basictypes.h" | 31 #include "base/basictypes.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
41 #endif | 43 #endif |
42 | 44 |
43 using content::MessageLoopRunner; | 45 using content::MessageLoopRunner; |
44 | 46 |
45 namespace options { | 47 namespace options { |
46 | 48 |
47 namespace { | 49 namespace { |
48 | 50 |
49 class SignOutWaiter : public SigninManagerBase::Observer { | 51 class SignOutWaiter : public SigninManagerBase::Observer { |
50 public: | 52 public: |
51 SignOutWaiter(SigninManagerBase* signin_manager) | 53 explicit SignOutWaiter(SigninManagerBase* signin_manager) |
52 : seen_(false), running_(false), scoped_observer_(this) { | 54 : seen_(false), running_(false), scoped_observer_(this) { |
53 scoped_observer_.Add(signin_manager); | 55 scoped_observer_.Add(signin_manager); |
54 } | 56 } |
55 virtual ~SignOutWaiter() {} | 57 virtual ~SignOutWaiter() {} |
56 | 58 |
57 void Wait() { | 59 void Wait() { |
58 if (seen_) | 60 if (seen_) |
59 return; | 61 return; |
60 | 62 |
61 running_ = true; | 63 running_ = true; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 base::string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); | 141 base::string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); |
140 EXPECT_NE(title.find(expected_title), base::string16::npos); | 142 EXPECT_NE(title.find(expected_title), base::string16::npos); |
141 } | 143 } |
142 | 144 |
143 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, LoadOptionsByURL) { | 145 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, LoadOptionsByURL) { |
144 NavigateToSettings(); | 146 NavigateToSettings(); |
145 VerifyTitle(); | 147 VerifyTitle(); |
146 VerifyNavbar(); | 148 VerifyNavbar(); |
147 } | 149 } |
148 | 150 |
151 // 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
| |
152 #if defined(OS_WIN) | |
153 #define MAYBE_VerifyManagedSignout DISABLED_VerifyManagedSignout | |
154 #else | |
155 #define MAYBE_VerifyManagedSignout VerifyManagedSignout | |
156 #endif | |
157 | |
149 #if !defined(OS_CHROMEOS) | 158 #if !defined(OS_CHROMEOS) |
159 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, MAYBE_VerifyManagedSignout) { | |
160 SigninManager* signin = | |
161 SigninManagerFactory::GetForProfile(browser()->profile()); | |
162 signin->OnExternalSigninCompleted("test@example.com"); | |
163 signin->ProhibitSignout(true); | |
164 | |
165 NavigateToSettingsFrame(); | |
166 | |
167 // This script simulates a click on the "Disconnect your Google Account" | |
168 // button and returns true if the hidden flag of the appropriate dialog gets | |
169 // flipped. | |
170 bool result = false; | |
171 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
172 browser()->tab_strip_model()->GetActiveWebContents(), | |
173 "var dialog = $('manage-profile-overlay-disconnect-managed');" | |
174 "var original_status = dialog.hidden;" | |
175 "$('start-stop-sync').click();" | |
176 "domAutomationController.send(original_status && !dialog.hidden);", | |
177 &result)); | |
178 | |
179 EXPECT_TRUE(result); | |
180 | |
181 base::FilePath profile_dir = browser()->profile()->GetPath(); | |
182 ProfileInfoCache& profile_info_cache = | |
183 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
184 | |
185 EXPECT_TRUE(DirectoryExists(profile_dir)); | |
186 EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) != | |
187 std::string::npos); | |
188 | |
189 content::WindowedNotificationObserver wait_for_profile_deletion( | |
190 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | |
191 content::NotificationService::AllSources()); | |
192 | |
193 // TODO(kaliamoorthi): Get the macos problem fixed and remove this code. | |
194 // Deleting the Profile also destroys all browser windows of that Profile. | |
195 // Wait for the current browser to close before resuming, otherwise | |
196 // the browser_tests shutdown code will be confused on the Mac. | |
197 content::WindowedNotificationObserver wait_for_browser_closed( | |
198 chrome::NOTIFICATION_BROWSER_CLOSED, | |
199 content::NotificationService::AllSources()); | |
200 | |
201 ASSERT_TRUE(content::ExecuteScript( | |
202 browser()->tab_strip_model()->GetActiveWebContents(), | |
203 "$('disconnect-managed-profile-ok').click();")); | |
204 | |
205 wait_for_profile_deletion.Wait(); | |
206 | |
207 EXPECT_TRUE(profile_info_cache.GetIndexOfProfileWithPath(profile_dir) == | |
208 std::string::npos); | |
209 | |
210 wait_for_browser_closed.Wait(); | |
211 } | |
212 | |
150 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) { | 213 IN_PROC_BROWSER_TEST_F(OptionsUIBrowserTest, VerifyUnmanagedSignout) { |
151 SigninManager* signin = | 214 SigninManager* signin = |
152 SigninManagerFactory::GetForProfile(browser()->profile()); | 215 SigninManagerFactory::GetForProfile(browser()->profile()); |
153 const std::string user = "test@example.com"; | 216 const std::string user = "test@example.com"; |
154 signin->OnExternalSigninCompleted(user); | 217 signin->OnExternalSigninCompleted(user); |
155 | 218 |
156 NavigateToSettingsFrame(); | 219 NavigateToSettingsFrame(); |
157 | 220 |
158 // This script simulates a click on the "Disconnect your Google Account" | 221 // This script simulates a click on the "Disconnect your Google Account" |
159 // button and returns true if the hidden flag of the appropriate dialog gets | 222 // 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... | |
223 run_loop.Run(); | 286 run_loop.Run(); |
224 | 287 |
225 // Verify that the settings page has updated and lists two profiles. | 288 // Verify that the settings page has updated and lists two profiles. |
226 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 289 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
227 contents, javascript, &profiles)); | 290 contents, javascript, &profiles)); |
228 EXPECT_EQ(2, profiles); | 291 EXPECT_EQ(2, profiles); |
229 } | 292 } |
230 #endif | 293 #endif |
231 | 294 |
232 } // namespace options | 295 } // namespace options |
OLD | NEW |