| 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/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 11 #include "chrome/test/base/render_view_test.h" | 11 #include "chrome/test/base/chrome_render_view_test.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.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 "content/test/render_view_test.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 18 | 19 |
| 19 // Create subclass that overrides TimeNow so that we can control the time used | 20 // Create subclass that overrides TimeNow so that we can control the time used |
| 20 // for closed tabs and windows. | 21 // for closed tabs and windows. |
| 21 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory { | 22 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory { |
| 22 public: | 23 public: |
| 23 TabRestoreTimeFactory() : time_(base::Time::Now()) {} | 24 TabRestoreTimeFactory() : time_(base::Time::Now()) {} |
| 24 | 25 |
| 25 virtual ~TabRestoreTimeFactory() {} | 26 virtual ~TabRestoreTimeFactory() {} |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 117 GURL url1_; | 118 GURL url1_; |
| 118 GURL url2_; | 119 GURL url2_; |
| 119 GURL url3_; | 120 GURL url3_; |
| 120 scoped_ptr<TabRestoreService> service_; | 121 scoped_ptr<TabRestoreService> service_; |
| 121 TabRestoreTimeFactory* time_factory_; | 122 TabRestoreTimeFactory* time_factory_; |
| 122 RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox | 123 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox |
| 123 webkit_platform_support_; | 124 webkit_platform_support_; |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 TEST_F(TabRestoreServiceTest, Basic) { | 127 TEST_F(TabRestoreServiceTest, Basic) { |
| 127 AddThreeNavigations(); | 128 AddThreeNavigations(); |
| 128 | 129 |
| 129 // Have the service record the tab. | 130 // Have the service record the tab. |
| 130 service_->CreateHistoricalTab(&controller(), -1); | 131 service_->CreateHistoricalTab(&controller(), -1); |
| 131 | 132 |
| 132 // Make sure an entry was created. | 133 // Make sure an entry was created. |
| 133 ASSERT_EQ(1U, service_->entries().size()); | 134 ASSERT_EQ(1U, service_->entries().size()); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 ASSERT_EQ(1U, service_->entries().size()); | 519 ASSERT_EQ(1U, service_->entries().size()); |
| 519 | 520 |
| 520 // And verify the entry. | 521 // And verify the entry. |
| 521 TabRestoreService::Entry* restored_entry = service_->entries().front(); | 522 TabRestoreService::Entry* restored_entry = service_->entries().front(); |
| 522 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); | 523 ASSERT_EQ(TabRestoreService::TAB, restored_entry->type); |
| 523 TabRestoreService::Tab* restored_tab = | 524 TabRestoreService::Tab* restored_tab = |
| 524 static_cast<TabRestoreService::Tab*>(restored_entry); | 525 static_cast<TabRestoreService::Tab*>(restored_entry); |
| 525 EXPECT_EQ(tab_timestamp.ToInternalValue(), | 526 EXPECT_EQ(tab_timestamp.ToInternalValue(), |
| 526 restored_tab->timestamp.ToInternalValue()); | 527 restored_tab->timestamp.ToInternalValue()); |
| 527 } | 528 } |
| OLD | NEW |