Example #1
0
    def testWebPageReplay(self):
        story_set = example_domain.ExampleDomainPageSet()
        body = []

        class TestWpr(page_test.PageTest):
            def ValidateAndMeasurePage(self, _, tab, __):
                body.append(tab.EvaluateJavaScript('document.body.innerText'))

        test = TestWpr()
        options = options_for_unittests.GetCopy()
        options.output_formats = ['none']
        options.suppress_gtest_report = True
        SetUpStoryRunnerArguments(options)
        results = results_options.CreateResults(EmptyMetadataForTest(),
                                                options)

        story_runner.Run(test, story_set, options, results)

        self.longMessage = True
        self.assertIn('Example Domain',
                      body[0],
                      msg='URL: %s' % story_set.stories[0].url)
        self.assertIn('Example Domain',
                      body[1],
                      msg='URL: %s' % story_set.stories[1].url)

        self.assertEquals(2, len(GetSuccessfulPageRuns(results)))
        self.assertEquals(0, len(results.failures))
  def testWebPageReplay(self):
    story_set = example_domain.ExampleDomainPageSet()
    body = []

    class TestWpr(legacy_page_test.LegacyPageTest):
      def ValidateAndMeasurePage(self, page, tab, results):
        del page, results  # unused
        body.append(tab.EvaluateJavaScript('document.body.innerText'))

      def DidRunPage(self, platform):
        # Force the replay server to restart between pages; this verifies that
        # the restart mechanism works.
        platform.network_controller.StopReplay()

    test = TestWpr()
    options = options_for_unittests.GetCopy()
    options.output_formats = ['none']
    options.suppress_gtest_report = True
    SetUpStoryRunnerArguments(options)
    results = results_options.CreateResults(EmptyMetadataForTest(), options)

    story_runner.Run(test, story_set, options, results)

    self.longMessage = True
    self.assertIn('Example Domain', body[0],
                  msg='URL: %s' % story_set.stories[0].url)
    self.assertIn('Example Domain', body[1],
                  msg='URL: %s' % story_set.stories[1].url)

    self.assertEquals(2, len(GetSuccessfulPageRuns(results)))
    self.assertEquals(0, len(results.failures))