1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.dumprendertree2;
18
19import android.webkit.WebView;
20
21/**
22 * A class that acts as a JS interface for webview to mock various touch events,
23 * mouse actions and key presses.
24 *
25 * The methods here just call corresponding methods on EventSenderImpl
26 * that contains the logic of how to execute the methods.
27 */
28public class EventSender {
29    EventSenderImpl mEventSenderImpl = new EventSenderImpl();
30
31    public void reset(WebView webView) {
32        mEventSenderImpl.reset(webView);
33    }
34
35    public void enableDOMUIEventLogging(int domNode) {
36        mEventSenderImpl.enableDOMUIEventLogging(domNode);
37    }
38
39    public void fireKeyboardEventsToElement(int domNode) {
40        mEventSenderImpl.fireKeyboardEventsToElement(domNode);
41    }
42
43    public void keyDown(String character, String[] withModifiers) {
44        mEventSenderImpl.keyDown(character, withModifiers);
45    }
46
47    public void keyDown(String character) {
48        keyDown(character, null);
49    }
50
51    public void leapForward(int milliseconds) {
52        mEventSenderImpl.leapForward(milliseconds);
53    }
54
55    public void mouseClick() {
56        mEventSenderImpl.mouseClick();
57    }
58
59    public void mouseDown() {
60        mEventSenderImpl.mouseDown();
61    }
62
63    public void mouseMoveTo(int x, int y) {
64        mEventSenderImpl.mouseMoveTo(x, y);
65    }
66
67    public void mouseUp() {
68        mEventSenderImpl.mouseUp();
69    }
70
71    public void touchStart() {
72        mEventSenderImpl.touchStart();
73    }
74
75    public void addTouchPoint(int x, int y) {
76        mEventSenderImpl.addTouchPoint(x, y);
77    }
78
79    public void updateTouchPoint(int id, int x, int y) {
80        mEventSenderImpl.updateTouchPoint(id, x, y);
81    }
82
83    public void setTouchModifier(String modifier, boolean enabled) {
84        mEventSenderImpl.setTouchModifier(modifier, enabled);
85    }
86
87    public void touchMove() {
88        mEventSenderImpl.touchMove();
89    }
90
91    public void releaseTouchPoint(int id) {
92        mEventSenderImpl.releaseTouchPoint(id);
93    }
94
95    public void touchEnd() {
96        mEventSenderImpl.touchEnd();
97    }
98
99    public void touchCancel() {
100        mEventSenderImpl.touchCancel();
101    }
102
103    public void clearTouchPoints() {
104        mEventSenderImpl.clearTouchPoints();
105    }
106
107    public void cancelTouchPoint(int id) {
108        mEventSenderImpl.cancelTouchPoint(id);
109    }
110}