OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" |
5 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
6 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
7 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/browser/translate/translate_infobar_delegate.h" | 11 #include "chrome/browser/translate/translate_infobar_delegate.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 public: | 49 public: |
49 TranslateBrowserTest() | 50 TranslateBrowserTest() |
50 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, | 51 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, |
51 SSLOptions(SSLOptions::CERT_OK), | 52 SSLOptions(SSLOptions::CERT_OK), |
52 base::FilePath(kTranslateRoot)) {} | 53 base::FilePath(kTranslateRoot)) {} |
53 | 54 |
54 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 55 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
55 ASSERT_TRUE(https_server_.Start()); | 56 ASSERT_TRUE(https_server_.Start()); |
56 } | 57 } |
57 | 58 |
| 59 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 60 // Setup altenate security-origin for testing. |
| 61 GURL origin = GetSecureURL(""); |
| 62 command_line->AppendSwitchASCII(switches::kTranslateSecurityOrigin, |
| 63 origin.spec()); |
| 64 } |
| 65 |
58 protected: | 66 protected: |
59 GURL GetNonSecureURL(const std::string& path) const { | 67 GURL GetNonSecureURL(const std::string& path) const { |
60 std::string prefix(kNonSecurePrefix); | 68 std::string prefix(kNonSecurePrefix); |
61 return embedded_test_server()->GetURL(prefix + path); | 69 return embedded_test_server()->GetURL(prefix + path); |
62 } | 70 } |
63 | 71 |
64 GURL GetSecureURL(const std::string& path) const { | 72 GURL GetSecureURL(const std::string& path) const { |
65 std::string prefix(kSecurePrefix); | 73 std::string prefix(kSecurePrefix); |
66 return https_server_.GetURL(prefix + path); | 74 return https_server_.GetURL(prefix + path); |
67 } | 75 } |
68 | 76 |
69 private: | 77 private: |
70 net::SpawnedTestServer https_server_; | 78 net::SpawnedTestServer https_server_; |
71 | 79 |
72 typedef net::SpawnedTestServer::SSLOptions SSLOptions; | 80 typedef net::SpawnedTestServer::SSLOptions SSLOptions; |
73 | 81 |
74 DISALLOW_COPY_AND_ASSIGN(TranslateBrowserTest); | 82 DISALLOW_COPY_AND_ASSIGN(TranslateBrowserTest); |
75 }; | 83 }; |
76 | 84 |
77 // TODO(toyoshim): This test should be changed to work in an isolated world. | 85 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, TranslateInIsolatedWorld) { |
78 // See also http://crbug.com/164547 . | |
79 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, DISABLED_Translate) { | |
80 #if defined(OS_WIN) && defined(USE_ASH) | 86 #if defined(OS_WIN) && defined(USE_ASH) |
81 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 87 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
82 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 88 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
83 return; | 89 return; |
84 #endif | 90 #endif |
85 | 91 |
86 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 92 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
87 | 93 |
88 content::WebContents* web_contents = | 94 content::WebContents* web_contents = |
89 browser()->tab_strip_model()->GetActiveWebContents(); | 95 browser()->tab_strip_model()->GetActiveWebContents(); |
90 ASSERT_TRUE(web_contents); | 96 ASSERT_TRUE(web_contents); |
91 | 97 |
92 net::TestURLFetcherFactory factory; | 98 net::TestURLFetcherFactory factory; |
93 | 99 |
94 // Setup infobar observer. | 100 // Setup infobar observer. |
95 InfoBarService* infobar_service = | 101 InfoBarService* infobar_service = |
96 InfoBarService::FromWebContents(web_contents); | 102 InfoBarService::FromWebContents(web_contents); |
97 ASSERT_TRUE(infobar_service); | 103 ASSERT_TRUE(infobar_service); |
98 EXPECT_EQ(0U, infobar_service->infobar_count()); | 104 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 105 ConfirmInfoBarDelegate* confirm = |
| 106 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 107 EXPECT_TRUE(confirm); |
99 content::WindowedNotificationObserver infobar( | 108 content::WindowedNotificationObserver infobar( |
100 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 109 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
101 content::NotificationService::AllSources()); | 110 content::NotificationService::AllSources()); |
102 | 111 |
103 // Setup page title observer. | 112 // Setup page title observer. |
104 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); | 113 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
105 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 114 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
106 | 115 |
107 // Visit non-secure page which is going to be translated. | 116 // Visit non-secure page which is going to be translated. |
108 ui_test_utils::NavigateToURL(browser(), GetNonSecureURL(kFrenchTestPath)); | 117 ui_test_utils::NavigateToURL(browser(), GetNonSecureURL(kFrenchTestPath)); |
109 | 118 |
110 // Wait for Chrome Translate infobar. | 119 // Wait for Chrome Translate infobar. |
111 infobar.Wait(); | 120 infobar.Wait(); |
112 | 121 |
113 // Perform Chrome Translate. | 122 // Perform Chrome Translate. |
114 ASSERT_EQ(1U, infobar_service->infobar_count()); | 123 ASSERT_EQ(2U, infobar_service->infobar_count()); |
| 124 confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 125 EXPECT_TRUE(confirm); |
| 126 |
115 TranslateInfoBarDelegate* translate = | 127 TranslateInfoBarDelegate* translate = |
116 infobar_service->infobar_at(0)->AsTranslateInfoBarDelegate(); | 128 infobar_service->infobar_at(1)->AsTranslateInfoBarDelegate(); |
117 ASSERT_TRUE(translate); | 129 ASSERT_TRUE(translate); |
118 translate->Translate(); | 130 translate->Translate(); |
119 | 131 |
120 // Hook URLFetcher for element.js. | 132 // Hook URLFetcher for element.js. |
121 GURL script1_url = GetSecureURL(kMainScriptPath); | 133 GURL script1_url = GetSecureURL(kMainScriptPath); |
122 GURL script2_url = GetSecureURL(kElementMainScriptPath); | 134 GURL script2_url = GetSecureURL(kElementMainScriptPath); |
123 std::string element_js = "main_script_url = '" + script1_url.spec() + "';\n"; | 135 std::string element_js = "main_script_url = '" + script1_url.spec() + "';\n"; |
124 element_js += "element_main_script_url = '" + script2_url.spec() + "';\n"; | 136 element_js += "element_main_script_url = '" + script2_url.spec() + "';\n"; |
125 element_js += | 137 element_js += |
126 "google = { 'translate' : { 'TranslateService' : function() { return {\n" | 138 "google = { 'translate' : { 'TranslateService' : function() { return {\n" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 172 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
161 | 173 |
162 content::WebContents* web_contents = | 174 content::WebContents* web_contents = |
163 browser()->tab_strip_model()->GetActiveWebContents(); | 175 browser()->tab_strip_model()->GetActiveWebContents(); |
164 ASSERT_TRUE(web_contents); | 176 ASSERT_TRUE(web_contents); |
165 | 177 |
166 // Check infobar count. | 178 // Check infobar count. |
167 InfoBarService* infobar_service = | 179 InfoBarService* infobar_service = |
168 InfoBarService::FromWebContents(web_contents); | 180 InfoBarService::FromWebContents(web_contents); |
169 ASSERT_TRUE(infobar_service); | 181 ASSERT_TRUE(infobar_service); |
170 EXPECT_EQ(0U, infobar_service->infobar_count()); | 182 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 183 ConfirmInfoBarDelegate* confirm = |
| 184 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 185 EXPECT_TRUE(confirm); |
171 | 186 |
172 // Setup page title observer. | 187 // Setup page title observer. |
173 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); | 188 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
174 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 189 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
175 | 190 |
176 // Visit a test page. | 191 // Visit a test page. |
177 ui_test_utils::NavigateToURL( | 192 ui_test_utils::NavigateToURL( |
178 browser(), | 193 browser(), |
179 GetNonSecureURL(kRefreshMetaTagTestPath)); | 194 GetNonSecureURL(kRefreshMetaTagTestPath)); |
180 | 195 |
181 // Wait for the page title is changed after the test finished. | 196 // Wait for the page title is changed after the test finished. |
182 const string16 result = watcher.WaitAndGetTitle(); | 197 const string16 result = watcher.WaitAndGetTitle(); |
183 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 198 EXPECT_EQ("PASS", UTF16ToASCII(result)); |
184 | 199 |
185 // Check there is not infobar. | 200 // Check there is not infobar. |
186 EXPECT_EQ(0U, infobar_service->infobar_count()); | 201 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 202 confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 203 EXPECT_TRUE(confirm); |
187 } | 204 } |
188 | 205 |
189 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, | 206 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, |
190 IgnoreRefreshMetaTagInCaseInsensitive) { | 207 IgnoreRefreshMetaTagInCaseInsensitive) { |
191 #if defined(OS_WIN) && defined(USE_ASH) | 208 #if defined(OS_WIN) && defined(USE_ASH) |
192 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 209 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
193 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 210 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
194 return; | 211 return; |
195 #endif | 212 #endif |
196 | 213 |
197 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 214 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
198 | 215 |
199 content::WebContents* web_contents = | 216 content::WebContents* web_contents = |
200 browser()->tab_strip_model()->GetActiveWebContents(); | 217 browser()->tab_strip_model()->GetActiveWebContents(); |
201 ASSERT_TRUE(web_contents); | 218 ASSERT_TRUE(web_contents); |
202 | 219 |
203 // Check infobar count. | 220 // Check infobar count. |
204 InfoBarService* infobar_service = | 221 InfoBarService* infobar_service = |
205 InfoBarService::FromWebContents(web_contents); | 222 InfoBarService::FromWebContents(web_contents); |
206 ASSERT_TRUE(infobar_service); | 223 ASSERT_TRUE(infobar_service); |
207 EXPECT_EQ(0U, infobar_service->infobar_count()); | 224 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 225 ConfirmInfoBarDelegate* confirm = |
| 226 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 227 EXPECT_TRUE(confirm); |
208 | 228 |
209 // Setup page title observer. | 229 // Setup page title observer. |
210 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); | 230 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
211 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 231 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
212 | 232 |
213 // Visit a test page. | 233 // Visit a test page. |
214 ui_test_utils::NavigateToURL( | 234 ui_test_utils::NavigateToURL( |
215 browser(), | 235 browser(), |
216 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath)); | 236 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath)); |
217 | 237 |
218 // Wait for the page title is changed after the test finished. | 238 // Wait for the page title is changed after the test finished. |
219 const string16 result = watcher.WaitAndGetTitle(); | 239 const string16 result = watcher.WaitAndGetTitle(); |
220 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 240 EXPECT_EQ("PASS", UTF16ToASCII(result)); |
221 | 241 |
222 // Check there is not infobar. | 242 // Check there is not infobar. |
223 EXPECT_EQ(0U, infobar_service->infobar_count()); | 243 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 244 confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 245 EXPECT_TRUE(confirm); |
224 } | 246 } |
225 | 247 |
226 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) { | 248 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) { |
227 #if defined(OS_WIN) && defined(USE_ASH) | 249 #if defined(OS_WIN) && defined(USE_ASH) |
228 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 250 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
229 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 251 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
230 return; | 252 return; |
231 #endif | 253 #endif |
232 | 254 |
233 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 255 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
234 | 256 |
235 content::WebContents* web_contents = | 257 content::WebContents* web_contents = |
236 browser()->tab_strip_model()->GetActiveWebContents(); | 258 browser()->tab_strip_model()->GetActiveWebContents(); |
237 ASSERT_TRUE(web_contents); | 259 ASSERT_TRUE(web_contents); |
238 | 260 |
239 // Check infobar count. | 261 // Check infobar count. |
240 InfoBarService* infobar_service = | 262 InfoBarService* infobar_service = |
241 InfoBarService::FromWebContents(web_contents); | 263 InfoBarService::FromWebContents(web_contents); |
242 ASSERT_TRUE(infobar_service); | 264 ASSERT_TRUE(infobar_service); |
243 EXPECT_EQ(0U, infobar_service->infobar_count()); | 265 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 266 ConfirmInfoBarDelegate* confirm = |
| 267 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 268 EXPECT_TRUE(confirm); |
244 | 269 |
245 // Setup page title observer. | 270 // Setup page title observer. |
246 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); | 271 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
247 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 272 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
248 | 273 |
249 // Visit a test page. | 274 // Visit a test page. |
250 ui_test_utils::NavigateToURL( | 275 ui_test_utils::NavigateToURL( |
251 browser(), | 276 browser(), |
252 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath)); | 277 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath)); |
253 | 278 |
254 // Wait for the page title is changed after the test finished. | 279 // Wait for the page title is changed after the test finished. |
255 const string16 result = watcher.WaitAndGetTitle(); | 280 const string16 result = watcher.WaitAndGetTitle(); |
256 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 281 EXPECT_EQ("PASS", UTF16ToASCII(result)); |
257 | 282 |
258 // Check there is not infobar. | 283 // Check there is not infobar. |
259 EXPECT_EQ(0U, infobar_service->infobar_count()); | 284 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 285 confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 286 EXPECT_TRUE(confirm); |
260 } | 287 } |
261 | 288 |
262 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) { | 289 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) { |
263 #if defined(OS_WIN) && defined(USE_ASH) | 290 #if defined(OS_WIN) && defined(USE_ASH) |
264 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 291 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
265 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 292 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
266 return; | 293 return; |
267 #endif | 294 #endif |
268 | 295 |
269 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 296 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
270 | 297 |
271 content::WebContents* web_contents = | 298 content::WebContents* web_contents = |
272 browser()->tab_strip_model()->GetActiveWebContents(); | 299 browser()->tab_strip_model()->GetActiveWebContents(); |
273 ASSERT_TRUE(web_contents); | 300 ASSERT_TRUE(web_contents); |
274 | 301 |
275 // Check infobar count. | 302 // Check infobar count. |
276 InfoBarService* infobar_service = | 303 InfoBarService* infobar_service = |
277 InfoBarService::FromWebContents(web_contents); | 304 InfoBarService::FromWebContents(web_contents); |
278 ASSERT_TRUE(infobar_service); | 305 ASSERT_TRUE(infobar_service); |
279 EXPECT_EQ(0U, infobar_service->infobar_count()); | 306 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 307 ConfirmInfoBarDelegate* confirm = |
| 308 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 309 EXPECT_TRUE(confirm); |
280 | 310 |
281 // Setup page title observer. | 311 // Setup page title observer. |
282 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); | 312 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
283 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 313 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
284 | 314 |
285 // Visit a test page. | 315 // Visit a test page. |
286 ui_test_utils::NavigateToURL( | 316 ui_test_utils::NavigateToURL( |
287 browser(), | 317 browser(), |
288 GetNonSecureURL(kUpdateLocationTestPath)); | 318 GetNonSecureURL(kUpdateLocationTestPath)); |
289 | 319 |
290 // Wait for the page title is changed after the test finished. | 320 // Wait for the page title is changed after the test finished. |
291 const string16 result = watcher.WaitAndGetTitle(); | 321 const string16 result = watcher.WaitAndGetTitle(); |
292 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 322 EXPECT_EQ("PASS", UTF16ToASCII(result)); |
293 | 323 |
294 // Check there is not infobar. | 324 // Check there is not infobar. |
295 EXPECT_EQ(0U, infobar_service->infobar_count()); | 325 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 326 confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 327 EXPECT_TRUE(confirm); |
296 } | 328 } |
297 | 329 |
298 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) { | 330 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) { |
299 #if defined(OS_WIN) && defined(USE_ASH) | 331 #if defined(OS_WIN) && defined(USE_ASH) |
300 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 332 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
301 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 333 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
302 return; | 334 return; |
303 #endif | 335 #endif |
304 | 336 |
305 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 337 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
306 | 338 |
307 content::WebContents* web_contents = | 339 content::WebContents* web_contents = |
308 browser()->tab_strip_model()->GetActiveWebContents(); | 340 browser()->tab_strip_model()->GetActiveWebContents(); |
309 ASSERT_TRUE(web_contents); | 341 ASSERT_TRUE(web_contents); |
310 | 342 |
311 // Check infobar count. | 343 // Check infobar count. |
312 InfoBarService* infobar_service = | 344 InfoBarService* infobar_service = |
313 InfoBarService::FromWebContents(web_contents); | 345 InfoBarService::FromWebContents(web_contents); |
314 ASSERT_TRUE(infobar_service); | 346 ASSERT_TRUE(infobar_service); |
315 EXPECT_EQ(0U, infobar_service->infobar_count()); | 347 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 348 ConfirmInfoBarDelegate* confirm = |
| 349 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 350 EXPECT_TRUE(confirm); |
316 | 351 |
317 // Setup page title observer. | 352 // Setup page title observer. |
318 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); | 353 content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
319 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 354 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
320 | 355 |
321 // Visit a test page. | 356 // Visit a test page. |
322 ui_test_utils::NavigateToURL( | 357 ui_test_utils::NavigateToURL( |
323 browser(), | 358 browser(), |
324 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); | 359 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); |
325 | 360 |
326 // Wait for the page title is changed after the test finished. | 361 // Wait for the page title is changed after the test finished. |
327 const string16 result = watcher.WaitAndGetTitle(); | 362 const string16 result = watcher.WaitAndGetTitle(); |
328 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 363 EXPECT_EQ("PASS", UTF16ToASCII(result)); |
329 | 364 |
330 // Check there is not infobar. | 365 // Check there is not infobar. |
331 EXPECT_EQ(0U, infobar_service->infobar_count()); | 366 EXPECT_EQ(1U, infobar_service->infobar_count()); |
| 367 confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
| 368 EXPECT_TRUE(confirm); |
332 } | 369 } |
OLD | NEW |