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

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

Issue 8790012: Fix TabRestoreServiceTest and TranslateManagerTest when using use_webkit_compositor=1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 9 years 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
« no previous file with comments | « chrome/browser/sessions/tab_restore_service_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 21 matching lines...) Expand all
32 #include "content/public/browser/notification_registrar.h" 32 #include "content/public/browser/notification_registrar.h"
33 #include "content/test/notification_observer_mock.h" 33 #include "content/test/notification_observer_mock.h"
34 #include "content/test/test_browser_thread.h" 34 #include "content/test/test_browser_thread.h"
35 #include "content/test/test_url_fetcher_factory.h" 35 #include "content/test/test_url_fetcher_factory.h"
36 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
37 #include "ipc/ipc_test_sink.h" 37 #include "ipc/ipc_test_sink.h"
38 #include "testing/gmock/include/gmock/gmock.h" 38 #include "testing/gmock/include/gmock/gmock.h"
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
40 #include "third_party/cld/languages/public/languages.h" 40 #include "third_party/cld/languages/public/languages.h"
41 41
42 #if defined(USE_WEBKIT_COMPOSITOR)
43 #include "content/test/render_view_test.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
45 #endif
46
42 using content::BrowserThread; 47 using content::BrowserThread;
43 using testing::_; 48 using testing::_;
44 using testing::Pointee; 49 using testing::Pointee;
45 using testing::Property; 50 using testing::Property;
46 using WebKit::WebContextMenuData; 51 using WebKit::WebContextMenuData;
47 52
48 class TranslateManagerTest : public TabContentsWrapperTestHarness, 53 class TranslateManagerTest : public TabContentsWrapperTestHarness,
49 public content::NotificationObserver { 54 public content::NotificationObserver {
50 public: 55 public:
51 TranslateManagerTest() 56 TranslateManagerTest()
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 virtual void Observe(int type, 151 virtual void Observe(int type,
147 const content::NotificationSource& source, 152 const content::NotificationSource& source,
148 const content::NotificationDetails& details) { 153 const content::NotificationDetails& details) {
149 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); 154 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type);
150 removed_infobars_.insert( 155 removed_infobars_.insert(
151 content::Details<InfoBarRemovedDetails>(details)->first); 156 content::Details<InfoBarRemovedDetails>(details)->first);
152 } 157 }
153 158
154 protected: 159 protected:
155 virtual void SetUp() { 160 virtual void SetUp() {
161 #if defined(USE_WEBKIT_COMPOSITOR)
162 WebKit::initialize(&webkit_platform_support_);
163 #endif
156 // Access the TranslateManager singleton so it is created before we call 164 // Access the TranslateManager singleton so it is created before we call
157 // TabContentsWrapperTestHarness::SetUp() to match what's done in Chrome, 165 // TabContentsWrapperTestHarness::SetUp() to match what's done in Chrome,
158 // where the TranslateManager is created before the TabContents. This 166 // where the TranslateManager is created before the TabContents. This
159 // matters as they both register for similar events and we want the 167 // matters as they both register for similar events and we want the
160 // notifications to happen in the same sequence (TranslateManager first, 168 // notifications to happen in the same sequence (TranslateManager first,
161 // TabContents second). Also clears the translate script so it is fetched 169 // TabContents second). Also clears the translate script so it is fetched
162 // everytime and sets the expiration delay to a large value by default (in 170 // everytime and sets the expiration delay to a large value by default (in
163 // case it was zeroed in a previous test). 171 // case it was zeroed in a previous test).
164 TranslateManager::GetInstance()->ClearTranslateScript(); 172 TranslateManager::GetInstance()->ClearTranslateScript();
165 TranslateManager::GetInstance()-> 173 TranslateManager::GetInstance()->
166 set_translate_script_expiration_delay(60 * 60 * 1000); 174 set_translate_script_expiration_delay(60 * 60 * 1000);
167 175
168 TabContentsWrapperTestHarness::SetUp(); 176 TabContentsWrapperTestHarness::SetUp();
169 177
170 notification_registrar_.Add(this, 178 notification_registrar_.Add(this,
171 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 179 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
172 content::Source<InfoBarTabHelper>( 180 content::Source<InfoBarTabHelper>(
173 contents_wrapper()->infobar_tab_helper())); 181 contents_wrapper()->infobar_tab_helper()));
174 } 182 }
175 183
176 virtual void TearDown() { 184 virtual void TearDown() {
177 process()->sink().ClearMessages(); 185 process()->sink().ClearMessages();
178 186
179 notification_registrar_.Remove(this, 187 notification_registrar_.Remove(this,
180 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 188 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
181 content::Source<InfoBarTabHelper>( 189 content::Source<InfoBarTabHelper>(
182 contents_wrapper()->infobar_tab_helper())); 190 contents_wrapper()->infobar_tab_helper()));
183 191
184 TabContentsWrapperTestHarness::TearDown(); 192 TabContentsWrapperTestHarness::TearDown();
193 #if defined(USE_WEBKIT_COMPOSITOR)
194 WebKit::shutdown();
195 #endif
185 } 196 }
186 197
187 void SimulateTranslateScriptURLFetch(bool success) { 198 void SimulateTranslateScriptURLFetch(bool success) {
188 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 199 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
189 ASSERT_TRUE(fetcher); 200 ASSERT_TRUE(fetcher);
190 net::URLRequestStatus status; 201 net::URLRequestStatus status;
191 status.set_status(success ? net::URLRequestStatus::SUCCESS : 202 status.set_status(success ? net::URLRequestStatus::SUCCESS :
192 net::URLRequestStatus::FAILED); 203 net::URLRequestStatus::FAILED);
193 fetcher->set_url(fetcher->GetOriginalURL()); 204 fetcher->set_url(fetcher->GetOriginalURL());
194 fetcher->set_status(status); 205 fetcher->set_status(status);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 _, 243 _,
233 Property(&content::Details<std::string>::ptr, Pointee(path)))); 244 Property(&content::Details<std::string>::ptr, Pointee(path))));
234 } 245 }
235 246
236 content::NotificationObserverMock pref_observer_; 247 content::NotificationObserverMock pref_observer_;
237 248
238 private: 249 private:
239 content::NotificationRegistrar notification_registrar_; 250 content::NotificationRegistrar notification_registrar_;
240 TestURLFetcherFactory url_fetcher_factory_; 251 TestURLFetcherFactory url_fetcher_factory_;
241 content::TestBrowserThread ui_thread_; 252 content::TestBrowserThread ui_thread_;
253 #if defined(USE_WEBKIT_COMPOSITOR)
254 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox
255 webkit_platform_support_;
256 #endif
242 257
243 // The infobars that have been removed. 258 // The infobars that have been removed.
244 // WARNING: the pointers point to deleted objects, use only for comparison. 259 // WARNING: the pointers point to deleted objects, use only for comparison.
245 std::set<InfoBarDelegate*> removed_infobars_; 260 std::set<InfoBarDelegate*> removed_infobars_;
246 261
247 DISALLOW_COPY_AND_ASSIGN(TranslateManagerTest); 262 DISALLOW_COPY_AND_ASSIGN(TranslateManagerTest);
248 }; 263 };
249 264
250 // An observer that keeps track of whether a navigation entry was committed. 265 // An observer that keeps track of whether a navigation entry was committed.
251 class NavEntryCommittedObserver : public content::NotificationObserver { 266 class NavEntryCommittedObserver : public content::NotificationObserver {
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 NULL); 1355 NULL);
1341 // Now simulate the URL fetch. 1356 // Now simulate the URL fetch.
1342 SimulateTranslateScriptURLFetch(true); 1357 SimulateTranslateScriptURLFetch(true);
1343 // Now the message should have been sent. 1358 // Now the message should have been sent.
1344 int page_id = 0; 1359 int page_id = 0;
1345 std::string original_lang, target_lang; 1360 std::string original_lang, target_lang;
1346 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); 1361 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
1347 EXPECT_EQ("es", original_lang); 1362 EXPECT_EQ("es", original_lang);
1348 EXPECT_EQ("en", target_lang); 1363 EXPECT_EQ("en", target_lang);
1349 } 1364 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_restore_service_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698