OLD | NEW |
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 "chrome/app/chrome_dll_resource.h" | 5 #include "chrome/app/chrome_dll_resource.h" |
| 6 #include "chrome/browser/bookmarks/bookmark_model.h" |
6 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
7 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
8 #include "chrome/browser/tab_contents/navigation_controller.h" | 9 #include "chrome/browser/tab_contents/navigation_controller.h" |
9 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
10 #include "chrome/test/browser_with_test_window_test.h" | 11 #include "chrome/test/browser_with_test_window_test.h" |
| 12 #include "chrome/test/testing_profile.h" |
11 | 13 |
12 typedef BrowserWithTestWindowTest BrowserCommandsTest; | 14 typedef BrowserWithTestWindowTest BrowserCommandsTest; |
13 | 15 |
14 // Tests IDC_SELECT_TAB_0, IDC_SELECT_NEXT_TAB, IDC_SELECT_PREVIOUS_TAB and | 16 // Tests IDC_SELECT_TAB_0, IDC_SELECT_NEXT_TAB, IDC_SELECT_PREVIOUS_TAB and |
15 // IDC_SELECT_LAST_TAB. | 17 // IDC_SELECT_LAST_TAB. |
16 TEST_F(BrowserCommandsTest, TabNavigationAccelerators) { | 18 TEST_F(BrowserCommandsTest, TabNavigationAccelerators) { |
17 // Create three tabs. | 19 // Create three tabs. |
18 AddTestingTab(browser()); | 20 AddTestingTab(browser()); |
19 AddTestingTab(browser()); | 21 AddTestingTab(browser()); |
20 AddTestingTab(browser()); | 22 AddTestingTab(browser()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 67 |
66 // Verify the stack of urls. | 68 // Verify the stack of urls. |
67 NavigationController* controller = | 69 NavigationController* controller = |
68 browser()->GetTabContentsAt(1)->controller(); | 70 browser()->GetTabContentsAt(1)->controller(); |
69 ASSERT_EQ(3, controller->GetEntryCount()); | 71 ASSERT_EQ(3, controller->GetEntryCount()); |
70 ASSERT_EQ(2, controller->GetCurrentEntryIndex()); | 72 ASSERT_EQ(2, controller->GetCurrentEntryIndex()); |
71 ASSERT_TRUE(url1 == controller->GetEntryAtIndex(0)->url()); | 73 ASSERT_TRUE(url1 == controller->GetEntryAtIndex(0)->url()); |
72 ASSERT_TRUE(url2 == controller->GetEntryAtIndex(1)->url()); | 74 ASSERT_TRUE(url2 == controller->GetEntryAtIndex(1)->url()); |
73 ASSERT_TRUE(url3 == controller->GetEntryAtIndex(2)->url()); | 75 ASSERT_TRUE(url3 == controller->GetEntryAtIndex(2)->url()); |
74 } | 76 } |
| 77 |
| 78 TEST_F(BrowserCommandsTest, BookmarkCurrentPage) { |
| 79 // We use profile() here, since it's a TestingProfile. |
| 80 profile()->CreateBookmarkModel(true); |
| 81 profile()->BlockUntilBookmarkModelLoaded(); |
| 82 |
| 83 // Navigate to a url. |
| 84 GURL url1 = test_url_with_path("1"); |
| 85 AddTestingTab(browser()); |
| 86 browser()->OpenURL(url1, GURL(), CURRENT_TAB, PageTransition::TYPED); |
| 87 |
| 88 // TODO(beng): remove this once we can use WebContentses directly in testing |
| 89 // instead of the TestTabContents which causes this command not to |
| 90 // be enabled when the tab is added (and selected). |
| 91 browser()->command_updater()->UpdateCommandEnabled(IDC_STAR, true); |
| 92 |
| 93 // Star it. |
| 94 browser()->ExecuteCommand(IDC_STAR); |
| 95 |
| 96 // It should now be bookmarked in the bookmark model. |
| 97 EXPECT_EQ(profile(), browser()->profile()); |
| 98 EXPECT_TRUE(browser()->profile()->GetBookmarkModel()->IsBookmarked(url1)); |
| 99 } |
OLD | NEW |