Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java

Issue 2785543003: Revert of Let ImeAdapterAndroid have the same lifecycle as its Java peer (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.test.util.Feature; 16 import org.chromium.base.test.util.Feature;
17 import org.chromium.content.browser.input.ImeAdapter; 17 import org.chromium.content.browser.input.ImeAdapter;
18 import org.chromium.content.browser.input.TestImeAdapterDelegate; 18 import org.chromium.content.browser.input.TestImeAdapterDelegate;
19 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; 19 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper;
20 import org.chromium.content_public.browser.WebContents;
21 import org.chromium.content_shell_apk.ContentShellTestBase; 20 import org.chromium.content_shell_apk.ContentShellTestBase;
22 21
23 import java.util.concurrent.Callable;
24 import java.util.concurrent.FutureTask;
25
26 /** 22 /**
27 * Tests for PopupZoomer. 23 * Tests for PopupZoomer.
28 */ 24 */
29 public class PopupZoomerTest extends ContentShellTestBase { 25 public class PopupZoomerTest extends ContentShellTestBase {
30 private CustomCanvasPopupZoomer mPopupZoomer; 26 private CustomCanvasPopupZoomer mPopupZoomer;
31 private ContentViewCore mContentViewCore; 27 private ContentViewCore mContentViewCore;
32 28
33 private static class CustomCanvasPopupZoomer extends PopupZoomer { 29 private static class CustomCanvasPopupZoomer extends PopupZoomer {
34 Canvas mCanvas; 30 Canvas mCanvas;
35 long mPendingDraws = 0; 31 long mPendingDraws = 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 MotionEvent.obtain(downEvent, downEvent, MotionEvent.ACTION_DOWN , x, y, 0)); 73 MotionEvent.obtain(downEvent, downEvent, MotionEvent.ACTION_DOWN , x, y, 0));
78 view.onTouchEvent( 74 view.onTouchEvent(
79 MotionEvent.obtain(downEvent, downEvent + 10, MotionEvent.ACTION _UP, x, y, 0)); 75 MotionEvent.obtain(downEvent, downEvent + 10, MotionEvent.ACTION _UP, x, y, 0));
80 } 76 }
81 77
82 @Override 78 @Override
83 public void setUp() throws Exception { 79 public void setUp() throws Exception {
84 super.setUp(); 80 super.setUp();
85 mPopupZoomer = createPopupZoomerForTest(getInstrumentation().getTargetCo ntext()); 81 mPopupZoomer = createPopupZoomerForTest(getInstrumentation().getTargetCo ntext());
86 mContentViewCore = new ContentViewCore(getActivity(), ""); 82 mContentViewCore = new ContentViewCore(getActivity(), "");
87 83 ImeAdapter imeAdapter = new ImeAdapter(new TestInputMethodManagerWrapper (mContentViewCore),
88 // Use CVC from shell base for necessary but uninitialized parts, such a s container view 84 new TestImeAdapterDelegate(getContentViewCore().getContainerView ()));
89 // or web contents. This still works since they are checked only the ini t step, 85 mContentViewCore.setSelectionPopupControllerForTesting(
90 // not actually used in the tests themselves. 86 new SelectionPopupController(getActivity(), null, null, null,
91 ImeAdapter imeAdapter = createImeAdapterOnUiThread(getContentViewCore(). getWebContents()); 87 mContentViewCore.getRenderCoordinates(), imeAdapter));
92 mContentViewCore.setSelectionPopupControllerForTesting(new SelectionPopu pController(
93 getActivity(), null, null, null, mContentViewCore.getRenderCoord inates()));
94 mContentViewCore.setPopupZoomerForTest(mPopupZoomer); 88 mContentViewCore.setPopupZoomerForTest(mPopupZoomer);
95 mContentViewCore.setImeAdapterForTest(imeAdapter); 89 mContentViewCore.setImeAdapterForTest(imeAdapter);
96 } 90 }
97 91
98 private ImeAdapter createImeAdapterOnUiThread(final WebContents webContents) throws Exception {
99 // WebContents should be handled on UI thread.
100 FutureTask<ImeAdapter> task = new FutureTask<>(new Callable<ImeAdapter>( ) {
101 @Override
102 public ImeAdapter call() {
103 return new ImeAdapter(webContents,
104 new TestInputMethodManagerWrapper(mContentViewCore),
105 new TestImeAdapterDelegate(getContentViewCore().getConta inerView()));
106 }
107
108 });
109 getInstrumentation().runOnMainSync(task);
110 return task.get();
111 }
112
113 @SmallTest 92 @SmallTest
114 @Feature({"Navigation"}) 93 @Feature({"Navigation"})
115 public void testDefaultCreateState() throws Exception { 94 public void testDefaultCreateState() throws Exception {
116 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); 95 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility());
117 assertFalse(mPopupZoomer.isShowing()); 96 assertFalse(mPopupZoomer.isShowing());
118 } 97 }
119 98
120 @SmallTest 99 @SmallTest
121 @Feature({"Navigation"}) 100 @Feature({"Navigation"})
122 public void testShowWithoutBitmap() throws Exception { 101 public void testShowWithoutBitmap() throws Exception {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 mContentViewCore.onFocusChanged(false, true); 204 mContentViewCore.onFocusChanged(false, true);
226 205
227 // Wait for the hide animation to finish. 206 // Wait for the hide animation to finish.
228 mPopupZoomer.finishPendingDraws(); 207 mPopupZoomer.finishPendingDraws();
229 208
230 // Now that another view has been focused, the view should be invisible. 209 // Now that another view has been focused, the view should be invisible.
231 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility()); 210 assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility());
232 assertFalse(mPopupZoomer.isShowing()); 211 assertFalse(mPopupZoomer.isShowing());
233 } 212 }
234 } 213 }
OLDNEW
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698