diff options
author | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 06:28:50 +0000 |
---|---|---|
committer | scr@chromium.org <scr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 06:28:50 +0000 |
commit | 1582387e898ffc722d7f34768e257d1d25b9cde8 (patch) | |
tree | 1d0d81267afeac63c95d03dd4f9d1fd0fe1bd25b /chrome/browser/ui | |
parent | b945425ee28d986f665f9a51ceadbc787ddef0e2 (diff) | |
download | chromium_src-1582387e898ffc722d7f34768e257d1d25b9cde8.zip chromium_src-1582387e898ffc722d7f34768e257d1d25b9cde8.tar.gz chromium_src-1582387e898ffc722d7f34768e257d1d25b9cde8.tar.bz2 |
Allow WebUI Tests to use preLoad in HtmlDialogUI.
- Refactor JsInjectionReadyObserver to its own header/impl files.
- Call JsInjectionReadyObserver::OnJsInjectionReady when the dialog
is shown.
- Move preamble generation to after the AddLibrary calls & generate setting
of preload_* variables rather than passing in browsePreload and
browsePrintPreload.
- Modify tests that show HtmlDialogUI to show the dialogs using preamble
rather than SetUpOnMainThread so AddLibrary & set_preload_* calls precede
showing the dialog (so preload is called against the appropriate fixture).
R=flackr@chromium.org, jhawkins@chromium.org
BUG=104371
TEST=browser_tests --gtest_filter=Hung*.* -AND- CertificateViewerUITest*.*
Review URL: http://codereview.chromium.org/8586009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/webui/html_dialog_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/web_ui_browsertest.cc | 27 | ||||
-rw-r--r-- | chrome/browser/ui/webui/web_ui_browsertest.h | 19 |
3 files changed, 23 insertions, 25 deletions
diff --git a/chrome/browser/ui/webui/html_dialog_ui.cc b/chrome/browser/ui/webui/html_dialog_ui.cc index 788ee23..05d9fec 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.cc +++ b/chrome/browser/ui/webui/html_dialog_ui.cc @@ -73,7 +73,7 @@ void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { content::NotificationService::current()->Notify( chrome::NOTIFICATION_HTML_DIALOG_SHOWN, content::Source<WebUI>(this), - content::NotificationService::NoDetails()); + content::Details<RenderViewHost>(render_view_host)); } void HtmlDialogUI::OnDialogClosed(const ListValue* args) { diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc index 9049fd8..d960cc1 100644 --- a/chrome/browser/ui/webui/web_ui_browsertest.cc +++ b/chrome/browser/ui/webui/web_ui_browsertest.cc @@ -175,13 +175,7 @@ void WebUIBrowserTest::PreLoadJavascriptLibraries( libraries_preloaded_ = true; } -void WebUIBrowserTest::BrowsePreload(const GURL& browse_to, - const std::string& preload_test_fixture, - const std::string& preload_test_name) { - // Remember for callback OnJsInjectionReady(). - preload_test_fixture_ = preload_test_fixture; - preload_test_name_ = preload_test_name; - +void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) { TestNavigationObserver navigation_observer( content::Source<NavigationController>( &browser()->GetSelectedTabContentsWrapper()->controller()), @@ -193,14 +187,7 @@ void WebUIBrowserTest::BrowsePreload(const GURL& browse_to, navigation_observer.WaitForObservation(); } -void WebUIBrowserTest::BrowsePrintPreload( - const GURL& browse_to, - const std::string& preload_test_fixture, - const std::string& preload_test_name) { - // Remember for callback OnJsInjectionReady(). - preload_test_fixture_ = preload_test_fixture; - preload_test_name_ = preload_test_name; - +void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) { ui_test_utils::NavigateToURL(browser(), browse_to); TestTabStripModelObserver tabstrip_observer( @@ -223,6 +210,16 @@ WebUIBrowserTest::WebUIBrowserTest() libraries_preloaded_(false), override_selected_web_ui_(NULL) {} +void WebUIBrowserTest::set_preload_test_fixture( + const std::string& preload_test_fixture) { + preload_test_fixture_ = preload_test_fixture; +} + +void WebUIBrowserTest::set_preload_test_name( + const std::string& preload_test_name) { + preload_test_name_ = preload_test_name; +} + namespace { class MockWebUIProvider : public TestChromeWebUIFactory::WebUIProvider { diff --git a/chrome/browser/ui/webui/web_ui_browsertest.h b/chrome/browser/ui/webui/web_ui_browsertest.h index 99f086a..59895da 100644 --- a/chrome/browser/ui/webui/web_ui_browsertest.h +++ b/chrome/browser/ui/webui/web_ui_browsertest.h @@ -12,7 +12,8 @@ #include "base/string16.h" #include "chrome/browser/ui/webui/web_ui_test_handler.h" #include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/test_navigation_observer.h" +#include "chrome/test/base/js_injection_ready_observer.h" +#include "chrome/test/base/test_navigation_observer.h" class RenderViewHost; class WebUIMessageHandler; @@ -37,7 +38,7 @@ class Value; // and the lone test within this class. class WebUIBrowserTest : public InProcessBrowserTest, - public TestNavigationObserver::JsInjectionReadyObserver { + public JsInjectionReadyObserver { public: typedef std::vector<const base::Value*> ConstValueVector; virtual ~WebUIBrowserTest(); @@ -101,17 +102,13 @@ class WebUIBrowserTest // the javascript for the given |preload_test_fixture| and // |preload_test_name|. chrome.send will be overridden to allow javascript // handler mocking. - void BrowsePreload(const GURL& browse_to, - const std::string& preload_test_fixture, - const std::string& preload_test_name); + void BrowsePreload(const GURL& browse_to); // Called by javascript-generated test bodies to browse to a page and preload // the javascript for the given |preload_test_fixture| and // |preload_test_name|. chrome.send will be overridden to allow javascript // handler mocking. - void BrowsePrintPreload(const GURL& browse_to, - const std::string& preload_test_fixture, - const std::string& preload_test_name); + void BrowsePrintPreload(const GURL& browse_to); protected: // URL to dummy WebUI page for testing framework. @@ -119,6 +116,10 @@ class WebUIBrowserTest WebUIBrowserTest(); + // Accessors for preload test fixture and name. + void set_preload_test_fixture(const std::string& preload_test_fixture); + void set_preload_test_name(const std::string& preload_test_name); + // Set up & tear down console error catching. virtual void SetUpOnMainThread() OVERRIDE; virtual void CleanUpOnMainThread() OVERRIDE; @@ -140,7 +141,7 @@ class WebUIBrowserTest static GURL WebUITestDataPathToURL(const FilePath::StringType& path); private: - // TestNavigationObserver::JsInjectionReadyObserver implementation. + // JsInjectionReadyObserver implementation. virtual void OnJsInjectionReady(RenderViewHost* render_view_host) OVERRIDE; // Builds a string containing all added javascript libraries. |