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

Unified Diff: functional/about_plugins_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/about_plugins_ui.py
===================================================================
--- functional/about_plugins_ui.py (revision 0)
+++ functional/about_plugins_ui.py (revision 0)
@@ -0,0 +1,146 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import re
+
+import pyauto_functional # Must be imported before pyauto
+import pyauto
+
+
+class AboutPluginsTest(pyauto.PyUITest):
+ """TestCase for chrome://plugins."""
Nirnimesh 2012/02/03 09:31:40 UI tests for chrome://plugins
+
+ def Debug(self):
+ """chrome://plugins test debug method.
+
+ This method will not run automatically.
+ """
+ self.NavigateToURL('chrome://plugins/')
+ driver = self.NewWebDriver()
+ import pdb
+ pdb.set_trace()
+
+ 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)
Nirnimesh 2012/02/03 09:31:40 move os.remove to next line. OR os.path.exists(pa
+ crdownload = path + '.crdownload'
+ if os.path.exists(crdownload): os.remove(crdownload)
Nirnimesh 2012/02/03 09:31:40 same here
+
+ 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, driver, tab_index=0, windex=0,
+ is_pdf_enabled=True):
+ """Navigate to PDF file site and verify PDF viewer plugin.
+
+ When PDF Viewer plugin is disabled, navigating to the site should not
+ trigger PDF file download and if PDF viewer plugin is enabled, PDF
+ file should be viewable in browser.
+
+ 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:
Nirnimesh 2012/02/03 09:31:40 if not is_pdf_enabled:
+ self.assertTrue(self.WaitUntil(lambda:
Nirnimesh 2012/02/03 09:31:40 Why are you doing functional verification in a tes
+ len(self.GetDownloadsInfo().Downloads()) == num_downloads + 1))
+ else:
+ self.assertTrue(self.WaitUntil(lambda: len(
Nirnimesh 2012/02/03 09:31:40 what does this check for?
+ 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="path"][text()="internal-remoting-viewer"]'))))
+
+ def testAboutPluginEnableAndDisablePDFPlugin(self):
Nirnimesh 2012/02/03 09:31:40 Couldn't you have picked some other plugin so that
+ """Verify enable and disable plugins from about:plugins page."""
Nirnimesh 2012/02/03 09:31:40 If you really want to verify functionality, move t
+ 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)
+ pdf_disable_link.click()
+ self.assertTrue(self.WaitUntil(lambda: not
+ self._IsEnabled('Chrome PDF Viewer')))
+
+ # Navigate to a PDF file and verify the pdf file is downloaded.
+ self.OpenNewBrowserWindow(True)
+ self._GoPDFSiteAndVerify('fw4.pdf', driver, 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/')
+ 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)
+ driver = self.NewWebDriver()
+ self._GoPDFSiteAndVerify('fw4.pdf', driver, 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