TestInputEvent.java revision f862155e3476f8d9644d57072a6d92375bde628e
1package com.android.documentsui;
2
3import android.graphics.Point;
4import android.support.v7.widget.RecyclerView;
5
6public class TestInputEvent implements Events.InputEvent {
7
8    public boolean mouseEvent;
9    public boolean primaryButtonPressed;
10    public boolean secondaryButtonPressed;
11    public boolean shiftKeyDow;
12    public boolean actionDown;
13    public boolean actionUp;
14    public Point location;
15    public int position = Integer.MIN_VALUE;
16
17    public TestInputEvent() {}
18
19    public TestInputEvent(int position) {
20        this.position = position;
21    }
22
23    @Override
24    public boolean isMouseEvent() {
25        return mouseEvent;
26    }
27
28    @Override
29    public boolean isPrimaryButtonPressed() {
30        return primaryButtonPressed;
31    }
32
33    @Override
34    public boolean isSecondaryButtonPressed() {
35        return secondaryButtonPressed;
36    }
37
38    @Override
39    public boolean isShiftKeyDown() {
40        return shiftKeyDow;
41    }
42
43    @Override
44    public boolean isActionDown() {
45        return actionDown;
46    }
47
48    @Override
49    public boolean isActionUp() {
50        return actionUp;
51    }
52
53    @Override
54    public Point getOrigin() {
55        return location;
56    }
57
58    @Override
59    public boolean isOverItem() {
60        return position != Integer.MIN_VALUE && position != RecyclerView.NO_POSITION;
61    }
62
63    @Override
64    public int getItemPosition() {
65        return position;
66    }
67
68    public static TestInputEvent tap(int position) {
69        return new TestInputEvent(position);
70    }
71
72    public static TestInputEvent shiftTap(int position) {
73        TestInputEvent e = new TestInputEvent(position);
74        e.shiftKeyDow = true;
75        return e;
76    }
77
78    public static TestInputEvent click(int position) {
79        TestInputEvent e = new TestInputEvent(position);
80        e.mouseEvent = true;
81        return e;
82    }
83
84    public static TestInputEvent shiftClick(int position) {
85        TestInputEvent e = new TestInputEvent(position);
86        e.mouseEvent = true;
87        e.shiftKeyDow = true;
88        return e;
89    }
90}
91