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/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/infobars/infobar.h" | 10 #include "chrome/browser/infobars/infobar.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 net::URLRequestStatus status; | 183 net::URLRequestStatus status; |
184 status.set_status(net::URLRequestStatus::SUCCESS); | 184 status.set_status(net::URLRequestStatus::SUCCESS); |
185 fetcher->set_status(status); | 185 fetcher->set_status(status); |
186 fetcher->set_url(fetcher->GetOriginalURL()); | 186 fetcher->set_url(fetcher->GetOriginalURL()); |
187 fetcher->set_response_code(net::HTTP_OK); | 187 fetcher->set_response_code(net::HTTP_OK); |
188 fetcher->SetResponseString(element_js); | 188 fetcher->SetResponseString(element_js); |
189 fetcher->delegate()->OnURLFetchComplete(fetcher); | 189 fetcher->delegate()->OnURLFetchComplete(fetcher); |
190 | 190 |
191 // Wait for the page title is changed after the test finished. | 191 // Wait for the page title is changed after the test finished. |
192 const base::string16 result = watcher.WaitAndGetTitle(); | 192 const base::string16 result = watcher.WaitAndGetTitle(); |
193 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 193 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
194 } | 194 } |
195 | 195 |
196 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) { | 196 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) { |
197 #if defined(OS_WIN) && defined(USE_ASH) | 197 #if defined(OS_WIN) && defined(USE_ASH) |
198 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 198 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
199 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 199 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
200 return; | 200 return; |
201 #endif | 201 #endif |
202 | 202 |
203 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 203 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
204 | 204 |
205 // Check if there is no Translate infobar. | 205 // Check if there is no Translate infobar. |
206 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); | 206 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); |
207 EXPECT_FALSE(translate); | 207 EXPECT_FALSE(translate); |
208 | 208 |
209 // Setup page title observer. | 209 // Setup page title observer. |
210 content::WebContents* web_contents = | 210 content::WebContents* web_contents = |
211 browser()->tab_strip_model()->GetActiveWebContents(); | 211 browser()->tab_strip_model()->GetActiveWebContents(); |
212 ASSERT_TRUE(web_contents); | 212 ASSERT_TRUE(web_contents); |
213 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 213 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
214 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 214 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
215 | 215 |
216 // Visit a test page. | 216 // Visit a test page. |
217 ui_test_utils::NavigateToURL( | 217 ui_test_utils::NavigateToURL( |
218 browser(), | 218 browser(), |
219 GetNonSecureURL(kRefreshMetaTagTestPath)); | 219 GetNonSecureURL(kRefreshMetaTagTestPath)); |
220 | 220 |
221 // Wait for the page title is changed after the test finished. | 221 // Wait for the page title is changed after the test finished. |
222 const base::string16 result = watcher.WaitAndGetTitle(); | 222 const base::string16 result = watcher.WaitAndGetTitle(); |
223 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 223 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
224 | 224 |
225 // Check if there is no Translate infobar. | 225 // Check if there is no Translate infobar. |
226 translate = GetExistingTranslateInfoBarDelegate(); | 226 translate = GetExistingTranslateInfoBarDelegate(); |
227 EXPECT_FALSE(translate); | 227 EXPECT_FALSE(translate); |
228 } | 228 } |
229 | 229 |
230 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, | 230 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, |
231 IgnoreRefreshMetaTagInCaseInsensitive) { | 231 IgnoreRefreshMetaTagInCaseInsensitive) { |
232 #if defined(OS_WIN) && defined(USE_ASH) | 232 #if defined(OS_WIN) && defined(USE_ASH) |
233 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 233 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
(...skipping 14 matching lines...) Expand all Loading... |
248 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 248 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
249 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 249 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
250 | 250 |
251 // Visit a test page. | 251 // Visit a test page. |
252 ui_test_utils::NavigateToURL( | 252 ui_test_utils::NavigateToURL( |
253 browser(), | 253 browser(), |
254 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath)); | 254 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath)); |
255 | 255 |
256 // Wait for the page title is changed after the test finished. | 256 // Wait for the page title is changed after the test finished. |
257 const base::string16 result = watcher.WaitAndGetTitle(); | 257 const base::string16 result = watcher.WaitAndGetTitle(); |
258 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 258 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
259 | 259 |
260 // Check if there is no Translate infobar. | 260 // Check if there is no Translate infobar. |
261 translate = GetExistingTranslateInfoBarDelegate(); | 261 translate = GetExistingTranslateInfoBarDelegate(); |
262 EXPECT_FALSE(translate); | 262 EXPECT_FALSE(translate); |
263 } | 263 } |
264 | 264 |
265 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) { | 265 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) { |
266 #if defined(OS_WIN) && defined(USE_ASH) | 266 #if defined(OS_WIN) && defined(USE_ASH) |
267 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 267 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
268 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 268 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
(...skipping 13 matching lines...) Expand all Loading... |
282 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 282 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
283 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 283 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
284 | 284 |
285 // Visit a test page. | 285 // Visit a test page. |
286 ui_test_utils::NavigateToURL( | 286 ui_test_utils::NavigateToURL( |
287 browser(), | 287 browser(), |
288 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath)); | 288 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath)); |
289 | 289 |
290 // Wait for the page title is changed after the test finished. | 290 // Wait for the page title is changed after the test finished. |
291 const base::string16 result = watcher.WaitAndGetTitle(); | 291 const base::string16 result = watcher.WaitAndGetTitle(); |
292 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 292 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
293 | 293 |
294 // Check if there is no Translate infobar. | 294 // Check if there is no Translate infobar. |
295 translate = GetExistingTranslateInfoBarDelegate(); | 295 translate = GetExistingTranslateInfoBarDelegate(); |
296 EXPECT_FALSE(translate); | 296 EXPECT_FALSE(translate); |
297 } | 297 } |
298 | 298 |
299 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) { | 299 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) { |
300 #if defined(OS_WIN) && defined(USE_ASH) | 300 #if defined(OS_WIN) && defined(USE_ASH) |
301 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 301 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
302 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 302 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
(...skipping 13 matching lines...) Expand all Loading... |
316 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 316 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
317 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 317 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
318 | 318 |
319 // Visit a test page. | 319 // Visit a test page. |
320 ui_test_utils::NavigateToURL( | 320 ui_test_utils::NavigateToURL( |
321 browser(), | 321 browser(), |
322 GetNonSecureURL(kUpdateLocationTestPath)); | 322 GetNonSecureURL(kUpdateLocationTestPath)); |
323 | 323 |
324 // Wait for the page title is changed after the test finished. | 324 // Wait for the page title is changed after the test finished. |
325 const base::string16 result = watcher.WaitAndGetTitle(); | 325 const base::string16 result = watcher.WaitAndGetTitle(); |
326 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 326 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
327 | 327 |
328 // Check if there is no Translate infobar. | 328 // Check if there is no Translate infobar. |
329 translate = GetExistingTranslateInfoBarDelegate(); | 329 translate = GetExistingTranslateInfoBarDelegate(); |
330 EXPECT_FALSE(translate); | 330 EXPECT_FALSE(translate); |
331 } | 331 } |
332 | 332 |
333 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) { | 333 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) { |
334 #if defined(OS_WIN) && defined(USE_ASH) | 334 #if defined(OS_WIN) && defined(USE_ASH) |
335 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 335 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
336 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 336 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
(...skipping 13 matching lines...) Expand all Loading... |
350 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 350 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
351 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 351 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
352 | 352 |
353 // Visit a test page. | 353 // Visit a test page. |
354 ui_test_utils::NavigateToURL( | 354 ui_test_utils::NavigateToURL( |
355 browser(), | 355 browser(), |
356 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); | 356 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); |
357 | 357 |
358 // Wait for the page title is changed after the test finished. | 358 // Wait for the page title is changed after the test finished. |
359 const base::string16 result = watcher.WaitAndGetTitle(); | 359 const base::string16 result = watcher.WaitAndGetTitle(); |
360 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 360 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
361 | 361 |
362 // Check if there is no Translate infobar. | 362 // Check if there is no Translate infobar. |
363 translate = GetExistingTranslateInfoBarDelegate(); | 363 translate = GetExistingTranslateInfoBarDelegate(); |
364 EXPECT_FALSE(translate); | 364 EXPECT_FALSE(translate); |
365 } | 365 } |
OLD | NEW |