| 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)
|
|
|