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

Side by Side Diff: chrome/test/functional/plugins_check.py

Issue 6802014: Update plugins_check to run on ChromeOS (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 8 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
« no previous file with comments | « chrome/test/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
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import logging 6 import logging
7 import os 7 import os
8 import pprint
8 import sys 9 import sys
9 10
10 import pyauto_functional # Must be imported before pyauto 11 import pyauto_functional # Must be imported before pyauto
11 import pyauto 12 import pyauto
12 13
13 14
14 class PluginsCheck(pyauto.PyUITest): 15 class PluginsCheck(pyauto.PyUITest):
15 """TestCase for Plugins.""" 16 """TestCase for Plugins."""
16 17
17 def _ReadPluginsList(self, plugins_list_file): 18 def _ReadPluginsList(self, plugins_list_file):
18 """Read test plugins list from a file based on the test platform 19 """Read test plugins list from a file based on the test platform
19 20
20 File contains list of plugins like, 21 File contains list of plugins like,
21 [ 22 [
22 {u'name':'Shockwave Flash', u'enabled':True, u'version':u'10.2.154.9'} 23 {u'name':'Shockwave Flash', u'enabled':True, u'version':u'10.2.154.9'}
23 {u'name':'Chrome PDF Viewer', u'enabled':True, u'version':u''} 24 {u'name':'Chrome PDF Viewer', u'enabled':True, u'version':u''}
24 ... 25 ...
25 ] 26 ]
26 """ 27 """
27 file_path = os.path.join(self.DataDir(), plugins_list_file) 28 file_path = os.path.join(self.DataDir(), plugins_list_file)
28 return self.EvalDataFrom(file_path) 29 return self.EvalDataFrom(file_path)
29 30
30 def testPluginsStates(self): 31 def testPluginsStates(self):
31 """Verify plugins' versions and states.""" 32 """Verify plugins' versions and states."""
32 if self.IsWin(): 33 if self.IsWin():
33 plugins_list = self._ReadPluginsList('win_plugins_list.txt') 34 plugins_list = self._ReadPluginsList('win_plugins_list.txt')
34 elif self.IsMac(): 35 elif self.IsMac():
35 plugins_list = self._ReadPluginsList('mac_plugins_list.txt') 36 plugins_list = self._ReadPluginsList('mac_plugins_list.txt')
37 elif self.IsChromeOS():
38 plugins_list = self._ReadPluginsList('chromeos_plugins_list.txt')
36 elif self.IsLinux(): 39 elif self.IsLinux():
37 # TODO(rohitbm) 40 # TODO(rohitbm)
38 # Add plugins_check support for Linux 41 # Add plugins_check support for Linux
39 logging.debug('Not performing plugins check on linux') 42 logging.debug('Not performing plugins check on linux')
40 return 43 return
41 44
42 browser_plugins_list = self.GetPluginsInfo().Plugins() 45 browser_plugins_list = self.GetPluginsInfo().Plugins()
43 for plugin in plugins_list: 46 for plugin in plugins_list:
44 test_plugin = [x['name'] for x in browser_plugins_list \ 47 # We will compare the keys available in the plugin list
45 if x['version'] == plugin['version'] and \ 48 found_plugin = False
46 str(x['enabled']) == plugin['enabled'] and \ 49 for browser_plugin in browser_plugins_list:
47 x['name'] == plugin['name']] 50 whitelist_keys = plugin.keys()
48 plugin_info = '[ NAME : %s, VERSION: %s, ENABLED: %s]' % \ 51 if 'unique_key' in plugin:
49 (plugin['name'], plugin['version'], plugin['enabled']) 52 unique_key = plugin['unique_key']
50 logging.debug(plugin_info) 53 whitelist_keys.remove('unique_key')
51 self.assertTrue(test_plugin, '%s - Failed to match with plugins' 54 else:
52 ' available in the browser plugins list' % plugin_info) 55 unique_key = 'name'
56 if browser_plugin[unique_key] == plugin[unique_key]:
57 found_plugin = True
58 for key in whitelist_keys:
59 if browser_plugin[key] != plugin[key]:
60 self.assertEqual(browser_plugin[key], plugin[key], 'The following'
61 ' plugin attributes do not match the whitelist:'
62 '\n\tplugin:\n%s\n\tlist:\n%s'
63 % (pprint.pformat(browser_plugin), pprint.pformat(plugin)))
64 break;
65 self.assertTrue(found_plugin, 'The following plugin in the whitelist '
66 'does not match any on the system:\n%s' % pprint.pformat(plugin))
67 if self.IsChromeOS():
68 self.assertEqual(len(plugins_list), len(browser_plugins_list),
69 'The number of plugins on the system do not match the number in the '
70 'whitelist.')
53 71
54 72
55 if __name__ == '__main__': 73 if __name__ == '__main__':
56 pyauto_functional.Main() 74 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698