OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 base64 | 5 import base64 |
6 import unittest | 6 import unittest |
7 | 7 |
8 from metrics import test_page_measurement_results | 8 from metrics import test_page_measurement_results |
9 from metrics import network | 9 from metrics import network |
10 from telemetry.core.timeline import event | 10 from telemetry.timeline import event |
11 | 11 |
12 | 12 |
13 HTML_BODY = """<!DOCTYPE HTML> | 13 HTML_BODY = """<!DOCTYPE HTML> |
14 <html> | 14 <html> |
15 <head> </head> | 15 <head> </head> |
16 <body> | 16 <body> |
17 <div id="test"> TEST HTML</div> | 17 <div id="test"> TEST HTML</div> |
18 </body> | 18 </body> |
19 </html>""" | 19 </html>""" |
20 IMAGE_BODY = """fake image data""" | 20 IMAGE_BODY = """fake image data""" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 cl = len(HTML_BODY) + GZIPPED_HTML_LEN + len(IMAGE_BODY) | 165 cl = len(HTML_BODY) + GZIPPED_HTML_LEN + len(IMAGE_BODY) |
166 results.AssertHasPageSpecificScalarValue('content_length', 'bytes', cl) | 166 results.AssertHasPageSpecificScalarValue('content_length', 'bytes', cl) |
167 | 167 |
168 ocl = len(HTML_BODY) + len(HTML_BODY) + IMAGE_OCL | 168 ocl = len(HTML_BODY) + len(HTML_BODY) + IMAGE_OCL |
169 results.AssertHasPageSpecificScalarValue( | 169 results.AssertHasPageSpecificScalarValue( |
170 'original_content_length', 'bytes', ocl) | 170 'original_content_length', 'bytes', ocl) |
171 | 171 |
172 saving_percent = float(ocl - cl) * 100/ ocl | 172 saving_percent = float(ocl - cl) * 100/ ocl |
173 results.AssertHasPageSpecificScalarValue( | 173 results.AssertHasPageSpecificScalarValue( |
174 'data_saving', 'percent', saving_percent) | 174 'data_saving', 'percent', saving_percent) |
OLD | NEW |