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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 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/browser/ui/webui/web_ui_browsertest.h" 5 #include "chrome/browser/ui/webui/web_ui_browsertest.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/printing/print_preview_tab_controller.h" 17 #include "chrome/browser/printing/print_preview_tab_controller.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h" 20 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/browser_navigator.h" 21 #include "chrome/browser/ui/browser_navigator.h"
22 #include "chrome/browser/ui/browser_tabstrip.h"
22 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 23 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
23 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h" 24 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
24 #include "chrome/browser/ui/webui/web_ui_test_handler.h" 25 #include "chrome/browser/ui/webui/web_ui_test_handler.h"
25 #include "chrome/browser/ui/tab_contents/tab_contents.h" 26 #include "chrome/browser/ui/tab_contents/tab_contents.h"
26 #include "chrome/common/chrome_paths.h" 27 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
28 #include "chrome/test/base/test_tab_strip_model_observer.h" 29 #include "chrome/test/base/test_tab_strip_model_observer.h"
29 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
30 #include "content/public/browser/navigation_controller.h" 31 #include "content/public/browser/navigation_controller.h"
31 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 args.push_back(Value::CreateStringValue(preload_test_fixture)); 191 args.push_back(Value::CreateStringValue(preload_test_fixture));
191 args.push_back(Value::CreateStringValue(preload_test_name)); 192 args.push_back(Value::CreateStringValue(preload_test_name));
192 RunJavascriptUsingHandler( 193 RunJavascriptUsingHandler(
193 "preloadJavascriptLibraries", args, false, false, preload_host); 194 "preloadJavascriptLibraries", args, false, false, preload_host);
194 libraries_preloaded_ = true; 195 libraries_preloaded_ = true;
195 } 196 }
196 197
197 void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) { 198 void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) {
198 content::TestNavigationObserver navigation_observer( 199 content::TestNavigationObserver navigation_observer(
199 content::Source<NavigationController>( 200 content::Source<NavigationController>(
200 &browser()->GetActiveWebContents()->GetController()), 201 &chrome::GetActiveWebContents(browser())->GetController()),
201 this, 1); 202 this, 1);
202 browser::NavigateParams params( 203 browser::NavigateParams params(
203 browser(), GURL(browse_to), content::PAGE_TRANSITION_TYPED); 204 browser(), GURL(browse_to), content::PAGE_TRANSITION_TYPED);
204 params.disposition = CURRENT_TAB; 205 params.disposition = CURRENT_TAB;
205 browser::Navigate(&params); 206 browser::Navigate(&params);
206 navigation_observer.WaitForObservation( 207 navigation_observer.WaitForObservation(
207 base::Bind(&ui_test_utils::RunMessageLoop), 208 base::Bind(&ui_test_utils::RunMessageLoop),
208 base::Bind(&MessageLoop::Quit, 209 base::Bind(&MessageLoop::Quit,
209 base::Unretained(MessageLoopForUI::current()))); 210 base::Unretained(MessageLoopForUI::current())));
210 } 211 }
211 212
212 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { 213 void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) {
213 ui_test_utils::NavigateToURL(browser(), browse_to); 214 ui_test_utils::NavigateToURL(browser(), browse_to);
214 215
215 TestTabStripModelObserver tabstrip_observer( 216 TestTabStripModelObserver tabstrip_observer(
216 browser()->tab_strip_model(), this); 217 browser()->tab_strip_model(), this);
217 chrome::Print(browser()); 218 chrome::Print(browser());
218 tabstrip_observer.WaitForObservation( 219 tabstrip_observer.WaitForObservation(
219 base::Bind(&ui_test_utils::RunMessageLoop), 220 base::Bind(&ui_test_utils::RunMessageLoop),
220 base::Bind(&MessageLoop::Quit, 221 base::Bind(&MessageLoop::Quit,
221 base::Unretained(MessageLoopForUI::current()))); 222 base::Unretained(MessageLoopForUI::current())));
222 223
223 printing::PrintPreviewTabController* tab_controller = 224 printing::PrintPreviewTabController* tab_controller =
224 printing::PrintPreviewTabController::GetInstance(); 225 printing::PrintPreviewTabController::GetInstance();
225 ASSERT_TRUE(tab_controller); 226 ASSERT_TRUE(tab_controller);
226 TabContents* preview_tab = tab_controller->GetPrintPreviewForTab( 227 TabContents* preview_tab = tab_controller->GetPrintPreviewForTab(
227 browser()->GetActiveTabContents()); 228 chrome::GetActiveTabContents(browser()));
228 ASSERT_TRUE(preview_tab); 229 ASSERT_TRUE(preview_tab);
229 SetWebUIInstance(preview_tab->web_contents()->GetWebUI()); 230 SetWebUIInstance(preview_tab->web_contents()->GetWebUI());
230 } 231 }
231 232
232 const char WebUIBrowserTest::kDummyURL[] = "chrome://DummyURL"; 233 const char WebUIBrowserTest::kDummyURL[] = "chrome://DummyURL";
233 234
234 WebUIBrowserTest::WebUIBrowserTest() 235 WebUIBrowserTest::WebUIBrowserTest()
235 : test_handler_(new WebUITestHandler()), 236 : test_handler_(new WebUITestHandler()),
236 libraries_preloaded_(false), 237 libraries_preloaded_(false),
237 override_selected_web_ui_(NULL) {} 238 override_selected_web_ui_(NULL) {}
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 LOG(ERROR) << "Encountered javascript console error(s)"; 459 LOG(ERROR) << "Encountered javascript console error(s)";
459 result = false; 460 result = false;
460 error_messages_.Get().clear(); 461 error_messages_.Get().clear();
461 } 462 }
462 return result; 463 return result;
463 } 464 }
464 465
465 void WebUIBrowserTest::SetupHandlers() { 466 void WebUIBrowserTest::SetupHandlers() {
466 content::WebUI* web_ui_instance = override_selected_web_ui_ ? 467 content::WebUI* web_ui_instance = override_selected_web_ui_ ?
467 override_selected_web_ui_ : 468 override_selected_web_ui_ :
468 browser()->GetActiveWebContents()->GetWebUI(); 469 chrome::GetActiveWebContents(browser())->GetWebUI();
469 ASSERT_TRUE(web_ui_instance != NULL); 470 ASSERT_TRUE(web_ui_instance != NULL);
470 471
471 test_handler_->set_web_ui(web_ui_instance); 472 test_handler_->set_web_ui(web_ui_instance);
472 test_handler_->RegisterMessages(); 473 test_handler_->RegisterMessages();
473 474
474 if (GetMockMessageHandler()) { 475 if (GetMockMessageHandler()) {
475 GetMockMessageHandler()->set_web_ui(web_ui_instance); 476 GetMockMessageHandler()->set_web_ui(web_ui_instance);
476 GetMockMessageHandler()->RegisterMessages(); 477 GetMockMessageHandler()->RegisterMessages();
477 } 478 }
478 } 479 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 // testDone directly and expect pass result. 698 // testDone directly and expect pass result.
698 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) { 699 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPassesAsync) {
699 ASSERT_TRUE(RunJavascriptAsyncTest("testDone")); 700 ASSERT_TRUE(RunJavascriptAsyncTest("testDone"));
700 } 701 }
701 702
702 // Test that calling testDone during RunJavascriptTest still completes when 703 // Test that calling testDone during RunJavascriptTest still completes when
703 // waiting for async result. 704 // waiting for async result.
704 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) { 705 IN_PROC_BROWSER_TEST_F(WebUIBrowserAsyncTest, TestTestDoneEarlyPasses) {
705 ASSERT_TRUE(RunJavascriptTest("testDone")); 706 ASSERT_TRUE(RunJavascriptTest("testDone"));
706 } 707 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc ('k') | chrome/browser/unload_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698