OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging, os, shutil | 5 import logging, os, shutil |
6 from autotest_lib.client.bin import site_ui_test, utils | 6 from autotest_lib.client.bin import site_ui_test, utils |
7 from autotest_lib.client.common_lib import error, site_httpd, site_ui | 7 from autotest_lib.client.common_lib import error, site_httpd, site_ui |
8 | 8 |
9 | 9 |
10 class graphics_WebGLConformance(site_ui_test.UITest): | 10 class graphics_WebGLConformance(site_ui_test.UITest): |
11 version = 1 | 11 version = 1 |
12 | 12 |
13 | 13 |
14 def initialize(self, creds = '$default'): | 14 def initialize(self, creds = '$default'): |
15 self._test_url = 'http://localhost:8000/webgl-conformance-tests.html' | 15 self._test_url = 'http://localhost:8000/webgl-conformance-tests.html' |
16 self._testServer = site_httpd.HTTPListener(8000, docroot=self.srcdir) | 16 self._testServer = site_httpd.HTTPListener(8000, docroot=self.srcdir) |
17 self._testServer.run() | 17 self._testServer.run() |
18 site_ui_test.UITest.initialize(self, creds) | 18 site_ui_test.UITest.initialize(self, creds) |
19 | 19 |
20 | 20 |
21 def setup(self): | 21 def setup(self, tarball='webgl-tests-0.0.1.tar.bz2'): |
22 shutil.rmtree(self.srcdir, ignore_errors=True) | 22 shutil.rmtree(self.srcdir, ignore_errors=True) |
| 23 |
| 24 dst_path = os.path.join(self.bindir, 'WebGL') |
| 25 tarball_path = os.path.join(self.bindir, tarball) |
| 26 if not os.path.exists(dst_path): |
| 27 if not os.path.exists(tarball_path): |
| 28 utils.get_file( |
| 29 'http://commondatastorage.googleapis.com/chromeos-localmirro
r/distfiles/' + tarball, |
| 30 tarball_path) |
| 31 utils.extract_tarball_to_dir(tarball_path, dst_path) |
| 32 |
23 shutil.copytree(os.path.join(self.bindir, 'WebGL'), self.srcdir) | 33 shutil.copytree(os.path.join(self.bindir, 'WebGL'), self.srcdir) |
24 os.chdir(self.srcdir) | 34 os.chdir(self.srcdir) |
25 utils.system('patch -p1 < ../r11002.patch') | 35 utils.system('patch -p1 < ../r11002.patch') |
26 | 36 |
27 | 37 |
28 def cleanup(self): | 38 def cleanup(self): |
29 self._testServer.stop() | 39 self._testServer.stop() |
30 site_ui_test.UITest.cleanup(self) | 40 site_ui_test.UITest.cleanup(self) |
31 | 41 |
32 | 42 |
33 def run_once(self, timeout=300): | 43 def run_once(self, timeout=300): |
34 latch = self._testServer.add_wait_url('/WebGL/results') | 44 latch = self._testServer.add_wait_url('/WebGL/results') |
35 session = site_ui.ChromeSession(' --enable-webgl %s' % self._test_url) | 45 session = site_ui.ChromeSession(' --enable-webgl %s' % self._test_url) |
36 logging.debug('Chrome session started.') | 46 logging.debug('Chrome session started.') |
37 latch.wait(timeout) | 47 latch.wait(timeout) |
38 session.close() | 48 session.close() |
39 | 49 |
40 if not latch.is_set(): | 50 if not latch.is_set(): |
41 raise error.TestFail('Never received callback from browser.') | 51 raise error.TestFail('Never received callback from browser.') |
42 results = self._testServer.get_form_entries() | 52 results = self._testServer.get_form_entries() |
43 total = int(results['total']) | 53 total = int(results['total']) |
44 passed = int(results['pass']) | 54 passed = int(results['pass']) |
45 if passed < total: | 55 if passed < total: |
46 raise error.TestFail('Results: %d out of %d tests failed!' % | 56 raise error.TestFail('Results: %d out of %d tests failed!' % |
47 (total - passed, total)) | 57 (total - passed, total)) |
OLD | NEW |