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

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

Issue 8772068: Add PyAuto tests for triggering browser/page action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/extensions.py
diff --git a/chrome/test/functional/extensions.py b/chrome/test/functional/extensions.py
index e5a12a833c5c0293de9b6d4dab85c708b72b65ac..f158efd2432473b63699ab908e8c2260c0d59a76 100755
--- a/chrome/test/functional/extensions.py
+++ b/chrome/test/functional/extensions.py
@@ -181,6 +181,87 @@ 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.
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698