| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 private class TestFactory extends ThreadedInputConnectionFactory { | 52 private class TestFactory extends ThreadedInputConnectionFactory { |
| 53 | 53 |
| 54 private boolean mSucceeded; | 54 private boolean mSucceeded; |
| 55 private boolean mFailed; | 55 private boolean mFailed; |
| 56 | 56 |
| 57 TestFactory(InputMethodManagerWrapper inputMethodManagerWrapper) { | 57 TestFactory(InputMethodManagerWrapper inputMethodManagerWrapper) { |
| 58 super(inputMethodManagerWrapper); | 58 super(inputMethodManagerWrapper); |
| 59 } | 59 } |
| 60 | 60 |
| 61 @Override | 61 @Override |
| 62 protected Handler createHandler() { | |
| 63 mImeHandler = super.createHandler(); | |
| 64 mImeShadowLooper = (ShadowLooper) ShadowExtractor.extract(mImeHandle
r.getLooper()); | |
| 65 return mImeHandler; | |
| 66 } | |
| 67 | |
| 68 @Override | |
| 69 protected ThreadedInputConnectionProxyView createProxyView(Handler handl
er, | 62 protected ThreadedInputConnectionProxyView createProxyView(Handler handl
er, |
| 70 View containerView) { | 63 View containerView) { |
| 71 return mProxyView; | 64 return mProxyView; |
| 72 } | 65 } |
| 73 | 66 |
| 74 @Override | 67 @Override |
| 75 protected InputMethodUma createInputMethodUma() { | 68 protected InputMethodUma createInputMethodUma() { |
| 76 return null; | 69 return null; |
| 77 } | 70 } |
| 78 | 71 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 mEditorInfo = new EditorInfo(); | 121 mEditorInfo = new EditorInfo(); |
| 129 mUiHandler = new Handler(); | 122 mUiHandler = new Handler(); |
| 130 | 123 |
| 131 mContext = Mockito.mock(Context.class); | 124 mContext = Mockito.mock(Context.class); |
| 132 mContainerView = Mockito.mock(View.class); | 125 mContainerView = Mockito.mock(View.class); |
| 133 mImeAdapter = Mockito.mock(ImeAdapter.class); | 126 mImeAdapter = Mockito.mock(ImeAdapter.class); |
| 134 mInputMethodManager = Mockito.mock(InputMethodManager.class); | 127 mInputMethodManager = Mockito.mock(InputMethodManager.class); |
| 135 | 128 |
| 136 mFactory = new TestFactory(new InputMethodManagerWrapper(mContext)); | 129 mFactory = new TestFactory(new InputMethodManagerWrapper(mContext)); |
| 137 mFactory.onWindowFocusChanged(true); | 130 mFactory.onWindowFocusChanged(true); |
| 131 mImeHandler = mFactory.getHandler(); |
| 132 mImeShadowLooper = (ShadowLooper) ShadowExtractor.extract(mImeHandler.ge
tLooper()); |
| 138 | 133 |
| 139 when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)) | 134 when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)) |
| 140 .thenReturn(mInputMethodManager); | 135 .thenReturn(mInputMethodManager); |
| 141 when(mContainerView.getContext()).thenReturn(mContext); | 136 when(mContainerView.getContext()).thenReturn(mContext); |
| 142 when(mContainerView.getHandler()).thenReturn(mUiHandler); | 137 when(mContainerView.getHandler()).thenReturn(mUiHandler); |
| 143 when(mContainerView.hasFocus()).thenReturn(true); | 138 when(mContainerView.hasFocus()).thenReturn(true); |
| 144 when(mContainerView.hasWindowFocus()).thenReturn(true); | 139 when(mContainerView.hasWindowFocus()).thenReturn(true); |
| 145 | 140 |
| 146 mProxyView = Mockito.mock(ThreadedInputConnectionProxyView.class); | 141 mProxyView = Mockito.mock(ThreadedInputConnectionProxyView.class); |
| 147 when(mProxyView.getContext()).thenReturn(mContext); | 142 when(mProxyView.getContext()).thenReturn(mContext); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 runOneUiTask(); | 278 runOneUiTask(); |
| 284 mInOrder.verify(mInputMethodManager).isActive(mProxyView); | 279 mInOrder.verify(mInputMethodManager).isActive(mProxyView); |
| 285 | 280 |
| 286 mInOrder.verifyNoMoreInteractions(); | 281 mInOrder.verifyNoMoreInteractions(); |
| 287 // Failed, but no logging because check has been invalidated. | 282 // Failed, but no logging because check has been invalidated. |
| 288 assertNull(mInputConnection); | 283 assertNull(mInputConnection); |
| 289 assertFalse(mFactory.hasSucceeded()); | 284 assertFalse(mFactory.hasSucceeded()); |
| 290 assertFalse(mFactory.hasFailed()); | 285 assertFalse(mFactory.hasFailed()); |
| 291 } | 286 } |
| 292 } | 287 } |
| OLD | NEW |