• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

development


Commit MetaInfo

修訂6310bf8f3be51ec84f7ecbed4116d633232d864b (tree)
時間2011-02-10 08:56:04
作者Yu Shan Emily Lau <yslau@goog...>
CommiterAndroid (Google) Code Review

Log Message

Merge "Added the Drag action to the scripted moneky"

Change Summary

差異

--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java
@@ -115,6 +115,8 @@ public class MonkeySourceScript implements MonkeyEventSource {
115115
116116 private static final String EVENT_KEYWORD_PRESSANDHOLD = "PressAndHold";
117117
118+ private static final String EVENT_KEYWORD_DRAG = "Drag";
119+
118120 // a line at the end of the header
119121 private static final String STARTING_DATA_LINE = "start data >>";
120122
@@ -345,6 +347,44 @@ public class MonkeySourceScript implements MonkeyEventSource {
345347 return;
346348 }
347349
350+ // Handle drag event
351+ if ((s.indexOf(EVENT_KEYWORD_DRAG) >= 0) && args.length == 5) {
352+ float xStart = Float.parseFloat(args[0]);
353+ float yStart = Float.parseFloat(args[1]);
354+ float xEnd = Float.parseFloat(args[2]);
355+ float yEnd = Float.parseFloat(args[3]);
356+ int stepCount = Integer.parseInt(args[4]);
357+
358+ float x = xStart;
359+ float y = yStart;
360+ long downTime = SystemClock.uptimeMillis();
361+ long eventTime = SystemClock.uptimeMillis();
362+
363+ if (stepCount > 0) {
364+ float xStep = (xEnd - xStart) / stepCount;
365+ float yStep = (yEnd - yStart) / stepCount;
366+
367+ MonkeyMotionEvent e =
368+ new MonkeyTouchEvent(MotionEvent.ACTION_DOWN).setDownTime(downTime)
369+ .setEventTime(eventTime).addPointer(0, x, y, 1, 5);
370+ mQ.addLast(e);
371+
372+ for (int i = 0; i < stepCount; ++i) {
373+ x += xStep;
374+ y += yStep;
375+ eventTime = SystemClock.uptimeMillis();
376+ e = new MonkeyTouchEvent(MotionEvent.ACTION_MOVE).setDownTime(downTime)
377+ .setEventTime(eventTime).addPointer(0, x, y, 1, 5);
378+ mQ.addLast(e);
379+ }
380+
381+ eventTime = SystemClock.uptimeMillis();
382+ e = new MonkeyTouchEvent(MotionEvent.ACTION_UP).setDownTime(downTime)
383+ .setEventTime(eventTime).addPointer(0, x, y, 1, 5);
384+ mQ.addLast(e);
385+ }
386+ }
387+
348388 // Handle flip events
349389 if (s.indexOf(EVENT_KEYWORD_FLIP) >= 0 && args.length == 1) {
350390 boolean keyboardOpen = Boolean.parseBoolean(args[0]);