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(); |
137 mFactory.onWindowFocusChanged(true); | 139 mFactory.onWindowFocusChanged(true); |
138 | 140 |
139 when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)) | 141 when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)) |
140 .thenReturn(mInputMethodManager); | 142 .thenReturn(mInputMethodManager); |
141 when(mContainerView.getContext()).thenReturn(mContext); | 143 when(mContainerView.getContext()).thenReturn(mContext); |
142 when(mContainerView.getHandler()).thenReturn(mUiHandler); | 144 when(mContainerView.getHandler()).thenReturn(mUiHandler); |
143 when(mContainerView.hasFocus()).thenReturn(true); | 145 when(mContainerView.hasFocus()).thenReturn(true); |
144 when(mContainerView.hasWindowFocus()).thenReturn(true); | 146 when(mContainerView.hasWindowFocus()).thenReturn(true); |
145 | 147 |
146 mProxyView = Mockito.mock(ThreadedInputConnectionProxyView.class); | 148 mProxyView = Mockito.mock(ThreadedInputConnectionProxyView.class); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 runOneUiTask(); | 285 runOneUiTask(); |
284 mInOrder.verify(mInputMethodManager).isActive(mProxyView); | 286 mInOrder.verify(mInputMethodManager).isActive(mProxyView); |
285 | 287 |
286 mInOrder.verifyNoMoreInteractions(); | 288 mInOrder.verifyNoMoreInteractions(); |
287 // Failed, but no logging because check has been invalidated. | 289 // Failed, but no logging because check has been invalidated. |
288 assertNull(mInputConnection); | 290 assertNull(mInputConnection); |
289 assertFalse(mFactory.hasSucceeded()); | 291 assertFalse(mFactory.hasSucceeded()); |
290 assertFalse(mFactory.hasFailed()); | 292 assertFalse(mFactory.hasFailed()); |
291 } | 293 } |
292 } | 294 } |
OLD | NEW |