| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer_host/test/test_render_view_host.h" | 5 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/renderer_host/mock_render_process_host.h" | 10 #include "chrome/browser/renderer_host/mock_render_process_host.h" |
| 11 #include "chrome/browser/tab_contents/navigation_controller.h" | |
| 12 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 11 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 13 #include "chrome/browser/tab_contents/test_tab_contents.h" | 12 #include "chrome/browser/tab_contents/test_tab_contents.h" |
| 14 #include "chrome/browser/translate/translate_infobar_delegate.h" | 13 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 15 #include "chrome/browser/translate/translate_manager.h" | 14 #include "chrome/browser/translate/translate_manager.h" |
| 16 #include "chrome/browser/translate/translate_prefs.h" | 15 #include "chrome/browser/translate/translate_prefs.h" |
| 17 #include "chrome/common/ipc_test_sink.h" | 16 #include "chrome/common/ipc_test_sink.h" |
| 18 #include "chrome/common/notification_details.h" | 17 #include "chrome/common/notification_details.h" |
| 19 #include "chrome/common/notification_observer_mock.h" | 18 #include "chrome/common/notification_observer_mock.h" |
| 20 #include "chrome/common/notification_registrar.h" | 19 #include "chrome/common/notification_registrar.h" |
| 21 #include "chrome/common/notification_service.h" | 20 #include "chrome/common/notification_service.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 using testing::Property; | 34 using testing::Property; |
| 36 using WebKit::WebContextMenuData; | 35 using WebKit::WebContextMenuData; |
| 37 | 36 |
| 38 class TranslateManagerTest : public RenderViewHostTestHarness, | 37 class TranslateManagerTest : public RenderViewHostTestHarness, |
| 39 public NotificationObserver { | 38 public NotificationObserver { |
| 40 public: | 39 public: |
| 41 TranslateManagerTest() {} | 40 TranslateManagerTest() {} |
| 42 | 41 |
| 43 // Simluates navigating to a page and getting the page contents and language | 42 // Simluates navigating to a page and getting the page contents and language |
| 44 // for that navigation. | 43 // for that navigation. |
| 45 void SimulateNavigation(const GURL& url, | 44 void SimulateNavigation(const GURL& url, int page_id, |
| 46 const std::string& contents, | 45 const std::string& contents, |
| 47 const std::string& lang, | 46 const std::string& lang, |
| 48 bool page_translatable) { | 47 bool page_translatable) { |
| 49 NavigateAndCommit(url); | 48 NavigateAndCommit(url); |
| 50 int page_id = RenderViewHostTestHarness::contents()->controller(). | |
| 51 GetLastCommittedEntry()->page_id(); | |
| 52 SimulateOnPageContents(url, page_id, contents, lang, page_translatable); | 49 SimulateOnPageContents(url, page_id, contents, lang, page_translatable); |
| 53 } | 50 } |
| 54 | 51 |
| 55 void SimulateOnPageContents(const GURL& url, int page_id, | 52 void SimulateOnPageContents(const GURL& url, int page_id, |
| 56 const std::string& contents, | 53 const std::string& contents, |
| 57 const std::string& lang, | 54 const std::string& lang, |
| 58 bool page_translatable) { | 55 bool page_translatable) { |
| 59 rvh()->TestOnMessageReceived(ViewHostMsg_PageContents(0, url, page_id, | 56 rvh()->TestOnMessageReceived(ViewHostMsg_PageContents(0, url, page_id, |
| 60 UTF8ToUTF16(contents), | 57 UTF8ToUTF16(contents), |
| 61 lang, | 58 lang, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 TestRenderViewContextMenu(TabContents* tab_contents, | 272 TestRenderViewContextMenu(TabContents* tab_contents, |
| 276 const ContextMenuParams& params) | 273 const ContextMenuParams& params) |
| 277 : RenderViewContextMenu(tab_contents, params) { | 274 : RenderViewContextMenu(tab_contents, params) { |
| 278 } | 275 } |
| 279 | 276 |
| 280 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); | 277 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); |
| 281 }; | 278 }; |
| 282 | 279 |
| 283 TEST_F(TranslateManagerTest, NormalTranslate) { | 280 TEST_F(TranslateManagerTest, NormalTranslate) { |
| 284 // Simulate navigating to a page. | 281 // Simulate navigating to a page. |
| 285 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 282 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 286 | 283 |
| 287 // We should have an infobar. | 284 // We should have an infobar. |
| 288 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 285 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 289 ASSERT_TRUE(infobar != NULL); | 286 ASSERT_TRUE(infobar != NULL); |
| 290 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); | 287 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); |
| 291 | 288 |
| 292 // Simulate clicking translate. | 289 // Simulate clicking translate. |
| 293 process()->sink().ClearMessages(); | 290 process()->sink().ClearMessages(); |
| 294 infobar->Translate(); | 291 infobar->Translate(); |
| 295 | 292 |
| 296 // The "Translating..." infobar should be showing. | 293 // The "Translating..." infobar should be showing. |
| 297 infobar = GetTranslateInfoBar(); | 294 infobar = GetTranslateInfoBar(); |
| 298 ASSERT_TRUE(infobar != NULL); | 295 ASSERT_TRUE(infobar != NULL); |
| 299 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATING, infobar->type()); | 296 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATING, infobar->type()); |
| 300 | 297 |
| 301 // Simulate the translate script being retrieved (it only needs to be done | 298 // Simulate the translate script being retrieved (it only needs to be done |
| 302 // once in the test as it is cached). | 299 // once in the test as it is cached). |
| 303 SimulateURLFetch(true); | 300 SimulateURLFetch(true); |
| 304 | 301 |
| 305 // Test that we sent the right message to the renderer. | 302 // Test that we sent the right message to the renderer. |
| 306 int page_id = 0; | 303 int page_id = 0; |
| 307 std::string original_lang, target_lang; | 304 std::string original_lang, target_lang; |
| 308 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 305 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 306 EXPECT_EQ(0, page_id); |
| 309 EXPECT_EQ("fr", original_lang); | 307 EXPECT_EQ("fr", original_lang); |
| 310 EXPECT_EQ("en", target_lang); | 308 EXPECT_EQ("en", target_lang); |
| 311 | 309 |
| 312 // Simulate the render notifying the translation has been done. | 310 // Simulate the render notifying the translation has been done. |
| 313 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", | 311 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", |
| 314 TranslateErrors::NONE)); | 312 TranslateErrors::NONE)); |
| 315 | 313 |
| 316 // The after translate infobar should be showing. | 314 // The after translate infobar should be showing. |
| 317 infobar = GetTranslateInfoBar(); | 315 infobar = GetTranslateInfoBar(); |
| 318 ASSERT_TRUE(infobar != NULL); | 316 ASSERT_TRUE(infobar != NULL); |
| 319 EXPECT_EQ(TranslateInfoBarDelegate::AFTER_TRANSLATE, infobar->type()); | 317 EXPECT_EQ(TranslateInfoBarDelegate::AFTER_TRANSLATE, infobar->type()); |
| 320 | 318 |
| 321 // Simulate changing the original language, this should trigger a translation. | 319 // Simulate changing the original language, this should trigger a translation. |
| 322 process()->sink().ClearMessages(); | 320 process()->sink().ClearMessages(); |
| 323 std::string new_original_lang = infobar->GetLanguageCodeAt(0); | 321 std::string new_original_lang = infobar->GetLanguageCodeAt(0); |
| 324 infobar->SetOriginalLanguage(0); | 322 infobar->SetOriginalLanguage(0); |
| 325 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 323 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 324 EXPECT_EQ(0, page_id); |
| 326 EXPECT_EQ(new_original_lang, original_lang); | 325 EXPECT_EQ(new_original_lang, original_lang); |
| 327 EXPECT_EQ("en", target_lang); | 326 EXPECT_EQ("en", target_lang); |
| 328 // Simulate the render notifying the translation has been done. | 327 // Simulate the render notifying the translation has been done. |
| 329 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, | 328 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, |
| 330 new_original_lang, "en", TranslateErrors::NONE)); | 329 new_original_lang, "en", TranslateErrors::NONE)); |
| 331 // infobar is now invalid. | 330 // infobar is now invalid. |
| 332 TranslateInfoBarDelegate* new_infobar = GetTranslateInfoBar(); | 331 TranslateInfoBarDelegate* new_infobar = GetTranslateInfoBar(); |
| 333 ASSERT_TRUE(new_infobar != NULL); | 332 ASSERT_TRUE(new_infobar != NULL); |
| 334 infobar = new_infobar; | 333 infobar = new_infobar; |
| 335 | 334 |
| 336 // Simulate changing the target language, this should trigger a translation. | 335 // Simulate changing the target language, this should trigger a translation. |
| 337 process()->sink().ClearMessages(); | 336 process()->sink().ClearMessages(); |
| 338 std::string new_target_lang = infobar->GetLanguageCodeAt(1); | 337 std::string new_target_lang = infobar->GetLanguageCodeAt(1); |
| 339 infobar->SetTargetLanguage(1); | 338 infobar->SetTargetLanguage(1); |
| 340 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 339 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 340 EXPECT_EQ(0, page_id); |
| 341 EXPECT_EQ(new_original_lang, original_lang); | 341 EXPECT_EQ(new_original_lang, original_lang); |
| 342 EXPECT_EQ(new_target_lang, target_lang); | 342 EXPECT_EQ(new_target_lang, target_lang); |
| 343 // Simulate the render notifying the translation has been done. | 343 // Simulate the render notifying the translation has been done. |
| 344 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, | 344 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, |
| 345 new_original_lang, new_target_lang, TranslateErrors::NONE)); | 345 new_original_lang, new_target_lang, TranslateErrors::NONE)); |
| 346 // infobar is now invalid. | 346 // infobar is now invalid. |
| 347 new_infobar = GetTranslateInfoBar(); | 347 new_infobar = GetTranslateInfoBar(); |
| 348 ASSERT_TRUE(new_infobar != NULL); | 348 ASSERT_TRUE(new_infobar != NULL); |
| 349 } | 349 } |
| 350 | 350 |
| 351 TEST_F(TranslateManagerTest, TranslateScriptNotAvailable) { | 351 TEST_F(TranslateManagerTest, TranslateScriptNotAvailable) { |
| 352 // Simulate navigating to a page. | 352 // Simulate navigating to a page. |
| 353 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 353 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 354 | 354 |
| 355 // We should have an infobar. | 355 // We should have an infobar. |
| 356 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 356 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 357 ASSERT_TRUE(infobar != NULL); | 357 ASSERT_TRUE(infobar != NULL); |
| 358 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); | 358 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); |
| 359 | 359 |
| 360 // Simulate clicking translate. | 360 // Simulate clicking translate. |
| 361 process()->sink().ClearMessages(); | 361 process()->sink().ClearMessages(); |
| 362 infobar->Translate(); | 362 infobar->Translate(); |
| 363 // Simulate a failure retrieving the translate script. | 363 // Simulate a failure retrieving the translate script. |
| 364 SimulateURLFetch(false); | 364 SimulateURLFetch(false); |
| 365 | 365 |
| 366 // We should not have sent any message to translate to the renderer. | 366 // We should not have sent any message to translate to the renderer. |
| 367 EXPECT_FALSE(GetTranslateMessage(NULL, NULL, NULL)); | 367 EXPECT_FALSE(GetTranslateMessage(NULL, NULL, NULL)); |
| 368 | 368 |
| 369 // And we should have an error infobar showing. | 369 // And we should have an error infobar showing. |
| 370 infobar = GetTranslateInfoBar(); | 370 infobar = GetTranslateInfoBar(); |
| 371 ASSERT_TRUE(infobar != NULL); | 371 ASSERT_TRUE(infobar != NULL); |
| 372 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATION_ERROR, infobar->type()); | 372 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATION_ERROR, infobar->type()); |
| 373 } | 373 } |
| 374 | 374 |
| 375 // Ensures we deal correctly with pages for which the browser does not recognize | 375 // Ensures we deal correctly with pages for which the browser does not recognize |
| 376 // the language (the translate server may or not detect the language). | 376 // the language (the translate server may or not detect the language). |
| 377 TEST_F(TranslateManagerTest, TranslateUnknownLanguage) { | 377 TEST_F(TranslateManagerTest, TranslateUnknownLanguage) { |
| 378 // Simulate navigating to a page ("und" is the string returned by the CLD for | 378 // Simulate navigating to a page ("und" is the string returned by the CLD for |
| 379 // languages it does not recognize). | 379 // languages it does not recognize). |
| 380 SimulateNavigation(GURL("http://www.google.mys"), "G00g1e", "und", true); | 380 SimulateNavigation(GURL("http://www.google.mys"), 0, "G00g1e", "und", true); |
| 381 | 381 |
| 382 // We should not have an infobar as we don't know the language. | 382 // We should not have an infobar as we don't know the language. |
| 383 ASSERT_TRUE(GetTranslateInfoBar() == NULL); | 383 ASSERT_TRUE(GetTranslateInfoBar() == NULL); |
| 384 | 384 |
| 385 // Translate the page anyway throught the context menu. | 385 // Translate the page anyway throught the context menu. |
| 386 scoped_ptr<TestRenderViewContextMenu> menu( | 386 scoped_ptr<TestRenderViewContextMenu> menu( |
| 387 TestRenderViewContextMenu::CreateContextMenu(contents())); | 387 TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 388 menu->Init(); | 388 menu->Init(); |
| 389 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); | 389 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); |
| 390 | 390 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 404 | 404 |
| 405 // The after translate infobar should be showing. | 405 // The after translate infobar should be showing. |
| 406 infobar = GetTranslateInfoBar(); | 406 infobar = GetTranslateInfoBar(); |
| 407 ASSERT_TRUE(infobar != NULL); | 407 ASSERT_TRUE(infobar != NULL); |
| 408 EXPECT_EQ(TranslateInfoBarDelegate::AFTER_TRANSLATE, infobar->type()); | 408 EXPECT_EQ(TranslateInfoBarDelegate::AFTER_TRANSLATE, infobar->type()); |
| 409 EXPECT_EQ("fr", infobar->GetOriginalLanguageCode()); | 409 EXPECT_EQ("fr", infobar->GetOriginalLanguageCode()); |
| 410 EXPECT_EQ("en", infobar->GetTargetLanguageCode()); | 410 EXPECT_EQ("en", infobar->GetTargetLanguageCode()); |
| 411 | 411 |
| 412 // Let's run the same steps but this time the server detects the page is | 412 // Let's run the same steps but this time the server detects the page is |
| 413 // already in English. | 413 // already in English. |
| 414 SimulateNavigation(GURL("http://www.google.com"), "The Google", "und", true); | 414 SimulateNavigation(GURL("http://www.google.com"), 1, "The Google", "und", |
| 415 true); |
| 415 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 416 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 416 menu->Init(); | 417 menu->Init(); |
| 417 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); | 418 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); |
| 418 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(1, 0, "en", "en", | 419 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(1, 0, "en", "en", |
| 419 TranslateErrors::IDENTICAL_LANGUAGES)); | 420 TranslateErrors::IDENTICAL_LANGUAGES)); |
| 420 infobar = GetTranslateInfoBar(); | 421 infobar = GetTranslateInfoBar(); |
| 421 ASSERT_TRUE(infobar != NULL); | 422 ASSERT_TRUE(infobar != NULL); |
| 422 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATION_ERROR, infobar->type()); | 423 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATION_ERROR, infobar->type()); |
| 423 EXPECT_EQ(TranslateErrors::IDENTICAL_LANGUAGES, infobar->error()); | 424 EXPECT_EQ(TranslateErrors::IDENTICAL_LANGUAGES, infobar->error()); |
| 424 | 425 |
| 425 // Let's run the same steps again but this time the server fails to detect the | 426 // Let's run the same steps again but this time the server fails to detect the |
| 426 // page's language (it returns an empty string). | 427 // page's language (it returns an empty string). |
| 427 SimulateNavigation(GURL("http://www.google.com"), "The Google", "und", true); | 428 SimulateNavigation(GURL("http://www.google.com"), 2, "The Google", "und", |
| 429 true); |
| 428 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 430 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 429 menu->Init(); | 431 menu->Init(); |
| 430 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); | 432 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); |
| 431 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(2, 0, "", "en", | 433 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(2, 0, "", "en", |
| 432 TranslateErrors::UNKNOWN_LANGUAGE)); | 434 TranslateErrors::UNKNOWN_LANGUAGE)); |
| 433 infobar = GetTranslateInfoBar(); | 435 infobar = GetTranslateInfoBar(); |
| 434 ASSERT_TRUE(infobar != NULL); | 436 ASSERT_TRUE(infobar != NULL); |
| 435 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATION_ERROR, infobar->type()); | 437 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATION_ERROR, infobar->type()); |
| 436 EXPECT_EQ(TranslateErrors::UNKNOWN_LANGUAGE, infobar->error()); | 438 EXPECT_EQ(TranslateErrors::UNKNOWN_LANGUAGE, infobar->error()); |
| 437 } | 439 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 504 |
| 503 // Close the info-bar if applicable. | 505 // Close the info-bar if applicable. |
| 504 if (infobar != NULL) | 506 if (infobar != NULL) |
| 505 EXPECT_TRUE(CloseTranslateInfoBar()); | 507 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 506 } | 508 } |
| 507 } | 509 } |
| 508 | 510 |
| 509 // Tests auto-translate on page. | 511 // Tests auto-translate on page. |
| 510 TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) { | 512 TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) { |
| 511 // Simulate navigating to a page and getting its language. | 513 // Simulate navigating to a page and getting its language. |
| 512 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 514 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 513 | 515 |
| 514 // Simulate the user translating. | 516 // Simulate the user translating. |
| 515 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 517 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 516 ASSERT_TRUE(infobar != NULL); | 518 ASSERT_TRUE(infobar != NULL); |
| 517 infobar->Translate(); | 519 infobar->Translate(); |
| 518 SimulateURLFetch(true); // Simulate the translate script being retrieved. | 520 SimulateURLFetch(true); // Simulate the translate script being retrieved. |
| 519 | 521 |
| 520 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", | 522 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", |
| 521 TranslateErrors::NONE)); | 523 TranslateErrors::NONE)); |
| 522 | 524 |
| 523 // Now navigate to a new page in the same language. | 525 // Now navigate to a new page in the same language. |
| 524 process()->sink().ClearMessages(); | 526 process()->sink().ClearMessages(); |
| 525 SimulateNavigation(GURL("http://news.google.fr"), "Les news", "fr", true); | 527 SimulateNavigation(GURL("http://news.google.fr"), 1, "Les news", "fr", true); |
| 526 | 528 |
| 527 // This should have automatically triggered a translation. | 529 // This should have automatically triggered a translation. |
| 528 int page_id = 0; | 530 int page_id = 0; |
| 529 std::string original_lang, target_lang; | 531 std::string original_lang, target_lang; |
| 530 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 532 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 531 EXPECT_EQ(1, page_id); | 533 EXPECT_EQ(1, page_id); |
| 532 EXPECT_EQ("fr", original_lang); | 534 EXPECT_EQ("fr", original_lang); |
| 533 EXPECT_EQ("en", target_lang); | 535 EXPECT_EQ("en", target_lang); |
| 534 | 536 |
| 535 // Now navigate to a page in a different language. | 537 // Now navigate to a page in a different language. |
| 536 process()->sink().ClearMessages(); | 538 process()->sink().ClearMessages(); |
| 537 SimulateNavigation(GURL("http://news.google.es"), "Las news", "es", true); | 539 SimulateNavigation(GURL("http://news.google.es"), 1, "Las news", "es", true); |
| 538 | 540 |
| 539 // This should not have triggered a translate. | 541 // This should not have triggered a translate. |
| 540 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 542 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 541 } | 543 } |
| 542 | 544 |
| 543 // Tests that multiple OnPageContents do not cause multiple infobars. | 545 // Tests that multiple OnPageContents do not cause multiple infobars. |
| 544 TEST_F(TranslateManagerTest, MultipleOnPageContents) { | 546 TEST_F(TranslateManagerTest, MultipleOnPageContents) { |
| 545 // Simulate navigating to a page and getting its language. | 547 // Simulate navigating to a page and getting its language. |
| 546 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 548 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 547 | 549 |
| 548 // Simulate clicking 'Nope' (don't translate). | 550 // Simulate clicking 'Nope' (don't translate). |
| 549 EXPECT_TRUE(DenyTranslation()); | 551 EXPECT_TRUE(DenyTranslation()); |
| 550 EXPECT_EQ(0, contents()->infobar_delegate_count()); | 552 EXPECT_EQ(0, contents()->infobar_delegate_count()); |
| 551 | 553 |
| 552 // Send a new PageContents, we should not show an infobar. | 554 // Send a new PageContents, we should not show an infobar. |
| 553 SimulateOnPageContents(GURL("http://www.google.fr"), 0, "Le Google", "fr", | 555 SimulateOnPageContents(GURL("http://www.google.fr"), 0, "Le Google", "fr", |
| 554 true); | 556 true); |
| 555 EXPECT_EQ(0, contents()->infobar_delegate_count()); | 557 EXPECT_EQ(0, contents()->infobar_delegate_count()); |
| 556 | 558 |
| 557 // Do the same steps but simulate closing the infobar this time. | 559 // Do the same steps but simulate closing the infobar this time. |
| 558 SimulateNavigation(GURL("http://www.youtube.fr"), "Le YouTube", "fr", | 560 SimulateNavigation(GURL("http://www.youtube.fr"), 1, "Le YouTube", "fr", |
| 559 true); | 561 true); |
| 560 EXPECT_TRUE(CloseTranslateInfoBar()); | 562 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 561 EXPECT_EQ(0, contents()->infobar_delegate_count()); | 563 EXPECT_EQ(0, contents()->infobar_delegate_count()); |
| 562 SimulateOnPageContents(GURL("http://www.youtube.fr"), 1, "Le YouTube", "fr", | 564 SimulateOnPageContents(GURL("http://www.youtube.fr"), 1, "Le YouTube", "fr", |
| 563 true); | 565 true); |
| 564 EXPECT_EQ(0, contents()->infobar_delegate_count()); | 566 EXPECT_EQ(0, contents()->infobar_delegate_count()); |
| 565 } | 567 } |
| 566 | 568 |
| 567 // Test that reloading the page brings back the infobar. | 569 // Test that reloading the page brings back the infobar. |
| 568 TEST_F(TranslateManagerTest, Reload) { | 570 TEST_F(TranslateManagerTest, Reload) { |
| 569 // Simulate navigating to a page and getting its language. | 571 // Simulate navigating to a page and getting its language. |
| 570 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 572 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 571 | 573 |
| 572 // Close the infobar. | 574 // Close the infobar. |
| 573 EXPECT_TRUE(CloseTranslateInfoBar()); | 575 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 574 | 576 |
| 575 // Reload should bring back the infobar. | 577 // Reload should bring back the infobar. |
| 576 NavEntryCommittedObserver nav_observer(contents()); | 578 NavEntryCommittedObserver nav_observer(contents()); |
| 577 Reload(); | 579 Reload(); |
| 578 | 580 |
| 579 // Ensures it is really handled a reload. | 581 // Ensures it is really handled a reload. |
| 580 const NavigationController::LoadCommittedDetails& nav_details = | 582 const NavigationController::LoadCommittedDetails& nav_details = |
| 581 nav_observer.get_load_commited_details(); | 583 nav_observer.get_load_commited_details(); |
| 582 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. | 584 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. |
| 583 EXPECT_EQ(NavigationType::EXISTING_PAGE, nav_details.type); | 585 EXPECT_EQ(NavigationType::EXISTING_PAGE, nav_details.type); |
| 584 | 586 |
| 585 // The TranslateManager class processes the navigation entry committed | 587 // The TranslateManager class processes the navigation entry committed |
| 586 // notification in a posted task; process that task. | 588 // notification in a posted task; process that task. |
| 587 MessageLoop::current()->RunAllPending(); | 589 MessageLoop::current()->RunAllPending(); |
| 588 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 590 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 589 } | 591 } |
| 590 | 592 |
| 591 // Test that reloading the page by way of typing again the URL in the | 593 // Test that reloading the page by way of typing again the URL in the |
| 592 // location bar brings back the infobar. | 594 // location bar brings back the infobar. |
| 593 TEST_F(TranslateManagerTest, ReloadFromLocationBar) { | 595 TEST_F(TranslateManagerTest, ReloadFromLocationBar) { |
| 594 GURL url("http://www.google.fr"); | 596 GURL url("http://www.google.fr"); |
| 595 | 597 |
| 596 // Simulate navigating to a page and getting its language. | 598 // Simulate navigating to a page and getting its language. |
| 597 SimulateNavigation(url, "Le Google", "fr", true); | 599 SimulateNavigation(url, 0, "Le Google", "fr", true); |
| 598 | 600 |
| 599 // Close the infobar. | 601 // Close the infobar. |
| 600 EXPECT_TRUE(CloseTranslateInfoBar()); | 602 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 601 | 603 |
| 602 // Create a pending navigation and simulate a page load. That should be the | 604 // Create a pending navigation and simulate a page load. That should be the |
| 603 // equivalent of typing the URL again in the location bar. | 605 // equivalent of typing the URL again in the location bar. |
| 604 NavEntryCommittedObserver nav_observer(contents()); | 606 NavEntryCommittedObserver nav_observer(contents()); |
| 605 contents()->controller().LoadURL(url, GURL(), PageTransition::TYPED); | 607 contents()->controller().LoadURL(url, GURL(), PageTransition::TYPED); |
| 606 rvh()->SendNavigate(0, url); | 608 rvh()->SendNavigate(0, url); |
| 607 | 609 |
| 608 // Test that we are really getting a same page navigation, the test would be | 610 // Test that we are really getting a same page navigation, the test would be |
| 609 // useless if it was not the case. | 611 // useless if it was not the case. |
| 610 const NavigationController::LoadCommittedDetails& nav_details = | 612 const NavigationController::LoadCommittedDetails& nav_details = |
| 611 nav_observer.get_load_commited_details(); | 613 nav_observer.get_load_commited_details(); |
| 612 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. | 614 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. |
| 613 EXPECT_EQ(NavigationType::SAME_PAGE, nav_details.type); | 615 EXPECT_EQ(NavigationType::SAME_PAGE, nav_details.type); |
| 614 | 616 |
| 615 // The TranslateManager class processes the navigation entry committed | 617 // The TranslateManager class processes the navigation entry committed |
| 616 // notification in a posted task; process that task. | 618 // notification in a posted task; process that task. |
| 617 MessageLoop::current()->RunAllPending(); | 619 MessageLoop::current()->RunAllPending(); |
| 618 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 620 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 619 } | 621 } |
| 620 | 622 |
| 621 // Tests that a closed translate infobar does not reappear when navigating | 623 // Tests that a closed translate infobar does not reappear when navigating |
| 622 // in-page. | 624 // in-page. |
| 623 TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) { | 625 TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) { |
| 624 // Simulate navigating to a page and getting its language. | 626 // Simulate navigating to a page and getting its language. |
| 625 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 627 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 626 | 628 |
| 627 // Close the infobar. | 629 // Close the infobar. |
| 628 EXPECT_TRUE(CloseTranslateInfoBar()); | 630 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 629 | 631 |
| 630 // Navigate in page, no infobar should be shown. | 632 // Navigate in page, no infobar should be shown. |
| 631 SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr", | 633 SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr", |
| 632 true); | 634 true); |
| 633 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 635 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 634 | 636 |
| 635 // Navigate out of page, a new infobar should show. | 637 // Navigate out of page, a new infobar should show. |
| 636 SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr", | 638 SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr", |
| 637 true); | 639 true); |
| 638 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 640 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 639 } | 641 } |
| 640 | 642 |
| 641 // Tests that a closed translate infobar does not reappear when navigating | 643 // Tests that a closed translate infobar does not reappear when navigating |
| 642 // in a subframe. (http://crbug.com/48215) | 644 // in a subframe. (http://crbug.com/48215) |
| 643 TEST_F(TranslateManagerTest, CloseInfoBarInSubframeNavigation) { | 645 TEST_F(TranslateManagerTest, CloseInfoBarInSubframeNavigation) { |
| 644 // Simulate navigating to a page and getting its language. | 646 // Simulate navigating to a page and getting its language. |
| 645 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 647 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 646 | 648 |
| 647 // Close the infobar. | 649 // Close the infobar. |
| 648 EXPECT_TRUE(CloseTranslateInfoBar()); | 650 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 649 | 651 |
| 650 // Simulate a sub-frame auto-navigating. | 652 // Simulate a sub-frame auto-navigating. |
| 651 rvh()->SendNavigateWithTransition(1, GURL("http://pub.com"), | 653 rvh()->SendNavigateWithTransition(1, GURL("http://pub.com"), |
| 652 PageTransition::AUTO_SUBFRAME); | 654 PageTransition::AUTO_SUBFRAME); |
| 653 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 655 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 654 | 656 |
| 655 // Simulate the user navigating in a sub-frame. | 657 // Simulate the user navigating in a sub-frame. |
| 656 rvh()->SendNavigateWithTransition(2, GURL("http://pub.com"), | 658 rvh()->SendNavigateWithTransition(2, GURL("http://pub.com"), |
| 657 PageTransition::MANUAL_SUBFRAME); | 659 PageTransition::MANUAL_SUBFRAME); |
| 658 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 660 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 659 | 661 |
| 660 // Navigate out of page, a new infobar should show. | 662 // Navigate out of page, a new infobar should show. |
| 661 SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr", | 663 SimulateNavigation(GURL("http://www.google.fr/foot"), 3, "Le Google", "fr", |
| 662 true); | 664 true); |
| 663 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 665 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 664 } | 666 } |
| 665 | 667 |
| 666 | 668 |
| 667 | 669 |
| 668 // Tests that denying translation is sticky when navigating in page. | 670 // Tests that denying translation is sticky when navigating in page. |
| 669 TEST_F(TranslateManagerTest, DenyTranslateInPageNavigation) { | 671 TEST_F(TranslateManagerTest, DenyTranslateInPageNavigation) { |
| 670 // Simulate navigating to a page and getting its language. | 672 // Simulate navigating to a page and getting its language. |
| 671 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 673 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 672 | 674 |
| 673 // Simulate clicking 'Nope' (don't translate). | 675 // Simulate clicking 'Nope' (don't translate). |
| 674 EXPECT_TRUE(DenyTranslation()); | 676 EXPECT_TRUE(DenyTranslation()); |
| 675 | 677 |
| 676 // Navigate in page, no infobar should be shown. | 678 // Navigate in page, no infobar should be shown. |
| 677 SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr", | 679 SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr", |
| 678 true); | 680 true); |
| 679 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 681 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 680 | 682 |
| 681 // Navigate out of page, a new infobar should show. | 683 // Navigate out of page, a new infobar should show. |
| 682 SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr", | 684 SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr", |
| 683 true); | 685 true); |
| 684 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 686 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 685 } | 687 } |
| 686 | 688 |
| 687 // Tests that after translating and closing the infobar, the infobar does not | 689 // Tests that after translating and closing the infobar, the infobar does not |
| 688 // return when navigating in page. | 690 // return when navigating in page. |
| 689 TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) { | 691 TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) { |
| 690 // Simulate navigating to a page and getting its language. | 692 // Simulate navigating to a page and getting its language. |
| 691 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 693 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 692 | 694 |
| 693 // Simulate the user translating. | 695 // Simulate the user translating. |
| 694 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 696 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 695 ASSERT_TRUE(infobar != NULL); | 697 ASSERT_TRUE(infobar != NULL); |
| 696 infobar->Translate(); | 698 infobar->Translate(); |
| 697 SimulateURLFetch(true); // Simulate the translate script being retrieved. | 699 SimulateURLFetch(true); // Simulate the translate script being retrieved. |
| 698 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", | 700 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", |
| 699 TranslateErrors::NONE)); | 701 TranslateErrors::NONE)); |
| 700 | 702 |
| 701 // Close the infobar. | 703 // Close the infobar. |
| 702 EXPECT_TRUE(CloseTranslateInfoBar()); | 704 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 703 | 705 |
| 704 // Navigate in page, no infobar should be shown. | 706 // Navigate in page, no infobar should be shown. |
| 705 SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr", | 707 SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr", |
| 706 true); | 708 true); |
| 707 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 709 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 708 | 710 |
| 709 // Navigate out of page, a new infobar should show. | 711 // Navigate out of page, a new infobar should show. |
| 710 // Note that we navigate to a page in a different language so we don't trigger | 712 // Note that we navigate to a page in a different language so we don't trigger |
| 711 // the auto-translate feature (it would translate the page automatically and | 713 // the auto-translate feature (it would translate the page automatically and |
| 712 // the before translate inforbar would not be shown). | 714 // the before translate inforbar would not be shown). |
| 713 SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true); | 715 SimulateNavigation(GURL("http://www.google.de"), 0, "Das Google", "de", true); |
| 714 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 716 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 715 } | 717 } |
| 716 | 718 |
| 717 // Tests that the after translate the infobar still shows when navigating | 719 // Tests that the after translate the infobar still shows when navigating |
| 718 // in-page. | 720 // in-page. |
| 719 TEST_F(TranslateManagerTest, TranslateInPageNavigation) { | 721 TEST_F(TranslateManagerTest, TranslateInPageNavigation) { |
| 720 // Simulate navigating to a page and getting its language. | 722 // Simulate navigating to a page and getting its language. |
| 721 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 723 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 722 | 724 |
| 723 // Simulate the user translating. | 725 // Simulate the user translating. |
| 724 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 726 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 725 ASSERT_TRUE(infobar != NULL); | 727 ASSERT_TRUE(infobar != NULL); |
| 726 infobar->Translate(); | 728 infobar->Translate(); |
| 727 SimulateURLFetch(true); // Simulate the translate script being retrieved. | 729 SimulateURLFetch(true); // Simulate the translate script being retrieved. |
| 728 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", | 730 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", |
| 729 TranslateErrors::NONE)); | 731 TranslateErrors::NONE)); |
| 730 // The after translate infobar is showing. | 732 // The after translate infobar is showing. |
| 731 infobar = GetTranslateInfoBar(); | 733 infobar = GetTranslateInfoBar(); |
| 732 ASSERT_TRUE(infobar != NULL); | 734 ASSERT_TRUE(infobar != NULL); |
| 733 | 735 |
| 734 // Navigate in page, the same infobar should still be shown. | 736 // Navigate in page, the same infobar should still be shown. |
| 735 ClearRemovedInfoBars(); | 737 ClearRemovedInfoBars(); |
| 736 SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr", | 738 SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr", |
| 737 true); | 739 true); |
| 738 EXPECT_FALSE(InfoBarRemoved()); | 740 EXPECT_FALSE(InfoBarRemoved()); |
| 739 EXPECT_EQ(infobar, GetTranslateInfoBar()); | 741 EXPECT_EQ(infobar, GetTranslateInfoBar()); |
| 740 | 742 |
| 741 // Navigate out of page, a new infobar should show. | 743 // Navigate out of page, a new infobar should show. |
| 742 // See note in TranslateCloseInfoBarInPageNavigation test on why it is | 744 // See note in TranslateCloseInfoBarInPageNavigation test on why it is |
| 743 // important to navigate to a page in a different language for this test. | 745 // important to navigate to a page in a different language for this test. |
| 744 SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true); | 746 SimulateNavigation(GURL("http://www.google.de"), 0, "Das Google", "de", true); |
| 745 // The old infobar is gone. | 747 // The old infobar is gone. |
| 746 EXPECT_TRUE(CheckInfoBarRemovedAndReset(infobar)); | 748 EXPECT_TRUE(CheckInfoBarRemovedAndReset(infobar)); |
| 747 // And there is a new one. | 749 // And there is a new one. |
| 748 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 750 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 749 } | 751 } |
| 750 | 752 |
| 751 // Tests that no translate infobar is shown when navigating to a page in an | 753 // Tests that no translate infobar is shown when navigating to a page in an |
| 752 // unsupported language. | 754 // unsupported language. |
| 753 TEST_F(TranslateManagerTest, CLDReportsUnsupportedPageLanguage) { | 755 TEST_F(TranslateManagerTest, CLDReportsUnsupportedPageLanguage) { |
| 754 // Simulate navigating to a page and getting an unsupported language. | 756 // Simulate navigating to a page and getting an unsupported language. |
| 755 SimulateNavigation(GURL("http://www.google.com"), "Google", "qbz", true); | 757 SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "qbz", true); |
| 756 | 758 |
| 757 // No info-bar should be shown. | 759 // No info-bar should be shown. |
| 758 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 760 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 759 } | 761 } |
| 760 | 762 |
| 761 // Tests that we deal correctly with unsupported languages returned by the | 763 // Tests that we deal correctly with unsupported languages returned by the |
| 762 // server. | 764 // server. |
| 763 // The translation server might return a language we don't support. | 765 // The translation server might return a language we don't support. |
| 764 TEST_F(TranslateManagerTest, ServerReportsUnsupportedLanguage) { | 766 TEST_F(TranslateManagerTest, ServerReportsUnsupportedLanguage) { |
| 765 // Simulate navigating to a page and translating it. | 767 // Simulate navigating to a page and translating it. |
| 766 SimulateNavigation(GURL("http://mail.google.fr"), "Le Google", "fr", true); | 768 SimulateNavigation(GURL("http://mail.google.fr"), 0, "Le Google", "fr", |
| 769 true); |
| 767 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 770 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 768 ASSERT_TRUE(infobar != NULL); | 771 ASSERT_TRUE(infobar != NULL); |
| 769 process()->sink().ClearMessages(); | 772 process()->sink().ClearMessages(); |
| 770 infobar->Translate(); | 773 infobar->Translate(); |
| 771 SimulateURLFetch(true); | 774 SimulateURLFetch(true); |
| 772 // Simulate the render notifying the translation has been done, but it | 775 // Simulate the render notifying the translation has been done, but it |
| 773 // reports a language we don't support. | 776 // reports a language we don't support. |
| 774 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "qbz", "en", | 777 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "qbz", "en", |
| 775 TranslateErrors::NONE)); | 778 TranslateErrors::NONE)); |
| 776 | 779 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 796 // Tests that no translate infobar is shown when Chrome is in a language that | 799 // Tests that no translate infobar is shown when Chrome is in a language that |
| 797 // the translate server does not support. | 800 // the translate server does not support. |
| 798 TEST_F(TranslateManagerTest, UnsupportedUILanguage) { | 801 TEST_F(TranslateManagerTest, UnsupportedUILanguage) { |
| 799 TestingBrowserProcess* browser_process = | 802 TestingBrowserProcess* browser_process = |
| 800 static_cast<TestingBrowserProcess*>(g_browser_process); | 803 static_cast<TestingBrowserProcess*>(g_browser_process); |
| 801 std::string original_lang = browser_process->GetApplicationLocale(); | 804 std::string original_lang = browser_process->GetApplicationLocale(); |
| 802 browser_process->SetApplicationLocale("qbz"); | 805 browser_process->SetApplicationLocale("qbz"); |
| 803 | 806 |
| 804 // Simulate navigating to a page in a language supported by the translate | 807 // Simulate navigating to a page in a language supported by the translate |
| 805 // server. | 808 // server. |
| 806 SimulateNavigation(GURL("http://www.google.com"), "Google", "en", true); | 809 SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "en", true); |
| 807 | 810 |
| 808 // No info-bar should be shown. | 811 // No info-bar should be shown. |
| 809 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 812 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 810 | 813 |
| 811 browser_process->SetApplicationLocale(original_lang); | 814 browser_process->SetApplicationLocale(original_lang); |
| 812 } | 815 } |
| 813 | 816 |
| 814 // Tests that the translate enabled preference is honored. | 817 // Tests that the translate enabled preference is honored. |
| 815 TEST_F(TranslateManagerTest, TranslateEnabledPref) { | 818 TEST_F(TranslateManagerTest, TranslateEnabledPref) { |
| 816 // Make sure the pref allows translate. | 819 // Make sure the pref allows translate. |
| 817 PrefService* prefs = contents()->profile()->GetPrefs(); | 820 PrefService* prefs = contents()->profile()->GetPrefs(); |
| 818 prefs->SetBoolean(prefs::kEnableTranslate, true); | 821 prefs->SetBoolean(prefs::kEnableTranslate, true); |
| 819 | 822 |
| 820 // Simulate navigating to a page and getting its language. | 823 // Simulate navigating to a page and getting its language. |
| 821 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 824 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 822 | 825 |
| 823 // An infobar should be shown. | 826 // An infobar should be shown. |
| 824 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 827 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 825 EXPECT_TRUE(infobar != NULL); | 828 EXPECT_TRUE(infobar != NULL); |
| 826 | 829 |
| 827 // Disable translate. | 830 // Disable translate. |
| 828 prefs->SetBoolean(prefs::kEnableTranslate, false); | 831 prefs->SetBoolean(prefs::kEnableTranslate, false); |
| 829 | 832 |
| 830 // Navigate to a new page, that should close the previous infobar. | 833 // Navigate to a new page, that should close the previous infobar. |
| 831 GURL url("http://www.youtube.fr"); | 834 GURL url("http://www.youtube.fr"); |
| 832 NavigateAndCommit(url); | 835 NavigateAndCommit(url); |
| 833 infobar = GetTranslateInfoBar(); | 836 infobar = GetTranslateInfoBar(); |
| 834 EXPECT_TRUE(infobar == NULL); | 837 EXPECT_TRUE(infobar == NULL); |
| 835 | 838 |
| 836 // Simulate getting the page contents and language, that should not trigger | 839 // Simulate getting the page contents and language, that should not trigger |
| 837 // a translate infobar. | 840 // a translate infobar. |
| 838 SimulateOnPageContents(url, 1, "Le YouTube", "fr", true); | 841 SimulateOnPageContents(url, 1, "Le YouTube", "fr", true); |
| 839 infobar = GetTranslateInfoBar(); | 842 infobar = GetTranslateInfoBar(); |
| 840 EXPECT_TRUE(infobar == NULL); | 843 EXPECT_TRUE(infobar == NULL); |
| 841 } | 844 } |
| 842 | 845 |
| 843 // Tests the "Never translate <language>" pref. | 846 // Tests the "Never translate <language>" pref. |
| 844 TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) { | 847 TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) { |
| 845 // Simulate navigating to a page and getting its language. | 848 // Simulate navigating to a page and getting its language. |
| 846 GURL url("http://www.google.fr"); | 849 GURL url("http://www.google.fr"); |
| 847 SimulateNavigation(url, "Le Google", "fr", true); | 850 SimulateNavigation(url, 0, "Le Google", "fr", true); |
| 848 | 851 |
| 849 // An infobar should be shown. | 852 // An infobar should be shown. |
| 850 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 853 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 851 | 854 |
| 852 // Select never translate this language. | 855 // Select never translate this language. |
| 853 PrefService* prefs = contents()->profile()->GetPrefs(); | 856 PrefService* prefs = contents()->profile()->GetPrefs(); |
| 854 prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateLanguageBlacklist, | 857 prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateLanguageBlacklist, |
| 855 &pref_observer_); | 858 &pref_observer_); |
| 856 TranslatePrefs translate_prefs(prefs); | 859 TranslatePrefs translate_prefs(prefs); |
| 857 EXPECT_FALSE(translate_prefs.IsLanguageBlacklisted("fr")); | 860 EXPECT_FALSE(translate_prefs.IsLanguageBlacklisted("fr")); |
| 858 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); | 861 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); |
| 859 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateLanguageBlacklist); | 862 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateLanguageBlacklist); |
| 860 translate_prefs.BlacklistLanguage("fr"); | 863 translate_prefs.BlacklistLanguage("fr"); |
| 861 EXPECT_TRUE(translate_prefs.IsLanguageBlacklisted("fr")); | 864 EXPECT_TRUE(translate_prefs.IsLanguageBlacklisted("fr")); |
| 862 EXPECT_FALSE(translate_prefs.CanTranslate(prefs, "fr", url)); | 865 EXPECT_FALSE(translate_prefs.CanTranslate(prefs, "fr", url)); |
| 863 | 866 |
| 864 // Close the infobar. | 867 // Close the infobar. |
| 865 EXPECT_TRUE(CloseTranslateInfoBar()); | 868 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 866 | 869 |
| 867 // Navigate to a new page also in French. | 870 // Navigate to a new page also in French. |
| 868 SimulateNavigation(GURL("http://wwww.youtube.fr"), "Le YouTube", "fr", true); | 871 SimulateNavigation(GURL("http://wwww.youtube.fr"), 1, "Le YouTube", "fr", |
| 872 true); |
| 869 | 873 |
| 870 // There should not be a translate infobar. | 874 // There should not be a translate infobar. |
| 871 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 875 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 872 | 876 |
| 873 // Remove the language from the blacklist. | 877 // Remove the language from the blacklist. |
| 874 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateLanguageBlacklist); | 878 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateLanguageBlacklist); |
| 875 translate_prefs.RemoveLanguageFromBlacklist("fr"); | 879 translate_prefs.RemoveLanguageFromBlacklist("fr"); |
| 876 EXPECT_FALSE(translate_prefs.IsLanguageBlacklisted("fr")); | 880 EXPECT_FALSE(translate_prefs.IsLanguageBlacklisted("fr")); |
| 877 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); | 881 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); |
| 878 | 882 |
| 879 // Navigate to a page in French. | 883 // Navigate to a page in French. |
| 880 SimulateNavigation(url, "Le Google", "fr", true); | 884 SimulateNavigation(url, 2, "Le Google", "fr", true); |
| 881 | 885 |
| 882 // There should be a translate infobar. | 886 // There should be a translate infobar. |
| 883 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 887 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 884 prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateLanguageBlacklist, | 888 prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateLanguageBlacklist, |
| 885 &pref_observer_); | 889 &pref_observer_); |
| 886 } | 890 } |
| 887 | 891 |
| 888 // Tests the "Never translate this site" pref. | 892 // Tests the "Never translate this site" pref. |
| 889 TEST_F(TranslateManagerTest, NeverTranslateSitePref) { | 893 TEST_F(TranslateManagerTest, NeverTranslateSitePref) { |
| 890 // Simulate navigating to a page and getting its language. | 894 // Simulate navigating to a page and getting its language. |
| 891 GURL url("http://www.google.fr"); | 895 GURL url("http://www.google.fr"); |
| 892 std::string host(url.host()); | 896 std::string host(url.host()); |
| 893 SimulateNavigation(url, "Le Google", "fr", true); | 897 SimulateNavigation(url, 0, "Le Google", "fr", true); |
| 894 | 898 |
| 895 // An infobar should be shown. | 899 // An infobar should be shown. |
| 896 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 900 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 897 | 901 |
| 898 // Select never translate this site. | 902 // Select never translate this site. |
| 899 PrefService* prefs = contents()->profile()->GetPrefs(); | 903 PrefService* prefs = contents()->profile()->GetPrefs(); |
| 900 prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateSiteBlacklist, | 904 prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateSiteBlacklist, |
| 901 &pref_observer_); | 905 &pref_observer_); |
| 902 TranslatePrefs translate_prefs(prefs); | 906 TranslatePrefs translate_prefs(prefs); |
| 903 EXPECT_FALSE(translate_prefs.IsSiteBlacklisted(host)); | 907 EXPECT_FALSE(translate_prefs.IsSiteBlacklisted(host)); |
| 904 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); | 908 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); |
| 905 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateSiteBlacklist); | 909 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateSiteBlacklist); |
| 906 translate_prefs.BlacklistSite(host); | 910 translate_prefs.BlacklistSite(host); |
| 907 EXPECT_TRUE(translate_prefs.IsSiteBlacklisted(host)); | 911 EXPECT_TRUE(translate_prefs.IsSiteBlacklisted(host)); |
| 908 EXPECT_FALSE(translate_prefs.CanTranslate(prefs, "fr", url)); | 912 EXPECT_FALSE(translate_prefs.CanTranslate(prefs, "fr", url)); |
| 909 | 913 |
| 910 // Close the infobar. | 914 // Close the infobar. |
| 911 EXPECT_TRUE(CloseTranslateInfoBar()); | 915 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 912 | 916 |
| 913 // Navigate to a new page also on the same site. | 917 // Navigate to a new page also on the same site. |
| 914 SimulateNavigation(GURL("http://www.google.fr/hello"), "Bonjour", "fr", true); | 918 SimulateNavigation(GURL("http://www.google.fr/hello"), 1, "Bonjour", "fr", |
| 919 true); |
| 915 | 920 |
| 916 // There should not be a translate infobar. | 921 // There should not be a translate infobar. |
| 917 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 922 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 918 | 923 |
| 919 // Remove the site from the blacklist. | 924 // Remove the site from the blacklist. |
| 920 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateSiteBlacklist); | 925 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateSiteBlacklist); |
| 921 translate_prefs.RemoveSiteFromBlacklist(host); | 926 translate_prefs.RemoveSiteFromBlacklist(host); |
| 922 EXPECT_FALSE(translate_prefs.IsSiteBlacklisted(host)); | 927 EXPECT_FALSE(translate_prefs.IsSiteBlacklisted(host)); |
| 923 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); | 928 EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); |
| 924 | 929 |
| 925 // Navigate to a page in French. | 930 // Navigate to a page in French. |
| 926 SimulateNavigation(url, "Le Google", "fr", true); | 931 SimulateNavigation(url, 0, "Le Google", "fr", true); |
| 927 | 932 |
| 928 // There should be a translate infobar. | 933 // There should be a translate infobar. |
| 929 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 934 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 930 prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateSiteBlacklist, | 935 prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateSiteBlacklist, |
| 931 &pref_observer_); | 936 &pref_observer_); |
| 932 } | 937 } |
| 933 | 938 |
| 934 // Tests the "Always translate this language" pref. | 939 // Tests the "Always translate this language" pref. |
| 935 TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) { | 940 TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) { |
| 936 // Select always translate French to English. | 941 // Select always translate French to English. |
| 937 PrefService* prefs = contents()->profile()->GetPrefs(); | 942 PrefService* prefs = contents()->profile()->GetPrefs(); |
| 938 prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateWhitelists, | 943 prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateWhitelists, |
| 939 &pref_observer_); | 944 &pref_observer_); |
| 940 TranslatePrefs translate_prefs(prefs); | 945 TranslatePrefs translate_prefs(prefs); |
| 941 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists); | 946 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists); |
| 942 translate_prefs.WhitelistLanguagePair("fr", "en"); | 947 translate_prefs.WhitelistLanguagePair("fr", "en"); |
| 943 | 948 |
| 944 // Load a page in French. | 949 // Load a page in French. |
| 945 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 950 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 946 | 951 |
| 947 // It should have triggered an automatic translation to English. | 952 // It should have triggered an automatic translation to English. |
| 948 | 953 |
| 949 // The translating infobar should be showing. | 954 // The translating infobar should be showing. |
| 950 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 955 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 951 ASSERT_TRUE(infobar != NULL); | 956 ASSERT_TRUE(infobar != NULL); |
| 952 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATING, infobar->type()); | 957 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATING, infobar->type()); |
| 953 | 958 |
| 954 SimulateURLFetch(true); // Simulate the translate script being retrieved. | 959 SimulateURLFetch(true); // Simulate the translate script being retrieved. |
| 955 int page_id = 0; | 960 int page_id = 0; |
| 956 std::string original_lang, target_lang; | 961 std::string original_lang, target_lang; |
| 957 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 962 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 963 EXPECT_EQ(0, page_id); |
| 958 EXPECT_EQ("fr", original_lang); | 964 EXPECT_EQ("fr", original_lang); |
| 959 EXPECT_EQ("en", target_lang); | 965 EXPECT_EQ("en", target_lang); |
| 960 process()->sink().ClearMessages(); | 966 process()->sink().ClearMessages(); |
| 961 | 967 |
| 962 // Try another language, it should not be autotranslated. | 968 // Try another language, it should not be autotranslated. |
| 963 SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true); | 969 SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es", true); |
| 964 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 970 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 965 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 971 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 966 EXPECT_TRUE(CloseTranslateInfoBar()); | 972 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 967 | 973 |
| 968 // Let's switch to incognito mode, it should not be autotranslated in that | 974 // Let's switch to incognito mode, it should not be autotranslated in that |
| 969 // case either. | 975 // case either. |
| 970 TestingProfile* test_profile = | 976 TestingProfile* test_profile = |
| 971 static_cast<TestingProfile*>(contents()->profile()); | 977 static_cast<TestingProfile*>(contents()->profile()); |
| 972 test_profile->set_off_the_record(true); | 978 test_profile->set_off_the_record(true); |
| 973 SimulateNavigation(GURL("http://www.youtube.fr"), "Le YouTube", "fr", true); | 979 SimulateNavigation(GURL("http://www.youtube.fr"), 2, "Le YouTube", "fr", |
| 980 true); |
| 974 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 981 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 975 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 982 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 976 EXPECT_TRUE(CloseTranslateInfoBar()); | 983 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 977 test_profile->set_off_the_record(false); // Get back to non incognito. | 984 test_profile->set_off_the_record(false); // Get back to non incognito. |
| 978 | 985 |
| 979 // Now revert the always translate pref and make sure we go back to expected | 986 // Now revert the always translate pref and make sure we go back to expected |
| 980 // behavior, which is show a "before translate" infobar. | 987 // behavior, which is show a "before translate" infobar. |
| 981 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists); | 988 SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists); |
| 982 translate_prefs.RemoveLanguagePairFromWhitelist("fr", "en"); | 989 translate_prefs.RemoveLanguagePairFromWhitelist("fr", "en"); |
| 983 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 990 SimulateNavigation(GURL("http://www.google.fr"), 3, "Le Google", "fr", true); |
| 984 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 991 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 985 infobar = GetTranslateInfoBar(); | 992 infobar = GetTranslateInfoBar(); |
| 986 ASSERT_TRUE(infobar != NULL); | 993 ASSERT_TRUE(infobar != NULL); |
| 987 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); | 994 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); |
| 988 prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateWhitelists, | 995 prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateWhitelists, |
| 989 &pref_observer_); | 996 &pref_observer_); |
| 990 } | 997 } |
| 991 | 998 |
| 992 // Context menu. | 999 // Context menu. |
| 993 TEST_F(TranslateManagerTest, ContextMenu) { | 1000 TEST_F(TranslateManagerTest, ContextMenu) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1020 | 1027 |
| 1021 // That should have triggered a translation. | 1028 // That should have triggered a translation. |
| 1022 // The "translating..." infobar should be showing. | 1029 // The "translating..." infobar should be showing. |
| 1023 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1030 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 1024 ASSERT_TRUE(infobar != NULL); | 1031 ASSERT_TRUE(infobar != NULL); |
| 1025 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATING, infobar->type()); | 1032 EXPECT_EQ(TranslateInfoBarDelegate::TRANSLATING, infobar->type()); |
| 1026 SimulateURLFetch(true); // Simulate the translate script being retrieved. | 1033 SimulateURLFetch(true); // Simulate the translate script being retrieved. |
| 1027 int page_id = 0; | 1034 int page_id = 0; |
| 1028 std::string original_lang, target_lang; | 1035 std::string original_lang, target_lang; |
| 1029 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1036 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1037 EXPECT_EQ(0, page_id); |
| 1030 EXPECT_EQ("fr", original_lang); | 1038 EXPECT_EQ("fr", original_lang); |
| 1031 EXPECT_EQ("en", target_lang); | 1039 EXPECT_EQ("en", target_lang); |
| 1032 process()->sink().ClearMessages(); | 1040 process()->sink().ClearMessages(); |
| 1033 | 1041 |
| 1034 // This should also have reverted the blacklisting of this site and language. | 1042 // This should also have reverted the blacklisting of this site and language. |
| 1035 EXPECT_FALSE(translate_prefs.IsLanguageBlacklisted("fr")); | 1043 EXPECT_FALSE(translate_prefs.IsLanguageBlacklisted("fr")); |
| 1036 EXPECT_FALSE(translate_prefs.IsSiteBlacklisted(url.host())); | 1044 EXPECT_FALSE(translate_prefs.IsSiteBlacklisted(url.host())); |
| 1037 | 1045 |
| 1038 // Let's simulate the page being translated. | 1046 // Let's simulate the page being translated. |
| 1039 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", | 1047 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", |
| 1040 TranslateErrors::NONE)); | 1048 TranslateErrors::NONE)); |
| 1041 | 1049 |
| 1042 // The translate menu should now be disabled. | 1050 // The translate menu should now be disabled. |
| 1043 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 1051 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 1044 menu->Init(); | 1052 menu->Init(); |
| 1045 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1053 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1046 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1054 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1047 | 1055 |
| 1048 // Test that selecting translate in the context menu WHILE the page is being | 1056 // Test that selecting translate in the context menu WHILE the page is being |
| 1049 // translated does nothing (this could happen if autotranslate kicks-in and | 1057 // translated does nothing (this could happen if autotranslate kicks-in and |
| 1050 // the user selects the menu while the translation is being performed). | 1058 // the user selects the menu while the translation is being performed). |
| 1051 SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true); | 1059 SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es", true); |
| 1052 infobar = GetTranslateInfoBar(); | 1060 infobar = GetTranslateInfoBar(); |
| 1053 ASSERT_TRUE(infobar != NULL); | 1061 ASSERT_TRUE(infobar != NULL); |
| 1054 infobar->Translate(); | 1062 infobar->Translate(); |
| 1055 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1063 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1064 EXPECT_EQ(1, page_id); |
| 1056 process()->sink().ClearMessages(); | 1065 process()->sink().ClearMessages(); |
| 1057 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 1066 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 1058 menu->Init(); | 1067 menu->Init(); |
| 1059 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1068 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1060 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); | 1069 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); |
| 1061 // No message expected since the translation should have been ignored. | 1070 // No message expected since the translation should have been ignored. |
| 1062 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1071 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1063 | 1072 |
| 1064 // Now test that selecting translate in the context menu AFTER the page has | 1073 // Now test that selecting translate in the context menu AFTER the page has |
| 1065 // been translated does nothing. | 1074 // been translated does nothing. |
| 1066 SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true); | 1075 SimulateNavigation(GURL("http://www.google.de"), 2, "Das Google", "de", true); |
| 1067 infobar = GetTranslateInfoBar(); | 1076 infobar = GetTranslateInfoBar(); |
| 1068 ASSERT_TRUE(infobar != NULL); | 1077 ASSERT_TRUE(infobar != NULL); |
| 1069 infobar->Translate(); | 1078 infobar->Translate(); |
| 1070 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1079 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1080 EXPECT_EQ(2, page_id); |
| 1071 process()->sink().ClearMessages(); | 1081 process()->sink().ClearMessages(); |
| 1072 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 1082 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 1073 menu->Init(); | 1083 menu->Init(); |
| 1074 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1084 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1075 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "de", "en", | 1085 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "de", "en", |
| 1076 TranslateErrors::NONE)); | 1086 TranslateErrors::NONE)); |
| 1077 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); | 1087 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE); |
| 1078 // No message expected since the translation should have been ignored. | 1088 // No message expected since the translation should have been ignored. |
| 1079 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1089 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1080 | 1090 |
| 1081 // Test that the translate context menu is disabled when the page is in the | 1091 // Test that the translate context menu is disabled when the page is in the |
| 1082 // same language as the UI. | 1092 // same language as the UI. |
| 1083 SimulateNavigation(url, "Google", "en", true); | 1093 SimulateNavigation(url, 0, "Google", "en", true); |
| 1084 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 1094 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 1085 menu->Init(); | 1095 menu->Init(); |
| 1086 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1096 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1087 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1097 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1088 | 1098 |
| 1089 // Test that the translate context menu is enabled when the page is in an | 1099 // Test that the translate context menu is enabled when the page is in an |
| 1090 // unknown language. | 1100 // unknown language. |
| 1091 SimulateNavigation(url, "G00g1e", "und", true); | 1101 SimulateNavigation(url, 0, "G00g1e", "und", true); |
| 1092 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 1102 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 1093 menu->Init(); | 1103 menu->Init(); |
| 1094 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1104 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1095 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1105 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1096 | 1106 |
| 1097 // Test that the translate context menu is disabled when the page is in an | 1107 // Test that the translate context menu is disabled when the page is in an |
| 1098 // unsupported language. | 1108 // unsupported language. |
| 1099 SimulateNavigation(url, "G00g1e", "qbz", true); | 1109 SimulateNavigation(url, 0, "G00g1e", "qbz", true); |
| 1100 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); | 1110 menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 1101 menu->Init(); | 1111 menu->Init(); |
| 1102 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1112 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1103 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1113 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1104 } | 1114 } |
| 1105 | 1115 |
| 1106 // Tests that an extra always/never translate button is shown on the "before | 1116 // Tests that an extra always/never translate button is shown on the "before |
| 1107 // translate" infobar when the translation is accepted/declined 3 times, | 1117 // translate" infobar when the translation is accepted/declined 3 times, |
| 1108 // only when not in incognito mode. | 1118 // only when not in incognito mode. |
| 1109 TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) { | 1119 TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) { |
| 1110 TranslatePrefs translate_prefs(contents()->profile()->GetPrefs()); | 1120 TranslatePrefs translate_prefs(contents()->profile()->GetPrefs()); |
| 1111 translate_prefs.ResetTranslationAcceptedCount("fr"); | 1121 translate_prefs.ResetTranslationAcceptedCount("fr"); |
| 1112 translate_prefs.ResetTranslationDeniedCount("fr"); | 1122 translate_prefs.ResetTranslationDeniedCount("fr"); |
| 1113 translate_prefs.ResetTranslationAcceptedCount("de"); | 1123 translate_prefs.ResetTranslationAcceptedCount("de"); |
| 1114 translate_prefs.ResetTranslationDeniedCount("de"); | 1124 translate_prefs.ResetTranslationDeniedCount("de"); |
| 1115 | 1125 |
| 1116 // We'll do 4 times in incognito mode first to make sure the button is not | 1126 // We'll do 4 times in incognito mode first to make sure the button is not |
| 1117 // shown in that case, then 4 times in normal mode. | 1127 // shown in that case, then 4 times in normal mode. |
| 1118 TranslateInfoBarDelegate* infobar; | 1128 TranslateInfoBarDelegate* infobar; |
| 1119 TestingProfile* test_profile = | 1129 TestingProfile* test_profile = |
| 1120 static_cast<TestingProfile*>(contents()->profile()); | 1130 static_cast<TestingProfile*>(contents()->profile()); |
| 1121 test_profile->set_off_the_record(true); | 1131 test_profile->set_off_the_record(true); |
| 1122 for (int i = 0; i < 8; ++i) { | 1132 for (int i = 0; i < 8; ++i) { |
| 1123 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << | 1133 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << |
| 1124 " incognito mode=" << test_profile->IsOffTheRecord()); | 1134 " incognito mode=" << test_profile->IsOffTheRecord()); |
| 1125 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 1135 SimulateNavigation(GURL("http://www.google.fr"), 1, "Le Google", "fr", |
| 1136 true); |
| 1126 infobar = GetTranslateInfoBar(); | 1137 infobar = GetTranslateInfoBar(); |
| 1127 ASSERT_TRUE(infobar != NULL); | 1138 ASSERT_TRUE(infobar != NULL); |
| 1128 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); | 1139 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); |
| 1129 if (i < 7) { | 1140 if (i < 7) { |
| 1130 EXPECT_FALSE(infobar->ShouldShowAlwaysTranslateButton()); | 1141 EXPECT_FALSE(infobar->ShouldShowAlwaysTranslateButton()); |
| 1131 infobar->Translate(); | 1142 infobar->Translate(); |
| 1132 process()->sink().ClearMessages(); | 1143 process()->sink().ClearMessages(); |
| 1133 } else { | 1144 } else { |
| 1134 EXPECT_TRUE(infobar->ShouldShowAlwaysTranslateButton()); | 1145 EXPECT_TRUE(infobar->ShouldShowAlwaysTranslateButton()); |
| 1135 } | 1146 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1147 std::string original_lang, target_lang; | 1158 std::string original_lang, target_lang; |
| 1148 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1159 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1149 process()->sink().ClearMessages(); | 1160 process()->sink().ClearMessages(); |
| 1150 | 1161 |
| 1151 // Now test that declining the translation causes a "never translate" button | 1162 // Now test that declining the translation causes a "never translate" button |
| 1152 // to be shown (in non incognito mode only). | 1163 // to be shown (in non incognito mode only). |
| 1153 test_profile->set_off_the_record(true); | 1164 test_profile->set_off_the_record(true); |
| 1154 for (int i = 0; i < 8; ++i) { | 1165 for (int i = 0; i < 8; ++i) { |
| 1155 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << | 1166 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << |
| 1156 " incognito mode=" << test_profile->IsOffTheRecord()); | 1167 " incognito mode=" << test_profile->IsOffTheRecord()); |
| 1157 SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true); | 1168 SimulateNavigation(GURL("http://www.google.de"), 1, "Das Google", "de", |
| 1169 true); |
| 1158 infobar = GetTranslateInfoBar(); | 1170 infobar = GetTranslateInfoBar(); |
| 1159 ASSERT_TRUE(infobar != NULL); | 1171 ASSERT_TRUE(infobar != NULL); |
| 1160 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); | 1172 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); |
| 1161 if (i < 7) { | 1173 if (i < 7) { |
| 1162 EXPECT_FALSE(infobar->ShouldShowNeverTranslateButton()); | 1174 EXPECT_FALSE(infobar->ShouldShowNeverTranslateButton()); |
| 1163 infobar->TranslationDeclined(); | 1175 infobar->TranslationDeclined(); |
| 1164 } else { | 1176 } else { |
| 1165 EXPECT_TRUE(infobar->ShouldShowNeverTranslateButton()); | 1177 EXPECT_TRUE(infobar->ShouldShowNeverTranslateButton()); |
| 1166 } | 1178 } |
| 1167 if (i == 3) | 1179 if (i == 3) |
| 1168 test_profile->set_off_the_record(false); | 1180 test_profile->set_off_the_record(false); |
| 1169 } | 1181 } |
| 1170 // Simulate the user pressing "Never translate French". | 1182 // Simulate the user pressing "Never translate French". |
| 1171 infobar->NeverTranslatePageLanguage(); | 1183 infobar->NeverTranslatePageLanguage(); |
| 1172 EXPECT_TRUE(translate_prefs.IsLanguageBlacklisted("de")); | 1184 EXPECT_TRUE(translate_prefs.IsLanguageBlacklisted("de")); |
| 1173 // No translation should have occured and the infobar should be gone. | 1185 // No translation should have occured and the infobar should be gone. |
| 1174 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1186 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1175 process()->sink().ClearMessages(); | 1187 process()->sink().ClearMessages(); |
| 1176 ASSERT_TRUE(GetTranslateInfoBar() == NULL); | 1188 ASSERT_TRUE(GetTranslateInfoBar() == NULL); |
| 1177 } | 1189 } |
| 1178 | 1190 |
| 1179 // Tests that we don't show a translate infobar when a page instructs that it | 1191 // Tests that we don't show a translate infobar when a page instructs that it |
| 1180 // should not be translated. | 1192 // should not be translated. |
| 1181 TEST_F(TranslateManagerTest, NonTranslatablePage) { | 1193 TEST_F(TranslateManagerTest, NonTranslatablePage) { |
| 1182 // Simulate navigating to a page. | 1194 // Simulate navigating to a page. |
| 1183 SimulateNavigation(GURL("http://mail.google.fr"), "Le Google", "fr", false); | 1195 SimulateNavigation(GURL("http://mail.google.fr"), 0, "Le Google", "fr", |
| 1196 false); |
| 1184 | 1197 |
| 1185 // We should not have an infobar. | 1198 // We should not have an infobar. |
| 1186 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 1199 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 1187 | 1200 |
| 1188 // The context menu should be disabled. | 1201 // The context menu should be disabled. |
| 1189 scoped_ptr<TestRenderViewContextMenu> menu( | 1202 scoped_ptr<TestRenderViewContextMenu> menu( |
| 1190 TestRenderViewContextMenu::CreateContextMenu(contents())); | 1203 TestRenderViewContextMenu::CreateContextMenu(contents())); |
| 1191 menu->Init(); | 1204 menu->Init(); |
| 1192 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1205 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1193 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1206 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
| 1194 } | 1207 } |
| 1195 | 1208 |
| 1196 // Tests that the script is expired and refetched as expected. | 1209 // Tests that the script is expired and refetched as expected. |
| 1197 TEST_F(TranslateManagerTest, ScriptExpires) { | 1210 TEST_F(TranslateManagerTest, ScriptExpires) { |
| 1198 ExpireTranslateScriptImmediately(); | 1211 ExpireTranslateScriptImmediately(); |
| 1199 | 1212 |
| 1200 // Simulate navigating to a page and translating it. | 1213 // Simulate navigating to a page and translating it. |
| 1201 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); | 1214 SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true); |
| 1202 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1215 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 1203 ASSERT_TRUE(infobar != NULL); | 1216 ASSERT_TRUE(infobar != NULL); |
| 1204 process()->sink().ClearMessages(); | 1217 process()->sink().ClearMessages(); |
| 1205 infobar->Translate(); | 1218 infobar->Translate(); |
| 1206 SimulateURLFetch(true); | 1219 SimulateURLFetch(true); |
| 1207 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", | 1220 rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", |
| 1208 TranslateErrors::NONE)); | 1221 TranslateErrors::NONE)); |
| 1209 | 1222 |
| 1210 // A task should have been posted to clear the script, run it. | 1223 // A task should have been posted to clear the script, run it. |
| 1211 MessageLoop::current()->RunAllPending(); | 1224 MessageLoop::current()->RunAllPending(); |
| 1212 | 1225 |
| 1213 // Do another navigation and translation. | 1226 // Do another navigation and translation. |
| 1214 SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true); | 1227 SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es", true); |
| 1215 infobar = GetTranslateInfoBar(); | 1228 infobar = GetTranslateInfoBar(); |
| 1216 ASSERT_TRUE(infobar != NULL); | 1229 ASSERT_TRUE(infobar != NULL); |
| 1217 process()->sink().ClearMessages(); | 1230 process()->sink().ClearMessages(); |
| 1218 infobar->Translate(); | 1231 infobar->Translate(); |
| 1219 // If we don't simulate the URL fetch, the TranslateManager should be waiting | 1232 // If we don't simulate the URL fetch, the TranslateManager should be waiting |
| 1220 // for the script and no message should have been sent to the renderer. | 1233 // for the script and no message should have been sent to the renderer. |
| 1221 EXPECT_TRUE( | 1234 EXPECT_TRUE( |
| 1222 process()->sink().GetFirstMessageMatching(ViewMsg_TranslatePage::ID) == | 1235 process()->sink().GetFirstMessageMatching(ViewMsg_TranslatePage::ID) == |
| 1223 NULL); | 1236 NULL); |
| 1224 // Now simulate the URL fetch. | 1237 // Now simulate the URL fetch. |
| 1225 SimulateURLFetch(true); | 1238 SimulateURLFetch(true); |
| 1226 // Now the message should have been sent. | 1239 // Now the message should have been sent. |
| 1227 int page_id = 0; | 1240 int page_id = 0; |
| 1228 std::string original_lang, target_lang; | 1241 std::string original_lang, target_lang; |
| 1229 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1242 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
| 1243 EXPECT_EQ(1, page_id); |
| 1230 EXPECT_EQ("es", original_lang); | 1244 EXPECT_EQ("es", original_lang); |
| 1231 EXPECT_EQ("en", target_lang); | 1245 EXPECT_EQ("en", target_lang); |
| 1232 } | 1246 } |
| OLD | NEW |