Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: tools/telemetry/telemetry/page/page_runner_unittest.py

Issue 329143004: Skip WPR archives when use-live-sites is set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4
5 import logging 5 import logging
6 import os 6 import os
7 import tempfile 7 import tempfile
8 import unittest 8 import unittest
9 9
10 from telemetry import decorators 10 from telemetry import decorators
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 470
471 test = Test() 471 test = Test()
472 options = options_for_unittests.GetCopy() 472 options = options_for_unittests.GetCopy()
473 options.output_format = 'none' 473 options.output_format = 'none'
474 SetUpPageRunnerArguments(options) 474 SetUpPageRunnerArguments(options)
475 results = page_runner.Run(test, ps, expectations, options) 475 results = page_runner.Run(test, ps, expectations, options)
476 self.assertFalse(test.will_navigate_to_page_called) 476 self.assertFalse(test.will_navigate_to_page_called)
477 self.assertEquals(0, len(results.successes)) 477 self.assertEquals(0, len(results.successes))
478 self.assertEquals(0, len(results.failures)) 478 self.assertEquals(0, len(results.failures))
479 self.assertEquals(0, len(results.errors)) 479 self.assertEquals(0, len(results.errors))
480
481 def TestUseLiveSitesFlag(self, options, expected_is_page_from_archive):
482 ps = page_set.PageSet(
483 file_path=util.GetUnittestDataDir(),
484 archive_data_file='data/archive_blank.json')
485 ps.pages.append(page_module.Page(
486 'file://blank.html', ps, base_dir=ps.base_dir))
487 expectations = test_expectations.TestExpectations()
488
489 class ArchiveTest(page_measurement.PageMeasurement):
490 def __init__(self):
491 super(ArchiveTest, self).__init__()
492 self.is_page_from_archive = False
493 self.archive_path_exist = True
494
495 def WillNavigateToPage(self, page, tab):
496 self.archive_path_exist = (page.archive_path
497 and os.path.isfile(page.archive_path))
498 self.is_page_from_archive = (
499 tab.browser._wpr_server is not None) # pylint: disable=W0212
500
501 def MeasurePage(self, _, __, results):
502 pass
503
504 test = ArchiveTest()
505 page_runner.Run(test, ps, expectations, options)
506 if expected_is_page_from_archive and not test.archive_path_exist:
507 logging.warning('archive path did not exist, asserting that page '
508 'is from archive is skipped.')
509 return
510 self.assertEquals(expected_is_page_from_archive, test.is_page_from_archive)
511
512 def testUseLiveSitesFlagSet(self):
513 options = options_for_unittests.GetCopy()
514 options.output_format = 'none'
515 options.use_live_sites = True
516 SetUpPageRunnerArguments(options)
517 self.TestUseLiveSitesFlag(options, expected_is_page_from_archive=False)
bolian 2014/06/11 20:59:22 s/expected_is_page_from_archive/expect_from_archiv
518
519 def testUseLiveSitesFlagUnset(self):
520 options = options_for_unittests.GetCopy()
521 options.output_format = 'none'
522 SetUpPageRunnerArguments(options)
523 self.TestUseLiveSitesFlag(options, expected_is_page_from_archive=True)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page/page_runner.py ('k') | tools/telemetry/unittest_data/data/archive_blank.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698