1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view.cts;
18 
19 import android.content.Context;
20 import android.graphics.Canvas;
21 import android.graphics.Rect;
22 import android.graphics.drawable.Drawable;
23 import android.os.Handler;
24 import android.os.Parcelable;
25 import android.util.AttributeSet;
26 import android.util.SparseArray;
27 import android.view.ContextMenu;
28 import android.view.ContextMenu.ContextMenuInfo;
29 import android.view.KeyEvent;
30 import android.view.MotionEvent;
31 import android.view.PointerIcon;
32 import android.view.View;
33 import android.view.ViewGroup;
34 
35 import java.util.concurrent.BlockingQueue;
36 import java.util.concurrent.LinkedBlockingQueue;
37 
38 public class MockView extends View {
39     private boolean mCalledOnCreateContextMenu = false;
40     private boolean mCalledOnAnimationStart = false;
41     private boolean mCalledOnAnimationEnd = false;
42     private boolean mCalledOnAttachedToWindow = false;
43     private boolean mCalledOnDetachedFromWindow = false;
44     private boolean mCalledOnCreateDrawableState = false;
45     private boolean mCalledDrawableStateChanged = false;
46     private boolean mCalledOnDraw = false;
47     private boolean mCalledDispatchDraw = false;
48     private boolean mCalledOnFinishInflate = false;
49     private boolean mCalledOnFocusChanged = false;
50     private boolean mCalledOnKeyDown = false;
51     private boolean mCalledOnKeyUp = false;
52     private boolean mCalledOnKeyMultiple = false;
53     private boolean mCalledOnKeyShortcut = false;
54     private boolean mCalledOnLayout = false;
55     private boolean mCalledOnMeasure = false;
56     private boolean mCalledOnSizeChanged = false;
57     private boolean mCalledOnSetAlpha = false;
58     private boolean mCalledOnTrackballEvent = false;
59     private boolean mCalledOnHoverEvent = false;
60     private boolean mCalledOnWindowFocusChanged = false;
61     private boolean mCalledDispatchRestoreInstanceState = false;
62     private boolean mCalledDispatchSaveInstanceState = false;
63     private boolean mCalledOnRestoreInstanceState = false;
64     private boolean mCalledOnSaveInstanceState = false;
65     private boolean mCalledOnWindowVisibilityChanged = false;
66     private boolean mCalledDispatchUnhandledMove = false;
67     private boolean mCalledDispatchWindowFocusChanged = false;
68     private boolean mCalledDispatchWindowVisibilityChanged =false;
69     private boolean mCalledOnScrollChanged = false;
70     private boolean mCalledInvalidate = false;
71     private boolean mCalledComputeScroll = false;
72     private boolean mCalledDispatchKeyEventPreIme = false;
73     private boolean mCalledOnKeyPreIme = false;
74     private boolean mCalledOnResolvePointerIcon = false;
75     private boolean mCalledOnVisibilityAggregated = false;
76     private boolean mCalledRequestFocus = false;
77     private boolean mCalledPerformHapticFeedback = false;
78 
79     private int mOldWidth = -1;
80     private int mOldHeight = -1;
81 
82     private boolean mLastAggregatedVisibility;
83 
84     private BlockingQueue<MotionEvent> mTouchEvents = new LinkedBlockingQueue<>();
85 
MockView(Context context)86     public MockView(Context context) {
87         super(context);
88     }
89 
MockView(Context context, AttributeSet attrs)90     public MockView(Context context, AttributeSet attrs) {
91         super(context, attrs, 0);
92     }
93 
MockView(Context context, AttributeSet attrs, int defStyle)94     public MockView(Context context, AttributeSet attrs, int defStyle) {
95         super(context, attrs, defStyle);
96     }
97 
98     @Override
onKeyShortcut(int keyCode, KeyEvent event)99     public boolean onKeyShortcut(int keyCode, KeyEvent event) {
100         mCalledOnKeyShortcut = true;
101         return super.onKeyShortcut(keyCode, event);
102     }
103 
hasCalledOnKeyShortcut()104     public boolean hasCalledOnKeyShortcut() {
105         return mCalledOnKeyShortcut;
106     }
107 
108     @Override
invalidate()109     public void invalidate() {
110         super.invalidate();
111         mCalledInvalidate = true;
112     }
113 
hasCalledInvalidate()114     public boolean hasCalledInvalidate() {
115         return mCalledInvalidate;
116     }
117 
setParent(ViewGroup parent)118     public void setParent(ViewGroup parent) {
119         parent.addView(this);
120     }
121 
getEnabledStateSet()122     public static int[] getEnabledStateSet() {
123         return ENABLED_STATE_SET;
124     }
125 
getPressedEnabledStateSet()126     public static int[] getPressedEnabledStateSet() {
127         return PRESSED_ENABLED_STATE_SET;
128     }
129 
130     @Override
isPaddingOffsetRequired()131     protected boolean isPaddingOffsetRequired() {
132         return super.isPaddingOffsetRequired();
133     }
134 
135     @Override
getBottomPaddingOffset()136     protected int getBottomPaddingOffset() {
137         return super.getBottomPaddingOffset();
138     }
139 
140     @Override
getLeftPaddingOffset()141     protected int getLeftPaddingOffset() {
142         return super.getLeftPaddingOffset();
143     }
144 
145     @Override
getRightPaddingOffset()146     protected int getRightPaddingOffset() {
147         return super.getRightPaddingOffset();
148     }
149 
150     @Override
getTopPaddingOffset()151     protected int getTopPaddingOffset() {
152         return super.getTopPaddingOffset();
153     }
154 
155     @Override
onAnimationEnd()156     protected void onAnimationEnd() {
157         super.onAnimationEnd();
158         mCalledOnAnimationEnd = true;
159     }
160 
161     @Override
onAnimationStart()162     protected void onAnimationStart() {
163         super.onAnimationStart();
164         mCalledOnAnimationStart = true;
165     }
166 
hasCalledOnAnimationStart()167     public boolean hasCalledOnAnimationStart() {
168         return mCalledOnAnimationStart;
169     }
170 
hasCalledOnAnimationEnd()171     public boolean hasCalledOnAnimationEnd() {
172         return mCalledOnAnimationEnd;
173     }
174 
175     @Override
getHorizontalScrollbarHeight()176     protected int getHorizontalScrollbarHeight() {
177         return super.getHorizontalScrollbarHeight();
178     }
179 
180     @Override
onKeyDown(int keyCode, KeyEvent event)181     public boolean onKeyDown(int keyCode, KeyEvent event) {
182         mCalledOnKeyDown = true;
183         return super.onKeyDown(keyCode, event);
184     }
185 
hasCalledOnKeyDown()186     public boolean hasCalledOnKeyDown() {
187         return mCalledOnKeyDown;
188     }
189 
190     @Override
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)191     public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
192         mCalledOnKeyMultiple = true;
193         return super.onKeyMultiple(keyCode, repeatCount, event);
194     }
195 
hasCalledOnKeyMultiple()196     public boolean hasCalledOnKeyMultiple() {
197         return mCalledOnKeyMultiple;
198     }
199 
200     @Override
onKeyUp(int keyCode, KeyEvent event)201     public boolean onKeyUp(int keyCode, KeyEvent event) {
202         mCalledOnKeyUp = true;
203         return super.onKeyUp(keyCode, event);
204     }
205 
hasCalledOnKeyUp()206     public boolean hasCalledOnKeyUp() {
207         return mCalledOnKeyUp;
208     }
209 
210     @Override
onTouchEvent(MotionEvent event)211     public boolean onTouchEvent(MotionEvent event) {
212         mTouchEvents.add(MotionEvent.obtain(event));
213         return super.onTouchEvent(event);
214     }
215 
216     @Override
onTrackballEvent(MotionEvent event)217     public boolean onTrackballEvent(MotionEvent event) {
218         mCalledOnTrackballEvent = true;
219         return super.onTrackballEvent(event);
220     }
221 
222     @Override
onHoverEvent(MotionEvent event)223     public boolean onHoverEvent(MotionEvent event) {
224         mCalledOnHoverEvent = true;
225         return super.onHoverEvent(event);
226     }
227 
228     /**
229      * Poll the queue for the oldest MotionEvent that was received by onTouchEvent.
230      * Caller is responsible for recycling the returned event.
231      * @return The oldest MotionEvent that was received by onTouchEvent
232      */
pollTouchEvent()233     public MotionEvent pollTouchEvent() {
234         return mTouchEvents.poll();
235     }
236 
hasCalledOnTouchEvent()237     public boolean hasCalledOnTouchEvent() {
238         return !mTouchEvents.isEmpty();
239     }
240 
hasCalledOnTrackballEvent()241     public boolean hasCalledOnTrackballEvent() {
242         return mCalledOnTrackballEvent;
243     }
244 
hasCalledOnHoverEvent()245     public boolean hasCalledOnHoverEvent() {
246         return mCalledOnHoverEvent;
247     }
248 
249     @Override
getSuggestedMinimumHeight()250     protected int getSuggestedMinimumHeight() {
251         return super.getSuggestedMinimumHeight();
252     }
253 
254     @Override
getSuggestedMinimumWidth()255     protected int getSuggestedMinimumWidth() {
256         return super.getSuggestedMinimumWidth();
257     }
258 
259     @Override
verifyDrawable(Drawable who)260     protected boolean verifyDrawable(Drawable who) {
261         return super.verifyDrawable(who);
262     }
263 
264     @Override
computeHorizontalScrollExtent()265     protected int computeHorizontalScrollExtent() {
266         return super.computeHorizontalScrollExtent();
267     }
268 
269     @Override
computeHorizontalScrollOffset()270     protected int computeHorizontalScrollOffset() {
271         return super.computeHorizontalScrollOffset();
272     }
273 
274     @Override
computeHorizontalScrollRange()275     protected int computeHorizontalScrollRange() {
276         return super.computeHorizontalScrollRange();
277     }
278 
279     @Override
computeVerticalScrollExtent()280     protected int computeVerticalScrollExtent() {
281         return super.computeVerticalScrollExtent();
282     }
283 
284     @Override
computeVerticalScrollOffset()285     protected int computeVerticalScrollOffset() {
286         return super.computeVerticalScrollOffset();
287     }
288 
289     @Override
computeVerticalScrollRange()290     protected int computeVerticalScrollRange() {
291         return super.computeVerticalScrollRange();
292     }
293 
294     @Override
getLeftFadingEdgeStrength()295     protected float getLeftFadingEdgeStrength() {
296         return super.getLeftFadingEdgeStrength();
297     }
298 
299     @Override
getRightFadingEdgeStrength()300     protected float getRightFadingEdgeStrength() {
301         return super.getRightFadingEdgeStrength();
302     }
303 
304     @Override
getBottomFadingEdgeStrength()305     protected float getBottomFadingEdgeStrength() {
306         return super.getBottomFadingEdgeStrength();
307     }
308 
309     @Override
getTopFadingEdgeStrength()310     protected float getTopFadingEdgeStrength() {
311         return super.getTopFadingEdgeStrength();
312     }
313 
314     @Override
getContextMenuInfo()315     protected ContextMenuInfo getContextMenuInfo() {
316         return super.getContextMenuInfo();
317     }
318 
319     @Override
onCreateContextMenu(ContextMenu menu)320     protected void onCreateContextMenu(ContextMenu menu) {
321         super.onCreateContextMenu(menu);
322         mCalledOnCreateContextMenu = true;
323     }
324 
hasCalledOnCreateContextMenu()325     public boolean hasCalledOnCreateContextMenu() {
326         return mCalledOnCreateContextMenu;
327     }
328 
329     @Override
onScrollChanged(int l, int t, int oldl, int oldt)330     protected void onScrollChanged(int l, int t, int oldl, int oldt) {
331         super.onScrollChanged(l, t, oldl, oldt);
332         mCalledOnScrollChanged = true;
333     }
334 
hasCalledOnScrollChanged()335     public boolean hasCalledOnScrollChanged() {
336         return mCalledOnScrollChanged;
337     }
338 
339     @Override
onSizeChanged(int w, int h, int oldw, int oldh)340     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
341         super.onSizeChanged(w, h, oldw, oldh);
342         mCalledOnSizeChanged = true;
343         mOldWidth = oldw;
344         mOldHeight = oldh;
345     }
346 
getOldWOnSizeChanged()347     public int getOldWOnSizeChanged() {
348         return mOldWidth;
349     }
350 
getOldHOnSizeChanged()351     public int getOldHOnSizeChanged() {
352         return mOldHeight;
353     }
354 
hasCalledOnSizeChanged()355     public boolean hasCalledOnSizeChanged() {
356         return mCalledOnSizeChanged;
357     }
358 
359     @Override
onLayout(boolean changed, int left, int top, int right, int bottom)360     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
361         super.onLayout(changed, left, top, right, bottom);
362         mCalledOnLayout = true;
363     }
364 
hasCalledOnLayout()365     public boolean hasCalledOnLayout() {
366         return mCalledOnLayout;
367     }
368 
369     @Override
computeScroll()370     public void computeScroll() {
371         super.computeScroll();
372         mCalledComputeScroll = true;
373     }
374 
hasCalledComputeScroll()375     public boolean hasCalledComputeScroll() {
376         return mCalledComputeScroll;
377     }
378 
379     @Override
dispatchSetSelected(boolean selected)380     protected void dispatchSetSelected(boolean selected) {
381         super.dispatchSetSelected(selected);
382     }
383 
384     @Override
dispatchSetPressed(boolean pressed)385     protected void dispatchSetPressed(boolean pressed) {
386         super.dispatchSetPressed(pressed);
387     }
388 
389     @Override
dispatchWindowFocusChanged(boolean hasFocus)390     public void dispatchWindowFocusChanged(boolean hasFocus) {
391         super.dispatchWindowFocusChanged(hasFocus);
392         mCalledDispatchWindowFocusChanged = true;
393     }
394 
hasCalledDispatchWindowFocusChanged()395     public boolean hasCalledDispatchWindowFocusChanged() {
396         return mCalledDispatchWindowFocusChanged;
397     }
398 
399     @Override
fitSystemWindows(Rect insets)400     protected boolean fitSystemWindows(Rect insets) {
401         return super.fitSystemWindows(insets);
402     }
403 
setMeasuredDimensionWrapper(int measuredWidth, int measuredHeight)404     public void setMeasuredDimensionWrapper(int measuredWidth, int measuredHeight) {
405         super.setMeasuredDimension(measuredWidth, measuredHeight);
406     }
407 
408     @Override
getHandler()409     public Handler getHandler() {
410         return super.getHandler();
411     }
412 
413     @Override
getWindowAttachCount()414     protected int getWindowAttachCount() {
415         return super.getWindowAttachCount();
416     }
417 
418     @Override
dispatchDraw(Canvas canvas)419     protected void dispatchDraw(Canvas canvas) {
420         super.dispatchDraw(canvas);
421         mCalledDispatchDraw = true;
422     }
423 
hasCalledDispatchDraw()424     public boolean hasCalledDispatchDraw() {
425         return mCalledDispatchDraw;
426     }
427 
428     @Override
dispatchUnhandledMove(View focused, int direction)429     public boolean dispatchUnhandledMove(View focused, int direction) {
430         mCalledDispatchUnhandledMove = true;
431         return super.dispatchUnhandledMove(focused, direction);
432     }
433 
hasCalledDispatchUnhandledMove()434     public boolean hasCalledDispatchUnhandledMove() {
435         return mCalledDispatchUnhandledMove;
436     }
437 
438     @Override
onWindowVisibilityChanged(int visibility)439     protected void onWindowVisibilityChanged(int visibility) {
440         super.onWindowVisibilityChanged(visibility);
441         mCalledOnWindowVisibilityChanged = true;
442     }
443 
hasCalledOnWindowVisibilityChanged()444     public boolean hasCalledOnWindowVisibilityChanged() {
445         return mCalledOnWindowVisibilityChanged;
446     }
447 
448     @Override
dispatchWindowVisibilityChanged(int visibility)449     public void dispatchWindowVisibilityChanged(int visibility) {
450         super.dispatchWindowVisibilityChanged(visibility);
451         mCalledDispatchWindowVisibilityChanged = true;
452     }
453 
hasCalledDispatchWindowVisibilityChanged()454     public boolean hasCalledDispatchWindowVisibilityChanged() {
455         return mCalledDispatchWindowVisibilityChanged;
456     }
457 
458     @Override
onWindowFocusChanged(boolean hasWindowFocus)459     public void onWindowFocusChanged(boolean hasWindowFocus) {
460         mCalledOnWindowFocusChanged = true;
461         super.onWindowFocusChanged(hasWindowFocus);
462     }
463 
hasCalledOnWindowFocusChanged()464     public boolean hasCalledOnWindowFocusChanged() {
465         return mCalledOnWindowFocusChanged;
466     }
467 
mergeDrawableStatesWrapper(int[] baseState, int[] additionalState)468     protected int[] mergeDrawableStatesWrapper(int[] baseState, int[] additionalState) {
469         return super.mergeDrawableStates(baseState, additionalState);
470     }
471 
472     @Override
onAttachedToWindow()473     protected void onAttachedToWindow() {
474         super.onAttachedToWindow();
475         mCalledOnAttachedToWindow = true;
476     }
477 
hasCalledOnAttachedToWindow()478     public boolean hasCalledOnAttachedToWindow() {
479         return mCalledOnAttachedToWindow;
480     }
481 
482     @Override
onDetachedFromWindow()483     protected void onDetachedFromWindow() {
484         super.onDetachedFromWindow();
485         mCalledOnDetachedFromWindow = true;
486     }
487 
hasCalledOnDetachedFromWindow()488     public boolean hasCalledOnDetachedFromWindow() {
489         return mCalledOnDetachedFromWindow;
490     }
491 
492     @Override
onDraw(Canvas canvas)493     protected void onDraw(Canvas canvas) {
494         super.onDraw(canvas);
495         mCalledOnDraw = true;
496     }
497 
hasCalledOnDraw()498     public boolean hasCalledOnDraw() {
499         return mCalledOnDraw;
500     }
501 
502     @Override
onFinishInflate()503     protected void onFinishInflate() {
504         super.onFinishInflate();
505         mCalledOnFinishInflate = true;
506     }
507 
hasCalledOnFinishInflate()508     public boolean hasCalledOnFinishInflate() {
509         return mCalledOnFinishInflate;
510     }
511 
512     @Override
onMeasure(int widthMeasureSpec, int heightMeasureSpec)513     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
514         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
515         mCalledOnMeasure = true;
516     }
517 
hasCalledOnMeasure()518     public boolean hasCalledOnMeasure() {
519         return mCalledOnMeasure;
520     }
521 
522     @Override
onSaveInstanceState()523     protected Parcelable onSaveInstanceState() {
524         mCalledOnSaveInstanceState = true;
525         return super.onSaveInstanceState();
526     }
527 
hasCalledOnSaveInstanceState()528     public boolean hasCalledOnSaveInstanceState() {
529         return mCalledOnSaveInstanceState;
530     }
531 
532     @Override
onRestoreInstanceState(Parcelable state)533     protected void onRestoreInstanceState(Parcelable state) {
534         super.onRestoreInstanceState(state);
535         mCalledOnRestoreInstanceState = true;
536     }
537 
hasCalledOnRestoreInstanceState()538     public boolean hasCalledOnRestoreInstanceState() {
539         return mCalledOnRestoreInstanceState;
540     }
541 
542     @Override
onSetAlpha(int alpha)543     protected boolean onSetAlpha(int alpha) {
544         mCalledOnSetAlpha = true;
545         return super.onSetAlpha(alpha);
546     }
547 
hasCalledOnSetAlpha()548     public boolean hasCalledOnSetAlpha() {
549         return mCalledOnSetAlpha;
550     }
551 
552     @Override
onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)553     protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
554         super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
555         mCalledOnFocusChanged = true;
556     }
557 
hasCalledOnFocusChanged()558     public boolean hasCalledOnFocusChanged() {
559         return mCalledOnFocusChanged;
560     }
561 
562     @Override
onCreateDrawableState(int extraSpace)563     protected int[] onCreateDrawableState(int extraSpace) {
564         mCalledOnCreateDrawableState = true;
565         return super.onCreateDrawableState(extraSpace);
566     }
567 
hasCalledOnCreateDrawableState()568     public boolean hasCalledOnCreateDrawableState() {
569         return mCalledOnCreateDrawableState;
570     }
571 
572     @Override
playSoundEffect(int soundConstant)573     public void playSoundEffect(int soundConstant) {
574         super.playSoundEffect(soundConstant);
575     }
576 
577     @Override
dispatchRestoreInstanceState(SparseArray<Parcelable> container)578     protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
579         super.dispatchRestoreInstanceState(container);
580         mCalledDispatchRestoreInstanceState = true;
581     }
582 
hasCalledDispatchRestoreInstanceState()583     public boolean hasCalledDispatchRestoreInstanceState() {
584         return mCalledDispatchRestoreInstanceState;
585     }
586 
587     @Override
dispatchSaveInstanceState(SparseArray<Parcelable> container)588     protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) {
589         super.dispatchSaveInstanceState(container);
590         mCalledDispatchSaveInstanceState = true;
591     }
592 
hasCalledDispatchSaveInstanceState()593     public boolean hasCalledDispatchSaveInstanceState() {
594         return mCalledDispatchSaveInstanceState;
595     }
596 
597     @Override
drawableStateChanged()598     protected void drawableStateChanged() {
599         super.drawableStateChanged();
600         mCalledDrawableStateChanged = true;
601     }
602 
hasCalledDrawableStateChanged()603     public boolean hasCalledDrawableStateChanged() {
604         return mCalledDrawableStateChanged;
605     }
606 
607     @Override
dispatchKeyEventPreIme(KeyEvent event)608     public boolean dispatchKeyEventPreIme(KeyEvent event) {
609         mCalledDispatchKeyEventPreIme = true;
610         return super.dispatchKeyEventPreIme(event);
611     }
612 
hasCalledDispatchKeyEventPreIme()613     public boolean hasCalledDispatchKeyEventPreIme() {
614         return mCalledDispatchKeyEventPreIme;
615     }
616 
617     @Override
onKeyPreIme(int keyCode, KeyEvent event)618     public boolean onKeyPreIme(int keyCode, KeyEvent event) {
619         mCalledOnKeyPreIme = true;
620         return super.onKeyPreIme(keyCode, event);
621     }
622 
hasCalledOnKeyPreIme()623     public boolean hasCalledOnKeyPreIme() {
624         return mCalledOnKeyPreIme;
625     }
626 
627     @Override
onResolvePointerIcon(MotionEvent event, int pointerIndex)628     public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
629         mCalledOnResolvePointerIcon = true;
630         return super.onResolvePointerIcon(event, pointerIndex);
631     }
632 
hasCalledOnResolvePointerIcon()633     public boolean hasCalledOnResolvePointerIcon() {
634         return mCalledOnResolvePointerIcon;
635     }
636 
637     @Override
onVisibilityAggregated(boolean isVisible)638     public void onVisibilityAggregated(boolean isVisible) {
639         super.onVisibilityAggregated(isVisible);
640         mCalledOnVisibilityAggregated = true;
641         mLastAggregatedVisibility = isVisible;
642     }
643 
644     @Override
requestFocus(int direction, Rect previouslyFocusedRect)645     public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
646         mCalledRequestFocus = true;
647         return super.requestFocus(direction, previouslyFocusedRect);
648     }
649 
hasCalledOnVisibilityAggregated()650     public boolean hasCalledOnVisibilityAggregated() {
651         return mCalledOnVisibilityAggregated;
652     }
653 
hasCalledRequestFocus()654     public boolean hasCalledRequestFocus() {
655         return mCalledRequestFocus;
656     }
657 
getLastAggregatedVisibility()658     public boolean getLastAggregatedVisibility() {
659         return mLastAggregatedVisibility;
660     }
661 
hasCalledPerformHapticFeedback()662     public boolean hasCalledPerformHapticFeedback() {
663         return mCalledPerformHapticFeedback;
664     }
665 
666     @Override
performHapticFeedback(int feedbackConstant)667     public boolean performHapticFeedback(int feedbackConstant) {
668         mCalledPerformHapticFeedback = true;
669         return super.performHapticFeedback(feedbackConstant);
670     }
671 
reset()672     public void reset() {
673         mCalledOnCreateContextMenu = false;
674 
675         mCalledOnAnimationStart = false;
676         mCalledOnAnimationEnd = false;
677         mCalledOnAttachedToWindow = false;
678         mCalledOnDetachedFromWindow = false;
679         mCalledOnCreateDrawableState = false;
680         mCalledDrawableStateChanged = false;
681         mCalledOnDraw = false;
682         mCalledDispatchDraw = false;
683         mCalledOnFinishInflate = false;
684         mCalledOnFocusChanged = false;
685         mCalledOnKeyDown = false;
686         mCalledOnKeyUp = false;
687         mCalledOnKeyMultiple = false;
688         mCalledOnKeyShortcut = false;
689         mCalledOnLayout = false;
690         mCalledOnMeasure = false;
691         mCalledOnSizeChanged = false;
692         mCalledOnSetAlpha = false;
693         mCalledOnTrackballEvent = false;
694         mCalledOnHoverEvent = false;
695         mCalledOnWindowFocusChanged = false;
696         mCalledDispatchRestoreInstanceState = false;
697         mCalledDispatchSaveInstanceState = false;
698         mCalledOnRestoreInstanceState = false;
699         mCalledOnSaveInstanceState = false;
700         mCalledDispatchUnhandledMove = false;
701         mCalledDispatchWindowFocusChanged = false;
702         mCalledDispatchWindowVisibilityChanged = false;
703         mCalledOnWindowVisibilityChanged = false;
704         mCalledOnScrollChanged = false;
705         mCalledInvalidate = false;
706         mCalledComputeScroll = false;
707         mCalledDispatchKeyEventPreIme = false;
708         mCalledOnKeyPreIme = false;
709         mCalledOnResolvePointerIcon = false;
710         mCalledOnVisibilityAggregated = false;
711         mCalledRequestFocus = false;
712         mCalledPerformHapticFeedback = false;
713 
714         mOldWidth = -1;
715         mOldHeight = -1;
716         mLastAggregatedVisibility = false;
717 
718         while (!mTouchEvents.isEmpty()) {
719             mTouchEvents.poll().recycle();
720         }
721     }
722 }
723