OLD | NEW |
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 """) | 104 """) |
105 try: | 105 try: |
106 ps = page_set.PageSet() | 106 ps = page_set.PageSet() |
107 measurement = PageTestForReplay() | 107 measurement = PageTestForReplay() |
108 | 108 |
109 # First record an archive with only www.google.com. | 109 # First record an archive with only www.google.com. |
110 self._options.browser_options.wpr_mode = wpr_modes.WPR_RECORD | 110 self._options.browser_options.wpr_mode = wpr_modes.WPR_RECORD |
111 | 111 |
112 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( | 112 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( |
113 '', '', json.loads(archive_info_template % | 113 '', '', ps.bucket, json.loads(archive_info_template % |
114 (test_archive, google_url))) | 114 (test_archive, google_url))) |
115 ps.pages = [page_module.Page(google_url, ps)] | 115 ps.pages = [page_module.Page(google_url, ps)] |
116 all_results = self.RunMeasurement(measurement, ps, options=self._options) | 116 all_results = self.RunMeasurement(measurement, ps, options=self._options) |
117 self.assertEquals(0, len(all_results.failures)) | 117 self.assertEquals(0, len(all_results.failures)) |
118 | 118 |
119 # 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. |
120 self._options.browser_options.wpr_mode = wpr_modes.WPR_REPLAY | 120 self._options.browser_options.wpr_mode = wpr_modes.WPR_REPLAY |
121 | 121 |
122 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( | 122 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( |
123 '', '', json.loads(archive_info_template % (test_archive, foo_url))) | 123 '', '', ps.bucket, json.loads(archive_info_template % |
| 124 (test_archive, foo_url))) |
124 ps.pages = [page_module.Page(foo_url, ps)] | 125 ps.pages = [page_module.Page(foo_url, ps)] |
125 all_results = self.RunMeasurement(measurement, ps, options=self._options) | 126 all_results = self.RunMeasurement(measurement, ps, options=self._options) |
126 self.assertEquals(1, len(all_results.failures)) | 127 self.assertEquals(1, len(all_results.failures)) |
127 | 128 |
128 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( | 129 ps.wpr_archive_info = page_set_archive_info.PageSetArchiveInfo( |
129 '', '', json.loads(archive_info_template % | 130 '', '', ps.bucket, json.loads(archive_info_template % |
130 (test_archive, google_url))) | 131 (test_archive, google_url))) |
131 ps.pages = [page_module.Page(google_url, ps)] | 132 ps.pages = [page_module.Page(google_url, ps)] |
132 all_results = self.RunMeasurement(measurement, ps, options=self._options) | 133 all_results = self.RunMeasurement(measurement, ps, options=self._options) |
133 self.assertEquals(0, len(all_results.failures)) | 134 self.assertEquals(0, len(all_results.failures)) |
134 | 135 |
135 self.assertTrue(os.path.isfile(test_archive)) | 136 self.assertTrue(os.path.isfile(test_archive)) |
136 | 137 |
137 finally: | 138 finally: |
138 if os.path.isfile(test_archive): | 139 if os.path.isfile(test_archive): |
139 os.remove(test_archive) | 140 os.remove(test_archive) |
140 | 141 |
141 def testRunActions(self): | 142 def testRunActions(self): |
142 ps = self.CreateEmptyPageSet() | 143 ps = self.CreateEmptyPageSet() |
143 page = PageWithAction('file://blank.html', ps) | 144 page = PageWithAction('file://blank.html', ps) |
144 ps.AddPage(page) | 145 ps.AddPage(page) |
145 measurement = PageTestWithAction() | 146 measurement = PageTestWithAction() |
146 self.RunMeasurement(measurement, ps, options=self._options) | 147 self.RunMeasurement(measurement, ps, options=self._options) |
147 self.assertTrue(page.run_test_action_called) | 148 self.assertTrue(page.run_test_action_called) |
OLD | NEW |