diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-08 14:02:58 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-08 14:02:58 +0000 |
commit | 4cfc1d9243eaf01a3b736fa13f55b7400a891fb4 (patch) | |
tree | 8f8da34f968fdf547aefc55b3f5d9e210b1a03b3 /chrome/browser/extensions/extension_uitest.cc | |
parent | bb76183f666753f186e5234ddea409971753c784 (diff) | |
download | chromium_src-4cfc1d9243eaf01a3b736fa13f55b7400a891fb4.zip chromium_src-4cfc1d9243eaf01a3b736fa13f55b7400a891fb4.tar.gz chromium_src-4cfc1d9243eaf01a3b736fa13f55b7400a891fb4.tar.bz2 |
Modifying extension automation so that it is done through a particular
tab for all extension views. Previously, API routing to the
automation client would only work for extension views that were
contained in the particular ExternalTab instance being automated. This
meant you couldn't test API calls from e.g. background pages.
Also using async functions instead of the previous RVH-based hack.
Updating one of the UI tests to make the API calls from a background
page, to provide an end-to-end test of the new routing.
This makes AutomationProvider::SetEnableAutomationExtension
Windows-only, but it effectively always was since it was already
dependent on ExternalTabContainer (indirectly, to provide a non-empty
implementation of TabContentsDelegate::ForwardMessageToExternalHost).
BUG=none
TEST=ui_tests.exe, chrome_frame_tests.exe, chrome_frame_unittests.exe
Review URL: http://codereview.chromium.org/366025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_uitest.cc')
-rw-r--r-- | chrome/browser/extensions/extension_uitest.cc | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc index ac4504c..2cfcd7c 100644 --- a/chrome/browser/extensions/extension_uitest.cc +++ b/chrome/browser/extensions/extension_uitest.cc @@ -55,38 +55,46 @@ class ExtensionUITest : public ParentTestType { void SetUp() { ParentTestType::SetUp(); - automation()->SetEnableExtensionAutomation(functions_enabled_); + + AutomationProxyForExternalTab* proxy = + static_cast<AutomationProxyForExternalTab*>(automation()); + HWND external_tab_container = NULL; + HWND tab_wnd = NULL; + tab_ = proxy->CreateTabWithHostWindow(false, + GURL(), &external_tab_container, &tab_wnd); + + tab_->SetEnableExtensionAutomation(functions_enabled_); } void TearDown() { - automation()->SetEnableExtensionAutomation(std::vector<std::string>()); + tab_->SetEnableExtensionAutomation(std::vector<std::string>()); + + AutomationProxyForExternalTab* proxy = + static_cast<AutomationProxyForExternalTab*>(automation()); + proxy->DestroyHostWindow(); + proxy->WaitForTabCleanup(tab_, action_max_timeout_ms()); + EXPECT_FALSE(tab_->is_valid()); + tab_.release(); + ParentTestType::TearDown(); } void TestWithURL(const GURL& url) { - AutomationProxyForExternalTab* proxy = + EXPECT_TRUE(tab_->is_valid()); + if (tab_) { + AutomationProxyForExternalTab* proxy = static_cast<AutomationProxyForExternalTab*>(automation()); - HWND external_tab_container = NULL; - HWND tab_wnd = NULL; - scoped_refptr<TabProxy> tab(proxy->CreateTabWithHostWindow(false, - GURL(), &external_tab_container, &tab_wnd)); - EXPECT_TRUE(tab->is_valid()); - if (tab) { // Enter a message loop to allow the tab to be created proxy->WaitForNavigation(2000); - DoAdditionalPreNavigateSetup(tab.get()); + DoAdditionalPreNavigateSetup(tab_.get()); // We explicitly do not make this a toolstrip in the extension manifest, // so that the test can control when it gets loaded, and so that we test // the intended behavior that tabs should be able to show extension pages // (useful for development etc.) - tab->NavigateInExternalTab(url, GURL()); + tab_->NavigateInExternalTab(url, GURL()); EXPECT_TRUE(proxy->WaitForMessage(action_max_timeout_ms())); - - proxy->DestroyHostWindow(); - proxy->WaitForTabCleanup(tab, action_max_timeout_ms()); - EXPECT_FALSE(tab->is_valid()); } } @@ -97,6 +105,7 @@ class ExtensionUITest : public ParentTestType { protected: // Extension API functions that we want to take over. Defaults to all. std::vector<std::string> functions_enabled_; + scoped_refptr<TabProxy> tab_; private: DISALLOW_COPY_AND_ASSIGN(ExtensionUITest); |