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

Side by Side Diff: tools/telemetry/telemetry/page/test_expectations_unittest.py

Issue 16158006: Defining the test expectations object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/telemetry/telemetry/page/test_expectations.py ('k') | tools/telemetry/telemetry/test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 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
5
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set
8 from telemetry.page import test_expectations
9
10 class StubPlatform(object):
11 def __init__(self, os_name, os_version_name=None):
12 self.os_name = os_name
13 self.os_version_name = os_version_name
14
15 def GetOSName(self):
16 return self.os_name
17
18 def GetOSVersionName(self):
19 return self.os_version_name
20
21 class SampleTestExpectations(test_expectations.TestExpectations):
22 def SetExpectations(self):
23 self.Fail('page1.html', ['win', 'mac'], bug=123)
24 self.Fail('page2.html', ['vista'], bug=123)
25 self.Fail('page3.html', bug=123)
26 self.Fail('page4.*', bug=123)
27 self.Fail('http://test.com/page5.html', bug=123)
28
29 class TestExpectationsTest(unittest.TestCase):
30 def setUp(self):
31 self.expectations = SampleTestExpectations()
32
33 def assertExpectationEquals(self, expected, platform, page):
34 result = self.expectations.GetExpectationForPage(platform, page)
35 self.assertEquals(expected, result)
36
37 # Pages with no expectations should always return 'pass'
38 def testNoExpectations(self):
39 ps = page_set.PageSet()
40 page = page_module.Page('http://test.com/page0.html', ps)
41 self.assertExpectationEquals('pass', StubPlatform('win'), page)
42
43 # Pages with expectations for an OS should only return them when running on
44 # that OS
45 def testOSExpectations(self):
46 ps = page_set.PageSet()
47 page = page_module.Page('http://test.com/page1.html', ps)
48 self.assertExpectationEquals('fail', StubPlatform('win'), page)
49 self.assertExpectationEquals('fail', StubPlatform('mac'), page)
50 self.assertExpectationEquals('pass', StubPlatform('linux'), page)
51
52 # Pages with expectations for an OS version should only return them when
53 # running on that OS version
54 def testOSVersionExpectations(self):
55 ps = page_set.PageSet()
56 page = page_module.Page('http://test.com/page2.html', ps)
57 self.assertExpectationEquals('fail', StubPlatform('win', 'vista'), page)
58 self.assertExpectationEquals('pass', StubPlatform('win', 'win7'), page)
59
60 # Pages with non-conditional expectations should always return that
61 # expectation regardless of OS or OS version
62 def testConditionlessExpectations(self):
63 ps = page_set.PageSet()
64 page = page_module.Page('http://test.com/page3.html', ps)
65 self.assertExpectationEquals('fail', StubPlatform('win'), page)
66 self.assertExpectationEquals('fail', StubPlatform('mac', 'lion'), page)
67 self.assertExpectationEquals('fail', StubPlatform('linux'), page)
68
69 # Expectations with wildcard characters should return for matching patterns
70 def testWildcardExpectations(self):
71 ps = page_set.PageSet()
72 page = page_module.Page('http://test.com/page4.html', ps)
73 page_js = page_module.Page('http://test.com/page4.html', ps)
74 self.assertExpectationEquals('fail', StubPlatform('win'), page)
75 self.assertExpectationEquals('fail', StubPlatform('win'), page_js)
76
77 # Expectations with absolute paths should match the entire path
78 def testAbsoluteExpectations(self):
79 ps = page_set.PageSet()
80 page = page_module.Page('http://test.com/page5.html', ps)
81 page_org = page_module.Page('http://test.org/page5.html', ps)
82 page_https = page_module.Page('https://test.com/page5.html', ps)
83 self.assertExpectationEquals('fail', StubPlatform('win'), page)
84 self.assertExpectationEquals('pass', StubPlatform('win'), page_org)
85 self.assertExpectationEquals('pass', StubPlatform('win'), page_https)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page/test_expectations.py ('k') | tools/telemetry/telemetry/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698