| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 os | 5 import os |
| 6 import shutil | 6 import shutil |
| 7 import tempfile | 7 import tempfile |
| 8 | 8 |
| 9 from profile_creators import extension_profile_extender | 9 from profile_creators import extension_profile_extender |
| 10 from telemetry import decorators | 10 from telemetry import decorators |
| 11 from telemetry.testing import options_for_unittests | 11 from telemetry.testing import options_for_unittests |
| 12 from telemetry.testing import page_test_test_case | 12 from telemetry.testing import page_test_test_case |
| 13 | 13 |
| 14 | 14 |
| 15 class ExtensionProfileExtenderUnitTest(page_test_test_case.PageTestTestCase): | 15 class ExtensionProfileExtenderUnitTest(page_test_test_case.PageTestTestCase): |
| 16 """Smoke test for creating an extension profile. | 16 """Smoke test for creating an extension profile. |
| 17 | 17 |
| 18 Creates an extension profile and verifies that it has non-empty contents. | 18 Creates an extension profile and verifies that it has non-empty contents. |
| 19 """ | 19 """ |
| 20 # Should be enabled on mac, disabled because flaky: https://crbug.com/586362. | 20 # Should be enabled on mac, disabled because flaky: https://crbug.com/586362. |
| 21 @decorators.Disabled('all') # Extension generation only works on Mac for now. | 21 @decorators.Disabled('all') # Extension generation only works on Mac for now. |
| 22 def testExtensionProfileCreation(self): | 22 def testExtensionProfileCreation(self): |
| 23 tmp_dir = tempfile.mkdtemp() | 23 tmp_dir = tempfile.mkdtemp() |
| 24 files_in_crx_dir = 0 | 24 files_in_crx_dir = 0 |
| 25 try: | 25 try: |
| 26 options = options_for_unittests.GetCopy() | 26 options = options_for_unittests.GetCopy() |
| 27 options.output_profile_path = tmp_dir | 27 # TODO(eakuefner): Remove this after crrev.com/1874473006 rolls in. |
| 28 try: |
| 29 getattr(options, 'output_profile_path') |
| 30 options.output_profile_path = tmp_dir |
| 31 except AttributeError: |
| 32 options.browser_options.output_profile_path = tmp_dir |
| 28 extender = extension_profile_extender.ExtensionProfileExtender(options) | 33 extender = extension_profile_extender.ExtensionProfileExtender(options) |
| 29 extender.Run() | 34 extender.Run() |
| 30 | 35 |
| 31 crx_dir = os.path.join(tmp_dir, 'external_extensions_crx') | 36 crx_dir = os.path.join(tmp_dir, 'external_extensions_crx') |
| 32 files_in_crx_dir = len(os.listdir(crx_dir)) | 37 files_in_crx_dir = len(os.listdir(crx_dir)) |
| 33 finally: | 38 finally: |
| 34 shutil.rmtree(tmp_dir) | 39 shutil.rmtree(tmp_dir) |
| 35 self.assertGreater(files_in_crx_dir, 0) | 40 self.assertGreater(files_in_crx_dir, 0) |
| OLD | NEW |