def testPageTestWithIncompatibleStory(self):
        options = options_for_unittests.GetCopy()

        b = TestBenchmark(
            story_module.Story(
                name='test story',
                shared_state_class=shared_page_state.SharedPageState))
        with self.assertRaisesRegexp(
                Exception, 'containing only telemetry.page.Page stories'):
            story_runner.RunBenchmark(b, b.CreateStorySet(options), None,
                                      options.browser_options, options)

        state_class = story_module.SharedState
        b = TestBenchmark(
            story_module.Story(name='test benchmark',
                               shared_state_class=state_class))
        with self.assertRaisesRegexp(
                Exception, 'containing only telemetry.page.Page stories'):
            story_runner.RunBenchmark(b, b.CreateStorySet(options), None,
                                      options.browser_options, options)

        b = TestBenchmark(
            android.AndroidStory(name='test benchmark', start_intent=None))
        with self.assertRaisesRegexp(
                Exception, 'containing only telemetry.page.Page stories'):
            story_runner.RunBenchmark(b, b.CreateStorySet(options), None,
                                      options.browser_options, options)
Beispiel #2
0
    def testMakeJavaScriptDeterministic(self):
        s = story.Story(SharedStateBar)
        self.assertTrue(s.make_javascript_deterministic)

        s = story.Story(SharedStateBar, make_javascript_deterministic=False)
        self.assertFalse(s.make_javascript_deterministic)

        s = story.Story(SharedStateBar, make_javascript_deterministic=True)
        self.assertTrue(s.make_javascript_deterministic)
Beispiel #3
0
 def testValidTags(self):
     story.Story(SharedStateBar, tags=['abc'], name='story')
     story.Story(SharedStateBar,
                 tags=['a' * 50, 'b' * 25 + 'a' * 25],
                 name='story')
     story.Story(SharedStateBar, tags=['a_b'], name='story')
     story.Story(SharedStateBar, tags=['_1'], name='story')
     story.Story(SharedStateBar,
                 tags=['1honda_2tesla_3airplanes'],
                 name='story')
 def testAugmentExpectationsWithParserNoData(self):
   b = TestBenchmark(story_module.Story(
       name='test_name',
       shared_state_class=shared_page_state.SharedPageState))
   b.AugmentExpectationsWithParser('')
   expectations = b.expectations.AsDict()
   self.assertFalse(expectations.get('test_name'))
 def testCanRunOnPlatformReturnTrue(self):
   b = TestBenchmark(story_module.Story(
       name='test name',
       shared_state_class=shared_page_state.SharedPageState))
   # We can pass None for both arguments because it defaults to ALL for
   # supported platforms, which always returns true.
   self.assertTrue(b._CanRunOnPlatform(None, None))
 def testBenchmarkExpectationsEmpty(self):
     b = TestBenchmark(
         story_module.Story(
             name='test name',
             shared_state_class=shared_page_state.SharedPageState))
     self.assertIsInstance(b.expectations,
                           story_module.expectations.StoryExpectations)
 def testAugmentExpectationsWithParserData(self):
   b = TestBenchmark(story_module.Story(
       name='test_name',
       shared_state_class=shared_page_state.SharedPageState))
   data = 'crbug.com/123 benchmark_unittest.TestBenchmark/test_name [ Skip ]'
   b.AugmentExpectationsWithParser(data)
   expectations = b.expectations.AsDict()
   self.assertTrue(expectations['stories'].get('test_name'))
 def testCanRunOnPlatformReturnFalse(self):
   b = TestBenchmark(story_module.Story(
       name='test name',
       shared_state_class=shared_page_state.SharedPageState))
   b.SUPPORTED_PLATFORMS = [] # pylint: disable=invalid-name
   # We can pass None for both arguments because we select no platforms as
   # supported, which always returns false.
   self.assertFalse(b._CanRunOnPlatform(None, None))
 def testNewTestExpectationsFormatIsUsed(self):
     b = TestBenchmark(
         story_module.Story(
             name='test name',
             shared_state_class=shared_page_state.SharedPageState))
     b.AugmentExpectationsWithFile('# results: [ Skip ]\nb1 [ Skip ]\n')
     self.assertIsInstance(b.expectations,
                           typ_expectations.StoryExpectations)
Beispiel #10
0
    def testPageTestWithIncompatibleStory(self):
        b = TestBenchmark(
            story_module.Story(
                shared_state_class=shared_page_state.SharedPageState))
        with self.assertRaisesRegexp(
                Exception, 'containing only telemetry.page.Page stories'):
            b.Run(browser_options.BrowserFinderOptions())

        state_class = story_module.SharedState
        b = TestBenchmark(story_module.Story(shared_state_class=state_class))
        with self.assertRaisesRegexp(
                Exception, 'containing only telemetry.page.Page stories'):
            b.Run(browser_options.BrowserFinderOptions())

        b = TestBenchmark(android.AndroidStory(start_intent=None))
        with self.assertRaisesRegexp(
                Exception, 'containing only telemetry.page.Page stories'):
            b.Run(browser_options.BrowserFinderOptions())
  def testPageTestWithIncompatibleStory(self):
    b = TestBenchmark(story_module.Story(
        name='test story',
        shared_state_class=shared_page_state.SharedPageState))
    with self.assertRaisesRegexp(
        Exception, 'containing only telemetry.page.Page stories'):
      b.Run(options_for_unittests.GetCopy())

    state_class = story_module.SharedState
    b = TestBenchmark(story_module.Story(
        name='test benchmark',
        shared_state_class=state_class))
    with self.assertRaisesRegexp(
        Exception, 'containing only telemetry.page.Page stories'):
      b.Run(options_for_unittests.GetCopy())

    b = TestBenchmark(android.AndroidStory(
        name='test benchmark', start_intent=None))
    with self.assertRaisesRegexp(
        Exception, 'containing only telemetry.page.Page stories'):
      b.Run(options_for_unittests.GetCopy())
 def testAugmentExpectationsWithFileData(self):
     b = TestBenchmark(
         story_module.Story(
             name='test_name',
             shared_state_class=shared_page_state.SharedPageState))
     data = (
         '# results: [ skip ]\n'
         'crbug.com/123 benchmark_unittest.TestBenchmark/test_name [ Skip ]'
     )
     b.AugmentExpectationsWithFile(data)
     story = mock.MagicMock()
     story.name = 'test_name'
     self.assertTrue(b.expectations.IsStoryDisabled(story))
 def testInvalidTags(self):
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=['a@'], name='story')
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=['a:b'], name='story')
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=['tags with space'], name='story')
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=['a:b'], name='story')
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=[''], name='story')
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=['aaaaaa~1'], name='story')
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=['tag-with-dash'], name='story')
   with self.assertRaises(ValueError):
     story.Story(SharedStateBar, tags=['a'*51], name='story')
Beispiel #14
0
 def testNamelessStoryAsDict(self):
     s = story.Story(SharedStateBar)
     s_dict = s.AsDict()
     self.assertEquals(s_dict['id'], s.id)
     self.assertNotIn('name', s_dict)
 def testStoriesHaveDifferentIds(self):
   s0 = story.Story(SharedStateBar, 'foo')
   s1 = story.Story(SharedStateBar, 'bar')
   self.assertNotEqual(s0.id, s1.id)
Beispiel #16
0
 def setUp(self):
     self.story = story_module.Story(shared_state.SharedState, name='foo')
 def testStoryAsDict(self):
   s = story.Story(SharedStateBar, 'Foo')
   s_dict = s.AsDict()
   self.assertEquals(s_dict['id'], s.id)
   self.assertEquals('Foo', s_dict['name'])
 def testHasName(self):
   with self.assertRaises(AssertionError):
     story.Story(SharedStateBar)
Beispiel #19
0
def TestStory(name, **kwargs):
    return story_module.Story(shared_state.SharedState, name=name, **kwargs)
Beispiel #20
0
 def testBenchmarkExpectations(self):
     b = TestBenchmark(
         story_module.Story(
             shared_state_class=shared_page_state.SharedPageState))
     self.assertIsInstance(b.GetExpectations(),
                           story_module.expectations.StoryExpectations)