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

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

Issue 14494004: Added the 'Translation Logs' tab to chrome://translate-internals/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (Rebasing) Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 29 matching lines...) Expand all
40 #include "chrome/browser/ui/browser_window.h" 40 #include "chrome/browser/ui/browser_window.h"
41 #include "chrome/browser/ui/extensions/application_launch.h" 41 #include "chrome/browser/ui/extensions/application_launch.h"
42 #include "chrome/browser/ui/host_desktop.h" 42 #include "chrome/browser/ui/host_desktop.h"
43 #include "chrome/browser/ui/startup/startup_browser_creator.h" 43 #include "chrome/browser/ui/startup/startup_browser_creator.h"
44 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" 44 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
45 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" 45 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
46 #include "chrome/browser/ui/tabs/tab_strip_model.h" 46 #include "chrome/browser/ui/tabs/tab_strip_model.h"
47 #include "chrome/common/chrome_notification_types.h" 47 #include "chrome/common/chrome_notification_types.h"
48 #include "chrome/common/chrome_switches.h" 48 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/extensions/extension.h" 49 #include "chrome/common/extensions/extension.h"
50 #include "chrome/common/language_detection_details.h"
50 #include "chrome/common/url_constants.h" 51 #include "chrome/common/url_constants.h"
51 #include "chrome/test/base/in_process_browser_test.h" 52 #include "chrome/test/base/in_process_browser_test.h"
52 #include "chrome/test/base/ui_test_utils.h" 53 #include "chrome/test/base/ui_test_utils.h"
53 #include "content/public/browser/favicon_status.h" 54 #include "content/public/browser/favicon_status.h"
54 #include "content/public/browser/host_zoom_map.h" 55 #include "content/public/browser/host_zoom_map.h"
55 #include "content/public/browser/interstitial_page.h" 56 #include "content/public/browser/interstitial_page.h"
56 #include "content/public/browser/interstitial_page_delegate.h" 57 #include "content/public/browser/interstitial_page_delegate.h"
57 #include "content/public/browser/navigation_entry.h" 58 #include "content/public/browser/navigation_entry.h"
58 #include "content/public/browser/render_process_host.h" 59 #include "content/public/browser/render_process_host.h"
59 #include "content/public/browser/render_view_host.h" 60 #include "content/public/browser/render_view_host.h"
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 ASSERT_NE( 1033 ASSERT_NE(
1033 new_browser->app_name_.find(extension_app->id()), 1034 new_browser->app_name_.find(extension_app->id()),
1034 std::string::npos) << new_browser->app_name_; 1035 std::string::npos) << new_browser->app_name_;
1035 } 1036 }
1036 #endif 1037 #endif
1037 1038
1038 // Tests that the CLD (Compact Language Detection) works properly. 1039 // Tests that the CLD (Compact Language Detection) works properly.
1039 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { 1040 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) {
1040 ASSERT_TRUE(test_server()->Start()); 1041 ASSERT_TRUE(test_server()->Start());
1041 1042
1042 std::string lang; 1043 //std::string lang;
1044 LanguageDetectionDetails details;
1043 1045
1044 // Open a new tab with a page in English. 1046 // Open a new tab with a page in English.
1045 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), 1047 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")),
1046 content::PAGE_TRANSITION_TYPED); 1048 content::PAGE_TRANSITION_TYPED);
1047 1049
1048 WebContents* current_web_contents = 1050 WebContents* current_web_contents =
1049 browser()->tab_strip_model()->GetActiveWebContents(); 1051 browser()->tab_strip_model()->GetActiveWebContents();
1050 TranslateTabHelper* translate_tab_helper = 1052 TranslateTabHelper* translate_tab_helper =
1051 TranslateTabHelper::FromWebContents(current_web_contents); 1053 TranslateTabHelper::FromWebContents(current_web_contents);
1052 content::Source<WebContents> source(current_web_contents); 1054 content::Source<WebContents> source(current_web_contents);
1053 1055
1054 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 1056 ui_test_utils::WindowedNotificationObserverWithDetails<
1057 LanguageDetectionDetails>
1055 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1058 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1056 source); 1059 source);
1057 EXPECT_EQ("", translate_tab_helper->language_state().original_language()); 1060 EXPECT_EQ("", translate_tab_helper->language_state().original_language());
1058 en_language_detected_signal.Wait(); 1061 en_language_detected_signal.Wait();
1059 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( 1062 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor(
1060 source.map_key(), &lang)); 1063 source.map_key(), &details));
1061 EXPECT_EQ("en", lang); 1064 EXPECT_EQ("en", details.adopted_language);
1062 EXPECT_EQ("en", translate_tab_helper->language_state().original_language()); 1065 EXPECT_EQ("en", translate_tab_helper->language_state().original_language());
1063 1066
1064 // Now navigate to a page in French. 1067 // Now navigate to a page in French.
1065 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 1068 ui_test_utils::WindowedNotificationObserverWithDetails<
1069 LanguageDetectionDetails>
1066 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1070 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1067 source); 1071 source);
1068 ui_test_utils::NavigateToURL( 1072 ui_test_utils::NavigateToURL(
1069 browser(), GURL(test_server()->GetURL("files/french_page.html"))); 1073 browser(), GURL(test_server()->GetURL("files/french_page.html")));
1070 fr_language_detected_signal.Wait(); 1074 fr_language_detected_signal.Wait();
1071 lang.clear(); 1075 details.adopted_language.clear();
1072 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( 1076 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor(
1073 source.map_key(), &lang)); 1077 source.map_key(), &details));
1074 EXPECT_EQ("fr", lang); 1078 EXPECT_EQ("fr", details.adopted_language);
1075 EXPECT_EQ("fr", translate_tab_helper->language_state().original_language()); 1079 EXPECT_EQ("fr", translate_tab_helper->language_state().original_language());
1076 } 1080 }
1077 1081
1078 // Chromeos defaults to restoring the last session, so this test isn't 1082 // Chromeos defaults to restoring the last session, so this test isn't
1079 // applicable. 1083 // applicable.
1080 #if !defined(OS_CHROMEOS) 1084 #if !defined(OS_CHROMEOS)
1081 #if defined(OS_MACOSX) 1085 #if defined(OS_MACOSX)
1082 // Crashy, http://crbug.com/38522 1086 // Crashy, http://crbug.com/38522
1083 #define RestorePinnedTabs DISABLED_RestorePinnedTabs 1087 #define RestorePinnedTabs DISABLED_RestorePinnedTabs
1084 #endif 1088 #endif
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2157 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2154 } 2158 }
2155 2159
2156 // Shift-middle-clicks open in a foreground tab. 2160 // Shift-middle-clicks open in a foreground tab.
2157 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { 2161 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) {
2158 int modifiers = WebKit::WebInputEvent::ShiftKey; 2162 int modifiers = WebKit::WebInputEvent::ShiftKey;
2159 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; 2163 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle;
2160 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 2164 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
2161 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 2165 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
2162 } 2166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698