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

Unified Diff: functional/aboutplugins_ui.py

Issue 9114056: Automated chrome driver tests for about:plugins functionality tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: '' Created 8 years, 11 months 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
« functional/PYAUTO_TESTS ('K') | « functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: functional/aboutplugins_ui.py
===================================================================
--- functional/aboutplugins_ui.py (revision 0)
+++ functional/aboutplugins_ui.py (revision 0)
@@ -0,0 +1,145 @@
+import os
kkania 2012/01/20 17:16:28 rename this file to about_plugins_ui.py
vivianz 2012/01/27 23:24:36 Done.
+import re
+
+import pyauto_functional # Must be imported before pyauto
+import pyauto
+import test_utils
kkania 2012/01/20 17:16:28 you don't use this; remove?
vivianz 2012/01/27 23:24:36 Done.
+
+
+class AboutPluginsTest(pyauto.PyUITest):
+ """TestCase for chrome://plugins."""
+
+ def Debug(self):
+ """Test method for experimentation.
+
+ This method will not run automatically.
+ """
+ while True:
+ raw_input('Interact with the browser and hit <enter> to list plugins...')
kkania 2012/01/20 17:16:28 this method is more useful for the plugins test; h
vivianz 2012/01/27 23:24:36 Done.
+ self.pprint(self.GetPluginsInfo().Plugins())
+
+ def _ClearLocalDownloadState(self, path):
+ """Prepare for downloading the given path.
+
+ Clears the given path and the corresponding .crdownload, to prepare it to
+ be downloaded.
+ """
+ if os.path.exists(path): os.remove(path)
+ crdownload = path + '.crdownload'
+ if os.path.exists(crdownload): os.remove(crdownload)
+
+ def _IsEnabled(self, plugin_name):
+ """Checks if plugin is enabled."""
+ for plugin in self.GetPluginsInfo().Plugins():
+ if re.search(plugin_name, plugin['name']):
+ return plugin['enabled']
+
+ def _GoPDFSiteAndVerify(self, pdf_name, tab_index=0, windex=0,
+ is_pdf_enabled=True):
+ """Navigate to PDF file site and verify PDF viewer plugin.
+
+ When PDF Viewer plugin is enabled, navigate the site should not trigger
kkania 2012/01/20 17:16:28 navigating to the site
vivianz 2012/01/27 23:24:36 Done.
+ PDF file downloade and if PDF viewer plugin is disabled, PDF file should
kkania 2012/01/20 17:16:28 downloade?
vivianz 2012/01/27 23:24:36 fixed
+ be viewable in browser.
kkania 2012/01/20 17:16:28 if plugin is disable, the pdf should be viewable i
vivianz 2012/01/27 23:24:36 my bad :) fixed
+
+ Args:
+ pdf_name: the name of the PDF file.
+ This should exist in the 'dangerous' directory.
+ tab_index: tab index. Default 0.
+ windex: window index. Default 0.
+ is_pdf_enabled: the boolean flag check if PDF viewer plugin is enabled.
+ Default True.
+ """
+ file_url = self.GetHttpURLForDataPath('downloads', 'dangerous',
+ 'download-dangerous.html' + '?' + pdf_name)
+ num_downloads = len(self.GetDownloadsInfo().Downloads())
+ self.NavigateToURL(file_url, windex, tab_index)
+ # It might take a while for the download to kick in, hold on until then.
+ if is_pdf_enabled == False:
+ self.assertTrue(self.WaitUntil(lambda:
+ len(self.GetDownloadsInfo().Downloads()) == num_downloads + 1))
+ else:
+ driver = self.NewWebDriver()
kkania 2012/01/20 17:16:28 don't create a new webdriver here; pass it in as a
vivianz 2012/01/27 23:24:36 Done.
+ self.assertTrue(self.WaitUntil(lambda: len(
+ driver.find_elements_by_name('plugin')) == 1))
+
+ def testAboutPluginDetailInfo(self):
+ """Verify about:plugin page shows plugin details."""
+ self.NavigateToURL('chrome://plugins/')
+ driver = self.NewWebDriver()
+ detail_link = driver.find_element_by_id('details-link')
+ while not detail_link.is_displayed():
+ pass
+ detail_link.click()
+ # Verify the detail info for Remote Viewer plugin show up.
+ self.assertTrue(self.WaitUntil(lambda: len(driver.find_elements_by_xpath(
+ '//*[@jscontent="name"][text()="Remoting Viewer"]' +
kkania 2012/01/20 17:16:28 don't use jscontent, use class instead
vivianz 2012/01/27 23:24:36 have to use jscontent, that is the only unique lab
+ '//ancestor::*[@class="plugin-text"]//a[text()="Disable"]')) == 1))
kkania 2012/01/20 17:16:28 this isn't sufficient to determine if the details
vivianz 2012/01/27 23:24:36 change to locate the detail plugin path for Remote
+
+ def testAboutPluginEnableAndDisablePDFPlugin(self):
+ """Verify enable and disable plugins from about:plugins page."""
+ self.NavigateToURL('chrome://plugins/')
+ driver = self.NewWebDriver()
+ # Override the animation for expanding detail info to make sure element
+ # remain at the same location where web driver found it.
+ override_animation_style_js = """
+ style = document.createElement('style');
+ style.innerHTML = "* { -webkit-transition: all 0s ease-in !important}";
+ document.head.appendChild(style);
+ """
+ driver.execute_script(override_animation_style_js)
+
+ # Click Details link to expand details.
+ detail_link = driver.find_element_by_id('details-link')
+ while not detail_link.is_displayed():
+ pass
+ detail_link.click()
+ pdf_disable_path = '//*[@class="plugin-name"][text()="Chrome PDF Viewer"' \
+ ']//ancestor::*[@class="plugin-text"]//a[text()="Disable"]'
+ # Confirm Chrome PDF Viewer plugin is found.
+ self.assertTrue(self.WaitUntil(lambda: len(driver.find_elements_by_xpath(
+ pdf_disable_path)) == 1),
+ msg='Failed to find Chrome PDF Viewer plugin')
+
+ # Disable PDF viewer plugin in about:plugins.
+ pdf_disable_link = driver.find_element_by_xpath(pdf_disable_path)
+
+ # Need to sleep off 100ms for the detail-info expansion webkit transition.
kkania 2012/01/20 17:16:28 ?
vivianz 2012/01/27 23:24:36 legacy comment deleted.
+ pdf_disable_link.click()
+ self.assertFalse(self.WaitUntil(lambda:
+ self._IsEnabled('Chrome PDF Viewer')))
kkania 2012/01/20 17:16:28 i don't think this is correct
vivianz 2012/01/27 23:24:36 change to assertTrue wait until chrome PDF viewer
+
+ # Navigate to a PDF file and verify the pdf file is downloaded.
+ self.OpenNewBrowserWindow(True)
+ self._GoPDFSiteAndVerify('fw4.pdf', tab_index=0, windex=1,
+ is_pdf_enabled=False)
+ id = self.GetDownloadsInfo().Downloads()[0]['id']
+ self.PerformActionOnDownload(id,
+ 'save_dangerous_download',
+ window_index=1)
+ self.WaitForAllDownloadsToComplete(windex=1)
+
+ pdf_download = self.GetDownloadsInfo(1).Downloads()
+ # Verify that download info exists in the correct profile.
+ self.assertEqual(len(pdf_download), 1)
+ download_pkg = os.path.join(self.GetDownloadDirectory().value(),
+ 'fw4.pdf')
+ self._ClearLocalDownloadState(download_pkg)
+
+ # Navigate to plugins settings again and re-enable PDF viewer plugin.
+ self.NavigateToURL('chrome://plugins/')
+ driver = self.NewWebDriver()
kkania 2012/01/20 17:16:28 don't make a new driver
vivianz 2012/01/27 23:24:36 Done. removed.
+ pdf_enable_path = '//*[@class="plugin-name"][text()="Chrome PDF Viewer"]' \
+ '//ancestor::*[@class="plugin-text"]//a[text()="Enable"]'
+ self.assertTrue(self.WaitUntil(lambda: len(driver.find_elements_by_xpath(
+ pdf_enable_path)) == 1))
+ pdf_enable_link = driver.find_element_by_xpath(pdf_enable_path)
+ pdf_enable_link.click()
+ self.CloseBrowserWindow(0)
+ self.OpenNewBrowserWindow(True)
+ self._GoPDFSiteAndVerify('fw4.pdf', tab_index=0, windex=0,
+ is_pdf_enabled=True)
+
+
+if __name__ == '__main__':
+ pyauto_functional.Main()
« functional/PYAUTO_TESTS ('K') | « functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698