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

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

Issue 779383002: Move WPR-related attributes to UserStorySet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import os 6 import os
7 7
8 from telemetry import benchmark 8 from telemetry import benchmark
9 from telemetry.core import exceptions 9 from telemetry.core import exceptions
10 from telemetry.core import wpr_modes 10 from telemetry.core import wpr_modes
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 } 102 }
103 """) 103 """)
104 try: 104 try:
105 ps = page_set.PageSet() 105 ps = page_set.PageSet()
106 measurement = PageTestForReplay() 106 measurement = PageTestForReplay()
107 107
108 # First record an archive with only www.google.com. 108 # First record an archive with only www.google.com.
109 self._options.browser_options.wpr_mode = wpr_modes.WPR_RECORD 109 self._options.browser_options.wpr_mode = wpr_modes.WPR_RECORD
110 110
111 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( 111 # pylint: disable=protected-access
112 ps._wpr_archive_info = page_set_archive_info.PageSetArchiveInfo(
112 '', '', ps.bucket, json.loads(archive_info_template % 113 '', '', ps.bucket, json.loads(archive_info_template %
113 (test_archive, google_url))) 114 (test_archive, google_url)))
114 ps.pages = [page_module.Page(google_url, ps)] 115 ps.pages = [page_module.Page(google_url, ps)]
115 all_results = self.RunMeasurement(measurement, ps, options=self._options) 116 all_results = self.RunMeasurement(measurement, ps, options=self._options)
116 self.assertEquals(0, len(all_results.failures)) 117 self.assertEquals(0, len(all_results.failures))
117 118
118 # Now replay it and verify that google.com is found but foo.com is not. 119 # Now replay it and verify that google.com is found but foo.com is not.
119 self._options.browser_options.wpr_mode = wpr_modes.WPR_REPLAY 120 self._options.browser_options.wpr_mode = wpr_modes.WPR_REPLAY
120 121
121 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( 122 # pylint: disable=protected-access
123 ps._wpr_archive_info = page_set_archive_info.PageSetArchiveInfo(
122 '', '', ps.bucket, json.loads(archive_info_template % 124 '', '', ps.bucket, json.loads(archive_info_template %
123 (test_archive, foo_url))) 125 (test_archive, foo_url)))
124 ps.pages = [page_module.Page(foo_url, ps)] 126 ps.pages = [page_module.Page(foo_url, ps)]
125 all_results = self.RunMeasurement(measurement, ps, options=self._options) 127 all_results = self.RunMeasurement(measurement, ps, options=self._options)
126 self.assertEquals(1, len(all_results.failures)) 128 self.assertEquals(1, len(all_results.failures))
127 129
128 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( 130 # pylint: disable=protected-access
131 ps._wpr_archive_info = page_set_archive_info.PageSetArchiveInfo(
129 '', '', ps.bucket, json.loads(archive_info_template % 132 '', '', ps.bucket, json.loads(archive_info_template %
130 (test_archive, google_url))) 133 (test_archive, google_url)))
131 ps.pages = [page_module.Page(google_url, ps)] 134 ps.pages = [page_module.Page(google_url, ps)]
132 all_results = self.RunMeasurement(measurement, ps, options=self._options) 135 all_results = self.RunMeasurement(measurement, ps, options=self._options)
133 self.assertEquals(0, len(all_results.failures)) 136 self.assertEquals(0, len(all_results.failures))
134 137
135 self.assertTrue(os.path.isfile(test_archive)) 138 self.assertTrue(os.path.isfile(test_archive))
136 139
137 finally: 140 finally:
138 if os.path.isfile(test_archive): 141 if os.path.isfile(test_archive):
139 os.remove(test_archive) 142 os.remove(test_archive)
140 143
141 def testRunActions(self): 144 def testRunActions(self):
142 ps = self.CreateEmptyPageSet() 145 ps = self.CreateEmptyPageSet()
143 page = PageWithAction('file://blank.html', ps) 146 page = PageWithAction('file://blank.html', ps)
144 ps.AddPage(page) 147 ps.AddPage(page)
145 measurement = PageTestWithAction() 148 measurement = PageTestWithAction()
146 self.RunMeasurement(measurement, ps, options=self._options) 149 self.RunMeasurement(measurement, ps, options=self._options)
147 self.assertTrue(page.run_test_action_called) 150 self.assertTrue(page.run_test_action_called)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page/page_set_unittest.py ('k') | tools/telemetry/telemetry/unittest_util/page_set_smoke_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698