| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 import json | 4 import json |
| 5 import os | 5 import os |
| 6 import shutil | 6 import shutil |
| 7 import tempfile | 7 import tempfile |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 from py_utils import cloud_storage # pylint: disable=import-error | 10 from py_utils import cloud_storage # pylint: disable=import-error |
| 11 | 11 |
| 12 from telemetry.page import page | 12 from telemetry.page import page |
| 13 from telemetry.testing import system_stub | 13 from telemetry.testing import system_stub |
| 14 from telemetry.wpr import archive_info | 14 from telemetry.wpr import archive_info |
| 15 from telemetry.wpr import archive_info2 |
| 15 | 16 |
| 16 | 17 |
| 17 class MockPage(page.Page): | 18 class MockPage(page.Page): |
| 18 def __init__(self, url, name=None): | 19 def __init__(self, url, name=None): |
| 19 super(MockPage, self).__init__(url, None, name=name) | 20 super(MockPage, self).__init__(url, None, name=name) |
| 20 | 21 |
| 21 | 22 |
| 22 page1 = MockPage('http://www.foo.com/', 'Foo') | 23 page1 = MockPage('http://www.foo.com/', 'Foo') |
| 23 page2 = MockPage('http://www.bar.com/', 'Bar') | 24 page2 = MockPage('http://www.bar.com/', 'Bar') |
| 24 page3 = MockPage('http://www.baz.com/') | 25 page3 = MockPage('http://www.baz.com/') |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 self.assertTrue(os.path.exists(new_recording)) | 221 self.assertTrue(os.path.exists(new_recording)) |
| 221 self.assertFalse(os.path.exists(new_temp_recording)) | 222 self.assertFalse(os.path.exists(new_temp_recording)) |
| 222 self.assertCorrectHashFile(new_recording) | 223 self.assertCorrectHashFile(new_recording) |
| 223 | 224 |
| 224 # Check that the archive info was written correctly. | 225 # Check that the archive info was written correctly. |
| 225 self.assertTrue(os.path.exists(self.story_set_archive_info_file)) | 226 self.assertTrue(os.path.exists(self.story_set_archive_info_file)) |
| 226 read_archive_info = archive_info.WprArchiveInfo.FromFile( | 227 read_archive_info = archive_info.WprArchiveInfo.FromFile( |
| 227 self.story_set_archive_info_file, cloud_storage.PUBLIC_BUCKET) | 228 self.story_set_archive_info_file, cloud_storage.PUBLIC_BUCKET) |
| 228 self.assertEquals(new_recording, | 229 self.assertEquals(new_recording, |
| 229 read_archive_info.WprFilePathForStory(page1)) | 230 read_archive_info.WprFilePathForStory(page1)) |
| 231 |
| 232 def testFromFileMultiplatform(self): |
| 233 multiplatform_archive_info_contents = (""" |
| 234 { |
| 235 "platform_specific": true, |
| 236 "archives": { |
| 237 "%s": ["%s", "%s"], |
| 238 "%s": ["%s"] |
| 239 } |
| 240 } |
| 241 """ % (recording1, page1.display_name, page2.display_name, recording2, |
| 242 page3.display_name)) |
| 243 |
| 244 archive_info_file = os.path.join( |
| 245 self.tmp_dir, 'info2.json') |
| 246 with open(archive_info_file, 'w') as f: |
| 247 f.write(multiplatform_archive_info_contents) |
| 248 |
| 249 archive = archive_info.WprArchiveInfo.FromFile( |
| 250 archive_info_file, cloud_storage.PUBLIC_BUCKET) |
| 251 self.assertTrue(isinstance(archive, archive_info2.WprArchiveInfo)) |
| OLD | NEW |