OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
6 | 6 |
7 import static org.junit.Assert.assertFalse; | 7 import static org.junit.Assert.assertFalse; |
8 import static org.junit.Assert.assertNotNull; | 8 import static org.junit.Assert.assertNotNull; |
9 import static org.junit.Assert.assertNull; | 9 import static org.junit.Assert.assertNull; |
10 import static org.junit.Assert.assertTrue; | 10 import static org.junit.Assert.assertTrue; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 mEditorInfo = new EditorInfo(); | 128 mEditorInfo = new EditorInfo(); |
129 mUiHandler = new Handler(); | 129 mUiHandler = new Handler(); |
130 | 130 |
131 mContext = Mockito.mock(Context.class); | 131 mContext = Mockito.mock(Context.class); |
132 mContainerView = Mockito.mock(View.class); | 132 mContainerView = Mockito.mock(View.class); |
133 mImeAdapter = Mockito.mock(ImeAdapter.class); | 133 mImeAdapter = Mockito.mock(ImeAdapter.class); |
134 mInputMethodManager = Mockito.mock(InputMethodManager.class); | 134 mInputMethodManager = Mockito.mock(InputMethodManager.class); |
135 | 135 |
136 mFactory = new TestFactory(new InputMethodManagerWrapper(mContext)); | 136 mFactory = new TestFactory(new InputMethodManagerWrapper(mContext)); |
137 // Needed to access handler's looper even before we initialize handler. | |
138 mFactory.createHandler(); | |
139 mFactory.onWindowFocusChanged(true); | 137 mFactory.onWindowFocusChanged(true); |
140 | 138 |
141 when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)) | 139 when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)) |
142 .thenReturn(mInputMethodManager); | 140 .thenReturn(mInputMethodManager); |
143 when(mContainerView.getContext()).thenReturn(mContext); | 141 when(mContainerView.getContext()).thenReturn(mContext); |
144 when(mContainerView.getHandler()).thenReturn(mUiHandler); | 142 when(mContainerView.getHandler()).thenReturn(mUiHandler); |
145 when(mContainerView.hasFocus()).thenReturn(true); | 143 when(mContainerView.hasFocus()).thenReturn(true); |
146 when(mContainerView.hasWindowFocus()).thenReturn(true); | 144 when(mContainerView.hasWindowFocus()).thenReturn(true); |
147 | 145 |
148 mProxyView = Mockito.mock(ThreadedInputConnectionProxyView.class); | 146 mProxyView = Mockito.mock(ThreadedInputConnectionProxyView.class); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 runOneUiTask(); | 283 runOneUiTask(); |
286 mInOrder.verify(mInputMethodManager).isActive(mProxyView); | 284 mInOrder.verify(mInputMethodManager).isActive(mProxyView); |
287 | 285 |
288 mInOrder.verifyNoMoreInteractions(); | 286 mInOrder.verifyNoMoreInteractions(); |
289 // Failed, but no logging because check has been invalidated. | 287 // Failed, but no logging because check has been invalidated. |
290 assertNull(mInputConnection); | 288 assertNull(mInputConnection); |
291 assertFalse(mFactory.hasSucceeded()); | 289 assertFalse(mFactory.hasSucceeded()); |
292 assertFalse(mFactory.hasFailed()); | 290 assertFalse(mFactory.hasFailed()); |
293 } | 291 } |
294 } | 292 } |
OLD | NEW |