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

Side by Side Diff: chrome/browser/ui/browser_list_unittest.cc

Issue 9645003: Introduce abstractions to allow embedders to test RenderViewHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 8 years, 9 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/browser_process.h" 5 #include "chrome/browser/browser_process.h"
6 #include "chrome/browser/browser_shutdown.h" 6 #include "chrome/browser/browser_shutdown.h"
7 #include "chrome/browser/prefs/pref_service.h" 7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/printing/background_printing_manager.h" 8 #include "chrome/browser/printing/background_printing_manager.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser_list.h" 10 #include "chrome/browser/ui/browser_list.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/browser_with_test_window_test.h" 14 #include "chrome/test/base/browser_with_test_window_test.h"
15 #include "chrome/test/base/testing_browser_process.h" 15 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_pref_service.h" 16 #include "chrome/test/base/testing_pref_service.h"
17 #include "chrome/test/base/testing_profile_manager.h" 17 #include "chrome/test/base/testing_profile_manager.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/test/test_renderer_host.h"
19 20
20 typedef BrowserWithTestWindowTest BrowserListTest; 21 typedef BrowserWithTestWindowTest BrowserListTest;
21 22
22 namespace { 23 namespace {
23 24
24 // Helper function to iterate and count all the tabs. 25 // Helper function to iterate and count all the tabs.
25 size_t CountAllTabs() { 26 size_t CountAllTabs() {
26 size_t count = 0; 27 size_t count = 0;
27 for (TabContentsIterator iterator; !iterator.done(); ++iterator) 28 for (TabContentsIterator iterator; !iterator.done(); ++iterator)
28 ++count; 29 ++count;
29 return count; 30 return count;
30 } 31 }
31 32
32 // Helper function to navigate to the print preview page. 33 // Helper function to navigate to the print preview page.
33 void NavigateToPrintUrl(TabContentsWrapper* tab, int page_id) { 34 void NavigateToPrintUrl(TabContentsWrapper* tab, int page_id) {
34 static_cast<content::TestRenderViewHost*>( 35 content::RenderViewHostTester::For(
35 tab->web_contents()->GetRenderViewHost())->SendNavigate( 36 tab->web_contents()->GetRenderViewHost())->SendNavigate(
36 page_id, GURL(chrome::kChromeUIPrintURL)); 37 page_id, GURL(chrome::kChromeUIPrintURL));
37 } 38 }
38 39
39 } // namespace 40 } // namespace
40 41
41 TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) { 42 TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) {
42 // Make sure we have 1 window to start with. 43 // Make sure we have 1 window to start with.
43 EXPECT_EQ(1U, BrowserList::size()); 44 EXPECT_EQ(1U, BrowserList::size());
44 45
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 testing_browser_process->SetProfileManager(profile_manager); 263 testing_browser_process->SetProfileManager(profile_manager);
263 264
264 BrowserList::AttemptRestart(); 265 BrowserList::AttemptRestart();
265 // Cancel the effects of us calling BrowserList::AttemptRestart. Otherwise 266 // Cancel the effects of us calling BrowserList::AttemptRestart. Otherwise
266 // tests ran after this one will fail. 267 // tests ran after this one will fail.
267 browser_shutdown::SetTryingToQuit(false); 268 browser_shutdown::SetTryingToQuit(false);
268 269
269 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); 270 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted));
270 testing_browser_process->SetLocalState(NULL); 271 testing_browser_process->SetLocalState(NULL);
271 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698