OLD | NEW |
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 | 5 |
6 #include <algorithm> | 6 #include <algorithm> |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // for that navigation. | 105 // for that navigation. |
106 void SimulateNavigation(const GURL& url, | 106 void SimulateNavigation(const GURL& url, |
107 const std::string& lang, | 107 const std::string& lang, |
108 bool page_translatable) { | 108 bool page_translatable) { |
109 NavigateAndCommit(url); | 109 NavigateAndCommit(url); |
110 SimulateOnTranslateLanguageDetermined(lang, page_translatable); | 110 SimulateOnTranslateLanguageDetermined(lang, page_translatable); |
111 } | 111 } |
112 | 112 |
113 void SimulateOnTranslateLanguageDetermined(const std::string& lang, | 113 void SimulateOnTranslateLanguageDetermined(const std::string& lang, |
114 bool page_translatable) { | 114 bool page_translatable) { |
| 115 LanguageDetectionDetails details; |
| 116 details.adopted_language = lang; |
115 RenderViewHostTester::TestOnMessageReceived( | 117 RenderViewHostTester::TestOnMessageReceived( |
116 rvh(), | 118 rvh(), |
117 ChromeViewHostMsg_TranslateLanguageDetermined( | 119 ChromeViewHostMsg_TranslateLanguageDetermined( |
118 0, lang, page_translatable)); | 120 0, details, page_translatable)); |
119 } | 121 } |
120 | 122 |
121 bool GetTranslateMessage(int* page_id, | 123 bool GetTranslateMessage(int* page_id, |
122 std::string* original_lang, | 124 std::string* original_lang, |
123 std::string* target_lang) { | 125 std::string* target_lang) { |
124 const IPC::Message* message = | 126 const IPC::Message* message = |
125 process()->sink().GetFirstMessageMatching( | 127 process()->sink().GetFirstMessageMatching( |
126 ChromeViewMsg_TranslatePage::ID); | 128 ChromeViewMsg_TranslatePage::ID); |
127 if (!message) | 129 if (!message) |
128 return false; | 130 return false; |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) { | 1517 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) { |
1516 WebContents* current_web_contents = | 1518 WebContents* current_web_contents = |
1517 browser()->tab_strip_model()->GetActiveWebContents(); | 1519 browser()->tab_strip_model()->GetActiveWebContents(); |
1518 content::Source<WebContents> source(current_web_contents); | 1520 content::Source<WebContents> source(current_web_contents); |
1519 | 1521 |
1520 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> | 1522 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> |
1521 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1523 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1522 source); | 1524 source); |
1523 fr_language_detected_signal.Wait(); | 1525 fr_language_detected_signal.Wait(); |
1524 } | 1526 } |
OLD | NEW |