summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorr.ghatage@samsung.com <r.ghatage@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-22 16:36:10 +0000
committerr.ghatage@samsung.com <r.ghatage@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-22 16:38:28 +0000
commite348fa0f007d2834b4501dba203e0ce1cd4df698 (patch)
tree220e3bbb516542573ccb54df40c6d9b633d21cf3
parentc5e080b8e02abdf1d04fffd191a139c641520f8f (diff)
downloadchromium_src-e348fa0f007d2834b4501dba203e0ce1cd4df698.zip
chromium_src-e348fa0f007d2834b4501dba203e0ce1cd4df698.tar.gz
chromium_src-e348fa0f007d2834b4501dba203e0ce1cd4df698.tar.bz2
Hide PopupZoomer when the container view or window loses focus
Resubmitting the patch https://src.chromium.org/viewvc/chrome?view=rev&revision=291365 which was reverted as it caused a FindBug failure due to not calling the Super method in the setUp method in PopupZoomerTest class. Adding call to to super.setUp() to fix the warning. BUG=405477, 406272 Review URL: https://codereview.chromium.org/497753003 Cr-Commit-Position: refs/heads/master@{#291430} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291430 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java11
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java35
2 files changed, 40 insertions, 6 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 51546ed..295bb67 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -521,9 +521,7 @@ public class ContentViewCore
new ImeAdapter.ImeAdapterDelegate() {
@Override
public void onImeEvent() {
- if (mPopupZoomer.isShowing()) {
- mPopupZoomer.hide(true);
- }
+ mPopupZoomer.hide(true);
getContentViewClient().onImeEvent();
hideTextHandles();
}
@@ -754,6 +752,11 @@ public class ContentViewCore
mPopupZoomer.setOnTapListener(listener);
}
+ @VisibleForTesting
+ public void setPopupZoomerForTest(PopupZoomer popupZoomer) {
+ mPopupZoomer = popupZoomer;
+ }
+
/**
* Destroy the internal state of the ContentView. This method may only be
* called after the ContentView has been removed from the view system. No
@@ -1434,6 +1437,7 @@ public class ContentViewCore
hidePastePopup();
hideSelectPopup();
hideTextHandles();
+ mPopupZoomer.hide(false);
}
public void hideSelectActionBar() {
@@ -1627,6 +1631,7 @@ public class ContentViewCore
cancelRequestToScrollFocusedEditableNodeIntoView();
hidePastePopup();
hideTextHandles();
+ mPopupZoomer.hide(false);
}
if (mNativeContentViewCore != 0) nativeSetFocus(mNativeContentViewCore, gainFocus);
}
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 946a0c1..8ecc52e 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());
+ }
}