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

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

Issue 141533006: [Android] Move the java content/ package to content_public/ to start the split. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small fixes and findbugs line update Created 6 years, 11 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
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
deleted file mode 100644
index 946a0c11c202bcde6e4c31beea53cc5fcab0978d..0000000000000000000000000000000000000000
--- a/content/public/android/javatests/src/org/chromium/content/browser/PopupZoomerTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.content.browser;
-
-import android.content.Context;
-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;
-
-/**
- * Tests for PopupZoomer.
- */
-public class PopupZoomerTest extends InstrumentationTestCase {
- private CustomCanvasPopupZoomer mPopupZoomer;
-
- private static class CustomCanvasPopupZoomer extends PopupZoomer {
- Canvas mCanvas;
- long mPendingDraws = 0;
-
- CustomCanvasPopupZoomer(Context context, Canvas c) {
- super(context);
- mCanvas = c;
- }
-
- @Override
- public void invalidate() {
- mPendingDraws++;
- }
-
- @Override
- public void onDraw(Canvas c) {
- mPendingDraws--;
- super.onDraw(c);
- }
-
- // Test doesn't attach PopupZoomer to the view hierarchy,
- // but onDraw() should still go on.
- @Override
- protected boolean acceptZeroSizeView() {
- return true;
- }
-
- public void finishPendingDraws() {
- // Finish all pending draw calls. A draw call may change mPendingDraws.
- while (mPendingDraws > 0) {
- onDraw(mCanvas);
- }
- }
-
- }
-
- private CustomCanvasPopupZoomer createPopupZoomerForTest(Context context) {
- return new CustomCanvasPopupZoomer(
- context, new Canvas(Bitmap.createBitmap(100, 100, Bitmap.Config.ALPHA_8)));
- }
-
- private void sendSingleTapTouchEventOnView(View view, float x, float y) {
- final long downEvent = SystemClock.uptimeMillis();
- view.onTouchEvent(
- MotionEvent.obtain(downEvent, downEvent, MotionEvent.ACTION_DOWN, x, y, 0));
- view.onTouchEvent(
- MotionEvent.obtain(downEvent, downEvent + 10, MotionEvent.ACTION_UP, x, y, 0));
- }
-
- @Override
- public void setUp() {
- mPopupZoomer = createPopupZoomerForTest(getInstrumentation().getTargetContext());
- }
-
- @SmallTest
- @Feature({"Navigation"})
- public void testDefaultCreateState() throws Exception {
- assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility());
- assertFalse(mPopupZoomer.isShowing());
- }
-
- @SmallTest
- @Feature({"Navigation"})
- public void testShowWithoutBitmap() throws Exception {
- mPopupZoomer.show(new Rect(0, 0, 5, 5));
-
- // The view should be invisible.
- assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility());
- assertFalse(mPopupZoomer.isShowing());
- }
-
- @SmallTest
- @Feature({"Navigation"})
- public void testShowWithBitmap() throws Exception {
- mPopupZoomer.setBitmap(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8));
- mPopupZoomer.show(new Rect(0, 0, 5, 5));
-
- // The view should become visible.
- assertEquals(View.VISIBLE, mPopupZoomer.getVisibility());
- assertTrue(mPopupZoomer.isShowing());
- }
-
- @SmallTest
- @Feature({"Navigation"})
- public void testHide() throws Exception {
- mPopupZoomer.setBitmap(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8));
- mPopupZoomer.show(new Rect(0, 0, 5, 5));
-
- // The view should become visible.
- assertEquals(View.VISIBLE, mPopupZoomer.getVisibility());
- assertTrue(mPopupZoomer.isShowing());
-
- // Call hide without animation.
- mPopupZoomer.hide(false);
-
- // The view should be invisible.
- assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility());
- assertFalse(mPopupZoomer.isShowing());
- }
-
- @SmallTest
- @Feature({"Navigation"})
- public void testOnTouchEventOutsidePopup() throws Exception {
- mPopupZoomer.setBitmap(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8));
- mPopupZoomer.show(new Rect(0, 0, 5, 5));
-
- // Wait for the show animation to finish.
- mPopupZoomer.finishPendingDraws();
-
- // The view should be visible.
- assertEquals(View.VISIBLE, mPopupZoomer.getVisibility());
- assertTrue(mPopupZoomer.isShowing());
-
- // Send tap event at a point outside the popup.
- // i.e. coordinates greater than 10 + PopupZoomer.ZOOM_BOUNDS_MARGIN
- sendSingleTapTouchEventOnView(mPopupZoomer, 50, 50);
-
- // Wait for the hide animation to finish.
- mPopupZoomer.finishPendingDraws();
-
- // The view should be invisible.
- assertEquals(View.INVISIBLE, mPopupZoomer.getVisibility());
- assertFalse(mPopupZoomer.isShowing());
- }
-
- @SmallTest
- @Feature({"Navigation"})
- public void testOnTouchEventInsidePopupNoOnTapListener() 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());
-
- // Send tap event at a point inside the popup.
- // i.e. coordinates between PopupZoomer.ZOOM_BOUNDS_MARGIN and
- // PopupZoomer.ZOOM_BOUNDS_MARGIN + 10
- sendSingleTapTouchEventOnView(mPopupZoomer, 30, 30);
-
- // Wait for the animation to finish (if there is any).
- mPopupZoomer.finishPendingDraws();
-
- // The view should still be visible as no OnTapListener is set.
- assertEquals(View.VISIBLE, mPopupZoomer.getVisibility());
- assertTrue(mPopupZoomer.isShowing());
- }
-}

Powered by Google App Engine
This is Rietveld 408576698