Commit d16b7adb authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

CVC.isSelectPopupVisibleForTesting

This CL replaces |getSelectPopupForTesting| with the one that simply
returns its visibility (showing or hidden), which is enough for
testing purposes. It helps CVC not return/expose non-public class
when moved to content_public https://crrev.com/c/900884

Bug: 807155
Change-Id: I8dbdace17ace9068ee7807dfa1abf7ac85f4c357
Reviewed-on: https://chromium-review.googlesource.com/902982Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534829}
parent 1e290a05
...@@ -799,10 +799,9 @@ public class CustomTabActivityTest { ...@@ -799,10 +799,9 @@ public class CustomTabActivityTest {
@Override @Override
public boolean isSatisfied() { public boolean isSatisfied() {
return mCustomTabActivityTestRule.getActivity() return mCustomTabActivityTestRule.getActivity()
.getActivityTab() .getActivityTab()
.getContentViewCore() .getContentViewCore()
.getSelectPopupForTest() .isSelectPopupVisibleForTest();
!= null;
} }
}); });
final ChromeActivity newActivity = reparentAndVerifyTab(); final ChromeActivity newActivity = reparentAndVerifyTab();
...@@ -810,9 +809,8 @@ public class CustomTabActivityTest { ...@@ -810,9 +809,8 @@ public class CustomTabActivityTest {
@Override @Override
public boolean isSatisfied() { public boolean isSatisfied() {
Tab currentTab = newActivity.getActivityTab(); Tab currentTab = newActivity.getActivityTab();
return currentTab != null return currentTab != null && currentTab.getContentViewCore() != null
&& currentTab.getContentViewCore() != null && !currentTab.getContentViewCore().isSelectPopupVisibleForTest();
&& currentTab.getContentViewCore().getSelectPopupForTest() == null;
} }
}); });
} }
......
...@@ -65,7 +65,7 @@ public class SelectPopupOtherContentViewTest { ...@@ -65,7 +65,7 @@ public class SelectPopupOtherContentViewTest {
public boolean isSatisfied() { public boolean isSatisfied() {
ContentViewCore contentViewCore = ContentViewCore contentViewCore =
mActivityTestRule.getActivity().getCurrentContentViewCore(); mActivityTestRule.getActivity().getCurrentContentViewCore();
return contentViewCore.getSelectPopupForTest() != null; return contentViewCore.isSelectPopupVisibleForTest();
} }
} }
...@@ -112,8 +112,7 @@ public class SelectPopupOtherContentViewTest { ...@@ -112,8 +112,7 @@ public class SelectPopupOtherContentViewTest {
InstrumentationRegistry.getInstrumentation().waitForIdleSync(); InstrumentationRegistry.getInstrumentation().waitForIdleSync();
// The popup should still be shown. // The popup should still be shown.
Assert.assertNotNull( Assert.assertTrue("The select popup got hidden by destroying of unrelated ContentViewCore.",
"The select popup got hidden by destroying of unrelated ContentViewCore.", viewCore.isSelectPopupVisibleForTest());
viewCore.getSelectPopupForTest());
} }
} }
...@@ -12,7 +12,6 @@ import android.view.View; ...@@ -12,7 +12,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.content.browser.input.SelectPopup;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.ViewAndroidDelegate; import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
...@@ -388,8 +387,8 @@ public interface ContentViewCore { ...@@ -388,8 +387,8 @@ public interface ContentViewCore {
void sendDoubleTapForTest(long timeMs, int x, int y); void sendDoubleTapForTest(long timeMs, int x, int y);
/** /**
* @return The visible select popup being shown. * @return {@code true} if select popup is being shown.
*/ */
@VisibleForTesting @VisibleForTesting
SelectPopup getSelectPopupForTest(); boolean isSelectPopupVisibleForTest();
} }
...@@ -1036,13 +1036,10 @@ public class ContentViewCoreImpl ...@@ -1036,13 +1036,10 @@ public class ContentViewCoreImpl
if (mSelectPopup != null) mSelectPopup.hide(true); if (mSelectPopup != null) mSelectPopup.hide(true);
} }
/**
* @return The visible select popup being shown.
*/
@VisibleForTesting @VisibleForTesting
@Override @Override
public SelectPopup getSelectPopupForTest() { public boolean isSelectPopupVisibleForTest() {
return mSelectPopup; return mSelectPopup != null;
} }
private void destroyPastePopup() { private void destroyPastePopup() {
......
...@@ -60,7 +60,7 @@ public class SelectPopupTest { ...@@ -60,7 +60,7 @@ public class SelectPopupTest {
@Override @Override
public boolean isSatisfied() { public boolean isSatisfied() {
return mActivityTestRule.getContentViewCore().getSelectPopupForTest() != null; return mActivityTestRule.getContentViewCore().isSelectPopupVisibleForTest();
} }
} }
...@@ -71,7 +71,7 @@ public class SelectPopupTest { ...@@ -71,7 +71,7 @@ public class SelectPopupTest {
@Override @Override
public boolean isSatisfied() { public boolean isSatisfied() {
return mActivityTestRule.getContentViewCore().getSelectPopupForTest() == null; return !mActivityTestRule.getContentViewCore().isSelectPopupVisibleForTest();
} }
} }
......
...@@ -12,7 +12,6 @@ import android.view.ViewGroup; ...@@ -12,7 +12,6 @@ import android.view.ViewGroup;
import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewCore.InternalAccessDelegate; import org.chromium.content.browser.ContentViewCore.InternalAccessDelegate;
import org.chromium.content.browser.input.SelectPopup;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.ViewAndroidDelegate; import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
...@@ -202,8 +201,8 @@ public class TestContentViewCore implements ContentViewCore { ...@@ -202,8 +201,8 @@ public class TestContentViewCore implements ContentViewCore {
public void preserveSelectionOnNextLossOfFocus() {} public void preserveSelectionOnNextLossOfFocus() {}
@Override @Override
public SelectPopup getSelectPopupForTest() { public boolean isSelectPopupVisibleForTest() {
return null; return false;
} }
@Override @Override
......
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