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

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

Issue 14651015: Revert 198977 "Remove unused third_party/WebKit #includes from c..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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" 46 #include "content/public/test/test_browser_thread.h"
47 #include "content/public/test/test_renderer_host.h" 47 #include "content/public/test/test_renderer_host.h"
48 #include "grit/generated_resources.h" 48 #include "grit/generated_resources.h"
49 #include "ipc/ipc_test_sink.h" 49 #include "ipc/ipc_test_sink.h"
50 #include "net/url_request/test_url_fetcher_factory.h" 50 #include "net/url_request/test_url_fetcher_factory.h"
51 #include "testing/gmock/include/gmock/gmock.h" 51 #include "testing/gmock/include/gmock/gmock.h"
52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
53 #include "third_party/cld/languages/public/languages.h" 54 #include "third_party/cld/languages/public/languages.h"
54 55
55 using content::BrowserThread; 56 using content::BrowserThread;
56 using content::NavigationController; 57 using content::NavigationController;
57 using content::RenderViewHostTester; 58 using content::RenderViewHostTester;
58 using content::WebContents; 59 using content::WebContents;
59 using testing::_; 60 using testing::_;
60 using testing::Pointee; 61 using testing::Pointee;
61 using testing::Property; 62 using testing::Property;
62 using WebKit::WebContextMenuData; 63 using WebKit::WebContextMenuData;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 const content::NotificationDetails& details) { 216 const content::NotificationDetails& details) {
216 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); 217 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type);
217 removed_infobars_.insert( 218 removed_infobars_.insert(
218 content::Details<InfoBarRemovedDetails>(details)->first); 219 content::Details<InfoBarRemovedDetails>(details)->first);
219 } 220 }
220 221
221 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&)); 222 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&));
222 223
223 protected: 224 protected:
224 virtual void SetUp() { 225 virtual void SetUp() {
226 WebKit::initialize(webkit_platform_support_.Get());
225 // Access the TranslateManager singleton so it is created before we call 227 // Access the TranslateManager singleton so it is created before we call
226 // ChromeRenderViewHostTestHarness::SetUp() to match what's done in Chrome, 228 // ChromeRenderViewHostTestHarness::SetUp() to match what's done in Chrome,
227 // where the TranslateManager is created before the WebContents. This 229 // where the TranslateManager is created before the WebContents. This
228 // matters as they both register for similar events and we want the 230 // matters as they both register for similar events and we want the
229 // notifications to happen in the same sequence (TranslateManager first, 231 // notifications to happen in the same sequence (TranslateManager first,
230 // WebContents second). Also clears the translate script so it is fetched 232 // WebContents second). Also clears the translate script so it is fetched
231 // everytime and sets the expiration delay to a large value by default (in 233 // everytime and sets the expiration delay to a large value by default (in
232 // case it was zeroed in a previous test). 234 // case it was zeroed in a previous test).
233 TranslateManager::GetInstance()->ClearTranslateScript(); 235 TranslateManager::GetInstance()->ClearTranslateScript();
234 TranslateManager::GetInstance()-> 236 TranslateManager::GetInstance()->
235 set_translate_script_expiration_delay(60 * 60 * 1000); 237 set_translate_script_expiration_delay(60 * 60 * 1000);
236 238
237 ChromeRenderViewHostTestHarness::SetUp(); 239 ChromeRenderViewHostTestHarness::SetUp();
238 InfoBarService::CreateForWebContents(web_contents()); 240 InfoBarService::CreateForWebContents(web_contents());
239 TranslateTabHelper::CreateForWebContents(web_contents()); 241 TranslateTabHelper::CreateForWebContents(web_contents());
240 242
241 notification_registrar_.Add(this, 243 notification_registrar_.Add(this,
242 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 244 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
243 content::Source<InfoBarService>(infobar_service())); 245 content::Source<InfoBarService>(infobar_service()));
244 } 246 }
245 247
246 virtual void TearDown() { 248 virtual void TearDown() {
247 process()->sink().ClearMessages(); 249 process()->sink().ClearMessages();
248 250
249 notification_registrar_.Remove(this, 251 notification_registrar_.Remove(this,
250 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 252 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
251 content::Source<InfoBarService>(infobar_service())); 253 content::Source<InfoBarService>(infobar_service()));
252 254
253 ChromeRenderViewHostTestHarness::TearDown(); 255 ChromeRenderViewHostTestHarness::TearDown();
256 WebKit::shutdown();
254 } 257 }
255 258
256 void SimulateTranslateScriptURLFetch(bool success) { 259 void SimulateTranslateScriptURLFetch(bool success) {
257 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 260 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
258 ASSERT_TRUE(fetcher); 261 ASSERT_TRUE(fetcher);
259 net::URLRequestStatus status; 262 net::URLRequestStatus status;
260 status.set_status(success ? net::URLRequestStatus::SUCCESS : 263 status.set_status(success ? net::URLRequestStatus::SUCCESS :
261 net::URLRequestStatus::FAILED); 264 net::URLRequestStatus::FAILED);
262 fetcher->set_url(fetcher->GetOriginalURL()); 265 fetcher->set_url(fetcher->GetOriginalURL());
263 fetcher->set_status(status); 266 fetcher->set_status(status);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void SetPrefObserverExpectation(const char* path) { 300 void SetPrefObserverExpectation(const char* path) {
298 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path))); 301 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path)));
299 } 302 }
300 303
301 PrefChangeRegistrar::NamedChangeCallback pref_callback_; 304 PrefChangeRegistrar::NamedChangeCallback pref_callback_;
302 305
303 private: 306 private:
304 content::NotificationRegistrar notification_registrar_; 307 content::NotificationRegistrar notification_registrar_;
305 net::TestURLFetcherFactory url_fetcher_factory_; 308 net::TestURLFetcherFactory url_fetcher_factory_;
306 content::TestBrowserThread ui_thread_; 309 content::TestBrowserThread ui_thread_;
310 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox
311 webkit_platform_support_;
307 312
308 // The infobars that have been removed. 313 // The infobars that have been removed.
309 // WARNING: the pointers point to deleted objects, use only for comparison. 314 // WARNING: the pointers point to deleted objects, use only for comparison.
310 std::set<InfoBarDelegate*> removed_infobars_; 315 std::set<InfoBarDelegate*> removed_infobars_;
311 316
312 DISALLOW_COPY_AND_ASSIGN(TranslateManagerBrowserTest); 317 DISALLOW_COPY_AND_ASSIGN(TranslateManagerBrowserTest);
313 }; 318 };
314 319
315 namespace { 320 namespace {
316 321
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) { 1515 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) {
1511 WebContents* current_web_contents = 1516 WebContents* current_web_contents =
1512 browser()->tab_strip_model()->GetActiveWebContents(); 1517 browser()->tab_strip_model()->GetActiveWebContents();
1513 content::Source<WebContents> source(current_web_contents); 1518 content::Source<WebContents> source(current_web_contents);
1514 1519
1515 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 1520 ui_test_utils::WindowedNotificationObserverWithDetails<std::string>
1516 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1521 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1517 source); 1522 source);
1518 fr_language_detected_signal.Wait(); 1523 fr_language_detected_signal.Wait();
1519 } 1524 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698