9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.glass.ui.monocle.input;
27
28 import org.junit.After;
29 import org.junit.Assume;
30 import org.junit.Before;
31 import org.junit.Test;
32
33 public class USKeyboardTest {
34
35 private UInput ui;
36
37 @Before
38 public void initDevice() {
39 TestLog.reset();
40 ui = new UInput();
41 }
42
43 @After
44 public void destroyDevice() throws InterruptedException {
45 ui.waitForQuiet();
46 try {
47 ui.processLine("DESTROY");
48 } catch (RuntimeException e) { }
49 ui.processLine("CLOSE");
183 TestLog.waitForLog("Key released: DIGIT1");
184 ui.processLine("EV_KEY KEY_3 1");
185 ui.processLine("EV_SYN");
186 TestLog.waitForLog("Key pressed: DIGIT3");
187 TestLog.waitForLog("Key typed: 3");
188 ui.processLine("EV_KEY KEY_2 0");
189 ui.processLine("EV_SYN");
190 TestLog.waitForLog("Key released: DIGIT2");
191 ui.processLine("EV_KEY KEY_4 1");
192 ui.processLine("EV_SYN");
193 TestLog.waitForLog("Key pressed: DIGIT4");
194 TestLog.waitForLog("Key typed: 4");
195 ui.processLine("EV_KEY KEY_3 0");
196 ui.processLine("EV_SYN");
197 TestLog.waitForLog("Key released: DIGIT3");
198 ui.processLine("EV_KEY KEY_4 0");
199 ui.processLine("EV_SYN");
200 TestLog.waitForLog("Key released: DIGIT3");
201 }
202
203 }
|
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.glass.ui.monocle.input;
27
28 import org.junit.After;
29 import org.junit.Assert;
30 import org.junit.Before;
31 import org.junit.Test;
32
33 public class USKeyboardTest {
34
35 private UInput ui;
36
37 @Before
38 public void initDevice() {
39 TestLog.reset();
40 ui = new UInput();
41 }
42
43 @After
44 public void destroyDevice() throws InterruptedException {
45 ui.waitForQuiet();
46 try {
47 ui.processLine("DESTROY");
48 } catch (RuntimeException e) { }
49 ui.processLine("CLOSE");
183 TestLog.waitForLog("Key released: DIGIT1");
184 ui.processLine("EV_KEY KEY_3 1");
185 ui.processLine("EV_SYN");
186 TestLog.waitForLog("Key pressed: DIGIT3");
187 TestLog.waitForLog("Key typed: 3");
188 ui.processLine("EV_KEY KEY_2 0");
189 ui.processLine("EV_SYN");
190 TestLog.waitForLog("Key released: DIGIT2");
191 ui.processLine("EV_KEY KEY_4 1");
192 ui.processLine("EV_SYN");
193 TestLog.waitForLog("Key pressed: DIGIT4");
194 TestLog.waitForLog("Key typed: 4");
195 ui.processLine("EV_KEY KEY_3 0");
196 ui.processLine("EV_SYN");
197 TestLog.waitForLog("Key released: DIGIT3");
198 ui.processLine("EV_KEY KEY_4 0");
199 ui.processLine("EV_SYN");
200 TestLog.waitForLog("Key released: DIGIT3");
201 }
202
203 @Test
204 public void testBackspace() throws Exception {
205 TestApplication.showFullScreenScene();
206 TestApplication.addKeyListeners();
207 ui.processLine("OPEN");
208 ui.processLine("EVBIT EV_KEY");
209 ui.processLine("EVBIT EV_SYN");
210 ui.processLine("KEYBIT KEY_BACKSPACE");
211 ui.processLine("KEYBIT KEY_LEFTSHIFT");
212 ui.processLine("KEYBIT KEY_CAPSLOCK");
213 ui.processLine("PROPERTY ID_INPUT_KEYBOARD 1");
214 ui.processLine("CREATE");
215
216 ui.processLine("EV_KEY KEY_BACKSPACE 1");
217 ui.processLine("EV_SYN");
218 TestLog.waitForLog("Key pressed: BACK_SPACE");
219 ui.processLine("EV_KEY KEY_BACKSPACE 0");
220 ui.processLine("EV_SYN");
221 TestLog.waitForLog("Key released: BACK_SPACE");
222 Assert.assertEquals(0l, TestLog.countLogContaining("Key typed"));
223
224 TestLog.reset();
225 ui.processLine("EV_KEY KEY_LEFTSHIFT 1");
226 ui.processLine("EV_SYN");
227 ui.processLine("EV_KEY KEY_BACKSPACE 1");
228 ui.processLine("EV_SYN");
229 TestLog.waitForLog("Key pressed: BACK_SPACE");
230 ui.processLine("EV_KEY KEY_BACKSPACE 0");
231 ui.processLine("EV_SYN");
232 ui.processLine("EV_KEY KEY_LEFTSHIFT 0");
233 ui.processLine("EV_SYN");
234 TestLog.waitForLog("Key released: BACK_SPACE");
235 Assert.assertEquals(0l, TestLog.countLogContaining("Key typed"));
236
237 TestLog.reset();
238 ui.processLine("EV_KEY KEY_CAPSLOCK 1");
239 ui.processLine("EV_SYN");
240 ui.processLine("EV_KEY KEY_CAPSLOCK 0");
241 ui.processLine("EV_SYN");
242 ui.processLine("EV_KEY KEY_BACKSPACE 1");
243 ui.processLine("EV_SYN");
244 TestLog.waitForLog("Key pressed: BACK_SPACE");
245 ui.processLine("EV_KEY KEY_BACKSPACE 0");
246 ui.processLine("EV_SYN");
247 ui.processLine("EV_KEY KEY_CAPSLOCK 1");
248 ui.processLine("EV_SYN");
249 ui.processLine("EV_KEY KEY_CAPSLOCK 0");
250 ui.processLine("EV_SYN");
251 TestLog.waitForLog("Key released: BACK_SPACE");
252 Assert.assertEquals(0l, TestLog.countLogContaining("Key typed"));
253
254 TestLog.reset();
255 ui.processLine("EV_KEY KEY_CAPSLOCK 1");
256 ui.processLine("EV_SYN");
257 ui.processLine("EV_KEY KEY_CAPSLOCK 0");
258 ui.processLine("EV_SYN");
259 ui.processLine("EV_KEY KEY_LEFTSHIFT 1");
260 ui.processLine("EV_SYN");
261 ui.processLine("EV_KEY KEY_BACKSPACE 1");
262 ui.processLine("EV_SYN");
263 TestLog.waitForLog("Key pressed: BACK_SPACE");
264 ui.processLine("EV_KEY KEY_BACKSPACE 0");
265 ui.processLine("EV_SYN");
266 ui.processLine("EV_KEY KEY_LEFTSHIFT 0");
267 ui.processLine("EV_SYN");
268 ui.processLine("EV_KEY KEY_CAPSLOCK 1");
269 ui.processLine("EV_SYN");
270 ui.processLine("EV_KEY KEY_CAPSLOCK 0");
271 ui.processLine("EV_SYN");
272 TestLog.waitForLog("Key released: BACK_SPACE");
273 Assert.assertEquals(0l, TestLog.countLogContaining("Key typed"));
274 }
275
276 }
|