OLD | NEW |
1 #!/usr/bin/python2.6.2 | 1 #!/usr/bin/python2.6.2 |
2 # Copyright 2009, Google Inc. | 2 # Copyright 2009, Google Inc. |
3 # All rights reserved. | 3 # All rights reserved. |
4 # | 4 # |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 import util | 55 import util |
56 | 56 |
57 # Resolution to configure video card to before running tests. | 57 # Resolution to configure video card to before running tests. |
58 SCREEN_WIDTH = 1280 | 58 SCREEN_WIDTH = 1280 |
59 SCREEN_HEIGHT = 1024 | 59 SCREEN_HEIGHT = 1024 |
60 SCREEN_BPP = 32 | 60 SCREEN_BPP = 32 |
61 | 61 |
62 join = os.path.join | 62 join = os.path.join |
63 | 63 |
64 if util.IsWindows(): | 64 if util.IsWindows(): |
65 IMAGE_DIFF_PATH = join(const.BASE_PATH, 'third_party', 'pdiff', 'files', | 65 IMAGE_DIFF_PATH = join(const.O3D_PATH, 'third_party', 'pdiff', 'files', |
66 'bin', 'win', 'perceptualdiff.exe') | 66 'bin', 'win', 'perceptualdiff.exe') |
67 elif util.IsMac(): | 67 elif util.IsMac(): |
68 IMAGE_DIFF_PATH = join(const.BASE_PATH, 'third_party', 'pdiff', 'files', | 68 IMAGE_DIFF_PATH = join(const.O3D_PATH, 'third_party', 'pdiff', 'files', |
69 'bin', 'mac', 'perceptualdiff') | 69 'bin', 'mac', 'perceptualdiff') |
70 else: | 70 else: |
71 IMAGE_DIFF_PATH = join(const.BASE_PATH, 'third_party', 'pdiff', 'files', | 71 IMAGE_DIFF_PATH = join(const.O3D_PATH, 'third_party', 'pdiff', 'files', |
72 'bin', 'linux', 'perceptualdiff') | 72 'bin', 'linux', 'perceptualdiff') |
73 | 73 |
74 SELENIUM_TEST_RUNNER_PATH = join(const.TEST_PATH, 'selenium', 'main.py') | 74 SELENIUM_TEST_RUNNER_PATH = join(const.O3D_PATH, 'o3d', 'tests', 'selenium', |
| 75 'main.py') |
75 | 76 |
76 SELENIUM_JAR_PATH = join(const.BASE_PATH, 'third_party', 'selenium_rc', 'files', | 77 SELENIUM_JAR_PATH = join(const.O3D_PATH, 'third_party', 'selenium_rc', 'files', |
77 'selenium-server', 'selenium-server.jar') | 78 'selenium-server', 'selenium-server.jar') |
78 | 79 |
79 O3D_REFERENCE_IMAGES_PATH = join(const.O3D_PATH, 'o3d_assets', 'tests', | 80 O3D_REFERENCE_IMAGES_PATH = join(const.O3D_PATH, 'o3d', 'o3d_assets', 'tests', |
80 'screenshots') | 81 'screenshots') |
81 | 82 |
82 SCREENSHOTS_PATH = join(const.RESULTS_PATH,'screenshots') | 83 SCREENSHOTS_PATH = join(const.RESULTS_PATH,'screenshots') |
83 | 84 |
84 # Set total test timeout to 90 minutes. | 85 # Set total test timeout to 90 minutes. |
85 TEST_TIMEOUT_SECS = 60 * 90.0 | 86 TEST_TIMEOUT_SECS = 60 * 90.0 |
86 | 87 |
87 SELENIUM_BROWSER_PREFIXES = { | 88 SELENIUM_BROWSER_PREFIXES = { |
88 'ie': '*iexplore', | 89 'ie': '*iexplore', |
89 'ff': '*firefox', | 90 'ff': '*firefox', |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 | 187 |
187 | 188 |
188 def RunTest(browser): | 189 def RunTest(browser): |
189 """Runs tests on |browser|. | 190 """Runs tests on |browser|. |
190 Args: | 191 Args: |
191 browser: the browser to test. | 192 browser: the browser to test. |
192 Returns: | 193 Returns: |
193 True on success. | 194 True on success. |
194 """ | 195 """ |
| 196 # Run selenium test. |
| 197 os.chdir(const.AUTO_PATH) |
| 198 |
195 if util.IsWindows(): | 199 if util.IsWindows(): |
196 if not run_util.EnsureWindowsScreenResolution(SCREEN_WIDTH, SCREEN_HEIGHT, | 200 if not run_util.EnsureWindowsScreenResolution(SCREEN_WIDTH, SCREEN_HEIGHT, |
197 SCREEN_BPP): | 201 SCREEN_BPP): |
198 logging.warn('Could not detect/change screen resolution.') | 202 logging.error('Failed to configure screen resolution.') |
| 203 return 1 |
199 | 204 |
| 205 |
| 206 |
200 # Clear all screenshots. | 207 # Clear all screenshots. |
201 logging.info('** Deleting previous screenshots.') | 208 logging.info('** Deleting previous screenshots.') |
202 if os.path.exists(SCREENSHOTS_PATH): | 209 if os.path.exists(SCREENSHOTS_PATH): |
203 shutil.rmtree(SCREENSHOTS_PATH) | 210 shutil.rmtree(SCREENSHOTS_PATH) |
204 | 211 |
205 os.makedirs(SCREENSHOTS_PATH) | 212 os.makedirs(SCREENSHOTS_PATH) |
206 | 213 |
207 logging.info('** Running selenium tests...') | 214 logging.info('** Running selenium tests...') |
208 | 215 |
209 # -u for unbuffered output. | 216 # -u for unbuffered output. |
210 # Use Python2.4 for two reasons. First, this is more or less the standard. | 217 # Use Python2.4 for two reasons. First, this is more or less the standard. |
211 # Second, if we use Python2.6 or later, we must manually shutdown the | 218 # Second, if we use Python2.6 or later, we must manually shutdown the |
212 # httpserver, or the next run will overlap ports, which causes | 219 # httpserver, or the next run will overlap ports, which causes |
213 # some strange problems/exceptions. | 220 # some strange problems/exceptions. |
214 args = [const.PYTHON, '-u', SELENIUM_TEST_RUNNER_PATH] | 221 args = [const.PYTHON, '-u', SELENIUM_TEST_RUNNER_PATH] |
215 | 222 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 256 |
250 if len(argv) > 2: | 257 if len(argv) > 2: |
251 logging.error('Usage: run_lab_test.py [test_config_file]') | 258 logging.error('Usage: run_lab_test.py [test_config_file]') |
252 return 1 | 259 return 1 |
253 | 260 |
254 if len(argv) == 2: | 261 if len(argv) == 2: |
255 # Use given config file. | 262 # Use given config file. |
256 config_path = argv[1] | 263 config_path = argv[1] |
257 else: | 264 else: |
258 # Use default config file. | 265 # Use default config file. |
259 config_path = os.path.join(const.HOME, 'test_config.txt') | 266 config_path = os.path.join(const.HOME_PATH, 'test_config.txt') |
260 | 267 |
261 # Uninstall/Install plugin. | 268 # Uninstall/Install plugin. |
262 if not run_util.UninstallO3DPlugin(): | 269 if not run_util.UninstallO3DPlugin(): |
263 logging.error('Could not successfully uninstall O3D. Tests will not be run.'
) | 270 logging.error('Could not successfully uninstall O3D. Tests will not be run.'
) |
264 return 1 | 271 return 1 |
265 if not run_util.InstallO3DPlugin(): | 272 if not run_util.InstallO3DPlugin(): |
266 logging.error('Unable to install O3D plugin. Tests will not be run.') | 273 logging.error('Unable to install O3D plugin. Tests will not be run.') |
267 return 1 | 274 return 1 |
268 | 275 |
269 # Grab test configuration info from config file. | 276 # Grab test configuration info from config file. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 if all_test_passed: | 317 if all_test_passed: |
311 logging.info('All tests passed.') | 318 logging.info('All tests passed.') |
312 return 0 | 319 return 0 |
313 else: | 320 else: |
314 logging.info('Tests failed.') | 321 logging.info('Tests failed.') |
315 return 1 | 322 return 1 |
316 | 323 |
317 if __name__ == '__main__': | 324 if __name__ == '__main__': |
318 code = main(sys.argv) | 325 code = main(sys.argv) |
319 sys.exit(code) | 326 sys.exit(code) |
OLD | NEW |