Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / test / gpu / gpu_tests / gpu_test_expectations_unittest.py
blob2519db4470c4099a4703ad19db92e60d425d8a1a
1 # Copyright 2015 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 import unittest
6 from telemetry.internal.platform import system_info
7 from telemetry.page import page as page_module
8 from telemetry.story import story_set
10 import gpu_test_expectations
12 class StubPlatform(object):
13 def __init__(self, os_name, os_version_name=None):
14 self.os_name = os_name
15 self.os_version_name = os_version_name
17 def GetOSName(self):
18 return self.os_name
20 def GetOSVersionName(self):
21 return self.os_version_name
23 class StubBrowser(object):
24 def __init__(self, platform, gpu, device, vendor_string, device_string):
25 self.platform = platform
26 self.system_info = system_info.SystemInfo.FromDict({
27 'model_name': '',
28 'gpu': {
29 'devices': [
30 {'vendor_id': gpu, 'device_id': device,
31 'vendor_string': vendor_string, 'device_string': device_string},
36 @property
37 def supports_system_info(self):
38 return False if not self.system_info else True
40 def GetSystemInfo(self):
41 return self.system_info
43 class SampleTestExpectations(gpu_test_expectations.GpuTestExpectations):
44 def SetExpectations(self):
45 self.Flaky('test1.html', bug=123, max_num_retries=5)
46 self.Flaky('test2.html', ['win'], bug=123, max_num_retries=6)
47 self.Flaky('wildcardtest*.html', ['win'], bug=123, max_num_retries=7)
49 class GpuTestExpectationsTest(unittest.TestCase):
50 def setUp(self):
51 self.expectations = SampleTestExpectations()
53 def assertExpectationEquals(self, expected, page, platform='', gpu=0,
54 device=0, vendor_string='', device_string=''):
55 result = self.expectations.GetExpectationForPage(StubBrowser(
56 platform, gpu, device, vendor_string, device_string), page)
57 self.assertEquals(expected, result)
59 def getRetriesForPage(self, page, platform='', gpu=0,
60 device=0, vendor_string='', device_string=''):
61 return self.expectations.GetFlakyRetriesForPage(page, StubBrowser(
62 platform, gpu, device, vendor_string, device_string))
64 # Ensure retry mechanism is working.
65 def testFlakyExpectation(self):
66 ps = story_set.StorySet()
67 page = page_module.Page('http://test.com/test1.html', ps)
68 self.assertExpectationEquals('pass', page)
69 self.assertEquals(5, self.getRetriesForPage(page))
71 # Ensure the filtering from the TestExpectations superclass still works.
72 def testFlakyPerPlatformExpectation(self):
73 ps = story_set.StorySet()
74 page1 = page_module.Page('http://test.com/test2.html', ps)
75 self.assertExpectationEquals('pass', page1, StubPlatform('win'))
76 self.assertEquals(6, self.getRetriesForPage(page1, StubPlatform('win')))
77 self.assertExpectationEquals('pass', page1, StubPlatform('mac'))
78 self.assertEquals(0, self.getRetriesForPage(page1, StubPlatform('mac')))
79 page2 = page_module.Page('http://test.com/wildcardtest1.html', ps)
80 self.assertExpectationEquals('pass', page2, StubPlatform('win'))
81 self.assertEquals(7, self.getRetriesForPage(page2, StubPlatform('win')))
82 self.assertExpectationEquals('pass', page2, StubPlatform('mac'))
83 self.assertEquals(0, self.getRetriesForPage(page2, StubPlatform('mac')))