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/browser/favicon/favicon_tab_helper.h" | 5 #include "chrome/browser/favicon/favicon_tab_helper.h" |
6 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 6 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
8 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 8 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
11 #include "content/browser/site_instance.h" | 11 #include "content/browser/site_instance.h" |
12 #include "content/browser/tab_contents/test_tab_contents.h" | 12 #include "content/browser/tab_contents/test_tab_contents.h" |
13 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
14 #include "content/test/test_browser_thread.h" | 14 #include "content/test/test_browser_thread.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 using content::NavigationController; |
18 | 19 |
19 class WebUITest : public TabContentsWrapperTestHarness { | 20 class WebUITest : public TabContentsWrapperTestHarness { |
20 public: | 21 public: |
21 WebUITest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {} | 22 WebUITest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {} |
22 | 23 |
23 // Tests navigating with a Web UI from a fresh (nothing pending or committed) | 24 // Tests navigating with a Web UI from a fresh (nothing pending or committed) |
24 // state, through pending, committed, then another navigation. The first page | 25 // state, through pending, committed, then another navigation. The first page |
25 // ID that we should use is passed as a parameter. We'll use the next two | 26 // ID that we should use is passed as a parameter. We'll use the next two |
26 // values. This must be increasing for the life of the tests. | 27 // values. This must be increasing for the life of the tests. |
27 static void DoNavigationTest(TabContentsWrapper* wrapper, int page_id) { | 28 static void DoNavigationTest(TabContentsWrapper* wrapper, int page_id) { |
28 TabContents* contents = wrapper->tab_contents(); | 29 TabContents* contents = wrapper->tab_contents(); |
29 content::NavigationController* controller = &contents->GetController(); | 30 NavigationController* controller = &contents->GetController(); |
30 | 31 |
31 // Start a pending load. | 32 // Start a pending load. |
32 GURL new_tab_url(chrome::kChromeUINewTabURL); | 33 GURL new_tab_url(chrome::kChromeUINewTabURL); |
33 controller->LoadURL(new_tab_url, content::Referrer(), | 34 controller->LoadURL(new_tab_url, content::Referrer(), |
34 content::PAGE_TRANSITION_LINK, | 35 content::PAGE_TRANSITION_LINK, |
35 std::string()); | 36 std::string()); |
36 | 37 |
37 // The navigation entry should be pending with no committed entry. | 38 // The navigation entry should be pending with no committed entry. |
38 ASSERT_TRUE(controller->GetPendingEntry()); | 39 ASSERT_TRUE(controller->GetPendingEntry()); |
39 ASSERT_FALSE(controller->GetLastCommittedEntry()); | 40 ASSERT_FALSE(controller->GetLastCommittedEntry()); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // Navigate forward. Shouldn't focus the location bar. | 205 // Navigate forward. Shouldn't focus the location bar. |
205 focus_called = tc->focus_called(); | 206 focus_called = tc->focus_called(); |
206 ASSERT_TRUE(controller().CanGoForward()); | 207 ASSERT_TRUE(controller().CanGoForward()); |
207 controller().GoForward(); | 208 controller().GoForward(); |
208 old_rvh = rvh(); | 209 old_rvh = rvh(); |
209 old_rvh->SendShouldCloseACK(true); | 210 old_rvh->SendShouldCloseACK(true); |
210 pending_rvh()->SendNavigate(next_page_id, next_url); | 211 pending_rvh()->SendNavigate(next_page_id, next_url); |
211 old_rvh->OnSwapOutACK(); | 212 old_rvh->OnSwapOutACK(); |
212 EXPECT_EQ(focus_called, tc->focus_called()); | 213 EXPECT_EQ(focus_called, tc->focus_called()); |
213 } | 214 } |
OLD | NEW |