Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: chrome/browser/ui/webui/web_ui_unittest.cc

Issue 9146028: Define the public interface for content browser SiteInstance. This interface is implemented by th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
12 #include "content/browser/tab_contents/test_tab_contents.h" 11 #include "content/browser/tab_contents/test_tab_contents.h"
13 #include "content/public/browser/navigation_controller.h" 12 #include "content/public/browser/navigation_controller.h"
13 #include "content/public/browser/site_instance.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 using content::NavigationController;
19 using content::SiteInstance;
19 using content::WebContents; 20 using content::WebContents;
20 21
21 class WebUITest : public TabContentsWrapperTestHarness { 22 class WebUITest : public TabContentsWrapperTestHarness {
22 public: 23 public:
23 WebUITest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {} 24 WebUITest() : ui_thread_(BrowserThread::UI, MessageLoop::current()) {}
24 25
25 // Tests navigating with a Web UI from a fresh (nothing pending or committed) 26 // Tests navigating with a Web UI from a fresh (nothing pending or committed)
26 // state, through pending, committed, then another navigation. The first page 27 // state, through pending, committed, then another navigation. The first page
27 // ID that we should use is passed as a parameter. We'll use the next two 28 // ID that we should use is passed as a parameter. We'll use the next two
28 // values. This must be increasing for the life of the tests. 29 // values. This must be increasing for the life of the tests.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 int focus_called() const { return focus_called_; } 164 int focus_called() const { return focus_called_; }
164 165
165 private: 166 private:
166 int focus_called_; 167 int focus_called_;
167 }; 168 };
168 169
169 TEST_F(WebUITest, FocusOnNavigate) { 170 TEST_F(WebUITest, FocusOnNavigate) {
170 // Setup. |tc| will be used to track when we try to focus the location bar. 171 // Setup. |tc| will be used to track when we try to focus the location bar.
171 TabContentsForFocusTest* tc = new TabContentsForFocusTest( 172 TabContentsForFocusTest* tc = new TabContentsForFocusTest(
172 contents()->GetBrowserContext(), 173 contents()->GetBrowserContext(),
173 SiteInstance::CreateSiteInstance(contents()->GetBrowserContext())); 174 SiteInstance::Create(contents()->GetBrowserContext()));
174 tc->GetController().CopyStateFrom(controller()); 175 tc->GetController().CopyStateFrom(controller());
175 SetContents(tc); 176 SetContents(tc);
176 int page_id = 200; 177 int page_id = 200;
177 178
178 // Load the NTP. 179 // Load the NTP.
179 GURL new_tab_url(chrome::kChromeUINewTabURL); 180 GURL new_tab_url(chrome::kChromeUINewTabURL);
180 controller().LoadURL(new_tab_url, content::Referrer(), 181 controller().LoadURL(new_tab_url, content::Referrer(),
181 content::PAGE_TRANSITION_LINK, 182 content::PAGE_TRANSITION_LINK,
182 std::string()); 183 std::string());
183 rvh()->SendNavigate(page_id, new_tab_url); 184 rvh()->SendNavigate(page_id, new_tab_url);
(...skipping 22 matching lines...) Expand all
206 // Navigate forward. Shouldn't focus the location bar. 207 // Navigate forward. Shouldn't focus the location bar.
207 focus_called = tc->focus_called(); 208 focus_called = tc->focus_called();
208 ASSERT_TRUE(controller().CanGoForward()); 209 ASSERT_TRUE(controller().CanGoForward());
209 controller().GoForward(); 210 controller().GoForward();
210 old_rvh = rvh(); 211 old_rvh = rvh();
211 old_rvh->SendShouldCloseACK(true); 212 old_rvh->SendShouldCloseACK(true);
212 pending_rvh()->SendNavigate(next_page_id, next_url); 213 pending_rvh()->SendNavigate(next_page_id, next_url);
213 old_rvh->OnSwapOutACK(); 214 old_rvh->OnSwapOutACK();
214 EXPECT_EQ(focus_called, tc->focus_called()); 215 EXPECT_EQ(focus_called, tc->focus_called());
215 } 216 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/extension_settings_handler.cc ('k') | content/browser/browsing_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698