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/ui/browser_command_controller.h" | 8 #include "chrome/browser/ui/browser_command_controller.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 11 #include "chrome/browser/ui/browser_tabstrip.h" |
11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
12 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
13 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
14 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Navigate to a url. | 100 // Navigate to a url. |
100 GURL url1("http://foo/1"); | 101 GURL url1("http://foo/1"); |
101 AddTab(browser(), url1); | 102 AddTab(browser(), url1); |
102 browser()->OpenURL(OpenURLParams( | 103 browser()->OpenURL(OpenURLParams( |
103 url1, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 104 url1, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); |
104 | 105 |
105 chrome::BookmarkCurrentPage(browser()); | 106 chrome::BookmarkCurrentPage(browser()); |
106 | 107 |
107 // It should now be bookmarked in the bookmark model. | 108 // It should now be bookmarked in the bookmark model. |
108 EXPECT_EQ(profile(), browser()->profile()); | 109 EXPECT_EQ(profile(), browser()->profile()); |
109 EXPECT_TRUE(browser()->profile()->GetBookmarkModel()->IsBookmarked(url1)); | 110 EXPECT_TRUE(BookmarkModelFactory::GetForProfile( |
| 111 browser()->profile())->IsBookmarked(url1)); |
110 } | 112 } |
111 | 113 |
112 // Tests back/forward in new tab (Control + Back/Forward button in the UI). | 114 // Tests back/forward in new tab (Control + Back/Forward button in the UI). |
113 TEST_F(BrowserCommandsTest, BackForwardInNewTab) { | 115 TEST_F(BrowserCommandsTest, BackForwardInNewTab) { |
114 GURL url1("http://foo/1"); | 116 GURL url1("http://foo/1"); |
115 GURL url2("http://foo/2"); | 117 GURL url2("http://foo/2"); |
116 | 118 |
117 // Make a tab with the two pages navigated in it. | 119 // Make a tab with the two pages navigated in it. |
118 AddTab(browser(), url1); | 120 AddTab(browser(), url1); |
119 NavigateAndCommitActiveTab(url2); | 121 NavigateAndCommitActiveTab(url2); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 ASSERT_EQ(url1, chrome::GetActiveWebContents(browser())->GetURL()); | 170 ASSERT_EQ(url1, chrome::GetActiveWebContents(browser())->GetURL()); |
169 | 171 |
170 // Same thing again for forward. | 172 // Same thing again for forward. |
171 // TODO(brettw) bug 11055: see the comment above about why we need this. | 173 // TODO(brettw) bug 11055: see the comment above about why we need this. |
172 CommitPendingLoad(&chrome::GetActiveWebContents(browser())->GetController()); | 174 CommitPendingLoad(&chrome::GetActiveWebContents(browser())->GetController()); |
173 chrome::GoForward(browser(), NEW_FOREGROUND_TAB); | 175 chrome::GoForward(browser(), NEW_FOREGROUND_TAB); |
174 ASSERT_EQ(4, browser()->active_index()); | 176 ASSERT_EQ(4, browser()->active_index()); |
175 ASSERT_EQ(url2, chrome::GetActiveWebContents(browser())->GetURL()); | 177 ASSERT_EQ(url2, chrome::GetActiveWebContents(browser())->GetURL()); |
176 } | 178 } |
177 | 179 |
OLD | NEW |