| 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" | |
| 20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
| 22 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
| 23 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 25 #include "content/public/test/render_view_test.h" | 24 #include "content/public/test/render_view_test.h" |
| 26 #include "content/public/test/test_browser_thread.h" | 25 #include "content/public/test/test_browser_thread.h" |
| 26 #include "content/public/test/test_utils.h" |
| 27 #include "content/public/test/web_contents_tester.h" | 27 #include "content/public/test/web_contents_tester.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 30 | 30 |
| 31 typedef TabRestoreService::Tab Tab; | 31 typedef TabRestoreService::Tab Tab; |
| 32 typedef TabRestoreService::Window Window; | 32 typedef TabRestoreService::Window Window; |
| 33 using content::WebContentsTester; | 33 using content::WebContentsTester; |
| 34 | 34 |
| 35 using content::NavigationEntry; | 35 using content::NavigationEntry; |
| 36 | 36 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 268 |
| 269 typedef InProcessBrowserTest TabRestoreServiceBrowserTest; | 269 typedef InProcessBrowserTest TabRestoreServiceBrowserTest; |
| 270 | 270 |
| 271 IN_PROC_BROWSER_TEST_F(TabRestoreServiceBrowserTest, RestoreApp) { | 271 IN_PROC_BROWSER_TEST_F(TabRestoreServiceBrowserTest, RestoreApp) { |
| 272 Profile* profile = browser()->profile(); | 272 Profile* profile = browser()->profile(); |
| 273 TabRestoreService* trs = TabRestoreServiceFactory::GetForProfile(profile); | 273 TabRestoreService* trs = TabRestoreServiceFactory::GetForProfile(profile); |
| 274 const char* app_name = "TestApp"; | 274 const char* app_name = "TestApp"; |
| 275 | 275 |
| 276 Browser* app_browser = CreateBrowserForApp(app_name, profile); | 276 Browser* app_browser = CreateBrowserForApp(app_name, profile); |
| 277 app_browser->window()->Close(); | 277 app_browser->window()->Close(); |
| 278 ui_test_utils::WindowedNotificationObserver observer( | 278 content::WindowedNotificationObserver observer( |
| 279 chrome::NOTIFICATION_BROWSER_CLOSED, | 279 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 280 content::Source<Browser>(app_browser)); | 280 content::Source<Browser>(app_browser)); |
| 281 observer.Wait(); | 281 observer.Wait(); |
| 282 | 282 |
| 283 // One entry should be created. | 283 // One entry should be created. |
| 284 ASSERT_EQ(1U, trs->entries().size()); | 284 ASSERT_EQ(1U, trs->entries().size()); |
| 285 const TabRestoreService::Entry* restored_entry = trs->entries().front(); | 285 const TabRestoreService::Entry* restored_entry = trs->entries().front(); |
| 286 | 286 |
| 287 // It should be a window with an app. | 287 // It should be a window with an app. |
| 288 ASSERT_EQ(TabRestoreService::WINDOW, restored_entry->type); | 288 ASSERT_EQ(TabRestoreService::WINDOW, restored_entry->type); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 for (size_t i = 0; i < max_entries + 5; i++) { | 644 for (size_t i = 0; i < max_entries + 5; i++) { |
| 645 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); | 645 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); |
| 646 service_->CreateHistoricalTab(contents(), -1); | 646 service_->CreateHistoricalTab(contents(), -1); |
| 647 } | 647 } |
| 648 | 648 |
| 649 EXPECT_EQ(max_entries, service_->entries_.size()); | 649 EXPECT_EQ(max_entries, service_->entries_.size()); |
| 650 // This should not crash. | 650 // This should not crash. |
| 651 service_->LoadTabsFromLastSession(); | 651 service_->LoadTabsFromLastSession(); |
| 652 EXPECT_EQ(max_entries, service_->entries_.size()); | 652 EXPECT_EQ(max_entries, service_->entries_.size()); |
| 653 } | 653 } |
| OLD | NEW |