OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 import os |
| 5 import shutil |
| 6 import tempfile |
| 7 import unittest |
| 8 |
| 9 from profile_creators.history_profile_extender import HistoryProfileExtender |
| 10 from telemetry.core import util |
| 11 from telemetry.unittest_util import options_for_unittests |
| 12 |
| 13 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') |
| 14 import mock |
| 15 |
| 16 |
| 17 # Testing private method. |
| 18 # pylint: disable=protected-access |
| 19 class HistoryProfileExtenderTest(unittest.TestCase): |
| 20 def testFullFunctionality(self): |
| 21 extender = HistoryProfileExtender() |
| 22 |
| 23 # Stop the extender at the earliest possible opportunity. |
| 24 extender.ShouldExit = mock.MagicMock(return_value=True) |
| 25 # Normally, the number of tabs depends on the number of cores. Use a |
| 26 # static, small number to increase the speed of the test. |
| 27 extender.NumTabs = mock.MagicMock(return_value=3) |
| 28 |
| 29 options = options_for_unittests.GetCopy() |
| 30 options.output_profile_path = tempfile.mkdtemp() |
| 31 |
| 32 try: |
| 33 extender.Run(options) |
| 34 self.assertEquals(extender.profile_path, options.output_profile_path) |
| 35 self.assertTrue(os.path.exists(extender.profile_path)) |
| 36 history_db_path = os.path.join(extender.profile_path, "Default", |
| 37 "History") |
| 38 stat_info = os.stat(history_db_path) |
| 39 self.assertGreater(stat_info.st_size, 1000) |
| 40 finally: |
| 41 shutil.rmtree(options.output_profile_path) |
OLD | NEW |