Chromium Code Reviews| 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_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 }; // namespace | 47 }; // namespace |
| 48 | 48 |
| 49 class TranslateBrowserTest : public InProcessBrowserTest { | 49 class TranslateBrowserTest : public InProcessBrowserTest { |
| 50 public: | 50 public: |
| 51 TranslateBrowserTest() | 51 TranslateBrowserTest() |
| 52 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, | 52 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, |
| 53 SSLOptions(SSLOptions::CERT_OK), | 53 SSLOptions(SSLOptions::CERT_OK), |
| 54 base::FilePath(kTranslateRoot)), | 54 base::FilePath(kTranslateRoot)), |
| 55 infobar_service_(NULL) {} | 55 infobar_service_(NULL) {} |
| 56 | 56 |
| 57 virtual void SetUpOnMainThread() OVERRIDE { | |
| 58 TranslateService::SetUseInfobar(true); | |
| 59 } | |
| 60 | |
| 61 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 57 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 62 ASSERT_TRUE(https_server_.Start()); | 58 ASSERT_TRUE(https_server_.Start()); |
| 63 // Setup alternate security origin for testing in order to allow XHR against | 59 // Setup alternate security origin for testing in order to allow XHR against |
| 64 // local test server. Note that this flag shows a confirm infobar in tests. | 60 // local test server. Note that this flag shows a confirm infobar in tests. |
| 65 GURL base_url = GetSecureURL(""); | 61 GURL base_url = GetSecureURL(""); |
| 66 command_line->AppendSwitchASCII( | 62 command_line->AppendSwitchASCII( |
| 67 translate::switches::kTranslateSecurityOrigin, | 63 translate::switches::kTranslateSecurityOrigin, |
| 68 base_url.GetOrigin().spec()); | 64 base_url.GetOrigin().spec()); |
| 69 } | 65 } |
| 70 | 66 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 private: | 116 private: |
| 121 net::SpawnedTestServer https_server_; | 117 net::SpawnedTestServer https_server_; |
| 122 InfoBarService* infobar_service_; | 118 InfoBarService* infobar_service_; |
| 123 | 119 |
| 124 typedef net::SpawnedTestServer::SSLOptions SSLOptions; | 120 typedef net::SpawnedTestServer::SSLOptions SSLOptions; |
| 125 | 121 |
| 126 DISALLOW_COPY_AND_ASSIGN(TranslateBrowserTest); | 122 DISALLOW_COPY_AND_ASSIGN(TranslateBrowserTest); |
| 127 }; | 123 }; |
| 128 | 124 |
| 129 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, TranslateInIsolatedWorld) { | 125 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, TranslateInIsolatedWorld) { |
| 130 #if defined(OS_WIN) && defined(USE_ASH) | 126 // This test only applies to the infobar translate UX, not the new bubble UX. |
|
Takashi Toyoshima
2014/06/11 04:54:32
IIUC, with this change, these tests are changed to
msw
2014/06/11 07:31:20
I filed Issue 383235 and added TODOs. Most of thes
| |
| 131 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 127 if (TranslateService::IsTranslateBubbleEnabled()) |
| 132 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 133 return; | 128 return; |
| 134 #endif | |
| 135 | 129 |
| 136 net::TestURLFetcherFactory factory; | 130 net::TestURLFetcherFactory factory; |
| 137 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 131 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 138 | 132 |
| 139 // Check if there is no Translate infobar. | 133 // Check if there is no Translate infobar. |
| 140 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); | 134 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); |
| 141 EXPECT_FALSE(translate); | 135 EXPECT_FALSE(translate); |
| 142 | 136 |
| 143 // Setup infobar observer. | 137 // Setup infobar observer. |
| 144 content::WindowedNotificationObserver infobar( | 138 content::WindowedNotificationObserver infobar( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 fetcher->set_response_code(net::HTTP_OK); | 183 fetcher->set_response_code(net::HTTP_OK); |
| 190 fetcher->SetResponseString(element_js); | 184 fetcher->SetResponseString(element_js); |
| 191 fetcher->delegate()->OnURLFetchComplete(fetcher); | 185 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 192 | 186 |
| 193 // Wait for the page title is changed after the test finished. | 187 // Wait for the page title is changed after the test finished. |
| 194 const base::string16 result = watcher.WaitAndGetTitle(); | 188 const base::string16 result = watcher.WaitAndGetTitle(); |
| 195 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 189 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
| 196 } | 190 } |
| 197 | 191 |
| 198 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) { | 192 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) { |
| 199 #if defined(OS_WIN) && defined(USE_ASH) | 193 // This test only applies to the infobar translate UX, not the new bubble UX. |
| 200 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 194 if (TranslateService::IsTranslateBubbleEnabled()) |
| 201 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 202 return; | 195 return; |
| 203 #endif | |
| 204 | 196 |
| 205 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 197 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 206 | 198 |
| 207 // Check if there is no Translate infobar. | 199 // Check if there is no Translate infobar. |
| 208 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); | 200 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); |
| 209 EXPECT_FALSE(translate); | 201 EXPECT_FALSE(translate); |
| 210 | 202 |
| 211 // Setup page title observer. | 203 // Setup page title observer. |
| 212 content::WebContents* web_contents = | 204 content::WebContents* web_contents = |
| 213 browser()->tab_strip_model()->GetActiveWebContents(); | 205 browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 224 const base::string16 result = watcher.WaitAndGetTitle(); | 216 const base::string16 result = watcher.WaitAndGetTitle(); |
| 225 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 217 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
| 226 | 218 |
| 227 // Check if there is no Translate infobar. | 219 // Check if there is no Translate infobar. |
| 228 translate = GetExistingTranslateInfoBarDelegate(); | 220 translate = GetExistingTranslateInfoBarDelegate(); |
| 229 EXPECT_FALSE(translate); | 221 EXPECT_FALSE(translate); |
| 230 } | 222 } |
| 231 | 223 |
| 232 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, | 224 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, |
| 233 IgnoreRefreshMetaTagInCaseInsensitive) { | 225 IgnoreRefreshMetaTagInCaseInsensitive) { |
| 234 #if defined(OS_WIN) && defined(USE_ASH) | 226 // This test only applies to the infobar translate UX, not the new bubble UX. |
| 235 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 227 if (TranslateService::IsTranslateBubbleEnabled()) |
| 236 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 237 return; | 228 return; |
| 238 #endif | |
| 239 | 229 |
| 240 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 230 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 241 | 231 |
| 242 // Check if there is no Translate infobar. | 232 // Check if there is no Translate infobar. |
| 243 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); | 233 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); |
| 244 EXPECT_FALSE(translate); | 234 EXPECT_FALSE(translate); |
| 245 | 235 |
| 246 // Setup page title observer. | 236 // Setup page title observer. |
| 247 content::WebContents* web_contents = | 237 content::WebContents* web_contents = |
| 248 browser()->tab_strip_model()->GetActiveWebContents(); | 238 browser()->tab_strip_model()->GetActiveWebContents(); |
| 249 ASSERT_TRUE(web_contents); | 239 ASSERT_TRUE(web_contents); |
| 250 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 240 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
| 251 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 241 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| 252 | 242 |
| 253 // Visit a test page. | 243 // Visit a test page. |
| 254 ui_test_utils::NavigateToURL( | 244 ui_test_utils::NavigateToURL( |
| 255 browser(), | 245 browser(), |
| 256 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath)); | 246 GetNonSecureURL(kRefreshMetaTagCaseInsensitiveTestPath)); |
| 257 | 247 |
| 258 // Wait for the page title is changed after the test finished. | 248 // Wait for the page title is changed after the test finished. |
| 259 const base::string16 result = watcher.WaitAndGetTitle(); | 249 const base::string16 result = watcher.WaitAndGetTitle(); |
| 260 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 250 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
| 261 | 251 |
| 262 // Check if there is no Translate infobar. | 252 // Check if there is no Translate infobar. |
| 263 translate = GetExistingTranslateInfoBarDelegate(); | 253 translate = GetExistingTranslateInfoBarDelegate(); |
| 264 EXPECT_FALSE(translate); | 254 EXPECT_FALSE(translate); |
| 265 } | 255 } |
| 266 | 256 |
| 267 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) { | 257 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) { |
| 268 #if defined(OS_WIN) && defined(USE_ASH) | 258 // This test only applies to the infobar translate UX, not the new bubble UX. |
| 269 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 259 if (TranslateService::IsTranslateBubbleEnabled()) |
| 270 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 271 return; | 260 return; |
| 272 #endif | |
| 273 | 261 |
| 274 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 262 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 275 | 263 |
| 276 // Check if there is no Translate infobar. | 264 // Check if there is no Translate infobar. |
| 277 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); | 265 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); |
| 278 EXPECT_FALSE(translate); | 266 EXPECT_FALSE(translate); |
| 279 | 267 |
| 280 // Setup page title observer. | 268 // Setup page title observer. |
| 281 content::WebContents* web_contents = | 269 content::WebContents* web_contents = |
| 282 browser()->tab_strip_model()->GetActiveWebContents(); | 270 browser()->tab_strip_model()->GetActiveWebContents(); |
| 283 ASSERT_TRUE(web_contents); | 271 ASSERT_TRUE(web_contents); |
| 284 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 272 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
| 285 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 273 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| 286 | 274 |
| 287 // Visit a test page. | 275 // Visit a test page. |
| 288 ui_test_utils::NavigateToURL( | 276 ui_test_utils::NavigateToURL( |
| 289 browser(), | 277 browser(), |
| 290 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath)); | 278 GetNonSecureURL(kRefreshMetaTagAtOnloadTestPath)); |
| 291 | 279 |
| 292 // Wait for the page title is changed after the test finished. | 280 // Wait for the page title is changed after the test finished. |
| 293 const base::string16 result = watcher.WaitAndGetTitle(); | 281 const base::string16 result = watcher.WaitAndGetTitle(); |
| 294 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 282 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
| 295 | 283 |
| 296 // Check if there is no Translate infobar. | 284 // Check if there is no Translate infobar. |
| 297 translate = GetExistingTranslateInfoBarDelegate(); | 285 translate = GetExistingTranslateInfoBarDelegate(); |
| 298 EXPECT_FALSE(translate); | 286 EXPECT_FALSE(translate); |
| 299 } | 287 } |
| 300 | 288 |
| 301 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) { | 289 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) { |
| 302 #if defined(OS_WIN) && defined(USE_ASH) | 290 // This test only applies to the infobar translate UX, not the new bubble UX. |
| 303 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 291 if (TranslateService::IsTranslateBubbleEnabled()) |
| 304 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 305 return; | 292 return; |
| 306 #endif | |
| 307 | 293 |
| 308 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 294 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 309 | 295 |
| 310 // Check if there is no Translate infobar. | 296 // Check if there is no Translate infobar. |
| 311 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); | 297 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); |
| 312 EXPECT_FALSE(translate); | 298 EXPECT_FALSE(translate); |
| 313 | 299 |
| 314 // Setup page title observer. | 300 // Setup page title observer. |
| 315 content::WebContents* web_contents = | 301 content::WebContents* web_contents = |
| 316 browser()->tab_strip_model()->GetActiveWebContents(); | 302 browser()->tab_strip_model()->GetActiveWebContents(); |
| 317 ASSERT_TRUE(web_contents); | 303 ASSERT_TRUE(web_contents); |
| 318 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 304 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
| 319 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 305 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| 320 | 306 |
| 321 // Visit a test page. | 307 // Visit a test page. |
| 322 ui_test_utils::NavigateToURL( | 308 ui_test_utils::NavigateToURL( |
| 323 browser(), | 309 browser(), |
| 324 GetNonSecureURL(kUpdateLocationTestPath)); | 310 GetNonSecureURL(kUpdateLocationTestPath)); |
| 325 | 311 |
| 326 // Wait for the page title is changed after the test finished. | 312 // Wait for the page title is changed after the test finished. |
| 327 const base::string16 result = watcher.WaitAndGetTitle(); | 313 const base::string16 result = watcher.WaitAndGetTitle(); |
| 328 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 314 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
| 329 | 315 |
| 330 // Check if there is no Translate infobar. | 316 // Check if there is no Translate infobar. |
| 331 translate = GetExistingTranslateInfoBarDelegate(); | 317 translate = GetExistingTranslateInfoBarDelegate(); |
| 332 EXPECT_FALSE(translate); | 318 EXPECT_FALSE(translate); |
| 333 } | 319 } |
| 334 | 320 |
| 335 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) { | 321 IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) { |
| 336 #if defined(OS_WIN) && defined(USE_ASH) | 322 // This test only applies to the infobar translate UX, not the new bubble UX. |
| 337 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 323 if (TranslateService::IsTranslateBubbleEnabled()) |
| 338 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | |
| 339 return; | 324 return; |
| 340 #endif | |
| 341 | 325 |
| 342 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 326 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 343 | 327 |
| 344 // Check if there is no Translate infobar. | 328 // Check if there is no Translate infobar. |
| 345 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); | 329 TranslateInfoBarDelegate* translate = GetExistingTranslateInfoBarDelegate(); |
| 346 EXPECT_FALSE(translate); | 330 EXPECT_FALSE(translate); |
| 347 | 331 |
| 348 // Setup page title observer. | 332 // Setup page title observer. |
| 349 content::WebContents* web_contents = | 333 content::WebContents* web_contents = |
| 350 browser()->tab_strip_model()->GetActiveWebContents(); | 334 browser()->tab_strip_model()->GetActiveWebContents(); |
| 351 ASSERT_TRUE(web_contents); | 335 ASSERT_TRUE(web_contents); |
| 352 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); | 336 content::TitleWatcher watcher(web_contents, base::ASCIIToUTF16("PASS")); |
| 353 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); | 337 watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| 354 | 338 |
| 355 // Visit a test page. | 339 // Visit a test page. |
| 356 ui_test_utils::NavigateToURL( | 340 ui_test_utils::NavigateToURL( |
| 357 browser(), | 341 browser(), |
| 358 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); | 342 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); |
| 359 | 343 |
| 360 // Wait for the page title is changed after the test finished. | 344 // Wait for the page title is changed after the test finished. |
| 361 const base::string16 result = watcher.WaitAndGetTitle(); | 345 const base::string16 result = watcher.WaitAndGetTitle(); |
| 362 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 346 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
| 363 | 347 |
| 364 // Check if there is no Translate infobar. | 348 // Check if there is no Translate infobar. |
| 365 translate = GetExistingTranslateInfoBarDelegate(); | 349 translate = GetExistingTranslateInfoBarDelegate(); |
| 366 EXPECT_FALSE(translate); | 350 EXPECT_FALSE(translate); |
| 367 } | 351 } |
| OLD | NEW |