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 "chrome/app/chrome_command_ids.h" | 5 #include "chrome/app/chrome_command_ids.h" |
6 #include "chrome/browser/bookmarks/bookmark_model.h" | 6 #include "chrome/browser/bookmarks/bookmark_model.h" |
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
8 #include "chrome/browser/ui/browser_command_controller.h" | 8 #include "chrome/browser/ui/browser_command_controller.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
13 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 | 18 |
19 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
20 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 20 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 AddTab(browser(), url1); | 69 AddTab(browser(), url1); |
70 NavigateAndCommitActiveTab(url2); | 70 NavigateAndCommitActiveTab(url2); |
71 NavigateAndCommitActiveTab(url3); | 71 NavigateAndCommitActiveTab(url3); |
72 content::NavigationController& orig_controller = | 72 content::NavigationController& orig_controller = |
73 browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); | 73 browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); |
74 orig_controller.LoadURL( | 74 orig_controller.LoadURL( |
75 url4, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 75 url4, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
76 EXPECT_EQ(3, orig_controller.GetEntryCount()); | 76 EXPECT_EQ(3, orig_controller.GetEntryCount()); |
77 EXPECT_TRUE(orig_controller.GetPendingEntry()); | 77 EXPECT_TRUE(orig_controller.GetPendingEntry()); |
78 | 78 |
79 size_t initial_window_count = BrowserList::size(); | 79 size_t initial_window_count = chrome::GetTotalBrowserCount(); |
80 | 80 |
81 // Duplicate the tab. | 81 // Duplicate the tab. |
82 chrome::ExecuteCommand(browser(), IDC_DUPLICATE_TAB); | 82 chrome::ExecuteCommand(browser(), IDC_DUPLICATE_TAB); |
83 | 83 |
84 // The duplicated tab should not end up in a new window. | 84 // The duplicated tab should not end up in a new window. |
85 size_t window_count = BrowserList::size(); | 85 size_t window_count = chrome::GetTotalBrowserCount(); |
86 ASSERT_EQ(initial_window_count, window_count); | 86 ASSERT_EQ(initial_window_count, window_count); |
87 | 87 |
88 // And we should have a newly duplicated tab. | 88 // And we should have a newly duplicated tab. |
89 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 89 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
90 | 90 |
91 // Verify the stack of urls. | 91 // Verify the stack of urls. |
92 content::NavigationController& controller = | 92 content::NavigationController& controller = |
93 browser()->tab_strip_model()->GetWebContentsAt(1)->GetController(); | 93 browser()->tab_strip_model()->GetWebContentsAt(1)->GetController(); |
94 EXPECT_EQ(3, controller.GetEntryCount()); | 94 EXPECT_EQ(3, controller.GetEntryCount()); |
95 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); | 95 EXPECT_EQ(2, controller.GetCurrentEntryIndex()); |
(...skipping 10 matching lines...) Expand all Loading... |
106 | 106 |
107 // Navigate to a URL, plus a pending URL that hasn't committed. | 107 // Navigate to a URL, plus a pending URL that hasn't committed. |
108 AddTab(browser(), url1); | 108 AddTab(browser(), url1); |
109 content::NavigationController& orig_controller = | 109 content::NavigationController& orig_controller = |
110 browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); | 110 browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); |
111 orig_controller.LoadURL( | 111 orig_controller.LoadURL( |
112 url2, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 112 url2, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
113 EXPECT_EQ(1, orig_controller.GetEntryCount()); | 113 EXPECT_EQ(1, orig_controller.GetEntryCount()); |
114 EXPECT_TRUE(orig_controller.GetPendingEntry()); | 114 EXPECT_TRUE(orig_controller.GetPendingEntry()); |
115 | 115 |
116 size_t initial_window_count = BrowserList::size(); | 116 size_t initial_window_count = chrome::GetTotalBrowserCount(); |
117 | 117 |
118 // View Source. | 118 // View Source. |
119 chrome::ExecuteCommand(browser(), IDC_VIEW_SOURCE); | 119 chrome::ExecuteCommand(browser(), IDC_VIEW_SOURCE); |
120 | 120 |
121 // The view source tab should not end up in a new window. | 121 // The view source tab should not end up in a new window. |
122 size_t window_count = BrowserList::size(); | 122 size_t window_count = chrome::GetTotalBrowserCount(); |
123 ASSERT_EQ(initial_window_count, window_count); | 123 ASSERT_EQ(initial_window_count, window_count); |
124 | 124 |
125 // And we should have a newly duplicated tab. | 125 // And we should have a newly duplicated tab. |
126 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 126 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
127 | 127 |
128 // Verify we are viewing the source of the last committed entry. | 128 // Verify we are viewing the source of the last committed entry. |
129 GURL view_source_url("view-source:http://foo/1"); | 129 GURL view_source_url("view-source:http://foo/1"); |
130 content::NavigationController& controller = | 130 content::NavigationController& controller = |
131 browser()->tab_strip_model()->GetWebContentsAt(1)->GetController(); | 131 browser()->tab_strip_model()->GetWebContentsAt(1)->GetController(); |
132 EXPECT_EQ(1, controller.GetEntryCount()); | 132 EXPECT_EQ(1, controller.GetEntryCount()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Same thing again for forward. | 217 // Same thing again for forward. |
218 // TODO(brettw) bug 11055: see the comment above about why we need this. | 218 // TODO(brettw) bug 11055: see the comment above about why we need this. |
219 CommitPendingLoad(& | 219 CommitPendingLoad(& |
220 browser()->tab_strip_model()->GetActiveWebContents()->GetController()); | 220 browser()->tab_strip_model()->GetActiveWebContents()->GetController()); |
221 chrome::GoForward(browser(), NEW_FOREGROUND_TAB); | 221 chrome::GoForward(browser(), NEW_FOREGROUND_TAB); |
222 ASSERT_EQ(4, browser()->tab_strip_model()->active_index()); | 222 ASSERT_EQ(4, browser()->tab_strip_model()->active_index()); |
223 ASSERT_EQ(url2, | 223 ASSERT_EQ(url2, |
224 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); | 224 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); |
225 } | 225 } |
226 | 226 |
OLD | NEW |