96 {
97 final ViewTreeObserver viewTreeObserver = mock(ViewTreeObserver.class);
98 when(viewTreeObserver.isAlive()).thenReturn(true);
99
100 final PlatformViewWrapper view =
101 new PlatformViewWrapper(ctx) {
102 @Override
103 public ViewTreeObserver getViewTreeObserver() {
104 return viewTreeObserver;
105 }
106
107 @Override
108 public boolean hasFocus() {
109 return false;
110 }
111 };
112
113 final OnFocusChangeListener focusListener = mock(OnFocusChangeListener.class);
114 view.setOnDescendantFocusChangeListener(focusListener);
115
116 final ArgumentCaptor<ViewTreeObserver.OnGlobalFocusChangeListener> focusListenerCaptor =
117 ArgumentCaptor.forClass(ViewTreeObserver.OnGlobalFocusChangeListener.class);
118 verify(viewTreeObserver).addOnGlobalFocusChangeListener(focusListenerCaptor.capture());
119
120 focusListenerCaptor.getValue().onGlobalFocusChanged(null, null);
121 verify(focusListener).onFocusChange(view, false);
122 }