Commit e4abc5e7 authored by finnur@chromium.org's avatar finnur@chromium.org

Revert 291359 "Hide PopupZoomer when the container view or windo..."

It caused a failure on Android bot:

********************************************************************************
New warnings.
Please fix, or perhaps add to /mnt/data/b/build/slave/Android_Arm64_Builder__dbg_/build/src/build/android/findbugs_filter/findbugs_known_bugs.txt
--------------------------------------------------------------------------------
M C IJU: TestCase org.chromium.content.browser.PopupZoomerTest defines setUp that doesn't call super.setUp()  At PopupZoomerTest.java
--------------------------------------------------------------------------------



Original patch comments:

> Hide PopupZoomer when the container view or window loses focus
> 
> Currently there is a method which hides all the popups but call to 
> hide PopupZoomer is missing. Added the call to hide PopupZoomer inside 
> hidePopups and hiding the zoomer when the view loses focus or the 
> window loses focus. Also added unit test code.
> 
> BUG=405477
> 
> Review URL: https://codereview.chromium.org/470193005

TBR=r.ghatage@samsung.com

Review URL: https://codereview.chromium.org/497693002

Cr-Commit-Position: refs/heads/master@{#291365}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291365 0039d316-1c4b-4281-b951-d872f2087c98
parent c9d98808
...@@ -521,7 +521,9 @@ public class ContentViewCore ...@@ -521,7 +521,9 @@ public class ContentViewCore
new ImeAdapter.ImeAdapterDelegate() { new ImeAdapter.ImeAdapterDelegate() {
@Override @Override
public void onImeEvent() { public void onImeEvent() {
mPopupZoomer.hide(true); if (mPopupZoomer.isShowing()) {
mPopupZoomer.hide(true);
}
getContentViewClient().onImeEvent(); getContentViewClient().onImeEvent();
hideTextHandles(); hideTextHandles();
} }
...@@ -752,11 +754,6 @@ public class ContentViewCore ...@@ -752,11 +754,6 @@ public class ContentViewCore
mPopupZoomer.setOnTapListener(listener); mPopupZoomer.setOnTapListener(listener);
} }
@VisibleForTesting
public void setPopupZoomerForTest(PopupZoomer popupZoomer) {
mPopupZoomer = popupZoomer;
}
/** /**
* Destroy the internal state of the ContentView. This method may only be * Destroy the internal state of the ContentView. This method may only be
* called after the ContentView has been removed from the view system. No * called after the ContentView has been removed from the view system. No
...@@ -1433,7 +1430,6 @@ public class ContentViewCore ...@@ -1433,7 +1430,6 @@ public class ContentViewCore
hidePastePopup(); hidePastePopup();
hideSelectPopup(); hideSelectPopup();
hideTextHandles(); hideTextHandles();
mPopupZoomer.hide(false);
} }
public void hideSelectActionBar() { public void hideSelectActionBar() {
...@@ -1627,7 +1623,6 @@ public class ContentViewCore ...@@ -1627,7 +1623,6 @@ public class ContentViewCore
cancelRequestToScrollFocusedEditableNodeIntoView(); cancelRequestToScrollFocusedEditableNodeIntoView();
hidePastePopup(); hidePastePopup();
hideTextHandles(); hideTextHandles();
mPopupZoomer.hide(false);
} }
if (mNativeContentViewCore != 0) nativeSetFocus(mNativeContentViewCore, gainFocus); if (mNativeContentViewCore != 0) nativeSetFocus(mNativeContentViewCore, gainFocus);
} }
......
...@@ -9,19 +9,18 @@ import android.graphics.Bitmap; ...@@ -9,19 +9,18 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.SystemClock; import android.os.SystemClock;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content_shell_apk.ContentShellTestBase;
/** /**
* Tests for PopupZoomer. * Tests for PopupZoomer.
*/ */
public class PopupZoomerTest extends ContentShellTestBase { public class PopupZoomerTest extends InstrumentationTestCase {
private CustomCanvasPopupZoomer mPopupZoomer; private CustomCanvasPopupZoomer mPopupZoomer;
private ContentViewCore mContentViewCore;
private static class CustomCanvasPopupZoomer extends PopupZoomer { private static class CustomCanvasPopupZoomer extends PopupZoomer {
Canvas mCanvas; Canvas mCanvas;
...@@ -75,8 +74,6 @@ public class PopupZoomerTest extends ContentShellTestBase { ...@@ -75,8 +74,6 @@ public class PopupZoomerTest extends ContentShellTestBase {
@Override @Override
public void setUp() { public void setUp() {
mPopupZoomer = createPopupZoomerForTest(getInstrumentation().getTargetContext()); mPopupZoomer = createPopupZoomerForTest(getInstrumentation().getTargetContext());
mContentViewCore = new ContentViewCore(getActivity());
mContentViewCore.setPopupZoomerForTest(mPopupZoomer);
} }
@SmallTest @SmallTest
...@@ -175,29 +172,4 @@ public class PopupZoomerTest extends ContentShellTestBase { ...@@ -175,29 +172,4 @@ public class PopupZoomerTest extends ContentShellTestBase {
assertEquals(View.VISIBLE, mPopupZoomer.getVisibility()); assertEquals(View.VISIBLE, mPopupZoomer.getVisibility());
assertTrue(mPopupZoomer.isShowing()); 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());
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment