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/public/test/render_view_test.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 20 matching lines...) Expand all Loading... |
55 url2_ = GURL("http://2"); | 55 url2_ = GURL("http://2"); |
56 url3_ = GURL("http://3"); | 56 url3_ = GURL("http://3"); |
57 } | 57 } |
58 | 58 |
59 ~TabRestoreServiceTest() { | 59 ~TabRestoreServiceTest() { |
60 } | 60 } |
61 | 61 |
62 protected: | 62 protected: |
63 // testing::Test overrides | 63 // testing::Test overrides |
64 virtual void SetUp() { | 64 virtual void SetUp() { |
65 WebKit::initialize(&webkit_platform_support_); | 65 WebKit::initialize(webkit_platform_support_.Get()); |
66 ChromeRenderViewHostTestHarness::SetUp(); | 66 ChromeRenderViewHostTestHarness::SetUp(); |
67 time_factory_ = new TabRestoreTimeFactory(); | 67 time_factory_ = new TabRestoreTimeFactory(); |
68 service_.reset(new TabRestoreService(profile(), time_factory_)); | 68 service_.reset(new TabRestoreService(profile(), time_factory_)); |
69 } | 69 } |
70 | 70 |
71 virtual void TearDown() { | 71 virtual void TearDown() { |
72 service_->Shutdown(); | 72 service_->Shutdown(); |
73 service_.reset(); | 73 service_.reset(); |
74 delete time_factory_; | 74 delete time_factory_; |
75 ChromeRenderViewHostTestHarness::TearDown(); | 75 ChromeRenderViewHostTestHarness::TearDown(); |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 for (size_t i = 0; i < max_entries + 5; i++) { | 640 for (size_t i = 0; i < max_entries + 5; i++) { |
641 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); | 641 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); |
642 service_->CreateHistoricalTab(&controller(), -1); | 642 service_->CreateHistoricalTab(&controller(), -1); |
643 } | 643 } |
644 | 644 |
645 EXPECT_EQ(max_entries, service_->entries_.size()); | 645 EXPECT_EQ(max_entries, service_->entries_.size()); |
646 // This should not crash. | 646 // This should not crash. |
647 service_->LoadTabsFromLastSession(); | 647 service_->LoadTabsFromLastSession(); |
648 EXPECT_EQ(max_entries, service_->entries_.size()); | 648 EXPECT_EQ(max_entries, service_->entries_.size()); |
649 } | 649 } |
OLD | NEW |