01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.tests.harness.util;
11:
12: import org.eclipse.swt.widgets.Display;
13: import org.eclipse.swt.widgets.Event;
14:
15: /**
16: * <code>AutomationUtil</code> contains utility methods to mimic key events.
17: * Mouse event methods can be added if needed to complete this class.
18: */
19: public class AutomationUtil {
20:
21: /**
22: * Method to mimic a key code event on a display.
23: *
24: * @param display
25: * The display.
26: * @param eventType
27: * The event type.
28: * @param keyCode
29: * The key code.
30: */
31: public static void performKeyCodeEvent(Display display,
32: int eventType, int keyCode) {
33: Event event = new Event();
34: event.type = eventType;
35: event.keyCode = keyCode;
36: display.post(event);
37: }
38:
39: /**
40: * Method to mimic a character event on a display.
41: *
42: * @param display
43: * The display.
44: * @param eventType
45: * The event type.
46: * @param character
47: * The character to mimic.
48: */
49: public static void performCharacterEvent(Display display,
50: int eventType, char character) {
51: Event event = new Event();
52: event.type = eventType;
53: event.character = character;
54: display.post(event);
55: }
56: }
|