| OLD | NEW |
| 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 "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/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
| 8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
| 9 #include "chrome/test/base/browser_with_test_window_test.h" | 9 #include "chrome/test/base/browser_with_test_window_test.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "content/browser/tab_contents/navigation_controller.h" | |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 11 #include "content/browser/tab_contents/tab_contents.h" |
| 12 #include "content/public/browser/navigation_controller.h" |
| 13 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
| 14 #include "content/test/test_browser_thread.h" | 14 #include "content/test/test_browser_thread.h" |
| 15 | 15 |
| 16 typedef BrowserWithTestWindowTest BrowserCommandsTest; | 16 typedef BrowserWithTestWindowTest BrowserCommandsTest; |
| 17 | 17 |
| 18 using content::OpenURLParams; | 18 using content::OpenURLParams; |
| 19 using content::Referrer; | 19 using content::Referrer; |
| 20 | 20 |
| 21 // Tests IDC_SELECT_TAB_0, IDC_SELECT_NEXT_TAB, IDC_SELECT_PREVIOUS_TAB and | 21 // Tests IDC_SELECT_TAB_0, IDC_SELECT_NEXT_TAB, IDC_SELECT_PREVIOUS_TAB and |
| 22 // IDC_SELECT_LAST_TAB. | 22 // IDC_SELECT_LAST_TAB. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 browser()->ExecuteCommand(IDC_DUPLICATE_TAB); | 65 browser()->ExecuteCommand(IDC_DUPLICATE_TAB); |
| 66 | 66 |
| 67 // The duplicated tab should not end up in a new window. | 67 // The duplicated tab should not end up in a new window. |
| 68 size_t window_count = BrowserList::size(); | 68 size_t window_count = BrowserList::size(); |
| 69 ASSERT_EQ(initial_window_count, window_count); | 69 ASSERT_EQ(initial_window_count, window_count); |
| 70 | 70 |
| 71 // And we should have a newly duplicated tab. | 71 // And we should have a newly duplicated tab. |
| 72 ASSERT_EQ(2, browser()->tab_count()); | 72 ASSERT_EQ(2, browser()->tab_count()); |
| 73 | 73 |
| 74 // Verify the stack of urls. | 74 // Verify the stack of urls. |
| 75 NavigationController& controller = | 75 content::NavigationController& controller = |
| 76 browser()->GetTabContentsAt(1)->GetController(); | 76 browser()->GetTabContentsAt(1)->GetController(); |
| 77 ASSERT_EQ(3, controller.GetEntryCount()); | 77 ASSERT_EQ(3, controller.GetEntryCount()); |
| 78 ASSERT_EQ(2, controller.GetCurrentEntryIndex()); | 78 ASSERT_EQ(2, controller.GetCurrentEntryIndex()); |
| 79 ASSERT_TRUE(url1 == controller.GetEntryAtIndex(0)->GetURL()); | 79 ASSERT_TRUE(url1 == controller.GetEntryAtIndex(0)->GetURL()); |
| 80 ASSERT_TRUE(url2 == controller.GetEntryAtIndex(1)->GetURL()); | 80 ASSERT_TRUE(url2 == controller.GetEntryAtIndex(1)->GetURL()); |
| 81 ASSERT_TRUE(url3 == controller.GetEntryAtIndex(2)->GetURL()); | 81 ASSERT_TRUE(url3 == controller.GetEntryAtIndex(2)->GetURL()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 TEST_F(BrowserCommandsTest, BookmarkCurrentPage) { | 84 TEST_F(BrowserCommandsTest, BookmarkCurrentPage) { |
| 85 // We use profile() here, since it's a TestingProfile. | 85 // We use profile() here, since it's a TestingProfile. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 // Pressing it a second time while the NTP is open shouldn't change anything. | 191 // Pressing it a second time while the NTP is open shouldn't change anything. |
| 192 browser()->Search(); | 192 browser()->Search(); |
| 193 ASSERT_EQ(2, browser()->tab_count()); | 193 ASSERT_EQ(2, browser()->tab_count()); |
| 194 ASSERT_EQ(1, browser()->active_index()); | 194 ASSERT_EQ(1, browser()->active_index()); |
| 195 current_url = browser()->GetSelectedWebContents()->GetURL(); | 195 current_url = browser()->GetSelectedWebContents()->GetURL(); |
| 196 EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme)); | 196 EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme)); |
| 197 EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host()); | 197 EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host()); |
| 198 } | 198 } |
| 199 #endif | 199 #endif |
| OLD | NEW |