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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java

Issue 2372823003: [Contextual Search] Add a basic test for ContextualSearchImageControl (Closed)
Patch Set: Changes from donnd@ review Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
index 72eb85e71c0415fb604f6450c1e43bf1da79a6c0..704285a3ce2e9ec3d8c04f7edda7097adb9d7dfb 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
@@ -17,6 +17,7 @@ import android.graphics.Point;
import android.os.Environment;
import android.os.SystemClock;
import android.test.suitebuilder.annotation.SmallTest;
+import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewConfiguration;
@@ -37,6 +38,8 @@ import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate;
import org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressObserver;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState;
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChangeReason;
+import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchIconSpriteControl;
+import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchImageControl;
import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchPanel;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchFakeServer.FakeSlowResolveSearch;
import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler;
@@ -2653,4 +2656,47 @@ public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro
// Assert that the panel is closed.
waitForPanelToClose();
}
+
+ /**
+ * Tests that ContextualSearchImageControl correctly sets either the icon sprite or thumbnail
+ * as visible.
+ */
+ @SmallTest
+ @Feature({"ContextualSearch"})
+ @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
+ public void testImageControl() throws InterruptedException, TimeoutException {
+ simulateTapSearch("search");
+
+ ContextualSearchImageControl imageControl = mPanel.getImageControl();
+ final ContextualSearchIconSpriteControl iconSpriteControl =
+ imageControl.getIconSpriteControl();
+
+ assertTrue(iconSpriteControl.isVisible());
+ assertFalse(imageControl.getThumbnailVisible());
+ assertTrue(TextUtils.isEmpty(imageControl.getThumbnailUrl()));
+
+ imageControl.setThumbnailUrl("http://someimageurl.com/image.png");
+ imageControl.onThumbnailFetched(true);
+
+ assertTrue(imageControl.getThumbnailVisible());
+ assertEquals(imageControl.getThumbnailUrl(), "http://someimageurl.com/image.png");
+
+ // The switch between the icon sprite and thumbnail is animated. Poll the UI thread to
+ // check that the icon sprite is hidden at the end of the animation.
+ CriteriaHelper.pollUiThread(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return !iconSpriteControl.isVisible();
+ }
+ });
+
+ imageControl.hideThumbnail(false);
+
+ assertTrue(iconSpriteControl.isVisible());
+ assertFalse(imageControl.getThumbnailVisible());
+ assertTrue(TextUtils.isEmpty(imageControl.getThumbnailUrl()));
+ }
+
+ // TODO(twellington): Add an end-to-end integration test for fetching a thumbnail based on a
+ // a URL that is included with the resolution response.
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698