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

Side by Side Diff: chrome/browser/translate/translate_manager_browsertest.cc

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT Created 7 years, 6 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 | Annotate | Revision Log
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 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 27 matching lines...) Expand all
38 #include "chrome/test/base/testing_profile.h" 38 #include "chrome/test/base/testing_profile.h"
39 #include "chrome/test/base/ui_test_utils.h" 39 #include "chrome/test/base/ui_test_utils.h"
40 #include "content/public/browser/navigation_details.h" 40 #include "content/public/browser/navigation_details.h"
41 #include "content/public/browser/navigation_entry.h" 41 #include "content/public/browser/navigation_entry.h"
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_browser_thread.h"
49 #include "content/public/test/test_renderer_host.h" 48 #include "content/public/test/test_renderer_host.h"
50 #include "grit/generated_resources.h" 49 #include "grit/generated_resources.h"
51 #include "ipc/ipc_test_sink.h" 50 #include "ipc/ipc_test_sink.h"
52 #include "net/url_request/test_url_fetcher_factory.h" 51 #include "net/url_request/test_url_fetcher_factory.h"
53 #include "testing/gmock/include/gmock/gmock.h" 52 #include "testing/gmock/include/gmock/gmock.h"
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
56 #include "third_party/cld/languages/public/languages.h" 55 #include "third_party/cld/languages/public/languages.h"
57 56
58 using content::BrowserThread;
59 using content::NavigationController; 57 using content::NavigationController;
60 using content::RenderViewHostTester; 58 using content::RenderViewHostTester;
61 using content::WebContents; 59 using content::WebContents;
62 using testing::_; 60 using testing::_;
63 using testing::Pointee; 61 using testing::Pointee;
64 using testing::Property; 62 using testing::Property;
65 using WebKit::WebContextMenuData; 63 using WebKit::WebContextMenuData;
66 64
67 // An observer that keeps track of whether a navigation entry was committed. 65 // An observer that keeps track of whether a navigation entry was committed.
68 class NavEntryCommittedObserver : public content::NotificationObserver { 66 class NavEntryCommittedObserver : public content::NotificationObserver {
(...skipping 23 matching lines...) Expand all
92 90
93 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver); 91 DISALLOW_COPY_AND_ASSIGN(NavEntryCommittedObserver);
94 }; 92 };
95 93
96 class TranslateManagerBrowserTest : public ChromeRenderViewHostTestHarness, 94 class TranslateManagerBrowserTest : public ChromeRenderViewHostTestHarness,
97 public content::NotificationObserver { 95 public content::NotificationObserver {
98 public: 96 public:
99 TranslateManagerBrowserTest() 97 TranslateManagerBrowserTest()
100 : pref_callback_( 98 : pref_callback_(
101 base::Bind(&TranslateManagerBrowserTest::OnPreferenceChanged, 99 base::Bind(&TranslateManagerBrowserTest::OnPreferenceChanged,
102 base::Unretained(this))), 100 base::Unretained(this))) {
103 ui_thread_(BrowserThread::UI, &message_loop_) {
104 } 101 }
105 102
106 // Simulates navigating to a page and getting the page contents and language 103 // Simulates navigating to a page and getting the page contents and language
107 // for that navigation. 104 // for that navigation.
108 void SimulateNavigation(const GURL& url, 105 void SimulateNavigation(const GURL& url,
109 const std::string& lang, 106 const std::string& lang,
110 bool page_translatable) { 107 bool page_translatable) {
111 NavigateAndCommit(url); 108 NavigateAndCommit(url);
112 SimulateOnTranslateLanguageDetermined(lang, page_translatable); 109 SimulateOnTranslateLanguageDetermined(lang, page_translatable);
113 } 110 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 304
308 void SetPrefObserverExpectation(const char* path) { 305 void SetPrefObserverExpectation(const char* path) {
309 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path))); 306 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path)));
310 } 307 }
311 308
312 PrefChangeRegistrar::NamedChangeCallback pref_callback_; 309 PrefChangeRegistrar::NamedChangeCallback pref_callback_;
313 310
314 private: 311 private:
315 content::NotificationRegistrar notification_registrar_; 312 content::NotificationRegistrar notification_registrar_;
316 net::TestURLFetcherFactory url_fetcher_factory_; 313 net::TestURLFetcherFactory url_fetcher_factory_;
317 content::TestBrowserThread ui_thread_;
318 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox 314 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox
319 webkit_platform_support_; 315 webkit_platform_support_;
320 316
321 // The infobars that have been removed. 317 // The infobars that have been removed.
322 // WARNING: the pointers point to deleted objects, use only for comparison. 318 // WARNING: the pointers point to deleted objects, use only for comparison.
323 std::set<InfoBarDelegate*> removed_infobars_; 319 std::set<InfoBarDelegate*> removed_infobars_;
324 320
325 DISALLOW_COPY_AND_ASSIGN(TranslateManagerBrowserTest); 321 DISALLOW_COPY_AND_ASSIGN(TranslateManagerBrowserTest);
326 }; 322 };
327 323
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 WebContents* current_web_contents = 1527 WebContents* current_web_contents =
1532 browser()->tab_strip_model()->GetActiveWebContents(); 1528 browser()->tab_strip_model()->GetActiveWebContents();
1533 content::Source<WebContents> source(current_web_contents); 1529 content::Source<WebContents> source(current_web_contents);
1534 1530
1535 ui_test_utils::WindowedNotificationObserverWithDetails< 1531 ui_test_utils::WindowedNotificationObserverWithDetails<
1536 LanguageDetectionDetails> 1532 LanguageDetectionDetails>
1537 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1533 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1538 source); 1534 source);
1539 fr_language_detected_signal.Wait(); 1535 fr_language_detected_signal.Wait();
1540 } 1536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698