Android NTP: Add UMA for the time to click a most visited tile
[chromium-blink-merge.git] / media / tools / layout_tests / test_expectations_history_unittest.py
blobdafc980886c883711db39a93cb7ac1df35ef5e38
1 #!/usr/bin/env python
2 # Copyright (c) 2012 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.
6 from datetime import datetime
8 import calendar
9 import unittest
12 from test_expectations_history import TestExpectationsHistory
15 class TestTestExpectationsHistory(unittest.TestCase):
16 """Unit tests for the TestExpectationsHistory class."""
18 def AssertTestName(self, result_list, testname):
19 """Assert test name in the result_list.
21 Args:
22 result_list: a result list of tuples returned by
23 |GetDiffBetweenTimesOnly1Diff()|. Each tuple consists of
24 (old_rev, new_rev, author, date, message, lines) where
25 |lines| are the entries in the test expectation file.
26 testname: a testname string.
28 Returns:
29 True if the result contains the testname, False otherwise.
30 """
31 for (_, _, _, _, _, lines) in result_list:
32 if any([testname in line for line in lines]):
33 return True
34 return False
36 # These tests use the following commit.
37 # commit 235788e3a4fc71342a5c9fefe67ce9537706ce35
38 # Author: rniwa@webkit.org
39 # Date: Sat Aug 20 06:19:11 2011 +0000
41 def testGetDiffBetweenTimes(self):
42 ptime = calendar.timegm((2011, 8, 20, 0, 0, 0, 0, 0, 0))
43 ctime = calendar.timegm((2011, 8, 21, 0, 0, 0, 0, 0, 0))
44 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html'
45 testname_list = [testname]
46 result_list = TestExpectationsHistory.GetDiffBetweenTimes(
47 ptime, ctime, testname_list)
48 self.assertTrue(self.AssertTestName(result_list, testname))
50 def testGetDiffBetweenTimesOnly1Diff(self):
51 ptime = calendar.timegm((2011, 8, 20, 6, 0, 0, 0, 0, 0))
52 ctime = calendar.timegm((2011, 8, 20, 7, 0, 0, 0, 0, 0))
53 testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html'
54 testname_list = [testname]
55 result_list = TestExpectationsHistory.GetDiffBetweenTimes(
56 ptime, ctime, testname_list)
57 self.assertTrue(self.AssertTestName(result_list, testname))
59 def testGetDiffBetweenTimesOnly1DiffWithGobackSeveralDays(self):
60 ptime = calendar.timegm((2011, 9, 12, 1, 0, 0, 0, 0, 0))
61 ctime = calendar.timegm((2011, 9, 12, 2, 0, 0, 0, 0, 0))
62 testname = 'media/video-zoom-controls.html'
63 testname_list = [testname]
64 result_list = TestExpectationsHistory.GetDiffBetweenTimes(
65 ptime, ctime, testname_list)
66 self.assertTrue(self.AssertTestName(result_list, testname))
69 if __name__ == '__main__':
70 unittest.main()