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 os | 5 import os |
6 import tempfile | 6 import tempfile |
7 import unittest | 7 import unittest |
8 import StringIO | 8 import StringIO |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 _make_javascript_deterministic=False): | 680 _make_javascript_deterministic=False): |
681 self.archive_path = archive_path | 681 self.archive_path = archive_path |
682 self.wpr_mode = wpr_mode | 682 self.wpr_mode = wpr_mode |
683 | 683 |
684 | 684 |
685 class RunStateTest(unittest.TestCase): | 685 class RunStateTest(unittest.TestCase): |
686 | 686 |
687 # pylint: disable=W0212 | 687 # pylint: disable=W0212 |
688 def TestUseLiveSitesFlag(self, options, expected_wpr_mode): | 688 def TestUseLiveSitesFlag(self, options, expected_wpr_mode): |
689 with tempfile.NamedTemporaryFile() as f: | 689 with tempfile.NamedTemporaryFile() as f: |
690 run_state = page_runner._RunState(DummyTest()) | 690 run_state = page_runner._RunState(DummyTest(), options) |
691 fake_network_controller = FakeNetworkController() | 691 fake_network_controller = FakeNetworkController() |
692 run_state._PrepareWpr(options, fake_network_controller, f.name, None) | 692 run_state._PrepareWpr(fake_network_controller, f.name, None) |
693 self.assertEquals(fake_network_controller.wpr_mode, expected_wpr_mode) | 693 self.assertEquals(fake_network_controller.wpr_mode, expected_wpr_mode) |
694 self.assertEquals(fake_network_controller.archive_path, f.name) | 694 self.assertEquals(fake_network_controller.archive_path, f.name) |
695 | 695 |
696 def testUseLiveSitesFlagSet(self): | 696 def testUseLiveSitesFlagSet(self): |
697 options = options_for_unittests.GetCopy() | 697 options = options_for_unittests.GetCopy() |
698 options.output_formats = ['none'] | 698 options.output_formats = ['none'] |
699 options.suppress_gtest_report = True | 699 options.suppress_gtest_report = True |
700 options.use_live_sites = True | 700 options.use_live_sites = True |
701 SetUpPageRunnerArguments(options) | 701 SetUpPageRunnerArguments(options) |
702 self.TestUseLiveSitesFlag(options, expected_wpr_mode=wpr_modes.WPR_OFF) | 702 self.TestUseLiveSitesFlag(options, expected_wpr_mode=wpr_modes.WPR_OFF) |
703 | 703 |
704 def testUseLiveSitesFlagUnset(self): | 704 def testUseLiveSitesFlagUnset(self): |
705 options = options_for_unittests.GetCopy() | 705 options = options_for_unittests.GetCopy() |
706 options.output_formats = ['none'] | 706 options.output_formats = ['none'] |
707 options.suppress_gtest_report = True | 707 options.suppress_gtest_report = True |
708 SetUpPageRunnerArguments(options) | 708 SetUpPageRunnerArguments(options) |
709 self.TestUseLiveSitesFlag(options, expected_wpr_mode=wpr_modes.WPR_REPLAY) | 709 self.TestUseLiveSitesFlag(options, expected_wpr_mode=wpr_modes.WPR_REPLAY) |
OLD | NEW |