OLD | NEW |
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/stringprintf.h" | 5 #include "base/stringprintf.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/sessions/session_service_factory.h" | 7 #include "chrome/browser/sessions/session_service_factory.h" |
8 #include "chrome/browser/sessions/session_service.h" | 8 #include "chrome/browser/sessions/session_service.h" |
9 #include "chrome/browser/sessions/session_types.h" | 9 #include "chrome/browser/sessions/session_types.h" |
10 #include "chrome/browser/sessions/tab_restore_service.h" | 10 #include "chrome/browser/sessions/tab_restore_service.h" |
11 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 11 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
16 #include "chrome/test/base/chrome_render_view_test.h" | 16 #include "chrome/test/base/chrome_render_view_test.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
21 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
24 #include "content/test/render_view_test.h" | 24 #include "content/test/render_test_utils.h" |
25 #include "content/test/web_contents_tester.h" | 25 #include "content/test/web_contents_tester.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
28 | 28 |
29 typedef TabRestoreService::Tab Tab; | 29 typedef TabRestoreService::Tab Tab; |
30 typedef TabRestoreService::Window Window; | 30 typedef TabRestoreService::Window Window; |
31 using content::WebContentsTester; | 31 using content::WebContentsTester; |
32 | 32 |
33 using content::NavigationEntry; | 33 using content::NavigationEntry; |
34 | 34 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 // Set this, otherwise previous session won't be loaded. | 132 // Set this, otherwise previous session won't be loaded. |
133 profile()->set_last_session_exited_cleanly(false); | 133 profile()->set_last_session_exited_cleanly(false); |
134 } | 134 } |
135 | 135 |
136 GURL url1_; | 136 GURL url1_; |
137 GURL url2_; | 137 GURL url2_; |
138 GURL url3_; | 138 GURL url3_; |
139 scoped_ptr<TabRestoreService> service_; | 139 scoped_ptr<TabRestoreService> service_; |
140 TabRestoreTimeFactory* time_factory_; | 140 TabRestoreTimeFactory* time_factory_; |
141 content::RenderViewTest::RendererWebKitPlatformSupportImplNoSandbox | 141 content::RendererWebKitPlatformSupportImplNoSandbox webkit_platform_support_; |
142 webkit_platform_support_; | |
143 }; | 142 }; |
144 | 143 |
145 TEST_F(TabRestoreServiceTest, Basic) { | 144 TEST_F(TabRestoreServiceTest, Basic) { |
146 AddThreeNavigations(); | 145 AddThreeNavigations(); |
147 | 146 |
148 // Have the service record the tab. | 147 // Have the service record the tab. |
149 service_->CreateHistoricalTab(&controller(), -1); | 148 service_->CreateHistoricalTab(&controller(), -1); |
150 | 149 |
151 // Make sure an entry was created. | 150 // Make sure an entry was created. |
152 ASSERT_EQ(1U, service_->entries().size()); | 151 ASSERT_EQ(1U, service_->entries().size()); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 for (size_t i = 0; i < max_entries + 5; i++) { | 639 for (size_t i = 0; i < max_entries + 5; i++) { |
641 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); | 640 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); |
642 service_->CreateHistoricalTab(&controller(), -1); | 641 service_->CreateHistoricalTab(&controller(), -1); |
643 } | 642 } |
644 | 643 |
645 EXPECT_EQ(max_entries, service_->entries_.size()); | 644 EXPECT_EQ(max_entries, service_->entries_.size()); |
646 // This should not crash. | 645 // This should not crash. |
647 service_->LoadTabsFromLastSession(); | 646 service_->LoadTabsFromLastSession(); |
648 EXPECT_EQ(max_entries, service_->entries_.size()); | 647 EXPECT_EQ(max_entries, service_->entries_.size()); |
649 } | 648 } |
OLD | NEW |