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