Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: chrome/browser/browser_browsertest.cc

Issue 7044071: Rewrite BrowserTest.PageLanguageDetection to use a new tab instead of the one with about:blank. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/renderer/chrome_render_view_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 ASSERT_TRUE(new_browser != browser()); 583 ASSERT_TRUE(new_browser != browser());
584 584
585 // The browser's app_name should include the app's ID. 585 // The browser's app_name should include the app's ID.
586 ASSERT_NE( 586 ASSERT_NE(
587 new_browser->app_name_.find(extension_app->id()), 587 new_browser->app_name_.find(extension_app->id()),
588 std::string::npos) << new_browser->app_name_; 588 std::string::npos) << new_browser->app_name_;
589 } 589 }
590 #endif 590 #endif
591 591
592 #if defined(OS_WIN) 592 #if defined(OS_WIN)
593 // http://crbug.com/46198. On XP/Vista, the failure rate is 5 ~ 6%. 593 // http://crbug.com/46198: On XP/Vista, the failure rate is 5 ~ 6%.
594 #define MAYBE_PageLanguageDetection FLAKY_PageLanguageDetection 594 #define MAYBE_PageLanguageDetection FLAKY_PageLanguageDetection
595 #else 595 #else
596 #define MAYBE_PageLanguageDetection PageLanguageDetection 596 #define MAYBE_PageLanguageDetection PageLanguageDetection
597 #endif 597 #endif
598 // Tests that the CLD (Compact Language Detection) works properly. 598 // Tests that the CLD (Compact Language Detection) works properly.
599 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) { 599 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) {
600 ASSERT_TRUE(test_server()->Start()); 600 ASSERT_TRUE(test_server()->Start());
601 601
602 std::string lang;
603
604 // Open a new tab with a page in English.
605 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")),
606 PageTransition::TYPED);
607
602 TabContents* current_tab = browser()->GetSelectedTabContents(); 608 TabContents* current_tab = browser()->GetSelectedTabContents();
603 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); 609 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper();
604 TranslateTabHelper* helper = wrapper->translate_tab_helper(); 610 TranslateTabHelper* helper = wrapper->translate_tab_helper();
605 Source<TabContents> source(current_tab); 611 Source<TabContents> source(current_tab);
606 612
607 // Navigate to a page in English.
608 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 613 ui_test_utils::WindowedNotificationObserverWithDetails<std::string>
609 en_language_detected_signal(NotificationType::TAB_LANGUAGE_DETERMINED, 614 en_language_detected_signal(NotificationType::TAB_LANGUAGE_DETERMINED,
610 source); 615 source);
611 ui_test_utils::NavigateToURL(
612 browser(), GURL(test_server()->GetURL("files/english_page.html")));
613 EXPECT_TRUE(helper->language_state().original_language().empty()); 616 EXPECT_TRUE(helper->language_state().original_language().empty());
614 en_language_detected_signal.Wait(); 617 en_language_detected_signal.Wait();
615 std::string lang;
616 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( 618 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor(
617 source.map_key(), &lang)); 619 source.map_key(), &lang));
618 EXPECT_EQ("en", lang); 620 EXPECT_EQ("en", lang);
619 EXPECT_EQ("en", helper->language_state().original_language()); 621 EXPECT_EQ("en", helper->language_state().original_language());
620 622
621 // Now navigate to a page in French. 623 // Now navigate to a page in French.
622 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 624 ui_test_utils::WindowedNotificationObserverWithDetails<std::string>
623 fr_language_detected_signal(NotificationType::TAB_LANGUAGE_DETERMINED, 625 fr_language_detected_signal(NotificationType::TAB_LANGUAGE_DETERMINED,
624 source); 626 source);
625 ui_test_utils::NavigateToURL( 627 ui_test_utils::NavigateToURL(
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 848
847 // The normal browser should now have four. 849 // The normal browser should now have four.
848 EXPECT_EQ(4, browser()->tab_count()); 850 EXPECT_EQ(4, browser()->tab_count());
849 851
850 // Close the additional browsers. 852 // Close the additional browsers.
851 popup_browser->CloseAllTabs(); 853 popup_browser->CloseAllTabs();
852 app_browser->CloseAllTabs(); 854 app_browser->CloseAllTabs();
853 app_popup_browser->CloseAllTabs(); 855 app_popup_browser->CloseAllTabs();
854 } 856 }
855 #endif 857 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/chrome_render_view_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698