OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 # DESCRIPTION : | 6 # DESCRIPTION : |
7 # | 7 # |
8 # This factory test allows execution of a test-based script, with the | 8 # This factory test allows execution of a test-based script, with the |
9 # stdout of the script displayed in a the testing widget via gtk | 9 # stdout of the script displayed in a the testing widget via gtk |
10 # label. Keyboard input will be passed to the script via its stdin. | 10 # label. Keyboard input will be passed to the script via its stdin. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 self._proc.sendline(self._ibuf) | 58 self._proc.sendline(self._ibuf) |
59 self._ibuf = '' | 59 self._ibuf = '' |
60 | 60 |
61 | 61 |
62 class factory_ScriptWrapper(test.test): | 62 class factory_ScriptWrapper(test.test): |
63 version = 1 | 63 version = 1 |
64 | 64 |
65 def key_release_callback(self, widget, event): | 65 def key_release_callback(self, widget, event): |
66 char = event.keyval in range(32,127) and chr(event.keyval) or None | 66 char = event.keyval in range(32,127) and chr(event.keyval) or None |
67 char = event.keyval == gdk.keyval_from_name('Return') and '\n' or char | 67 char = event.keyval == gdk.keyval_from_name('Return') and '\n' or char |
68 if not self._ft_state.exit_on_trigger(event) and char is not None: | 68 if char is not None: |
69 self._script.send(char) | 69 self._script.send(char) |
70 return True | 70 return True |
71 | 71 |
72 def register_callbacks(self, window): | 72 def register_callbacks(self, window): |
73 window.connect('key-release-event', self.key_release_callback) | 73 window.connect('key-release-event', self.key_release_callback) |
74 window.add_events(gdk.KEY_RELEASE_MASK) | 74 window.add_events(gdk.KEY_RELEASE_MASK) |
75 | 75 |
76 def run_once(self, | 76 def run_once(self, cmdline=None): |
77 test_widget_size=None, | |
78 trigger_set=None, | |
79 cmdline=None): | |
80 | 77 |
81 factory.log('%s run_once' % self.__class__) | 78 factory.log('%s run_once' % self.__class__) |
82 | 79 |
83 self._ft_state = ful.State(trigger_set) | |
84 | |
85 label = ful.make_label('', alignment=(0.5, 0.5)) | 80 label = ful.make_label('', alignment=(0.5, 0.5)) |
86 | 81 |
87 test_widget = gtk.EventBox() | 82 test_widget = gtk.EventBox() |
88 test_widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) | 83 test_widget.modify_bg(gtk.STATE_NORMAL, ful.BLACK) |
89 test_widget.add(label) | 84 test_widget.add(label) |
90 | 85 |
91 self._script = Script(cmdline, pexpect, label) | 86 self._script = Script(cmdline, pexpect, label) |
92 | 87 |
93 self._ft_state.run_test_widget( | 88 ful.run_test_widget(self.job, test_widget, |
94 test_widget=test_widget, | |
95 test_widget_size=test_widget_size, | |
96 window_registration_callback=self.register_callbacks) | 89 window_registration_callback=self.register_callbacks) |
97 | 90 |
98 factory.log('%s run_once finished' % self.__class__) | 91 factory.log('%s run_once finished' % self.__class__) |
OLD | NEW |