| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
| 10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
| 11 import android.os.SystemClock; | 11 import android.os.SystemClock; |
| 12 import android.support.test.filters.SmallTest; | 12 import android.support.test.filters.SmallTest; |
| 13 import android.view.MotionEvent; | 13 import android.view.MotionEvent; |
| 14 import android.view.View; | 14 import android.view.View; |
| 15 | 15 |
| 16 import org.chromium.base.ThreadUtils; |
| 16 import org.chromium.base.test.util.Feature; | 17 import org.chromium.base.test.util.Feature; |
| 17 import org.chromium.content.browser.input.ImeAdapter; | 18 import org.chromium.content.browser.input.ImeAdapter; |
| 18 import org.chromium.content.browser.input.TestImeAdapterDelegate; | 19 import org.chromium.content.browser.input.TestImeAdapterDelegate; |
| 19 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; | 20 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; |
| 20 import org.chromium.content_shell_apk.ContentShellTestBase; | 21 import org.chromium.content_shell_apk.ContentShellTestBase; |
| 21 | 22 |
| 22 /** | 23 /** |
| 23 * Tests for PopupZoomer. | 24 * Tests for PopupZoomer. |
| 24 */ | 25 */ |
| 25 public class PopupZoomerTest extends ContentShellTestBase { | 26 public class PopupZoomerTest extends ContentShellTestBase { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 final long downEvent = SystemClock.uptimeMillis(); | 72 final long downEvent = SystemClock.uptimeMillis(); |
| 72 view.onTouchEvent( | 73 view.onTouchEvent( |
| 73 MotionEvent.obtain(downEvent, downEvent, MotionEvent.ACTION_DOWN
, x, y, 0)); | 74 MotionEvent.obtain(downEvent, downEvent, MotionEvent.ACTION_DOWN
, x, y, 0)); |
| 74 view.onTouchEvent( | 75 view.onTouchEvent( |
| 75 MotionEvent.obtain(downEvent, downEvent + 10, MotionEvent.ACTION
_UP, x, y, 0)); | 76 MotionEvent.obtain(downEvent, downEvent + 10, MotionEvent.ACTION
_UP, x, y, 0)); |
| 76 } | 77 } |
| 77 | 78 |
| 78 @Override | 79 @Override |
| 79 public void setUp() throws Exception { | 80 public void setUp() throws Exception { |
| 80 super.setUp(); | 81 super.setUp(); |
| 81 mPopupZoomer = createPopupZoomerForTest(getInstrumentation().getTargetCo
ntext()); | 82 |
| 82 mContentViewCore = new ContentViewCore(getActivity(), ""); | 83 final Context context = getActivity(); |
| 83 ImeAdapter imeAdapter = new ImeAdapter(new TestInputMethodManagerWrapper
(mContentViewCore), | 84 |
| 84 new TestImeAdapterDelegate(getContentViewCore().getContainerView
())); | 85 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 85 mContentViewCore.setSelectionPopupControllerForTesting( | 86 @Override |
| 86 new SelectionPopupController(getActivity(), null, null, null, | 87 public void run() { |
| 87 mContentViewCore.getRenderCoordinates(), imeAdapter)); | 88 mPopupZoomer = createPopupZoomerForTest(getInstrumentation().get
TargetContext()); |
| 88 mContentViewCore.setPopupZoomerForTest(mPopupZoomer); | 89 mContentViewCore = new ContentViewCore(context, ""); |
| 89 mContentViewCore.setImeAdapterForTest(imeAdapter); | 90 ImeAdapter imeAdapter = new ImeAdapter( |
| 91 new TestInputMethodManagerWrapper(mContentViewCore), |
| 92 new TestImeAdapterDelegate(getContentViewCore().getConta
inerView())); |
| 93 mContentViewCore.setSelectionPopupControllerForTesting( |
| 94 new SelectionPopupController(context, null, null, null, |
| 95 mContentViewCore.getRenderCoordinates(), imeAdap
ter)); |
| 96 mContentViewCore.setPopupZoomerForTest(mPopupZoomer); |
| 97 mContentViewCore.setImeAdapterForTest(imeAdapter); |
| 98 } |
| 99 }); |
| 90 } | 100 } |
| 91 | 101 |
| 92 @SmallTest | 102 @SmallTest |
| 93 @Feature({"Navigation"}) | 103 @Feature({"Navigation"}) |
| 94 public void testDefaultCreateState() throws Exception { | 104 public void testDefaultCreateState() throws Exception { |
| 95 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); | 105 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); |
| 96 assertFalse(mPopupZoomer.isShowing()); | 106 assertFalse(mPopupZoomer.isShowing()); |
| 97 } | 107 } |
| 98 | 108 |
| 99 @SmallTest | 109 @SmallTest |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 mContentViewCore.onFocusChanged(false, true); | 214 mContentViewCore.onFocusChanged(false, true); |
| 205 | 215 |
| 206 // Wait for the hide animation to finish. | 216 // Wait for the hide animation to finish. |
| 207 mPopupZoomer.finishPendingDraws(); | 217 mPopupZoomer.finishPendingDraws(); |
| 208 | 218 |
| 209 // Now that another view has been focused, the view should be invisible. | 219 // Now that another view has been focused, the view should be invisible. |
| 210 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); | 220 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); |
| 211 assertFalse(mPopupZoomer.isShowing()); | 221 assertFalse(mPopupZoomer.isShowing()); |
| 212 } | 222 } |
| 213 } | 223 } |
| OLD | NEW |