summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorfrankf@google.com <frankf@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 20:58:24 +0000
committerfrankf@google.com <frankf@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 20:58:24 +0000
commit2996d14979871a30c392955954ce5b7fdce37130 (patch)
tree61610f1e34955eb123067c369742f77883263882 /chrome
parent61e3009b9f5b3134fa3697befba4bc69c6be1e35 (diff)
downloadchromium_src-2996d14979871a30c392955954ce5b7fdce37130.zip
chromium_src-2996d14979871a30c392955954ce5b7fdce37130.tar.gz
chromium_src-2996d14979871a30c392955954ce5b7fdce37130.tar.bz2
Revert "Add PyAuto tests for triggering browser/page action."
Dues to link issues on chromeos clang. This reverts commit 2c6c8fc139bae1b64a184c13c979f408721316a3. TBR=dennisjeffrey@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/8774053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112779 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc132
-rw-r--r--chrome/browser/automation/testing_automation_provider.h10
-rw-r--r--chrome/browser/extensions/browser_action_test_util.h2
-rw-r--r--chrome/browser/extensions/browser_action_test_util_views.cc6
-rw-r--r--chrome/chrome_browser.gypi4
-rwxr-xr-xchrome/test/functional/extensions.py81
-rwxr-xr-xchrome/test/pyautolib/pyauto.py37
7 files changed, 3 insertions, 269 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index c2aa4ec..2ed7650 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -50,11 +50,10 @@
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/save_package_file_picker.h"
#include "chrome/browser/extensions/crx_installer.h"
-#include "chrome/browser/extensions/browser_action_test_util.h"
+#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_updater.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/history/top_sites.h"
@@ -108,7 +107,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_view_type.h"
#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/url_pattern.h"
#include "chrome/common/extensions/url_pattern_set.h"
#include "chrome/common/pref_names.h"
@@ -2328,10 +2326,6 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
&TestingAutomationProvider::GetExtensionsInfo;
handler_map["RefreshPolicies"] =
&TestingAutomationProvider::RefreshPolicies;
- handler_map["TriggerPageActionById"] =
- &TestingAutomationProvider::TriggerPageActionById;
- handler_map["TriggerBrowserActionById"] =
- &TestingAutomationProvider::TriggerBrowserActionById;
#if defined(OS_CHROMEOS)
handler_map["GetLoginInfo"] = &TestingAutomationProvider::GetLoginInfo;
handler_map["ShowCreateAccountUI"] =
@@ -2476,6 +2470,7 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
browser_handler_map["UninstallExtensionById"] =
&TestingAutomationProvider::UninstallExtensionById;
+
browser_handler_map["SetExtensionStateById"] =
&TestingAutomationProvider::SetExtensionStateById;
@@ -2801,17 +2796,6 @@ void TestingAutomationProvider::GetBrowserInfo(
browser_item->SetInteger("height", rect.height());
browser_item->SetBoolean("fullscreen",
browser->window()->IsFullscreen());
- ListValue* visible_page_actions = new ListValue;
- LocationBarTesting* loc_bar =
- browser->window()->GetLocationBar()->GetLocationBarForTesting();
- size_t page_action_visible_count =
- static_cast<size_t>(loc_bar->PageActionVisibleCount());
- for (size_t i = 0; i < page_action_visible_count; ++i) {
- StringValue* extension_id = new StringValue(
- loc_bar->GetVisiblePageAction(i)->extension_id());
- visible_page_actions->Append(extension_id);
- }
- browser_item->Set("visible_page_actions", visible_page_actions);
browser_item->SetInteger("selected_tab", browser->active_index());
browser_item->SetBoolean("incognito",
browser->profile()->IsOffTheRecord());
@@ -4512,118 +4496,6 @@ void TestingAutomationProvider::SetExtensionStateById(
reply.SendSuccess(NULL);
}
-// See TriggerPageActionById() in chrome/test/pyautolib/pyauto.py
-// for sample json input.
-void TestingAutomationProvider::TriggerPageActionById(
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
-
- std::string error;
- Browser* browser;
- if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
- reply.SendError(error);
- return;
- }
- std::string id;
- if (!args->GetString("id", &id)) {
- reply.SendError("Missing or invalid key: id");
- return;
- }
-
- ExtensionService* service = browser->profile()->GetExtensionService();
- if (!service) {
- reply.SendError("No extensions service.");
- return;
- }
- if (!service->GetInstalledExtension(id)) {
- // The extension ID does not correspond to any extension, whether crashed
- // or not.
- reply.SendError(base::StringPrintf("Extension %s is not installed.",
- id.c_str()));
- return;
- }
- const Extension* extension = service->GetExtensionById(id, false);
- if (!extension) {
- reply.SendError("Extension is disabled or has crashed.");
- return;
- }
-
- if (ExtensionAction* page_action = extension->page_action()) {
- LocationBarTesting* loc_bar =
- browser->window()->GetLocationBar()->GetLocationBarForTesting();
- size_t page_action_visible_count =
- static_cast<size_t>(loc_bar->PageActionVisibleCount());
- for (size_t i = 0; i < page_action_visible_count; ++i) {
- if (loc_bar->GetVisiblePageAction(i) == page_action) {
- loc_bar->TestPageActionPressed(i);
- reply.SendSuccess(NULL);
- return;
- }
- }
- reply.SendError("Extension doesn't have any visible page action icon.");
- } else {
- reply.SendError("Extension doesn't have any page action.");
- }
-}
-
-// See TriggerBrowserActionById() in chrome/test/pyautolib/pyauto.py
-// for sample json input.
-void TestingAutomationProvider::TriggerBrowserActionById(
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
-
- std::string error;
- Browser* browser;
- if (!GetBrowserFromJSONArgs(args, &browser, &error)) {
- reply.SendError(error);
- return;
- }
- std::string id;
- if (!args->GetString("id", &id)) {
- reply.SendError("Missing or invalid key: id");
- return;
- }
-
- ExtensionService* service = browser->profile()->GetExtensionService();
- if (!service) {
- reply.SendError("No extensions service.");
- return;
- }
- if (!service->GetInstalledExtension(id)) {
- // The extension ID does not correspond to any extension, whether crashed
- // or not.
- reply.SendError(base::StringPrintf("Extension %s is not installed.",
- id.c_str()));
- return;
- }
- const Extension* extension = service->GetExtensionById(id, false);
- if (!extension) {
- reply.SendError("Extension is disabled or has crashed.");
- return;
- }
-
- if (extension->browser_action()) {
- BrowserActionTestUtil browser_actions(browser);
- int num_browser_actions = browser_actions.NumberOfBrowserActions();
- // TODO: Implement the platform-specific GetExtensionId() in
- // BrowserActionTestUtil.
- if (num_browser_actions != 1) {
- reply.SendError(StringPrintf(
- "Found %d browser actions. Only one browser action must be active.",
- num_browser_actions));
- return;
- }
- browser_actions.Press(0);
- reply.SendSuccess(NULL);
- return;
- } else {
- reply.SendError("Extension doesn't have any browser action.");
- return;
- }
-}
-
// Sample json input:
// { "command": "GetAutofillProfile" }
// Refer to GetAutofillProfile() in chrome/test/pyautolib/pyauto.py for sample
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index c4157f9..18be8a8 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -658,16 +658,6 @@ class TestingAutomationProvider : public AutomationProvider,
base::DictionaryValue* args,
IPC::Message* reply_message);
- // Trigger page action asynchronously in the active tab.
- // Uses the JSON interface for input/output.
- void TriggerPageActionById(base::DictionaryValue* args,
- IPC::Message* reply_message);
-
- // Trigger browser action asynchronously in the active tab.
- // Uses the JSON interface for input/output.
- void TriggerBrowserActionById(base::DictionaryValue* args,
- IPC::Message* reply_message);
-
// Responds to the Find request and returns the match count.
void FindInPage(Browser* browser,
base::DictionaryValue* args,
diff --git a/chrome/browser/extensions/browser_action_test_util.h b/chrome/browser/extensions/browser_action_test_util.h
index 667f080..cadb12c 100644
--- a/chrome/browser/extensions/browser_action_test_util.h
+++ b/chrome/browser/extensions/browser_action_test_util.h
@@ -27,7 +27,7 @@ class BrowserActionTestUtil {
// Returns the number of browser action currently visible.
int VisibleBrowserActions();
-#if defined(TOOLKIT_VIEWS) && defined(UNIT_TEST)
+#if defined(TOOLKIT_VIEWS)
// Waits for a browser action at |index| to get updated.
void WaitForBrowserActionUpdated(int index);
#endif
diff --git a/chrome/browser/extensions/browser_action_test_util_views.cc b/chrome/browser/extensions/browser_action_test_util_views.cc
index a72be0c..2db9684 100644
--- a/chrome/browser/extensions/browser_action_test_util_views.cc
+++ b/chrome/browser/extensions/browser_action_test_util_views.cc
@@ -10,12 +10,8 @@
#include "chrome/browser/ui/views/browser_actions_container.h"
#include "chrome/browser/ui/views/extensions/extension_popup.h"
#include "chrome/browser/ui/views/toolbar_view.h"
-
-#ifdef UNIT_TEST
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#endif // UNIT_TEST
-
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
@@ -38,13 +34,11 @@ int BrowserActionTestUtil::VisibleBrowserActions() {
return GetContainer(browser_)->VisibleBrowserActions();
}
-#ifdef UNIT_TEST
void BrowserActionTestUtil::WaitForBrowserActionUpdated(int index) {
ui_test_utils::WaitForBrowserActionUpdated(
GetContainer(browser_)->GetBrowserActionViewAt(index)->
button()->extension()->browser_action());
}
-#endif // UNIT_TEST
bool BrowserActionTestUtil::HasIcon(int index) {
return GetContainer(browser_)->GetBrowserActionViewAt(index)->button()->
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 4d1d451..53c7e90 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -943,10 +943,6 @@
'browser/extensions/app_notify_channel_ui.h',
'browser/extensions/apps_promo.cc',
'browser/extensions/apps_promo.h',
- 'browser/extensions/browser_action_test_util.h',
- 'browser/extensions/browser_action_test_util_gtk.cc',
- 'browser/extensions/browser_action_test_util_mac.mm',
- 'browser/extensions/browser_action_test_util_views.cc',
'browser/extensions/component_loader.cc',
'browser/extensions/component_loader.h',
'browser/extensions/convert_user_script.cc',
diff --git a/chrome/test/functional/extensions.py b/chrome/test/functional/extensions.py
index f158efd..e5a12a8 100755
--- a/chrome/test/functional/extensions.py
+++ b/chrome/test/functional/extensions.py
@@ -181,87 +181,6 @@ class ExtensionsTest(pyauto.PyUITest):
extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id)
self.assertFalse(extension['allowed_in_incognito'])
- def testTriggerBrowserAction(self):
- """Test triggering browser action."""
- dir_path = os.path.abspath(
- os.path.join(self.DataDir(), 'extensions', 'trigger_actions',
- 'browser_action'))
- ext_id = self.InstallExtension(dir_path)
-
- self.NavigateToURL(self.GetFileURLForDataPath('simple.html'))
-
- self.TriggerBrowserActionById(ext_id)
-
- # Verify that the browser action turned the background red.
- self.assertTrue(self.WaitUntil(
- lambda: self.GetDOMValue('document.body.style.backgroundColor'),
- expect_retval='red'),
- msg='Browser action was not triggered.')
-
- def testTriggerBrowserActionWithPopup(self):
- """Test triggering browser action that shows a popup."""
- dir_path = os.path.abspath(
- os.path.join(self.DataDir(), 'extensions', 'trigger_actions',
- 'browser_action_popup'))
- ext_id = self.InstallExtension(dir_path)
-
- self.TriggerBrowserActionById(ext_id)
-
- # Verify that the extension popup is displayed.
- popup = self.WaitUntilExtensionViewLoaded(
- view_type='EXTENSION_POPUP')
- self.assertTrue(popup,
- msg='Browser action failed to display the popup (views=%s).' %
- self.GetBrowserInfo()['extension_views'])
-
- def testTriggerPageAction(self):
- """Test triggering page action."""
- dir_path = os.path.abspath(
- os.path.join(self.DataDir(), 'extensions', 'trigger_actions',
- 'page_action'))
- ext_id = self.InstallExtension(dir_path)
-
- # Page action icon is displayed when a tab is created.
- self.NavigateToURL(self.GetFileURLForDataPath('simple.html'))
- self.AppendTab(pyauto.GURL('chrome://newtab'))
- self.ActivateTab(0)
- self.assertTrue(self.WaitUntil(
- lambda: ext_id in
- self.GetBrowserInfo()['windows'][0]['visible_page_actions']),
- msg='Page action icon is not visible.')
-
- self.TriggerPageActionById(ext_id)
-
- # Verify that page action turned the background red.
- self.assertTrue(self.WaitUntil(
- lambda: self.GetDOMValue('document.body.style.backgroundColor'),
- expect_retval='red'),
- msg='Page action was not triggered.')
-
- def testTriggerPageActionWithPopup(self):
- """Test triggering page action that shows a popup."""
- dir_path = os.path.abspath(
- os.path.join(self.DataDir(), 'extensions', 'trigger_actions',
- 'page_action_popup'))
- ext_id = self.InstallExtension(dir_path)
-
- # Page action icon is displayed when a tab is created.
- self.AppendTab(pyauto.GURL('chrome://newtab'))
- self.ActivateTab(0)
- self.assertTrue(self.WaitUntil(
- lambda: ext_id in
- self.GetBrowserInfo()['windows'][0]['visible_page_actions']),
- msg='Page action icon is not visible.')
-
- self.TriggerPageActionById(ext_id)
-
- # Verify that the extension popup is displayed.
- popup = self.WaitUntilExtensionViewLoaded(
- view_type='EXTENSION_POPUP')
- self.assertTrue(popup,
- msg='Page action failed to display the popup (views=%s).' %
- self.GetBrowserInfo()['extension_views'])
-
def testAdblockExtensionCrash(self):
"""Test AdBlock extension successfully installed and enabled, and do not
cause browser crash.
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 3638e10..033d4b9 100755
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -1488,9 +1488,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
u'incognito': False,
u'profile_path': u'Default',
u'fullscreen': False,
- u'visible_page_actions':
- [u'dgcoklnmbeljaehamekjpeidmbicddfj',
- u'osfcklnfasdofpcldmalwpicslasdfgd']
u'selected_tab': 0,
u'tabs': [ {
u'index': 0,
@@ -1840,38 +1837,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
}
self._GetResultFromJSONRequest(cmd_dict)
- def TriggerPageActionById(self, id, windex=0):
- """Trigger page action asynchronously in the active tab.
-
- The page action icon must be displayed before invoking this function.
-
- Args:
- id: The string id of the extension.
- windex: Integer index of the browser window to use; defaults to 0
- (first window).
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'TriggerPageActionById',
- 'id': id,
- 'windex': windex,
- }
- self._GetResultFromJSONRequest(cmd_dict, windex=windex)
-
- def TriggerBrowserActionById(self, id, windex=0):
- """Trigger browser action asynchronously in the active tab.
-
- Args:
- id: The string id of the extension.
- windex: Integer index of the browser window to use; defaults to 0
- (first window).
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'TriggerBrowserActionById',
- 'id': id,
- 'windex': windex,
- }
- self._GetResultFromJSONRequest(cmd_dict, windex=windex)
-
def UpdateExtensionsNow(self):
"""Auto-updates installed extensions.
@@ -1902,8 +1867,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
extension_id: (optional) ID of the extension.
url: (optional) URL of the extension view.
view_type: (optional) Type of the extension view.
- ['EXTENSION_BACKGROUND_PAGE'|'EXTENSION_POPUP'|'EXTENSION_INFOBAR'|
- 'EXTENSION_DIALOG']
Returns:
The 'view' property of the extension view.