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

Unified Diff: tools/telemetry/telemetry/page/actions/play_unittest.py

Issue 16854013: Telemetry media_measurement plus play action and tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/actions/play_unittest.py
diff --git a/tools/telemetry/telemetry/page/actions/play_unittest.py b/tools/telemetry/telemetry/page/actions/play_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..d1fed083263e57b7398bdd7a8c4e386b61a1cfb6
--- /dev/null
+++ b/tools/telemetry/telemetry/page/actions/play_unittest.py
@@ -0,0 +1,86 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+
+from telemetry.page.actions import play
+from telemetry.unittest import tab_test_case
+
+
+class PlayActionTest(tab_test_case.TabTestCase):
+
+ def setUp(self):
+ tab_test_case.TabTestCase.setUp(self)
+ unittest_data_dir = os.path.join(os.path.dirname(__file__),
+ '..', '..', '..', 'unittest_data')
+ self._browser.SetHTTPServerDirectories(unittest_data_dir)
+ self._tab.Navigate(self._browser.http_server.UrlOf('video_test.html'))
+ self._tab.WaitForDocumentReadyStateToBeComplete()
+
+ def testPlayWithNoSelector(self):
+ """Tests that with no selector Play action plays first video element."""
+ data = {'wait_for_playing': True}
+ action = play.PlayAction(data)
+ action.WillRunAction(None, self._tab)
+ # Both videos not playing before running action
+ self.assertFalse(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_1"]', 'playing');
+ """))
+ self.assertFalse(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_2"]', 'playing');
+ """))
+ action.RunAction(None, self._tab, None)
+ # Assert only first video has played.
+ self.assertTrue(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_1"]', 'playing');
+ """))
+ self.assertFalse(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_2"]', 'playing');
+ """))
+
+ def testPlayWithVideoSelector(self):
+ """Tests that Play action plays video element matching selector."""
+ data = {'selector': 'video[id="video_2"]', 'wait_for_playing': True}
+ action = play.PlayAction(data)
+ action.WillRunAction(None, self._tab)
+ # Both videos not playing before running action
+ self.assertFalse(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_1"]', 'playing');
+ """))
+ self.assertFalse(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_2"]', 'playing');
+ """))
+ action.RunAction(None, self._tab, None)
+ # Assert only video matching selector has played.
+ self.assertFalse(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_1"]', 'playing');
+ """))
+ self.assertTrue(self._tab.EvaluateJavaScript("""
+ window.__hasEventCompleted('video[id="video_2"]', 'playing');
+ """))
+
+ def testPlayWithAllSelector(self):
+ """Tests that Play action plays all video elements with selector='all'."""
+ # TODO(shadi): Write test case!
+ return True
+
+ def testPlayDefaultAudio(self):
+ """Tests that Play action plays audio tags as well."""
+ # TODO(shadi): Write test case!
+ return True
+
+ def testPlayWaitForPlay(self):
+ """Tests that wait_for_playing waits for video to play."""
+ # TODO(shadi): Write test case!
+ return True
+
+ def testPlayWaitForEnded(self):
+ """Tests that wait_for_ended waits for video to end."""
+ # TODO(shadi): Write test case!
+ return True
+
+ def testPlayWaitForEndedTimeout(self):
+ """Tests that action raises exception if timeout is reached."""
+ # TODO(shadi): Write test case!
+ return True

Powered by Google App Engine
This is Rietveld 408576698