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

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

Issue 497753003: Hide PopupZoomer when the container view or window loses focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java
index 946a0c11c202bcde6e4c31beea53cc5fcab0978d..8ecc52edca7a2a1bff3f8100478228528ea93cf0 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java
@@ -9,18 +9,19 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.SystemClock;
-import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.MotionEvent;
import android.view.View;
import org.chromium.base.test.util.Feature;
+import org.chromium.content_shell_apk.ContentShellTestBase;
/**
* Tests for PopupZoomer.
*/
-public class PopupZoomerTest extends InstrumentationTestCase {
+public class PopupZoomerTest extends ContentShellTestBase {
private CustomCanvasPopupZoomer mPopupZoomer;
+ private ContentViewCore mContentViewCore;
private static class CustomCanvasPopupZoomer extends PopupZoomer {
Canvas mCanvas;
@@ -72,8 +73,11 @@ public class PopupZoomerTest extends InstrumentationTestCase {
}
@Override
- public void setUp() {
+ public void setUp() throws Exception {
+ super.setUp();
mPopupZoomer = createPopupZoomerForTest(getInstrumentation().getTargetContext());
+ mContentViewCore = new ContentViewCore(getActivity());
+ mContentViewCore.setPopupZoomerForTest(mPopupZoomer);
}
@SmallTest
@@ -172,4 +176,29 @@ public class PopupZoomerTest extends InstrumentationTestCase {
assertEquals(View.VISIBLE, mPopupZoomer.getVisibility());
assertTrue(mPopupZoomer.isShowing());
}
+
+ @SmallTest
+ @Feature({"Navigation"})
+ public void testHidePopupOnLosingFocus() throws Exception {
+ mPopupZoomer.setBitmap(
+ Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8));
+ mPopupZoomer.show(new Rect(0, 0, 5, 5));
+
+ // Wait for the animation to finish.
+ mPopupZoomer.finishPendingDraws();
+
+ // The view should be visible.
+ assertEquals(View.VISIBLE, mPopupZoomer.getVisibility());
+ assertTrue(mPopupZoomer.isShowing());
+
+ // Simulate losing the focus.
+ mContentViewCore.onFocusChanged(false);
+
+ // Wait for the hide animation to finish.
+ mPopupZoomer.finishPendingDraws();
+
+ // Now that another view has been focused, the view should be invisible.
+ assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility());
+ assertFalse(mPopupZoomer.isShowing());
+ }
}
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698