| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 named customcamera1_reference.png requires that there be a corresponding | 42 named customcamera1_reference.png requires that there be a corresponding |
| 43 screenshot. | 43 screenshot. |
| 44 """ | 44 """ |
| 45 | 45 |
| 46 | 46 |
| 47 import selenium_utilities | 47 import selenium_utilities |
| 48 | 48 |
| 49 class JavaScriptUnitTests(selenium_utilities.SeleniumTestCase): | 49 class JavaScriptUnitTests(selenium_utilities.SeleniumTestCase): |
| 50 """Runs the JavaScript unit tests for the sample utilities.""" | 50 """Runs the JavaScript unit tests for the sample utilities.""" |
| 51 | 51 |
| 52 def __init__(self, name, session, browser, path_to_html, test_type=None, | 52 def __init__(self, name, browser, path_to_html, test_type=None, |
| 53 sample_path=None, options=None): | 53 sample_path=None, options=None): |
| 54 selenium_utilities.SeleniumTestCase.__init__( | 54 selenium_utilities.SeleniumTestCase.__init__( |
| 55 self, name, session, browser, path_to_html, test_type, sample_path, | 55 self, name, browser, path_to_html, test_type, sample_path, |
| 56 options) | 56 options) |
| 57 | 57 |
| 58 def GenericTest(self): | 58 def GenericTest(self): |
| 59 """Generically test a sample. | 59 """Generically test a sample. |
| 60 | 60 |
| 61 Each sample is expected to have a global variable called g_testResult | 61 Each sample is expected to have a global variable called g_testResult |
| 62 That starts undefined and is set to true or false when the test is finished. | 62 That starts undefined and is set to true or false when the test is finished. |
| 63 """ | 63 """ |
| 64 self.RunGenericTest( | 64 self.RunGenericTest( |
| 65 "/tests/selenium/tests/", | 65 "/tests/selenium/tests/", |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 [1793, 2933, 2914, 2, 2746, 182, 2564], | 268 [1793, 2933, 2914, 2, 2746, 182, 2564], |
| 269 [1793, 2825, 2848, 2, 2604, 171, 2433], | 269 [1793, 2825, 2848, 2, 2604, 171, 2433], |
| 270 [1793, 2933, 2790, 2, 2870, 155, 2715], | 270 [1793, 2933, 2790, 2, 2870, 155, 2715], |
| 271 [1793, 4337, 3004, 2, 5360, 237, 5123]] | 271 [1793, 4337, 3004, 2, 5360, 237, 5123]] |
| 272 | 272 |
| 273 # Take screenshots | 273 # Take screenshots |
| 274 for clock in range(0, 8): | 274 for clock in range(0, 8): |
| 275 s.run_script("window.g_clock = " + str(clock * 3.14159 * 2.5 + 0.5)) | 275 s.run_script("window.g_clock = " + str(clock * 3.14159 * 2.5 + 0.5)) |
| 276 self.assertTrue( | 276 self.assertTrue( |
| 277 selenium_utilities.TakeScreenShot(s, self.browser, "window.g_client", | 277 selenium_utilities.TakeScreenShot(s, self.browser, "window.g_client", |
| 278 "cullingzsort" + str(clock))) | 278 "cullingzsort" + str(clock + 1))) |
| 279 s.run_script("g_framesRendered = 0") | 279 s.run_script("g_framesRendered = 0") |
| 280 while int(s.get_eval("window.g_framesRendered")) < 3: | 280 while int(s.get_eval("window.g_framesRendered")) < 3: |
| 281 s.run_script("window.g_client.render()") | 281 s.run_script("window.g_client.render()") |
| 282 data = [s.get_eval("window.g_totalTransformsElement.innerHTML"), | 282 data = [s.get_eval("window.g_totalTransformsElement.innerHTML"), |
| 283 s.get_eval("window.g_transformsProcessedElement.innerHTML"), | 283 s.get_eval("window.g_transformsProcessedElement.innerHTML"), |
| 284 s.get_eval("window.g_transformsCulledElement.innerHTML"), | 284 s.get_eval("window.g_transformsCulledElement.innerHTML"), |
| 285 s.get_eval("window.g_totalDrawElementsElement.innerHTML"), | 285 s.get_eval("window.g_totalDrawElementsElement.innerHTML"), |
| 286 s.get_eval("window.g_drawElementsProcessedElement.innerHTML"), | 286 s.get_eval("window.g_drawElementsProcessedElement.innerHTML"), |
| 287 s.get_eval("window.g_drawElementsCulledElement.innerHTML"), | 287 s.get_eval("window.g_drawElementsCulledElement.innerHTML"), |
| 288 s.get_eval("window.g_drawElementsRenderedElement.innerHTML")] | 288 s.get_eval("window.g_drawElementsRenderedElement.innerHTML")] |
| 289 new_data.append(data) | 289 new_data.append(data) |
| 290 print ", ".join(data) | 290 print ", ".join(data) |
| 291 | 291 |
| 292 # check the results | 292 # check the results |
| 293 for clock in range(0, 8): | 293 for clock in range(0, 8): |
| 294 for ii in range(0, 7): | 294 for ii in range(0, 7): |
| 295 # comment out the following line and add a "pass" line if you need new | 295 # comment out the following line and add a "pass" line if you need new |
| 296 # culling reference data. | 296 # culling reference data. |
| 297 self.assertEqual(int(new_data[clock][ii]), | 297 self.assertEqual(int(new_data[clock][ii]), |
| 298 culling_reference_data[clock][ii]) | 298 culling_reference_data[clock][ii]) |
| 299 | 299 |
| 300 | 300 |
| 301 if __name__ == "__main__": | 301 if __name__ == "__main__": |
| 302 pass | 302 pass |
| OLD | NEW |