| 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 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/test/base/testing_profile.h" | 37 #include "chrome/test/base/testing_profile.h" |
| 38 #include "chrome/test/base/ui_test_utils.h" | 38 #include "chrome/test/base/ui_test_utils.h" |
| 39 #include "content/public/browser/navigation_details.h" | 39 #include "content/public/browser/navigation_details.h" |
| 40 #include "content/public/browser/navigation_entry.h" | 40 #include "content/public/browser/navigation_entry.h" |
| 41 #include "content/public/browser/notification_details.h" | 41 #include "content/public/browser/notification_details.h" |
| 42 #include "content/public/browser/notification_registrar.h" | 42 #include "content/public/browser/notification_registrar.h" |
| 43 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/test/mock_notification_observer.h" | 44 #include "content/public/test/mock_notification_observer.h" |
| 45 #include "content/public/test/mock_render_process_host.h" | 45 #include "content/public/test/mock_render_process_host.h" |
| 46 #include "content/public/test/render_view_test.h" | 46 #include "content/public/test/render_view_test.h" |
| 47 #include "content/public/test/test_browser_thread.h" | |
| 48 #include "content/public/test/test_renderer_host.h" | 47 #include "content/public/test/test_renderer_host.h" |
| 49 #include "grit/generated_resources.h" | 48 #include "grit/generated_resources.h" |
| 50 #include "ipc/ipc_test_sink.h" | 49 #include "ipc/ipc_test_sink.h" |
| 51 #include "net/url_request/test_url_fetcher_factory.h" | 50 #include "net/url_request/test_url_fetcher_factory.h" |
| 52 #include "testing/gmock/include/gmock/gmock.h" | 51 #include "testing/gmock/include/gmock/gmock.h" |
| 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
| 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 55 #include "third_party/cld/languages/public/languages.h" | 54 #include "third_party/cld/languages/public/languages.h" |
| 56 | 55 |
| 57 using content::BrowserThread; | |
| 58 using content::NavigationController; | 56 using content::NavigationController; |
| 59 using content::RenderViewHostTester; | 57 using content::RenderViewHostTester; |
| 60 using content::WebContents; | 58 using content::WebContents; |
| 61 using testing::_; | 59 using testing::_; |
| 62 using testing::Pointee; | 60 using testing::Pointee; |
| 63 using testing::Property; | 61 using testing::Property; |
| 64 using WebKit::WebContextMenuData; | 62 using WebKit::WebContextMenuData; |
| 65 | 63 |
| 66 // An observer that keeps track of whether a navigation entry was committed. | 64 // An observer that keeps track of whether a navigation entry was committed. |
| 67 class NavEntryCommittedObserver : public content::NotificationObserver { | 65 class NavEntryCommittedObserver : public content::NotificationObserver { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 91 | 89 |
| 92 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver); | 90 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver); |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 class TranslateManagerBrowserTest : public ChromeRenderViewHostTestHarness, | 93 class TranslateManagerBrowserTest : public ChromeRenderViewHostTestHarness, |
| 96 public content::NotificationObserver { | 94 public content::NotificationObserver { |
| 97 public: | 95 public: |
| 98 TranslateManagerBrowserTest() | 96 TranslateManagerBrowserTest() |
| 99 : pref_callback_( | 97 : pref_callback_( |
| 100 base::Bind(&TranslateManagerBrowserTest::OnPreferenceChanged, | 98 base::Bind(&TranslateManagerBrowserTest::OnPreferenceChanged, |
| 101 base::Unretained(this))), | 99 base::Unretained(this))) { |
| 102 ui_thread_(BrowserThread::UI, &message_loop_) { | |
| 103 } | 100 } |
| 104 | 101 |
| 105 // Simulates navigating to a page and getting the page contents and language | 102 // Simulates navigating to a page and getting the page contents and language |
| 106 // for that navigation. | 103 // for that navigation. |
| 107 void SimulateNavigation(const GURL& url, | 104 void SimulateNavigation(const GURL& url, |
| 108 const std::string& lang, | 105 const std::string& lang, |
| 109 bool page_translatable) { | 106 bool page_translatable) { |
| 110 NavigateAndCommit(url); | 107 NavigateAndCommit(url); |
| 111 SimulateOnTranslateLanguageDetermined(lang, page_translatable); | 108 SimulateOnTranslateLanguageDetermined(lang, page_translatable); |
| 112 } | 109 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 300 |
| 304 void SetPrefObserverExpectation(const char* path) { | 301 void SetPrefObserverExpectation(const char* path) { |
| 305 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path))); | 302 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path))); |
| 306 } | 303 } |
| 307 | 304 |
| 308 PrefChangeRegistrar::NamedChangeCallback pref_callback_; | 305 PrefChangeRegistrar::NamedChangeCallback pref_callback_; |
| 309 | 306 |
| 310 private: | 307 private: |
| 311 content::NotificationRegistrar notification_registrar_; | 308 content::NotificationRegistrar notification_registrar_; |
| 312 net::TestURLFetcherFactory url_fetcher_factory_; | 309 net::TestURLFetcherFactory url_fetcher_factory_; |
| 313 content::TestBrowserThread ui_thread_; | |
| 314 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox | 310 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox |
| 315 webkit_platform_support_; | 311 webkit_platform_support_; |
| 316 | 312 |
| 317 // The infobars that have been removed. | 313 // The infobars that have been removed. |
| 318 // WARNING: the pointers point to deleted objects, use only for comparison. | 314 // WARNING: the pointers point to deleted objects, use only for comparison. |
| 319 std::set<InfoBarDelegate*> removed_infobars_; | 315 std::set<InfoBarDelegate*> removed_infobars_; |
| 320 | 316 |
| 321 DISALLOW_COPY_AND_ASSIGN(TranslateManagerBrowserTest); | 317 DISALLOW_COPY_AND_ASSIGN(TranslateManagerBrowserTest); |
| 322 }; | 318 }; |
| 323 | 319 |
| (...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 WebContents* current_web_contents = | 1523 WebContents* current_web_contents = |
| 1528 browser()->tab_strip_model()->GetActiveWebContents(); | 1524 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1529 content::Source<WebContents> source(current_web_contents); | 1525 content::Source<WebContents> source(current_web_contents); |
| 1530 | 1526 |
| 1531 ui_test_utils::WindowedNotificationObserverWithDetails< | 1527 ui_test_utils::WindowedNotificationObserverWithDetails< |
| 1532 LanguageDetectionDetails> | 1528 LanguageDetectionDetails> |
| 1533 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1529 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 1534 source); | 1530 source); |
| 1535 fr_language_detected_signal.Wait(); | 1531 fr_language_detected_signal.Wait(); |
| 1536 } | 1532 } |
| OLD | NEW |