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

Side by Side Diff: chrome/browser/prerender/prerender_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 3 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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h" 9 #include "base/time/time.h"
11 #include "chrome/browser/prerender/prerender_contents.h" 10 #include "chrome/browser/prerender/prerender_contents.h"
12 #include "chrome/browser/prerender/prerender_handle.h" 11 #include "chrome/browser/prerender/prerender_handle.h"
13 #include "chrome/browser/prerender/prerender_link_manager.h" 12 #include "chrome/browser/prerender/prerender_link_manager.h"
14 #include "chrome/browser/prerender/prerender_manager.h" 13 #include "chrome/browser/prerender/prerender_manager.h"
15 #include "chrome/browser/prerender/prerender_origin.h" 14 #include "chrome/browser/prerender/prerender_origin.h"
16 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
17 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
18 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 using base::Time; 25 using base::Time;
26 using base::TimeDelta; 26 using base::TimeDelta;
27 using base::TimeTicks; 27 using base::TimeTicks;
28 using content::BrowserThread; 28 using content::BrowserThread;
29 using content::Referrer; 29 using content::Referrer;
30 30
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 prerendering_has_started_ = true; 270 prerendering_has_started_ = true;
271 NotifyPrerenderStart(); 271 NotifyPrerenderStart();
272 } 272 }
273 } 273 }
274 274
275 class PrerenderTest : public testing::Test { 275 class PrerenderTest : public testing::Test {
276 public: 276 public:
277 static const int kDefaultChildId = -1; 277 static const int kDefaultChildId = -1;
278 static const int kDefaultRenderViewRouteId = -1; 278 static const int kDefaultRenderViewRouteId = -1;
279 279
280 PrerenderTest() : ui_thread_(BrowserThread::UI, &message_loop_), 280 PrerenderTest() : prerender_manager_(new UnitTestPrerenderManager(
281 prerender_manager_(new UnitTestPrerenderManager(
282 &profile_, prerender_tracker())), 281 &profile_, prerender_tracker())),
283 prerender_link_manager_( 282 prerender_link_manager_(
284 new PrerenderLinkManager(prerender_manager_.get())), 283 new PrerenderLinkManager(prerender_manager_.get())),
285 last_prerender_id_(0) { 284 last_prerender_id_(0) {
286 // Enable omnibox prerendering. 285 // Enable omnibox prerendering.
287 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 286 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
288 switches::kPrerenderFromOmnibox, 287 switches::kPrerenderFromOmnibox,
289 switches::kPrerenderFromOmniboxSwitchValueEnabled); 288 switches::kPrerenderFromOmniboxSwitchValueEnabled);
290 } 289 }
291 290
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 kSize, kDefaultRenderViewRouteId); 339 kSize, kDefaultRenderViewRouteId);
341 return LauncherHasRunningPrerender(kDefaultChildId, last_prerender_id()); 340 return LauncherHasRunningPrerender(kDefaultChildId, last_prerender_id());
342 } 341 }
343 342
344 private: 343 private:
345 PrerenderTracker* prerender_tracker() { 344 PrerenderTracker* prerender_tracker() {
346 return g_browser_process->prerender_tracker(); 345 return g_browser_process->prerender_tracker();
347 } 346 }
348 347
349 // Needed to pass PrerenderManager's DCHECKs. 348 // Needed to pass PrerenderManager's DCHECKs.
349 content::TestBrowserThreadBundle thread_bundle_;
350 TestingProfile profile_; 350 TestingProfile profile_;
351 base::MessageLoop message_loop_;
352 content::TestBrowserThread ui_thread_;
353 scoped_ptr<UnitTestPrerenderManager> prerender_manager_; 351 scoped_ptr<UnitTestPrerenderManager> prerender_manager_;
354 scoped_ptr<PrerenderLinkManager> prerender_link_manager_; 352 scoped_ptr<PrerenderLinkManager> prerender_link_manager_;
355 int last_prerender_id_; 353 int last_prerender_id_;
356 }; 354 };
357 355
358 TEST_F(PrerenderTest, FoundTest) { 356 TEST_F(PrerenderTest, FoundTest) {
359 GURL url("http://www.google.com/"); 357 GURL url("http://www.google.com/");
360 DummyPrerenderContents* prerender_contents = 358 DummyPrerenderContents* prerender_contents =
361 prerender_manager()->CreateNextPrerenderContents( 359 prerender_manager()->CreateNextPrerenderContents(
362 url, 360 url,
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url)); 1412 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url));
1415 1413
1416 // The first prerender should have died, giving life to the second one. 1414 // The first prerender should have died, giving life to the second one.
1417 prerender_manager()->AdvanceTimeTicks(wait_for_first_prerender_to_expire); 1415 prerender_manager()->AdvanceTimeTicks(wait_for_first_prerender_to_expire);
1418 EXPECT_EQ(null, prerender_manager()->FindEntry(first_url)); 1416 EXPECT_EQ(null, prerender_manager()->FindEntry(first_url));
1419 EXPECT_EQ(second_prerender_contents, 1417 EXPECT_EQ(second_prerender_contents,
1420 prerender_manager()->FindAndUseEntry(second_url)); 1418 prerender_manager()->FindAndUseEntry(second_url));
1421 } 1419 }
1422 1420
1423 } // namespace prerender 1421 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_model_associator_unittest.cc ('k') | chrome/browser/printing/print_dialog_cloud_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698