Ejemplo n.º 1
0
 def testLoadWithAllSelector(self):
   """Both elements are loaded with selector='all'."""
   action = LoadMediaAction(selector='all', timeout_in_seconds=5)
   action.WillRunAction(self._tab)
   action.RunAction(self._tab)
   self.assertTrue(self.eventFired('#video_1', 'canplaythrough'))
   self.assertTrue(self.eventFired('#audio_1', 'canplaythrough'))
Ejemplo n.º 2
0
 def testLoadWithSelector(self):
   """Only the element matching the selector is loaded."""
   action = LoadMediaAction(selector='#audio_1', timeout_in_seconds=5)
   action.WillRunAction(self._tab)
   action.RunAction(self._tab)
   self.assertFalse(self.eventFired('#video_1', 'canplaythrough'))
   self.assertTrue(self.eventFired('#audio_1', 'canplaythrough'))
Ejemplo n.º 3
0
 def testAwaitedEventIsConfigurable(self):
   """It's possible to wait for different events."""
   action = LoadMediaAction(selector='#video_1', timeout_in_seconds=0.1,
                            event_to_await='loadedmetadata')
   action.WillRunAction(self._tab)
   action.RunAction(self._tab)
   self.assertTrue(self.eventFired('#video_1', 'loadedmetadata'))
Ejemplo n.º 4
0
 def testLoadWithNoSelector(self):
   """With no selector the first media element is loaded."""
   action = LoadMediaAction(timeout_in_seconds=5)
   action.WillRunAction(self._tab)
   action.RunAction(self._tab)
   self.assertTrue(self.eventFired('#video_1', 'canplaythrough'))
   self.assertFalse(self.eventFired('#audio_1', 'canplaythrough'))
Ejemplo n.º 5
0
 def testLoadRaisesAnExceptionOnTimeout(self):
     """The load action times out if the event does not fire."""
     action = LoadMediaAction(selector='#video_1',
                              timeout_in_seconds=0.1,
                              event_to_await='a_nonexistent_event')
     action.WillRunAction(self._tab)
     self.assertRaises(py_utils.TimeoutException, action.RunAction,
                       self._tab)