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

Side by Side Diff: media/tools/layout_tests/test_expectations_history_unittest.py

Issue 7693018: Intial checkin of layout test analyzer. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import unittest
7 import time
8 from datetime import timedelta
9 from datetime import datetime
10 from test_expectations_history import TestExpectationsHistory
11
12
13 class TestTestExpectaionsHistory(unittest.TestCase):
14 """A Unittest class for test_expectation_history module."""
15
16 def AssertTestName(self, result_list, testname):
17 """Assert test name in the result_list
18
19 This method is to chek the test name is in the result.
20 Args:
21 result_list: a result list of tuples returned by
22 |GetDiffBetweenTimesOnly1Diff()|. Each tuple consists of
23 (old_rev, new_rev, author, date, message, lines) where
24 |lines| are the entries in the test expectaton
25 testname: a testname string.
26
27 Returns:
28 True if the result contains the testname.
29 """
30 for (old_rev, new_rev, author, date, message, lines) in result_list:
31 for line in lines:
32 if testname in line:
33 return True
34 return False
35
36 def testGetDiffBetweenTimes(self):
37 t = (2011, 8, 20, 0, 0, 0, 0, 0, 0)
38 ctime = time.mktime(t)
39 t = (2011, 8, 19, 0, 0, 0, 0, 0, 0)
40 ptime = time.mktime(t)
41 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html'
42 testname_list = (
43 [testname])
44 result_list = TestExpectationsHistory.GetDiffBetweenTimes(
45 ctime, ptime, testname_list)
46 self.assertTrue(self.AssertTestName(result_list, testname))
47
48 def testGetDiffBetweenTimesOnly1Diff(self):
49 ptime = '2011-08-19-23'
50 ptime = datetime.strptime(ptime, "%Y-%m-%d-%H")
51 ptime = time.mktime(ptime.timetuple())
52 ctime = '2011-08-20-00'
53 ctime = datetime.strptime(ctime, "%Y-%m-%d-%H")
54 ctime = time.mktime(ctime.timetuple())
55 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html'
56 testname_list = (
57 [testname])
58 result_list = TestExpectationsHistory.GetDiffBetweenTimes(
59 ctime, ptime, testname_list)
60 self.assertTrue(self.AssertTestName(result_list, testname))
61
62
63 if __name__ == '__main__':
64 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698