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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "content/public/browser/notification_details.h" | 42 #include "content/public/browser/notification_details.h" |
43 #include "content/public/browser/notification_registrar.h" | 43 #include "content/public/browser/notification_registrar.h" |
44 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
45 #include "content/public/test/mock_notification_observer.h" | 45 #include "content/public/test/mock_notification_observer.h" |
46 #include "content/public/test/mock_render_process_host.h" | 46 #include "content/public/test/mock_render_process_host.h" |
47 #include "content/public/test/render_view_test.h" | 47 #include "content/public/test/render_view_test.h" |
48 #include "content/public/test/test_renderer_host.h" | 48 #include "content/public/test/test_renderer_host.h" |
49 #include "grit/generated_resources.h" | 49 #include "grit/generated_resources.h" |
50 #include "ipc/ipc_test_sink.h" | 50 #include "ipc/ipc_test_sink.h" |
51 #include "net/url_request/test_url_fetcher_factory.h" | 51 #include "net/url_request/test_url_fetcher_factory.h" |
| 52 #include "net/url_request/url_fetcher_delegate.h" |
52 #include "testing/gmock/include/gmock/gmock.h" | 53 #include "testing/gmock/include/gmock/gmock.h" |
53 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 54 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
54 #include "third_party/WebKit/public/web/WebKit.h" | 55 #include "third_party/WebKit/public/web/WebKit.h" |
55 #include "third_party/cld/languages/public/languages.h" | 56 #include "third_party/cld/languages/public/languages.h" |
56 | 57 |
57 using content::NavigationController; | 58 using content::NavigationController; |
58 using content::RenderViewHostTester; | 59 using content::RenderViewHostTester; |
59 using content::WebContents; | 60 using content::WebContents; |
60 using testing::_; | 61 using testing::_; |
61 using testing::Pointee; | 62 using testing::Pointee; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 bool InfoBarRemoved() { | 174 bool InfoBarRemoved() { |
174 return !removed_infobars_.empty(); | 175 return !removed_infobars_.empty(); |
175 } | 176 } |
176 | 177 |
177 // Clears the list of stored removed infobars. | 178 // Clears the list of stored removed infobars. |
178 void ClearRemovedInfoBars() { | 179 void ClearRemovedInfoBars() { |
179 removed_infobars_.clear(); | 180 removed_infobars_.clear(); |
180 } | 181 } |
181 | 182 |
182 void ExpireTranslateScriptImmediately() { | 183 void ExpireTranslateScriptImmediately() { |
183 TranslateManager::GetInstance()->set_translate_script_expiration_delay(0); | 184 TranslateManager::GetInstance()->SetTranslateScriptExpirationDelay(0); |
184 } | 185 } |
185 | 186 |
186 // If there is 1 infobar and it is a translate infobar, deny translation and | 187 // If there is 1 infobar and it is a translate infobar, deny translation and |
187 // returns true. Returns false otherwise. | 188 // returns true. Returns false otherwise. |
188 bool DenyTranslation() { | 189 bool DenyTranslation() { |
189 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 190 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
190 if (!infobar) | 191 if (!infobar) |
191 return false; | 192 return false; |
192 infobar->TranslationDeclined(); | 193 infobar->TranslationDeclined(); |
193 infobar_service()->RemoveInfoBar(infobar); | 194 infobar_service()->RemoveInfoBar(infobar); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // Access the TranslateManager singleton so it is created before we call | 229 // Access the TranslateManager singleton so it is created before we call |
229 // ChromeRenderViewHostTestHarness::SetUp() to match what's done in Chrome, | 230 // ChromeRenderViewHostTestHarness::SetUp() to match what's done in Chrome, |
230 // where the TranslateManager is created before the WebContents. This | 231 // where the TranslateManager is created before the WebContents. This |
231 // matters as they both register for similar events and we want the | 232 // matters as they both register for similar events and we want the |
232 // notifications to happen in the same sequence (TranslateManager first, | 233 // notifications to happen in the same sequence (TranslateManager first, |
233 // WebContents second). Also clears the translate script so it is fetched | 234 // WebContents second). Also clears the translate script so it is fetched |
234 // everytime and sets the expiration delay to a large value by default (in | 235 // everytime and sets the expiration delay to a large value by default (in |
235 // case it was zeroed in a previous test). | 236 // case it was zeroed in a previous test). |
236 TranslateManager::GetInstance()->ClearTranslateScript(); | 237 TranslateManager::GetInstance()->ClearTranslateScript(); |
237 TranslateManager::GetInstance()-> | 238 TranslateManager::GetInstance()-> |
238 set_translate_script_expiration_delay(60 * 60 * 1000); | 239 SetTranslateScriptExpirationDelay(60 * 60 * 1000); |
239 TranslateManager::GetInstance()->set_translate_max_reload_attemps(0); | 240 TranslateManager::GetInstance()->set_translate_max_reload_attemps(0); |
240 | 241 |
241 ChromeRenderViewHostTestHarness::SetUp(); | 242 ChromeRenderViewHostTestHarness::SetUp(); |
242 InfoBarService::CreateForWebContents(web_contents()); | 243 InfoBarService::CreateForWebContents(web_contents()); |
243 TranslateTabHelper::CreateForWebContents(web_contents()); | 244 TranslateTabHelper::CreateForWebContents(web_contents()); |
244 | 245 |
245 notification_registrar_.Add(this, | 246 notification_registrar_.Add(this, |
246 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 247 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
247 content::Source<InfoBarService>(infobar_service())); | 248 content::Source<InfoBarService>(infobar_service())); |
248 } | 249 } |
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 WebContents* current_web_contents = | 1525 WebContents* current_web_contents = |
1525 browser()->tab_strip_model()->GetActiveWebContents(); | 1526 browser()->tab_strip_model()->GetActiveWebContents(); |
1526 content::Source<WebContents> source(current_web_contents); | 1527 content::Source<WebContents> source(current_web_contents); |
1527 | 1528 |
1528 ui_test_utils::WindowedNotificationObserverWithDetails< | 1529 ui_test_utils::WindowedNotificationObserverWithDetails< |
1529 LanguageDetectionDetails> | 1530 LanguageDetectionDetails> |
1530 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1531 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1531 source); | 1532 source); |
1532 fr_language_detected_signal.Wait(); | 1533 fr_language_detected_signal.Wait(); |
1533 } | 1534 } |
OLD | NEW |