32 final AndroidTouchProcessor touchProcessor = mock(AndroidTouchProcessor.class);
40 view.
onTouchEvent(MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0.0f, 0.0f, 0));
41 final ArgumentCaptor<Matrix> matrixCaptor = ArgumentCaptor.forClass(Matrix.class);
42 verify(touchProcessor).onTouchEvent(any(), matrixCaptor.capture());
44 final Matrix screenMatrix =
new Matrix();
45 screenMatrix.postTranslate(1, 2);
46 assertTrue(matrixCaptor.getValue().equals(screenMatrix));
49 reset(touchProcessor);
53 view.
onTouchEvent(MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0.0f, 0.0f, 0));
54 final ArgumentCaptor<Matrix> matrixCaptor = ArgumentCaptor.forClass(Matrix.class);
55 verify(touchProcessor).onTouchEvent(any(), matrixCaptor.capture());
57 final Matrix screenMatrix =
new Matrix();
58 screenMatrix.postTranslate(1, 2);
59 assertTrue(matrixCaptor.getValue().equals(screenMatrix));
62 reset(touchProcessor);
66 view.
onTouchEvent(MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0.0f, 0.0f, 0));
67 final ArgumentCaptor<Matrix> matrixCaptor = ArgumentCaptor.forClass(Matrix.class);
68 verify(touchProcessor).onTouchEvent(any(), matrixCaptor.capture());
70 final Matrix screenMatrix =
new Matrix();
71 screenMatrix.postTranslate(3, 4);
72 assertTrue(matrixCaptor.getValue().equals(screenMatrix));
75 reset(touchProcessor);
79 view.
onTouchEvent(MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0.0f, 0.0f, 0));
80 final ArgumentCaptor<Matrix> matrixCaptor = ArgumentCaptor.forClass(Matrix.class);
81 verify(touchProcessor).onTouchEvent(any(), matrixCaptor.capture());
83 final Matrix screenMatrix =
new Matrix();
84 screenMatrix.postTranslate(7, 8);
85 assertTrue(matrixCaptor.getValue().equals(screenMatrix));
91 final ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class);
92 when(viewTreeObserver.isAlive()).thenReturn(
true);
97 public ViewTreeObserver getViewTreeObserver() {
98 return viewTreeObserver;
102 public boolean hasFocus() {
107 final OnFocusChangeListener focusListener = mock(OnFocusChangeListener.class);
110 final ArgumentCaptor<ViewTreeObserver.OnGlobalFocusChangeListener> focusListenerCaptor =
111 ArgumentCaptor.forClass(ViewTreeObserver.OnGlobalFocusChangeListener.class);
112 verify(viewTreeObserver).addOnGlobalFocusChangeListener(focusListenerCaptor.capture());
114 focusListenerCaptor.getValue().onGlobalFocusChanged(
null,
null);
115 verify(focusListener).onFocusChange(view,
true);
120 final ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class);
121 when(viewTreeObserver.isAlive()).thenReturn(
true);
126 public ViewTreeObserver getViewTreeObserver() {
127 return viewTreeObserver;
131 public boolean hasFocus() {
136 final OnFocusChangeListener focusListener = mock(OnFocusChangeListener.class);
139 final ArgumentCaptor<ViewTreeObserver.OnGlobalFocusChangeListener> focusListenerCaptor =
140 ArgumentCaptor.forClass(ViewTreeObserver.OnGlobalFocusChangeListener.class);
141 verify(viewTreeObserver).addOnGlobalFocusChangeListener(focusListenerCaptor.capture());
143 focusListenerCaptor.getValue().onGlobalFocusChanged(
null,
null);
144 verify(focusListener).onFocusChange(view,
false);