Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/sessions/tab_restore_service_browsertest.cc

Issue 8956059: Rename NavigationController to NavigationControllerImpl and put it into the content namespace. Al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sessions/tab_restore_service.cc ('k') | chrome/browser/ssl/ssl_blocking_page.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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_types.h" 7 #include "chrome/browser/sessions/session_types.h"
8 #include "chrome/browser/sessions/session_service.h" 8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_service_factory.h" 9 #include "chrome/browser/sessions/session_service_factory.h"
10 #include "chrome/browser/sessions/tab_restore_service.h" 10 #include "chrome/browser/sessions/tab_restore_service.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "chrome/test/base/chrome_render_view_test.h" 13 #include "chrome/test/base/chrome_render_view_test.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "content/browser/tab_contents/navigation_controller.h" 15 #include "content/browser/tab_contents/navigation_controller.h"
16 #include "content/browser/tab_contents/test_tab_contents.h" 16 #include "content/browser/tab_contents/test_tab_contents.h"
17 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
18 #include "content/test/render_view_test.h" 18 #include "content/test/render_view_test.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
21 21
22 typedef TabRestoreService::Tab Tab; 22 typedef TabRestoreService::Tab Tab;
23 23
24 using content::NavigationEntry;
25
24 // Create subclass that overrides TimeNow so that we can control the time used 26 // Create subclass that overrides TimeNow so that we can control the time used
25 // for closed tabs and windows. 27 // for closed tabs and windows.
26 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory { 28 class TabRestoreTimeFactory : public TabRestoreService::TimeFactory {
27 public: 29 public:
28 TabRestoreTimeFactory() : time_(base::Time::Now()) {} 30 TabRestoreTimeFactory() : time_(base::Time::Now()) {}
29 31
30 virtual ~TabRestoreTimeFactory() {} 32 virtual ~TabRestoreTimeFactory() {}
31 33
32 virtual base::Time TimeNow() { 34 virtual base::Time TimeNow() {
33 return time_; 35 return time_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 SessionService* session_service = 94 SessionService* session_service =
93 SessionServiceFactory::GetForProfile(profile()); 95 SessionServiceFactory::GetForProfile(profile());
94 SessionID tab_id; 96 SessionID tab_id;
95 SessionID window_id; 97 SessionID window_id;
96 session_service->SetWindowType(window_id, Browser::TYPE_TABBED); 98 session_service->SetWindowType(window_id, Browser::TYPE_TABBED);
97 session_service->SetTabWindow(window_id, tab_id); 99 session_service->SetTabWindow(window_id, tab_id);
98 session_service->SetTabIndexInWindow(window_id, tab_id, 0); 100 session_service->SetTabIndexInWindow(window_id, tab_id, 0);
99 session_service->SetSelectedTabInWindow(window_id, 0); 101 session_service->SetSelectedTabInWindow(window_id, 0);
100 if (pinned) 102 if (pinned)
101 session_service->SetPinnedState(window_id, tab_id, true); 103 session_service->SetPinnedState(window_id, tab_id, true);
102 scoped_ptr<content::NavigationEntry> entry( 104 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());;
103 content::NavigationEntry::Create());;
104 entry->SetURL(url1_); 105 entry->SetURL(url1_);
105 session_service->UpdateTabNavigation(window_id, tab_id, 0, *entry.get()); 106 session_service->UpdateTabNavigation(window_id, tab_id, 0, *entry.get());
106 } 107 }
107 108
108 // Creates a SessionService and assigns it to the Profile. The SessionService 109 // Creates a SessionService and assigns it to the Profile. The SessionService
109 // is configured with a single window with a single tab pointing at url1_ by 110 // is configured with a single window with a single tab pointing at url1_ by
110 // way of AddWindowWithOneTabToSessionService. If |pinned| is true, the 111 // way of AddWindowWithOneTabToSessionService. If |pinned| is true, the
111 // tab is marked as pinned in the session service. 112 // tab is marked as pinned in the session service.
112 void CreateSessionServiceWithOneWindow(bool pinned) { 113 void CreateSessionServiceWithOneWindow(bool pinned) {
113 // The profile takes ownership of this. 114 // The profile takes ownership of this.
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 for (size_t i = 0; i < max_entries + 5; i++) { 632 for (size_t i = 0; i < max_entries + 5; i++) {
632 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); 633 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i))));
633 service_->CreateHistoricalTab(&controller(), -1); 634 service_->CreateHistoricalTab(&controller(), -1);
634 } 635 }
635 636
636 EXPECT_EQ(max_entries, service_->entries_.size()); 637 EXPECT_EQ(max_entries, service_->entries_.size());
637 // This should not crash. 638 // This should not crash.
638 service_->LoadTabsFromLastSession(); 639 service_->LoadTabsFromLastSession();
639 EXPECT_EQ(max_entries, service_->entries_.size()); 640 EXPECT_EQ(max_entries, service_->entries_.size());
640 } 641 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_restore_service.cc ('k') | chrome/browser/ssl/ssl_blocking_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698