Search in sources :

Example 6 with GestureDescription

use of android.accessibilityservice.GestureDescription in project robolectric by robolectric.

the class ShadowAccessibilityServiceTest method setCanDispatchGestures_false_stopsRecordingDispatchedGestures.

@Test
@Config(minSdk = N)
public void setCanDispatchGestures_false_stopsRecordingDispatchedGestures() {
    GestureDescription gestureDescription = createTestGesture();
    GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback();
    shadow.setCanDispatchGestures(false);
    service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/
    null);
    assertThat(shadow.getGesturesDispatched()).isEmpty();
}
Also used : GestureDescription(android.accessibilityservice.GestureDescription) GestureResultCallback(android.accessibilityservice.AccessibilityService.GestureResultCallback) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 7 with GestureDescription

use of android.accessibilityservice.GestureDescription in project robolectric by robolectric.

the class ShadowAccessibilityServiceTest method setCanDispatchGestures_false_causesDispatchGestureToReturnFalse.

@Test
@Config(minSdk = N)
public void setCanDispatchGestures_false_causesDispatchGestureToReturnFalse() {
    GestureDescription gestureDescription = createTestGesture();
    GestureResultCallback gestureResultCallback = createEmptyGestureResultCallback();
    shadow.setCanDispatchGestures(false);
    assertThat(service.dispatchGesture(gestureDescription, gestureResultCallback, /*handler=*/
    null)).isFalse();
}
Also used : GestureDescription(android.accessibilityservice.GestureDescription) GestureResultCallback(android.accessibilityservice.AccessibilityService.GestureResultCallback) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 8 with GestureDescription

use of android.accessibilityservice.GestureDescription in project WeChatLuckyMoney by geeeeeeeeek.

the class HongbaoService method openPacket.

private void openPacket() {
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    float dpi = metrics.densityDpi;
    Log.d(TAG, "openPacket!" + dpi);
    if (android.os.Build.VERSION.SDK_INT <= 23) {
        mUnpackNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
    } else {
        if (android.os.Build.VERSION.SDK_INT > 23) {
            Path path = new Path();
            if (640 == dpi) {
                // 1440
                path.moveTo(720, 1575);
            } else if (320 == dpi) {
                // 720p
                path.moveTo(355, 780);
            } else if (480 == dpi) {
                // 1080p
                path.moveTo(533, 1115);
            }
            GestureDescription.Builder builder = new GestureDescription.Builder();
            GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription(path, 450, 50)).build();
            dispatchGesture(gestureDescription, new GestureResultCallback() {

                @Override
                public void onCompleted(GestureDescription gestureDescription) {
                    Log.d(TAG, "onCompleted");
                    mMutex = false;
                    super.onCompleted(gestureDescription);
                }

                @Override
                public void onCancelled(GestureDescription gestureDescription) {
                    Log.d(TAG, "onCancelled");
                    mMutex = false;
                    super.onCancelled(gestureDescription);
                }
            }, null);
        }
    }
}
Also used : Path(android.graphics.Path) GestureDescription(android.accessibilityservice.GestureDescription) DisplayMetrics(android.util.DisplayMetrics)

Aggregations

GestureDescription (android.accessibilityservice.GestureDescription)8 GestureResultCallback (android.accessibilityservice.AccessibilityService.GestureResultCallback)5 Test (org.junit.Test)5 Config (org.robolectric.annotation.Config)5 Path (android.graphics.Path)2 AccessibilityService (android.accessibilityservice.AccessibilityService)1 Handler (android.os.Handler)1 RequiresApi (android.support.annotation.RequiresApi)1 DisplayMetrics (android.util.DisplayMetrics)1 RequiresApi (androidx.annotation.RequiresApi)1 VolatileBox (com.stardust.concurrent.VolatileBox)1