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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
« functional/PYAUTO_TESTS ('K') | « functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7 import re
8
9 import pyauto_functional # Must be imported before pyauto
10 import pyauto
11
12
13 class AboutPluginsTest(pyauto.PyUITest):
14 """TestCase for chrome://plugins."""
Nirnimesh 2012/02/03 09:31:40 UI tests for chrome://plugins
15
16 def Debug(self):
17 """chrome://plugins test debug method.
18
19 This method will not run automatically.
20 """
21 self.NavigateToURL('chrome://plugins/')
22 driver = self.NewWebDriver()
23 import pdb
24 pdb.set_trace()
25
26 def _ClearLocalDownloadState(self, path):
27 """Prepare for downloading the given path.
28
29 Clears the given path and the corresponding .crdownload, to prepare it to
30 be downloaded.
31 """
32 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
33 crdownload = path + '.crdownload'
34 if os.path.exists(crdownload): os.remove(crdownload)
Nirnimesh 2012/02/03 09:31:40 same here
35
36 def _IsEnabled(self, plugin_name):
37 """Checks if plugin is enabled."""
38 for plugin in self.GetPluginsInfo().Plugins():
39 if re.search(plugin_name, plugin['name']):
40 return plugin['enabled']
41
42 def _GoPDFSiteAndVerify(self, pdf_name, driver, tab_index=0, windex=0,
43 is_pdf_enabled=True):
44 """Navigate to PDF file site and verify PDF viewer plugin.
45
46 When PDF Viewer plugin is disabled, navigating to the site should not
47 trigger PDF file download and if PDF viewer plugin is enabled, PDF
48 file should be viewable in browser.
49
50 Args:
51 pdf_name: the name of the PDF file.
52 This should exist in the 'dangerous' directory.
53 tab_index: tab index. Default 0.
54 windex: window index. Default 0.
55 is_pdf_enabled: the boolean flag check if PDF viewer plugin is enabled.
56 Default True.
57 """
58 file_url = self.GetHttpURLForDataPath('downloads', 'dangerous',
59 'download-dangerous.html' + '?' + pdf_name)
60 num_downloads = len(self.GetDownloadsInfo().Downloads())
61 self.NavigateToURL(file_url, windex, tab_index)
62 # It might take a while for the download to kick in, hold on until then.
63 if is_pdf_enabled == False:
Nirnimesh 2012/02/03 09:31:40 if not is_pdf_enabled:
64 self.assertTrue(self.WaitUntil(lambda:
Nirnimesh 2012/02/03 09:31:40 Why are you doing functional verification in a tes
65 len(self.GetDownloadsInfo().Downloads()) == num_downloads + 1))
66 else:
67 self.assertTrue(self.WaitUntil(lambda: len(
Nirnimesh 2012/02/03 09:31:40 what does this check for?
68 driver.find_elements_by_name('plugin')) == 1))
69
70 def testAboutPluginDetailInfo(self):
71 """Verify about:plugin page shows plugin details."""
72 self.NavigateToURL('chrome://plugins/')
73 driver = self.NewWebDriver()
74 detail_link = driver.find_element_by_id('details-link')
75 while not detail_link.is_displayed():
76 pass
77 detail_link.click()
78 # Verify the detail info for Remote Viewer plugin show up.
79 self.assertTrue(self.WaitUntil(lambda: len(driver.find_elements_by_xpath(
80 '//*[@jscontent="path"][text()="internal-remoting-viewer"]'))))
81
82 def testAboutPluginEnableAndDisablePDFPlugin(self):
Nirnimesh 2012/02/03 09:31:40 Couldn't you have picked some other plugin so that
83 """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
84 self.NavigateToURL('chrome://plugins/')
85 driver = self.NewWebDriver()
86 # Override the animation for expanding detail info to make sure element
87 # remain at the same location where web driver found it.
88 override_animation_style_js = """
89 style = document.createElement('style');
90 style.innerHTML = "* { -webkit-transition: all 0s ease-in !important}";
91 document.head.appendChild(style);
92 """
93 driver.execute_script(override_animation_style_js)
94
95 # Click Details link to expand details.
96 detail_link = driver.find_element_by_id('details-link')
97 while not detail_link.is_displayed():
98 pass
99 detail_link.click()
100 pdf_disable_path = '//*[@class="plugin-name"][text()="Chrome PDF Viewer"' \
101 ']//ancestor::*[@class="plugin-text"]//a[text()="Disable"]'
102 # Confirm Chrome PDF Viewer plugin is found.
103 self.assertTrue(self.WaitUntil(lambda: len(driver.find_elements_by_xpath(
104 pdf_disable_path)) == 1),
105 msg='Failed to find Chrome PDF Viewer plugin')
106
107 # Disable PDF viewer plugin in about:plugins.
108 pdf_disable_link = driver.find_element_by_xpath(pdf_disable_path)
109 pdf_disable_link.click()
110 self.assertTrue(self.WaitUntil(lambda: not
111 self._IsEnabled('Chrome PDF Viewer')))
112
113 # Navigate to a PDF file and verify the pdf file is downloaded.
114 self.OpenNewBrowserWindow(True)
115 self._GoPDFSiteAndVerify('fw4.pdf', driver, tab_index=0, windex=1,
116 is_pdf_enabled=False)
117 id = self.GetDownloadsInfo().Downloads()[0]['id']
118 self.PerformActionOnDownload(id,
119 'save_dangerous_download',
120 window_index=1)
121 self.WaitForAllDownloadsToComplete(windex=1)
122
123 pdf_download = self.GetDownloadsInfo(1).Downloads()
124 # Verify that download info exists in the correct profile.
125 self.assertEqual(len(pdf_download), 1)
126 download_pkg = os.path.join(self.GetDownloadDirectory().value(),
127 'fw4.pdf')
128 self._ClearLocalDownloadState(download_pkg)
129
130 # Navigate to plugins settings again and re-enable PDF viewer plugin.
131 self.NavigateToURL('chrome://plugins/')
132 pdf_enable_path = '//*[@class="plugin-name"][text()="Chrome PDF Viewer"]' \
133 '//ancestor::*[@class="plugin-text"]//a[text()="Enable"]'
134 self.assertTrue(self.WaitUntil(lambda: len(driver.find_elements_by_xpath(
135 pdf_enable_path)) == 1))
136 pdf_enable_link = driver.find_element_by_xpath(pdf_enable_path)
137 pdf_enable_link.click()
138 self.CloseBrowserWindow(0)
139 self.OpenNewBrowserWindow(True)
140 driver = self.NewWebDriver()
141 self._GoPDFSiteAndVerify('fw4.pdf', driver, tab_index=0, windex=0,
142 is_pdf_enabled=True)
143
144
145 if __name__ == '__main__':
146 pyauto_functional.Main()
OLDNEW
« 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