예제 #1
0
  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, metadata=EmptyMetadataForTest())

    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.assertFalse(results.had_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()
        results = RunStorySet(test, story_set, self.options)

        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, results.num_successful)
        self.assertFalse(results.had_failures)