| OLD | NEW |
| 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/render_view_test.h" | 10 #include "chrome/test/render_view_test.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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 RenderViewHostTestHarness { |
| 36 public: | 36 public: |
| 37 TabRestoreServiceTest() { | 37 TabRestoreServiceTest() |
| 38 : ui_thread(BrowserThread::UI, &message_loop_) { |
| 38 url1_ = GURL("http://1"); | 39 url1_ = GURL("http://1"); |
| 39 url2_ = GURL("http://2"); | 40 url2_ = GURL("http://2"); |
| 40 url3_ = GURL("http://3"); | 41 url3_ = GURL("http://3"); |
| 41 } | 42 } |
| 42 | 43 |
| 43 ~TabRestoreServiceTest() { | 44 ~TabRestoreServiceTest() { |
| 44 } | 45 } |
| 45 | 46 |
| 46 protected: | 47 protected: |
| 47 // testing::Test overrides | 48 // testing::Test overrides |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // The profile takes ownership of this. | 108 // The profile takes ownership of this. |
| 108 SessionService* session_service = new SessionService(profile()); | 109 SessionService* session_service = new SessionService(profile()); |
| 109 SessionServiceFactory::SetForTestProfile(profile(), session_service); | 110 SessionServiceFactory::SetForTestProfile(profile(), session_service); |
| 110 | 111 |
| 111 AddWindowWithOneTabToSessionService(pinned); | 112 AddWindowWithOneTabToSessionService(pinned); |
| 112 | 113 |
| 113 // Set this, otherwise previous session won't be loaded. | 114 // Set this, otherwise previous session won't be loaded. |
| 114 profile()->set_last_session_exited_cleanly(false); | 115 profile()->set_last_session_exited_cleanly(false); |
| 115 } | 116 } |
| 116 | 117 |
| 118 BrowserThread ui_thread; |
| 117 GURL url1_; | 119 GURL url1_; |
| 118 GURL url2_; | 120 GURL url2_; |
| 119 GURL url3_; | 121 GURL url3_; |
| 120 scoped_ptr<TabRestoreService> service_; | 122 scoped_ptr<TabRestoreService> service_; |
| 121 TabRestoreTimeFactory* time_factory_; | 123 TabRestoreTimeFactory* time_factory_; |
| 122 RenderViewTest::RendererWebKitClientImplNoSandbox webkitclient_; | 124 RenderViewTest::RendererWebKitClientImplNoSandbox webkitclient_; |
| 123 }; | 125 }; |
| 124 | 126 |
| 125 TEST_F(TabRestoreServiceTest, Basic) { | 127 TEST_F(TabRestoreServiceTest, Basic) { |
| 126 AddThreeNavigations(); | 128 AddThreeNavigations(); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 ASSERT_EQ(1U, service_->entries().size()); | 519 ASSERT_EQ(1U, service_->entries().size()); |
| 518 | 520 |
| 519 // And verify the entry. | 521 // And verify the entry. |
| 520 TabRestoreService::Entry* restored_entry = service_->entries().front(); | 522 TabRestoreService::Entry* restored_entry = service_->entries().front(); |
| 521 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); | 523 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); |
| 522 TabRestoreService::Tab* restored_tab = | 524 TabRestoreService::Tab* restored_tab = |
| 523 static_cast<TabRestoreService::Tab*>(restored_entry); | 525 static_cast<TabRestoreService::Tab*>(restored_entry); |
| 524 EXPECT_EQ(tab_timestamp.ToInternalValue(), | 526 EXPECT_EQ(tab_timestamp.ToInternalValue(), |
| 525 restored_tab->timestamp.ToInternalValue()); | 527 restored_tab->timestamp.ToInternalValue()); |
| 526 } | 528 } |
| OLD | NEW |