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

Side by Side Diff: chrome/browser/tabs/tab_strip_model_unittest.cc

Issue 479: DidNavigate refactor of doom (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "chrome/browser/dom_ui/new_tab_ui.h" 7 #include "chrome/browser/dom_ui/new_tab_ui.h"
8 #include "chrome/browser/navigation_controller.h" 8 #include "chrome/browser/navigation_controller.h"
9 #include "chrome/browser/navigation_entry.h" 9 #include "chrome/browser/navigation_entry.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
(...skipping 13 matching lines...) Expand all
24 24
25 // Since you can't just instantiate a TabContents, and some of its methods 25 // Since you can't just instantiate a TabContents, and some of its methods
26 // are protected, we subclass TabContents with our own testing dummy which 26 // are protected, we subclass TabContents with our own testing dummy which
27 // knows how to drive the base class' NavigationController as URLs are 27 // knows how to drive the base class' NavigationController as URLs are
28 // loaded. 28 // loaded.
29 class TabStripModelTestTabContents : public TabContents { 29 class TabStripModelTestTabContents : public TabContents {
30 public: 30 public:
31 TabStripModelTestTabContents(const TabContentsType type) 31 TabStripModelTestTabContents(const TabContentsType type)
32 : TabContents(type) { 32 : TabContents(type) {
33 } 33 }
34
35 bool Navigate(const NavigationEntry& entry, bool reload) {
36 NavigationEntry* pending_entry = new NavigationEntry(entry);
37 if (pending_entry->page_id() == -1) {
38 pending_entry->set_page_id(g_page_id_++);
39 }
40 NavigationController::LoadCommittedDetails details;
41 DidNavigateToEntry(pending_entry, &details);
42
43 return true;
44 }
45
46 private:
47 // We need to use valid, incrementing page ids otherwise the TabContents
48 // and NavController will not play nice when we try to go back and forward.
49 static int g_page_id_;
50 }; 34 };
51 35
52 int TabStripModelTestTabContents::g_page_id_ = 0;
53 36
54 // This constructs our fake TabContents. 37 // This constructs our fake TabContents.
55 class TabStripModelTestTabContentsFactory : public TabContentsFactory { 38 class TabStripModelTestTabContentsFactory : public TabContentsFactory {
56 public: 39 public:
57 virtual TabContents* CreateInstance() { 40 virtual TabContents* CreateInstance() {
58 return new TabStripModelTestTabContents(kHTTPTabContentsType); 41 return new TabStripModelTestTabContents(kHTTPTabContentsType);
59 } 42 }
60 43
61 virtual bool CanHandleURL(const GURL& url) { 44 virtual bool CanHandleURL(const GURL& url) {
62 return url.scheme() == "http"; 45 return url.scheme() == "http";
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1159
1177 // Close the Tab. The next-adjacent should be selected. 1160 // Close the Tab. The next-adjacent should be selected.
1178 strip.CloseTabContentsAt(4); 1161 strip.CloseTabContentsAt(4);
1179 1162
1180 EXPECT_EQ(3, strip.selected_index()); 1163 EXPECT_EQ(3, strip.selected_index());
1181 1164
1182 // Clean up. 1165 // Clean up.
1183 strip.CloseAllTabs(); 1166 strip.CloseAllTabs();
1184 } 1167 }
1185 1168
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698