Add window.gc back to Smoothness.WillNavigateToPageHook
[chromium-blink-merge.git] / tools / perf / update_reference_build_unittest.py
blob814d116c0701085a8d44157cc29f6d2df655bdf7
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.
5 import unittest
6 import update_reference_build as update_ref_build
9 # Disable for accessing private API of update_reference_build class.
10 # pylint: disable=protected-access
11 class UpdateReferenceBuildUnittest(unittest.TestCase):
12 def testInit(self):
13 @classmethod
14 def EmptyVersions(_):
15 return {}
16 @classmethod
17 def AllOmahaVersion1(_):
18 return {'mac':'1', 'linux':'1', 'win':'1'}
19 @classmethod
20 def AllCurrentVersion1(_):
21 return {'Mac64':'1', 'Linux':'1', 'Linux_x64':'1', 'Win':'1'}
22 @classmethod
23 def MixedOmahaVersion23(_):
24 return {'mac':'2', 'linux':'3', 'win':'2'}
25 @classmethod
26 def MissingOmahaVersion(_):
27 return {'mac':'2', 'win':'1'}
28 old_stable = update_ref_build.BuildUpdater._OmahaVersionsMap
29 old_current = update_ref_build.BuildUpdater._CurrentRefBuildsMap
30 try:
31 update_ref_build.BuildUpdater._CurrentRefBuildsMap = EmptyVersions
32 update_ref_build.BuildUpdater._OmahaVersionsMap = AllOmahaVersion1
33 expected_versions = {'Mac64':'1', 'Linux':'1', 'Linux_x64':'1', 'Win':'1'}
34 b = update_ref_build.BuildUpdater()
35 self.assertEqual(expected_versions, b._platform_to_version_map)
37 update_ref_build.BuildUpdater._OmahaVersionsMap = MissingOmahaVersion
38 expected_versions = {'Mac64':'2', 'Win':'1'}
39 b = update_ref_build.BuildUpdater()
40 self.assertEqual(expected_versions, b._platform_to_version_map)
42 update_ref_build.BuildUpdater._CurrentRefBuildsMap = AllCurrentVersion1
43 expected_versions = {'Mac64':'2'}
44 b = update_ref_build.BuildUpdater()
45 self.assertEqual(expected_versions, b._platform_to_version_map)
47 update_ref_build.BuildUpdater._OmahaVersionsMap = MixedOmahaVersion23
48 expected_versions = {'Mac64':'2', 'Linux':'3', 'Linux_x64':'3', 'Win':'2'}
49 b = update_ref_build.BuildUpdater()
50 self.assertEqual(expected_versions, b._platform_to_version_map)
51 finally:
52 update_ref_build.BuildUpdater._OmahaVersionsMap = old_stable
53 update_ref_build.BuildUpdater._CurrentRefBuildsMap = old_current
56 def testOmahaVersions(self):
57 #This is an example of valid output from the _OmahaReport function.
58 #Taken from processing the omaha report on 3/18/15
59 lines = [['os', 'channel', 'current_version', 'previous_version',
60 'current_reldate', 'previous_reldate', 'branch_base_commit',
61 'branch_base_position', 'branch_commit', 'base_webkit_position',
62 'true_branch', 'v8_version\n'],
63 ['win', 'stable', '41.0.2272.89', '41.0.2272.76', '03/10/15',
64 '03/03/15', '827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4', '310958',
65 'a4d5695040a99b9b2cb196eb5b898383a274376e', '188177', 'master',
66 '4.1.0.21\n'],
67 ['mac', 'stable', '41.0.2272.89', '41.0.2272.76', '03/10/15',
68 '03/03/15', '827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4', '310958',
69 'a4d5695040a99b9b2cb196eb5b898383a274376e', '188177', 'master',
70 '4.1.0.21\n'],
71 ['linux', 'stable', '41.0.2272.89', '41.0.2272.76', '03/10/15',
72 '03/03/15', '827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4', '310958',
73 'a4d5695040a99b9b2cb196eb5b898383a274376e', '188177', 'master',
74 '4.1.0.21\n'],
75 ['cros', 'stable', '41.0.2272.89', '41.0.2272.76', '03/10/15',
76 '03/04/15', '827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4', '310958',
77 'a4d5695040a99b9b2cb196eb5b898383a274376e', '188177', 'master',
78 '4.1.0.21\n'],
79 ['android', 'stable', '41.0.2272.94', '40.0.2214.109', '03/18/15',
80 '02/04/15', '827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4', '310958',
81 '70c994cb9b14e4c6934654aaa7089b4b2e8f7788', '188177', '2272',
82 '4.1.0.21\n'],
83 ['ios', 'stable', '41.0.2272.56', '40.0.2214.73', '03/16/15',
84 '02/18/15', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A\n']]
85 @classmethod
86 def GetLines(_):
87 return lines
88 old_omaha_report = update_ref_build.BuildUpdater._OmahaReport
89 update_ref_build.BuildUpdater._OmahaReport = GetLines
90 expected_versions = {'win':'41.0.2272.89', 'mac':'41.0.2272.89',
91 'linux':'41.0.2272.89'}
92 b = update_ref_build.BuildUpdater()
93 try:
94 versions = b._OmahaVersionsMap()
95 self.assertEqual(expected_versions, versions)
96 lines = [['os', 'channel', 'current_version', 'previous_version',
97 'current_reldate', 'previous_reldate', 'branch_base_commit',
98 'branch_base_position', 'branch_commit', 'base_webkit_position',
99 'true_branch', 'v8_version\n'],
100 ['win', 'stable', '41.0.2272.89', '41.0.2272.76', '03/10/15',
101 '03/03/15', '827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4',
102 '310958', 'a4d5695040a99b9b2cb196eb5b898383a274376e', '188177',
103 'master', '4.1.0.21\n']]
104 self.assertRaises(ValueError, b._OmahaVersionsMap)
105 lines = ['random', 'list', 'of', 'strings']
106 self.assertRaises(ValueError, b._OmahaVersionsMap)
107 lines = []
108 self.assertRaises(ValueError, b._OmahaVersionsMap)
109 finally:
110 update_ref_build.BuildUpdater._OmahaReport = old_omaha_report