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

Side by Side Diff: chrome/browser/sessions/tab_restore_service_browsertest.cc

Issue 7892007: Add ChromeRenderViewHostTestHarness to get rid of the dependency from RVHTH to profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac Created 9 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) 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 #include "chrome/browser/sessions/session_types.h" 5 #include "chrome/browser/sessions/session_types.h"
6 #include "chrome/browser/sessions/session_service.h" 6 #include "chrome/browser/sessions/session_service.h"
7 #include "chrome/browser/sessions/session_service_factory.h" 7 #include "chrome/browser/sessions/session_service_factory.h"
8 #include "chrome/browser/sessions/tab_restore_service.h" 8 #include "chrome/browser/sessions/tab_restore_service.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "chrome/test/base/render_view_test.h" 11 #include "chrome/test/base/render_view_test.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "content/browser/renderer_host/test_render_view_host.h"
13 #include "content/browser/tab_contents/navigation_controller.h" 13 #include "content/browser/tab_contents/navigation_controller.h"
14 #include "content/browser/tab_contents/navigation_entry.h" 14 #include "content/browser/tab_contents/navigation_entry.h"
15 #include "content/browser/tab_contents/test_tab_contents.h" 15 #include "content/browser/tab_contents/test_tab_contents.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
18 18
19 // Create subclass that overrides TimeNow so that we can control the time used 19 // Create subclass that overrides TimeNow so that we can control the time used
20 // for closed tabs and windows. 20 // for closed tabs and windows.
21 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory { 21 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory {
22 public: 22 public:
23 TabRestoreTimeFactory() : time_(base::Time::Now()) {} 23 TabRestoreTimeFactory() : time_(base::Time::Now()) {}
24 24
25 virtual ~TabRestoreTimeFactory() {} 25 virtual ~TabRestoreTimeFactory() {}
26 26
27 virtual base::Time TimeNow() { 27 virtual base::Time TimeNow() {
28 return time_; 28 return time_;
29 } 29 }
30 30
31 private: 31 private:
32 base::Time time_; 32 base::Time time_;
33 }; 33 };
34 34
35 class TabRestoreServiceTest : public RenderViewHostTestHarness { 35 class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness {
36 public: 36 public:
37 TabRestoreServiceTest() { 37 TabRestoreServiceTest() {
38 url1_ = GURL("http://1"); 38 url1_ = GURL("http://1");
39 url2_ = GURL("http://2"); 39 url2_ = GURL("http://2");
40 url3_ = GURL("http://3"); 40 url3_ = GURL("http://3");
41 } 41 }
42 42
43 ~TabRestoreServiceTest() { 43 ~TabRestoreServiceTest() {
44 } 44 }
45 45
46 protected: 46 protected:
47 // testing::Test overrides 47 // testing::Test overrides
48 virtual void SetUp() { 48 virtual void SetUp() {
49 RenderViewHostTestHarness::SetUp(); 49 ChromeRenderViewHostTestHarness::SetUp();
50 time_factory_ = new TabRestoreTimeFactory(); 50 time_factory_ = new TabRestoreTimeFactory();
51 service_.reset(new TabRestoreService(profile(), time_factory_)); 51 service_.reset(new TabRestoreService(profile(), time_factory_));
52 WebKit::initialize(&webkit_platform_support_); 52 WebKit::initialize(&webkit_platform_support_);
53 } 53 }
54 54
55 virtual void TearDown() { 55 virtual void TearDown() {
56 service_.reset(); 56 service_.reset();
57 delete time_factory_; 57 delete time_factory_;
58 RenderViewHostTestHarness::TearDown(); 58 ChromeRenderViewHostTestHarness::TearDown();
59 WebKit::shutdown(); 59 WebKit::shutdown();
60 } 60 }
61 61
62 void AddThreeNavigations() { 62 void AddThreeNavigations() {
63 // Navigate to three URLs. 63 // Navigate to three URLs.
64 NavigateAndCommit(url1_); 64 NavigateAndCommit(url1_);
65 NavigateAndCommit(url2_); 65 NavigateAndCommit(url2_);
66 NavigateAndCommit(url3_); 66 NavigateAndCommit(url3_);
67 } 67 }
68 68
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 ASSERT_EQ(1U, service_->entries().size()); 518 ASSERT_EQ(1U, service_->entries().size());
519 519
520 // And verify the entry. 520 // And verify the entry.
521 TabRestoreService::Entry* restored_entry = service_->entries().front(); 521 TabRestoreService::Entry* restored_entry = service_->entries().front();
522 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); 522 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type);
523 TabRestoreService::Tab* restored_tab = 523 TabRestoreService::Tab* restored_tab =
524 static_cast<TabRestoreService::Tab*>(restored_entry); 524 static_cast<TabRestoreService::Tab*>(restored_entry);
525 EXPECT_EQ(tab_timestamp.ToInternalValue(), 525 EXPECT_EQ(tab_timestamp.ToInternalValue(),
526 restored_tab->timestamp.ToInternalValue()); 526 restored_tab->timestamp.ToInternalValue());
527 } 527 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698