Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
|
Ken Russell (switch to Gerrit)
2015/11/21 01:06:30
Does this new test fail, as it should, when the fi
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 from gpu_tests import gpu_test_base | |
| 5 import gpu_tests.driver_bug_workarounds_expectations as hw_expectations | |
| 6 | |
| 7 from telemetry.page import page_test | |
| 8 from telemetry.story import story_set as story_set_module | |
| 9 | |
| 10 test_harness_script = r""" | |
| 11 function VerifyDriverBugWorkarounds(workaround) { | |
| 12 var list = document.querySelector('.workarounds-list'); | |
| 13 for (var i=0; i < list.childElementCount; i++) { | |
| 14 var workaround_str = list.children[i].textContent; | |
| 15 if (workaround_str == workaround) { | |
| 16 return true; | |
| 17 } | |
| 18 } | |
| 19 return false; | |
| 20 }; | |
| 21 """ | |
| 22 | |
| 23 class DriverBugWorkaroundsValidator(gpu_test_base.ValidatorBase): | |
| 24 def __init__(self): | |
| 25 super(DriverBugWorkaroundsValidator, self).__init__() | |
| 26 self.workaround = "use_fake_gpu_driver_workaround" | |
| 27 | |
| 28 def ValidateAndMeasurePage(self, page, tab, results): | |
| 29 if not tab.EvaluateJavaScript('VerifyDriverBugWorkarounds("%s")' | |
| 30 % self.workaround): | |
| 31 print 'Test failed. Printing page contents:' | |
| 32 print tab.EvaluateJavaScript('document.body.innerHTML') | |
| 33 raise page_test.Failure('fake driver workaround not enabled') | |
| 34 | |
| 35 def CustomizeBrowserOptions(self, options): | |
| 36 options.AppendExtraBrowserArgs(['--' + self.workaround]) | |
| 37 | |
| 38 class ChromeGpuPage(gpu_test_base.PageBase): | |
| 39 def __init__(self, story_set, expectations): | |
| 40 super(ChromeGpuPage, self).__init__( | |
| 41 url='chrome://gpu', page_set=story_set, base_dir=story_set.base_dir, | |
| 42 name=('DriverBugWorkarounds'), | |
| 43 expectations=expectations) | |
| 44 self.script_to_evaluate_on_commit = test_harness_script | |
| 45 | |
| 46 class DriverBugWorkarounds(gpu_test_base.TestBase): | |
| 47 """Test fake driver workaround is enabled""" | |
| 48 test = DriverBugWorkaroundsValidator | |
| 49 | |
| 50 @classmethod | |
| 51 def Name(cls): | |
| 52 return 'driver_bug_workarounds' | |
| 53 | |
| 54 def _CreateExpectations(self): | |
| 55 return hw_expectations.DriverBugWorkaroundsExpectations() | |
| 56 | |
| 57 def CreateStorySet(self, options): | |
| 58 ps = story_set_module.StorySet() | |
| 59 ps.AddStory(ChromeGpuPage(story_set=ps, | |
| 60 expectations=self.GetExpectations())) | |
| 61 | |
| 62 return ps | |
| OLD | NEW |