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

Unified Diff: tools/chrome_remote_control/chrome_remote_control/test_helper_interaction.py

Issue 11369075: Chrome remote control multipage tests: Add interactions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more robust dispatching (allow splitting interactions to separate files) Created 8 years, 1 month 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/chrome_remote_control/chrome_remote_control/test_helper_interaction.py
diff --git a/tools/chrome_remote_control/chrome_remote_control/test_helper_interaction.py b/tools/chrome_remote_control/chrome_remote_control/test_helper_interaction.py
new file mode 100644
index 0000000000000000000000000000000000000000..be256b77923416998356b5cf0115d939714b8522
--- /dev/null
+++ b/tools/chrome_remote_control/chrome_remote_control/test_helper_interaction.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2012 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 json
+import os
+
+from chrome_remote_control import interaction
+from chrome_remote_control import util
+
+class TestHelperInteraction(interaction.Interaction):
+ def __init__(self, data):
+ super(TestHelperInteraction, self).__init__()
+ self._data = data
+ self._type = data['type']
+
+ def SupportedForPage(self, page, tab):
+ return True
+
+ def PerformInteraction(self, page, tab, test):
+ test_helpers_js_path = os.path.join(os.path.dirname(__file__),
+ 'interaction_' + self._type + '.js')
+ test_helpers_js = open(test_helpers_js_path, 'r').read()
+ tab.runtime.Execute(test_helpers_js)
+
+ test.WillPerformInteraction(self, page, tab)
+
+ code = ('window.__' + self._type + '(\'' + json.dumps(self._data) + '\');')
+ result = tab.runtime.Evaluate(code)
+ if not result:
+ raise interaction.InteractionFailed()
+
+ util.WaitFor(lambda: tab.runtime.Evaluate(
+ 'document.readyState == "complete"'), 60)
+
+ test.DidPerformInteraction(self, page, tab)
+
+ def CleanUp(self, page, tab):
+ pass
+
+
+interaction.RegisterClass('TestHelper', TestHelperInteraction)

Powered by Google App Engine
This is Rietveld 408576698