summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2010-08-20 16:00:04 -0700
committerGuang Zhu <guangzhu@google.com>2010-08-25 17:54:43 -0700
commitb5c4caa07819e59f909cf9d71e7e45ae2c88d715 (patch)
tree62e70a0f368ed09fa55f2aaab3d4bebc5f6f463e /tests
parent50395e80718e77d27ec5e2d474b255e05de68d82 (diff)
downloadframeworks_base-b5c4caa07819e59f909cf9d71e7e45ae2c88d715.zip
frameworks_base-b5c4caa07819e59f909cf9d71e7e45ae2c88d715.tar.gz
frameworks_base-b5c4caa07819e59f909cf9d71e7e45ae2c88d715.tar.bz2
add mouse up/down/click support in DumpRenderTree
use touchStart/End when mouseDown/Up is called in current EventSender implmentation. Change-Id: Iff3e7f45b6a7170d9be1c7ec9b12a74a74737732
Diffstat (limited to 'tests')
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java58
1 files changed, 16 insertions, 42 deletions
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java b/tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java
index 0c2347d..716086b 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/WebViewEventSender.java
@@ -16,14 +16,12 @@
package com.android.dumprendertree;
-import android.os.Handler;
import android.os.SystemClock;
import android.util.*;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.webkit.WebView;
-import java.lang.InterruptedException;
import java.util.Arrays;
import java.util.Vector;
@@ -33,7 +31,7 @@ public class WebViewEventSender implements EventSender {
WebViewEventSender(WebView webView) {
mWebView = webView;
- mTouchPoints = new Vector();
+ mTouchPoints = new Vector<TouchPoint>();
}
public void resetMouse() {
@@ -82,47 +80,23 @@ public class WebViewEventSender implements EventSender {
mouseUp();
}
- public void mouseDown() {
- /* KeyEvent event = new KeyEvent(
- KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER);
- mWebView.onKeyDown(event.getKeyCode(), event); */
- }
+ public void mouseDown() {
+ long ts = SystemClock.uptimeMillis();
+ MotionEvent event = MotionEvent.obtain(ts, ts, MotionEvent.ACTION_DOWN, mouseX, mouseY, 0);
+ mWebView.onTouchEvent(event);
+ }
- public void mouseMoveTo(int X, int Y) {
- if (X > mouseX) {
- KeyEvent event = new KeyEvent(
- KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT);
- mWebView.onKeyDown(event.getKeyCode(), event);
- mWebView.onKeyUp(event.getKeyCode(), event);
- } else if ( X < mouseX ) {
- KeyEvent event = new KeyEvent(
- KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_LEFT);
- mWebView.onKeyDown(event.getKeyCode(), event);
- mWebView.onKeyUp(event.getKeyCode(), event);
- }
- if (Y > mouseY) {
- KeyEvent event = new KeyEvent(
- KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_DOWN);
- mWebView.onKeyDown(event.getKeyCode(), event);
- mWebView.onKeyUp(event.getKeyCode(), event);
- } else if (Y < mouseY ) {
- KeyEvent event = new KeyEvent(
- KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_UP);
- mWebView.onKeyDown(event.getKeyCode(), event);
- mWebView.onKeyUp(event.getKeyCode(), event);
- }
- mouseX= X;
- mouseY= Y;
-
- }
+ public void mouseMoveTo(int X, int Y) {
+ mouseX= X;
+ mouseY= Y;
+ }
- public void mouseUp() {
- /* KeyEvent event = new KeyEvent(
- KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DPAD_CENTER);
- mWebView.onKeyDown(event.getKeyCode(), event);*/
+ public void mouseUp() {
+ long ts = SystemClock.uptimeMillis();
+ MotionEvent event = MotionEvent.obtain(ts, ts, MotionEvent.ACTION_UP, mouseX, mouseY, 0);
+ mWebView.onTouchEvent(event);
+ }
- }
-
// Assumes lowercase chars, case needs to be
// handled by calling function.
static int keyMapper(char c) {
@@ -365,7 +339,7 @@ public class WebViewEventSender implements EventSender {
mX = x;
mY = y;
}
- };
+ }
private Vector<TouchPoint> mTouchPoints;
private int mTouchMetaState;