Chromium Code Reviews| 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..60f18fce516fd3b53884e4f1c14ddc826c5c2690 |
| --- /dev/null |
| +++ b/tools/chrome_remote_control/chrome_remote_control/test_helper_interaction.py |
| @@ -0,0 +1,40 @@ |
| +# 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 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._code = data['code'] |
| + self._completion_condition = data['completion'] |
| + |
| + def SupportedForPage(self, page, tab): |
| + return True |
| + |
| + def PerformInteraction(self, page, tab, test): |
| + test_helpers_js_path = os.path.join(os.path.dirname(__file__), |
| + 'test_helpers.js') |
|
tonyg
2012/11/02 18:57:34
indentation is off here.
marja
2012/11/05 14:43:25
Done.
|
| + test_helpers_js = open(test_helpers_js_path, 'r').read() |
| + |
| + tab.runtime.Execute(test_helpers_js) |
| + |
| + test.WillPerformInteraction(self, page, tab) |
| + |
| + result = tab.runtime.Evaluate(self._code) |
| + if not result: |
| + raise interaction.InteractionFailed() |
| + |
| + util.WaitFor(lambda: tab.runtime.Evaluate( |
| + self._completion_condition), 60) |
| + |
| + test.DidPerformInteraction(self, page, tab) |
| + |
| + def CleanUp(self, page, tab): |
| + pass |
| + |
| + |
| +interaction.RegisterClass('TestHelper', TestHelperInteraction) |