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

Unified Diff: chrome/test/functional/extensions.py

Issue 8587004: Add PyAuto tests for triggering browser/page action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added extension data files Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/functional/extensions.py
diff --git a/chrome/test/functional/extensions.py b/chrome/test/functional/extensions.py
index c949a71d5e3a266a8834852c2dede4cbd659b98d..64e444674f2ff3405eaa0f58021d74b7abc8431d 100644
--- a/chrome/test/functional/extensions.py
+++ b/chrome/test/functional/extensions.py
@@ -182,6 +182,83 @@ 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, False)
+ self.assertTrue(ext_id, msg='Failed to install extension: %s.' % 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, False)
+ self.assertTrue(ext_id, msg='Failed to install extension: %s.' % 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, False)
+ self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path)
+
+ # Page action icon is displayed when a tab is created.
kkania 2011/11/21 18:53:58 I think we need another function for GetVisiblePag
frankf 2011/11/22 22:26:10 I've added this to GetBrowserInfo, same thing shou
+ self.NavigateToURL(self.GetFileURLForDataPath('simple.html'))
+ self.AppendTab(pyauto.GURL('chrome://newtab'))
+ self.ActivateTab(0)
+
+ 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, False)
+ self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path)
+
+ # Page action icon is displayed when a tab is created.
+ self.AppendTab(pyauto.GURL('chrome://newtab'))
+ self.ActivateTab(0)
+
+ 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.

Powered by Google App Engine
This is Rietveld 408576698