OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import os |
| 6 |
| 7 from gpu_tests import gpu_integration_test |
| 8 from gpu_tests import depth_capture_expectations |
| 9 from gpu_tests import path_util |
| 10 |
| 11 data_path = os.path.join( |
| 12 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'media') |
| 13 |
| 14 wait_timeout = 60 # seconds |
| 15 |
| 16 harness_script = r""" |
| 17 var domAutomationController = {}; |
| 18 |
| 19 domAutomationController._succeeded = false; |
| 20 domAutomationController._finished = false; |
| 21 domAutomationController._error_msg = ""; |
| 22 |
| 23 domAutomationController.setAutomationId = function(id) {} |
| 24 |
| 25 domAutomationController.send = function(msg) { |
| 26 if (msg == "OK") { |
| 27 if (!domAutomationController._finished) { |
| 28 domAutomationController._succeeded = true; |
| 29 } |
| 30 domAutomationController._finished = true; |
| 31 } else { |
| 32 domAutomationController._succeeded = false; |
| 33 domAutomationController._finished = true; |
| 34 domAutomationController._error_msg = msg; |
| 35 } |
| 36 } |
| 37 |
| 38 domAutomationController.reset = function() { |
| 39 domAutomationController._succeeded = false; |
| 40 domAutomationController._finished = false; |
| 41 } |
| 42 |
| 43 window.domAutomationController = domAutomationController; |
| 44 console.log("Harness injected."); |
| 45 """ |
| 46 |
| 47 class DepthCaptureIntegrationTest(gpu_integration_test.GpuIntegrationTest): |
| 48 |
| 49 @classmethod |
| 50 def Name(cls): |
| 51 return 'depth_capture' |
| 52 |
| 53 @classmethod |
| 54 def CustomizeOptions(cls): |
| 55 options = cls._finder_options.browser_options |
| 56 options.AppendExtraBrowserArgs( |
| 57 '--disable-domain-blocking-for-3d-apis') |
| 58 options.AppendExtraBrowserArgs( |
| 59 '--use-fake-ui-for-media-stream') |
| 60 options.AppendExtraBrowserArgs( |
| 61 '--use-fake-device-for-media-stream=device-count=2') |
| 62 # Required for about:gpucrash handling from Telemetry. |
| 63 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 64 |
| 65 @classmethod |
| 66 def GenerateGpuTests(cls, options): |
| 67 tests = (('DepthCapture_depthStreamToRGBAUint8Texture', |
| 68 'getusermedia-depth-capture.html?query=RGBAUint8'), |
| 69 ('DepthCapture_depthStreamToRGBAFloatTexture', |
| 70 'getusermedia-depth-capture.html?query=RGBAFloat')) |
| 71 for t in tests: |
| 72 yield (t[0], t[1], ('_' + t[0])) |
| 73 |
| 74 def RunActualGpuTest(self, test_path, *args): |
| 75 url = self.UrlOfStaticFilePath(test_path) |
| 76 tab = self.tab |
| 77 tab.Navigate(url, script_to_evaluate_on_commit=harness_script) |
| 78 tab.action_runner.WaitForJavaScriptCondition( |
| 79 'domAutomationController._finished', timeout_in_seconds=60) |
| 80 if not tab.EvaluateJavaScript('domAutomationController._succeeded'): |
| 81 self.fail('page indicated test failure:' + |
| 82 tab.EvaluateJavaScript('domAutomationController._error_msg')) |
| 83 |
| 84 @classmethod |
| 85 def _CreateExpectations(cls): |
| 86 return depth_capture_expectations.DepthCaptureExpectations() |
| 87 |
| 88 @classmethod |
| 89 def setUpClass(cls): |
| 90 super(cls, DepthCaptureIntegrationTest).setUpClass() |
| 91 cls.CustomizeOptions() |
| 92 cls.SetBrowserOptions(cls._finder_options) |
| 93 cls.StartBrowser() |
| 94 cls.SetStaticServerDirs([data_path]) |
OLD | NEW |