Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: tools/telemetry/telemetry/page/test_expectations_unittest.py

Issue 22909011: Added support for GPU-based expectations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed device ids to use tuples Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/test_expectations_unittest.py
diff --git a/tools/telemetry/telemetry/page/test_expectations_unittest.py b/tools/telemetry/telemetry/page/test_expectations_unittest.py
index ee4a1b82d1b0249a6924a61ffcf0d07263b5892a..27c56cd56c9d9e44b4fb643df0bb122c208dfc29 100644
--- a/tools/telemetry/telemetry/page/test_expectations_unittest.py
+++ b/tools/telemetry/telemetry/page/test_expectations_unittest.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import unittest
+from telemetry.core import system_info
from telemetry.page import page as page_module
from telemetry.page import page_set
from telemetry.page import test_expectations
@@ -18,6 +19,26 @@ class StubPlatform(object):
def GetOSVersionName(self):
return self.os_version_name
+class StubBrowser(object):
+ def __init__(self, platform, gpu, device_id):
+ self.platform = platform
+ self.system_info = system_info.SystemInfo.FromDict({
+ 'model_name': '',
+ 'gpu': {
+ 'devices': [
+ { 'vendor_id': 0, 'device_id': device_id,
+ 'vendor_string': gpu, 'device_string': '' },
Ken Russell (switch to Gerrit) 2013/08/20 20:48:43 It's unusual that the GPU information will come ba
+ ]
+ }
+ })
+
+ @property
+ def supports_system_info(self):
+ return False if not self.system_info else True
+
+ def GetSystemInfo(self):
+ return self.system_info
+
class SampleTestExpectations(test_expectations.TestExpectations):
def SetExpectations(self):
self.Fail('page1.html', ['win', 'mac'], bug=123)
@@ -25,54 +46,59 @@ class SampleTestExpectations(test_expectations.TestExpectations):
self.Fail('page3.html', bug=123)
self.Fail('page4.*', bug=123)
self.Fail('http://test.com/page5.html', bug=123)
+ self.Fail('page6.html', ['nvidia', 'intel'], bug=123)
+ self.Fail('page7.html', [('nvidia', 0x1001), ('nvidia', 0x1002)], bug=123)
+ self.Fail('page8.html', ['win', 'intel', ('amd', 0x1001)], bug=123)
class TestExpectationsTest(unittest.TestCase):
def setUp(self):
self.expectations = SampleTestExpectations()
- def assertExpectationEquals(self, expected, platform, page):
- result = self.expectations.GetExpectationForPage(platform, page)
+ def assertExpectationEquals(self, expected, page, platform='', gpu='',
+ device_id=0):
+ result = self.expectations.GetExpectationForPage(StubBrowser(platform, gpu,
+ device_id), page)
self.assertEquals(expected, result)
# Pages with no expectations should always return 'pass'
def testNoExpectations(self):
ps = page_set.PageSet()
page = page_module.Page('http://test.com/page0.html', ps)
- self.assertExpectationEquals('pass', StubPlatform('win'), page)
+ self.assertExpectationEquals('pass', page, StubPlatform('win'))
# Pages with expectations for an OS should only return them when running on
# that OS
def testOSExpectations(self):
ps = page_set.PageSet()
page = page_module.Page('http://test.com/page1.html', ps)
- self.assertExpectationEquals('fail', StubPlatform('win'), page)
- self.assertExpectationEquals('fail', StubPlatform('mac'), page)
- self.assertExpectationEquals('pass', StubPlatform('linux'), page)
+ self.assertExpectationEquals('fail', page, StubPlatform('win'))
+ self.assertExpectationEquals('fail', page, StubPlatform('mac'))
+ self.assertExpectationEquals('pass', page, StubPlatform('linux'))
# Pages with expectations for an OS version should only return them when
# running on that OS version
def testOSVersionExpectations(self):
ps = page_set.PageSet()
page = page_module.Page('http://test.com/page2.html', ps)
- self.assertExpectationEquals('fail', StubPlatform('win', 'vista'), page)
- self.assertExpectationEquals('pass', StubPlatform('win', 'win7'), page)
+ self.assertExpectationEquals('fail', page, StubPlatform('win', 'vista'))
+ self.assertExpectationEquals('pass', page, StubPlatform('win', 'win7'))
# Pages with non-conditional expectations should always return that
# expectation regardless of OS or OS version
def testConditionlessExpectations(self):
ps = page_set.PageSet()
page = page_module.Page('http://test.com/page3.html', ps)
- self.assertExpectationEquals('fail', StubPlatform('win'), page)
- self.assertExpectationEquals('fail', StubPlatform('mac', 'lion'), page)
- self.assertExpectationEquals('fail', StubPlatform('linux'), page)
+ self.assertExpectationEquals('fail', page, StubPlatform('win'))
+ self.assertExpectationEquals('fail', page, StubPlatform('mac', 'lion'))
+ self.assertExpectationEquals('fail', page, StubPlatform('linux'))
# Expectations with wildcard characters should return for matching patterns
def testWildcardExpectations(self):
ps = page_set.PageSet()
page = page_module.Page('http://test.com/page4.html', ps)
page_js = page_module.Page('http://test.com/page4.html', ps)
- self.assertExpectationEquals('fail', StubPlatform('win'), page)
- self.assertExpectationEquals('fail', StubPlatform('win'), page_js)
+ self.assertExpectationEquals('fail', page, StubPlatform('win'))
+ self.assertExpectationEquals('fail', page_js, StubPlatform('win'))
# Expectations with absolute paths should match the entire path
def testAbsoluteExpectations(self):
@@ -80,6 +106,41 @@ class TestExpectationsTest(unittest.TestCase):
page = page_module.Page('http://test.com/page5.html', ps)
page_org = page_module.Page('http://test.org/page5.html', ps)
page_https = page_module.Page('https://test.com/page5.html', ps)
- self.assertExpectationEquals('fail', StubPlatform('win'), page)
- self.assertExpectationEquals('pass', StubPlatform('win'), page_org)
- self.assertExpectationEquals('pass', StubPlatform('win'), page_https)
+ self.assertExpectationEquals('fail', page, StubPlatform('win'))
+ self.assertExpectationEquals('pass', page_org, StubPlatform('win'))
+ self.assertExpectationEquals('pass', page_https, StubPlatform('win'))
+
+ # Pages with expectations for a GPU should only return them when running with
+ # that GPU
+ def testGpuExpectations(self):
+ ps = page_set.PageSet()
+ page = page_module.Page('http://test.com/page6.html', ps)
+ self.assertExpectationEquals('fail', page, gpu='nvidia')
+ self.assertExpectationEquals('fail', page, gpu='intel')
+ self.assertExpectationEquals('pass', page, gpu='amd')
+
+ # Pages with expectations for a GPU should only return them when running with
+ # that GPU
+ def testGpuDeviceIdExpectations(self):
+ ps = page_set.PageSet()
+ page = page_module.Page('http://test.com/page7.html', ps)
+ self.assertExpectationEquals('fail', page, gpu='nvidia', device_id=0x1001)
+ self.assertExpectationEquals('fail', page, gpu='nvidia', device_id=0x1002)
+ self.assertExpectationEquals('pass', page, gpu='nvidia', device_id=0x1003)
+ self.assertExpectationEquals('pass', page, gpu='amd', device_id=0x1001)
+
+ # Pages with multiple expectations should only return them when all criteria
+ # is met
+ def testMultipleExpectations(self):
+ ps = page_set.PageSet()
+ page = page_module.Page('http://test.com/page8.html', ps)
+ self.assertExpectationEquals('fail', page,
+ StubPlatform('win'), 'amd', 0x1001)
+ self.assertExpectationEquals('fail', page,
+ StubPlatform('win'), 'intel', 0x1002)
+ self.assertExpectationEquals('pass', page,
+ StubPlatform('win'), 'nvidia', 0x1001)
+ self.assertExpectationEquals('pass', page,
+ StubPlatform('mac'), 'amd', 0x1001)
+ self.assertExpectationEquals('pass', page,
+ StubPlatform('win'), 'amd', 0x1002)

Powered by Google App Engine
This is Rietveld 408576698