summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-09 14:16:12 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-09 14:16:12 +0100
commit03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (patch)
tree52599cd0ab782b1768e23ad176f7618f98333cb6 /Source/WebKit/chromium/tests
parentcd44dc59cdfc39534aef4d417e9f3c412e3be139 (diff)
downloadqtwebkit-03e12282df9aa1e1fb05a8b90f1cfc2e08764cec.tar.gz
Imported WebKit commit e09a82039aa4273ab318b71122e92d8e5f233525 (http://svn.webkit.org/repository/webkit/trunk@107223)
Diffstat (limited to 'Source/WebKit/chromium/tests')
-rw-r--r--Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp25
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp200
-rw-r--r--Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp8
-rw-r--r--Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp16
-rw-r--r--Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp759
-rw-r--r--Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp156
-rw-r--r--Source/WebKit/chromium/tests/PopupMenuTest.cpp4
-rw-r--r--Source/WebKit/chromium/tests/TextureManagerTest.cpp60
-rw-r--r--Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp129
-rw-r--r--Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp221
-rw-r--r--Source/WebKit/chromium/tests/WebFrameTest.cpp2
11 files changed, 767 insertions, 813 deletions
diff --git a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
index 0f379d64e..a9f7b1c1a 100644
--- a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
@@ -70,7 +70,7 @@ void emulateDrawingOneFrame(CCLayerImpl* root)
// Iterate back-to-front, so that damage correctly propagates from descendant surfaces to ancestors.
for (int i = renderSurfaceLayerList.size() - 1; i >= 0; --i) {
CCRenderSurface* targetSurface = renderSurfaceLayerList[i]->renderSurface();
- targetSurface->damageTracker()->updateDamageRectForNextFrame(targetSurface->layerList(), targetSurface->owningLayerId(), renderSurfaceLayerList[i]->maskLayer());
+ targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->layerList(), targetSurface->owningLayerId(), renderSurfaceLayerList[i]->maskLayer());
}
root->resetAllChangeTrackingForSubtree();
@@ -748,4 +748,27 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask)
EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect);
}
+TEST_F(CCDamageTrackerTest, verifyDamageWhenReset)
+{
+ RefPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();
+ RefPtr<CCLayerImpl> child = root->children()[0];
+
+ // Case 1: This test ensures that when the tracker is forced to have full damage, that
+ // it takes priority over any other partial damage.
+ //
+ child->setUpdateRect(FloatRect(10, 11, 12, 13));
+ root->renderSurface()->damageTracker()->forceFullDamageNextUpdate();
+ emulateDrawingOneFrame(root.get());
+ FloatRect rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect();
+ EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect);
+
+ // Case 2: An additional sanity check that forcing full damage works even when nothing
+ // on the layer tree changed.
+ //
+ root->renderSurface()->damageTracker()->forceFullDamageNextUpdate();
+ emulateDrawingOneFrame(root.get());
+ rootDamageRect = root->renderSurface()->damageTracker()->currentDamageRect();
+ EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 500, 500), rootDamageRect);
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
index 41fe4fb65..fc414f739 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
@@ -1102,6 +1102,9 @@ public:
{
IntSize viewportSize(10, 10);
layerTreeHost()->setViewportSize(viewportSize);
+
+ layerTreeHost()->updateLayers();
+
EXPECT_EQ(viewportSize, layerTreeHost()->viewportSize());
EXPECT_EQ(TextureManager::highLimitBytes(viewportSize), layerTreeHost()->contentsTextureManager()->maxMemoryLimitBytes());
EXPECT_EQ(TextureManager::reclaimLimitBytes(viewportSize), layerTreeHost()->contentsTextureManager()->preferredMemoryLimitBytes());
@@ -1144,16 +1147,15 @@ public:
class CCLayerTreeHostTestAtomicCommit : public CCLayerTreeHostTest {
public:
CCLayerTreeHostTestAtomicCommit()
- : m_updateCheckLayer(ContentLayerChromiumWithUpdateTracking::create(&m_delegate))
- , m_numCommits(0)
+ : m_layer(ContentLayerChromiumWithUpdateTracking::create(&m_delegate))
{
// Make sure partial texture updates are turned off.
- m_settings.partialTextureUpdates = false;
+ m_settings.maxPartialTextureUpdates = 0;
}
virtual void beginTest()
{
- m_layerTreeHost->setRootLayer(m_updateCheckLayer);
+ m_layerTreeHost->setRootLayer(m_layer);
m_layerTreeHost->setViewportSize(IntSize(10, 10));
postSetNeedsCommitToMainThread();
@@ -1170,7 +1172,7 @@ public:
EXPECT_EQ(1, context->numTextures());
// Number of textures used for commit should be one.
EXPECT_EQ(1, context->numUsedTextures());
- // Verify used texture is correct.
+ // Verify that used texture is correct.
EXPECT_TRUE(context->usedTexture(context->texture(0)));
context->resetUsedTextures();
@@ -1211,7 +1213,7 @@ public:
virtual void layout()
{
- m_updateCheckLayer->setNeedsDisplay();
+ m_layer->setNeedsDisplay();
}
virtual void afterTest()
@@ -1220,8 +1222,7 @@ public:
private:
MockContentLayerDelegate m_delegate;
- RefPtr<ContentLayerChromiumWithUpdateTracking> m_updateCheckLayer;
- int m_numCommits;
+ RefPtr<ContentLayerChromiumWithUpdateTracking> m_layer;
};
TEST_F(CCLayerTreeHostTestAtomicCommit, runMultiThread)
@@ -1229,6 +1230,132 @@ TEST_F(CCLayerTreeHostTestAtomicCommit, runMultiThread)
runTest(true);
}
+class CCLayerTreeHostTestAtomicCommitWithPartialUpdate : public CCLayerTreeHostTest {
+public:
+ CCLayerTreeHostTestAtomicCommitWithPartialUpdate()
+ : m_parent(ContentLayerChromiumWithUpdateTracking::create(&m_delegate))
+ , m_child(ContentLayerChromiumWithUpdateTracking::create(&m_delegate))
+ , m_numCommits(0)
+ {
+ // Allow one partial texture update.
+ m_settings.maxPartialTextureUpdates = 1;
+ }
+
+ virtual void beginTest()
+ {
+ m_layerTreeHost->setRootLayer(m_parent);
+ m_layerTreeHost->setViewportSize(IntSize(10, 10));
+ m_parent->addChild(m_child);
+ m_child->setOpacity(0.5);
+ m_child->setBounds(IntSize(20, 20));
+
+ postSetNeedsCommitToMainThread();
+ postSetNeedsRedrawToMainThread();
+ }
+
+ virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl)
+ {
+ CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context()));
+
+ switch (impl->frameNumber()) {
+ case 0:
+ // Number of textures should be two.
+ EXPECT_EQ(2, context->numTextures());
+ // Number of textures used for commit should be two.
+ EXPECT_EQ(2, context->numUsedTextures());
+ // Verify that used textures are correct.
+ EXPECT_TRUE(context->usedTexture(context->texture(0)));
+ EXPECT_TRUE(context->usedTexture(context->texture(1)));
+
+ context->resetUsedTextures();
+ break;
+ case 1:
+ // Number of textures should be four as the first two
+ // textures are used by the impl thread.
+ EXPECT_EQ(4, context->numTextures());
+ // Number of textures used for commit should still be two.
+ EXPECT_EQ(2, context->numUsedTextures());
+ // First two textures should not have been used.
+ EXPECT_FALSE(context->usedTexture(context->texture(0)));
+ EXPECT_FALSE(context->usedTexture(context->texture(1)));
+ // New textures should have been used.
+ EXPECT_TRUE(context->usedTexture(context->texture(2)));
+ EXPECT_TRUE(context->usedTexture(context->texture(3)));
+
+ context->resetUsedTextures();
+ break;
+ case 2:
+ // Number of textures should be three as we allow one
+ // partial update and the first two textures are used by
+ // the impl thread.
+ EXPECT_EQ(3, context->numTextures());
+ // Number of textures used for commit should still be two.
+ EXPECT_EQ(2, context->numUsedTextures());
+ // First texture should not have been used.
+ EXPECT_FALSE(context->usedTexture(context->texture(0)));
+ // Second texture should have been used.
+ EXPECT_TRUE(context->usedTexture(context->texture(1)));
+ // New textures should have been used.
+ EXPECT_TRUE(context->usedTexture(context->texture(2)));
+
+ context->resetUsedTextures();
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+ virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
+ {
+ CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context()));
+
+ // Number of textures used for drawing should always be two.
+ EXPECT_EQ(2, context->numUsedTextures());
+
+ if (impl->frameNumber() < 3) {
+ context->resetUsedTextures();
+ postSetNeedsAnimateAndCommitToMainThread();
+ postSetNeedsRedrawToMainThread();
+ } else
+ endTest();
+ }
+
+ virtual void layout()
+ {
+ switch (m_numCommits++) {
+ case 0:
+ case 1:
+ m_parent->setNeedsDisplay();
+ m_child->setNeedsDisplay();
+ break;
+ case 2:
+ // Damage part of layers.
+ m_parent->setNeedsDisplayRect(FloatRect(0, 0, 5, 5));
+ m_child->setNeedsDisplayRect(FloatRect(0, 0, 5, 5));
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+ virtual void afterTest()
+ {
+ }
+
+private:
+ MockContentLayerDelegate m_delegate;
+ RefPtr<ContentLayerChromiumWithUpdateTracking> m_parent;
+ RefPtr<ContentLayerChromiumWithUpdateTracking> m_child;
+ int m_numCommits;
+};
+
+TEST_F(CCLayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread)
+{
+ runTest(true);
+}
+
#define EXPECT_EQ_RECT(a, b) \
EXPECT_EQ(a.x(), b.x()); \
EXPECT_EQ(a.y(), b.y()); \
@@ -1469,4 +1596,61 @@ public:
SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusion)
+class CCLayerTreeHostTestManySurfaces : public CCLayerTreeHostTest {
+public:
+ CCLayerTreeHostTestManySurfaces() { }
+
+ virtual void beginTest()
+ {
+ // We create enough RenderSurfaces that it will trigger Vector reallocation while computing occlusion.
+ Region occluded;
+ const TransformationMatrix identityMatrix;
+ Vector<RefPtr<TestLayerChromium> > layers;
+ Vector<RefPtr<TestLayerChromium> > children;
+ int numSurfaces = 20;
+ RefPtr<TestLayerChromium> replica = TestLayerChromium::create();
+
+ for (int i = 0; i < numSurfaces; ++i) {
+ layers.append(TestLayerChromium::create());
+ if (!i) {
+ setLayerPropertiesForTesting(layers.last().get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true);
+ layers.last()->createRenderSurface();
+ } else {
+ setLayerPropertiesForTesting(layers.last().get(), layers[layers.size()-2].get(), identityMatrix, FloatPoint(0, 0), FloatPoint(1, 1), IntSize(100-i, 100-i), true);
+ layers.last()->setMasksToBounds(true);
+ layers.last()->setReplicaLayer(replica.get()); // Make it have a RenderSurface
+ }
+ }
+
+ for (int i = 1; i < numSurfaces; ++i) {
+ children.append(TestLayerChromium::create());
+ setLayerPropertiesForTesting(children.last().get(), layers[i].get(), identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false);
+ }
+
+ m_layerTreeHost->setRootLayer(layers[0].get());
+ m_layerTreeHost->setViewportSize(layers[0]->bounds());
+ m_layerTreeHost->updateLayers();
+ m_layerTreeHost->commitComplete();
+
+ for (int i = 0; i < numSurfaces-1; ++i) {
+ IntRect expectedOcclusion(i+1, i+1, 100-i-1, 100-i-1);
+
+ EXPECT_EQ_RECT(expectedOcclusion, layers[i]->occludedScreenSpace().bounds());
+ EXPECT_EQ(1u, layers[i]->occludedScreenSpace().rects().size());
+ }
+
+ // Kill the layerTreeHost immediately.
+ m_layerTreeHost->setRootLayer(0);
+ m_layerTreeHost.clear();
+
+ endTest();
+ }
+
+ virtual void afterTest()
+ {
+ }
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestManySurfaces)
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp
index 1df27c011..4b3dd27d3 100644
--- a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp
@@ -75,12 +75,6 @@ namespace WebCore {
class Canvas2DLayerChromiumTest : public Test {
protected:
- // This indirection is needed because individual tests aren't friends of Canvas2DLayerChromium.
- void setTextureManager(Canvas2DLayerChromium* layer, TextureManager* manager)
- {
- layer->setTextureManager(manager);
- }
-
void fullLifecycleTest(bool threaded)
{
GraphicsContext3D::Attributes attrs;
@@ -133,7 +127,7 @@ protected:
RefPtr<Canvas2DLayerChromium> canvas = Canvas2DLayerChromium::create(mainContext.get(), size);
canvas->setIsDrawable(true);
- setTextureManager(canvas.get(), textureManager.get());
+ canvas->setTextureManager(textureManager.get());
canvas->setBounds(IntSize(600, 300));
canvas->setTextureId(backTextureId);
diff --git a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
index c2311a843..2b76b80ad 100644
--- a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
+++ b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
@@ -101,13 +101,13 @@ private:
};
-TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
+TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldNotMakeCurrent)
{
GraphicsContext3D::Attributes attrs;
RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);
EXPECT_TRUE(context);
ContextThatCountsMakeCurrents& mockContext = *static_cast<ContextThatCountsMakeCurrents*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()));
- EXPECT_EQ(1, mockContext.makeCurrentCount());
+ EXPECT_EQ(0, mockContext.makeCurrentCount());
}
TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
@@ -119,15 +119,3 @@ TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
EXPECT_EQ(0, mockContext.makeCurrentCount());
}
-class ContextWithMakeCurrentThatFails : public FakeWebGraphicsContext3D {
-public:
- ContextWithMakeCurrentThatFails() { }
- virtual bool makeContextCurrent() { return false; }
-};
-
-TEST(FakeGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails)
-{
- GraphicsContext3D::Attributes attrs;
- RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextWithMakeCurrentThatFails()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread);
- EXPECT_FALSE(context);
-}
diff --git a/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp b/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
deleted file mode 100644
index 191054e4b..000000000
--- a/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "GestureRecognizerChromium.h"
-
-#include <gtest/gtest.h>
-#include <stdarg.h>
-
-using namespace WebCore;
-
-class InspectableGestureRecognizerChromium : public WebCore::GestureRecognizerChromium {
-public:
- InspectableGestureRecognizerChromium()
- : WebCore::GestureRecognizerChromium()
- {
- }
-
- int signature(State gestureState, unsigned id, PlatformTouchPoint::State touchType, bool handled)
- {
- return GestureRecognizerChromium::signature(gestureState, id, touchType, handled);
- };
-
- IntPoint firstTouchPosition() { return m_firstTouchPosition; };
-
- void setFirstTouchTime(double t) { m_firstTouchTime = t; };
- double firstTouchTime() { return m_firstTouchTime; };
-
- void setLastTouchTime(double t) { m_lastTouchTime = t; };
- double lastTouchTime() { return m_lastTouchTime; };
-
- GestureRecognizerChromium::GestureTransitionFunction edgeFunction(int hash)
- {
- return m_edgeFunctions.get(hash);
- };
-
- virtual void updateValues(double d, const PlatformTouchPoint &p)
- {
- GestureRecognizerChromium::updateValues(d, p);
- };
-
- void addEdgeFunction(State state, unsigned finger, PlatformTouchPoint::State touchState, bool touchHandledByJavaScript, GestureTransitionFunction function)
- {
- GestureRecognizerChromium::addEdgeFunction(state, finger, touchState, touchHandledByJavaScript, function);
- };
-
- bool stubEdgeFunction(const PlatformTouchPoint&, GestureRecognizerChromium::Gestures*);
-
- void setStateTest(State value)
- {
- GestureRecognizerChromium::setState(value);
- };
-
- bool isInsideManhattanSquare(const PlatformTouchPoint& touchPoint)
- {
- return GestureRecognizerChromium::isInsideManhattanSquare(touchPoint);
- };
-
- bool isInClickTimeWindow()
- {
- return GestureRecognizerChromium::isInClickTimeWindow();
- };
-
-};
-
-bool InspectableGestureRecognizerChromium::stubEdgeFunction(const PlatformTouchPoint&, GestureRecognizerChromium::Gestures*)
-{
- return false;
-}
-
-class BuildablePlatformTouchPoint : public WebCore::PlatformTouchPoint {
-public:
- BuildablePlatformTouchPoint();
- BuildablePlatformTouchPoint(int x, int y);
- BuildablePlatformTouchPoint(int x, int y, PlatformTouchPoint::State);
-
- void setX(int x)
- {
- m_pos.setX(x);
- m_screenPos.setX(x);
- };
-
- void setY(int y)
- {
- m_pos.setY(y);
- m_screenPos.setY(y);
- };
-};
-
-BuildablePlatformTouchPoint::BuildablePlatformTouchPoint()
-{
- m_id = 0;
- m_state = PlatformTouchPoint::TouchStationary;
- m_pos = IntPoint::zero();
- m_screenPos = IntPoint::zero();
-}
-
-BuildablePlatformTouchPoint::BuildablePlatformTouchPoint(int x, int y)
-{
- m_id = 0;
- m_state = PlatformTouchPoint::TouchStationary;
- m_pos = IntPoint(x, y);
- m_screenPos = IntPoint(x, y);
-}
-
-BuildablePlatformTouchPoint::BuildablePlatformTouchPoint(int x, int y, PlatformTouchPoint::State state)
-{
- m_id = 0;
- m_state = state;
- m_pos = IntPoint(x, y);
- m_screenPos = IntPoint(x, y);
-}
-
-class BuildablePlatformTouchEvent : public WebCore::PlatformTouchEvent {
-public:
- BuildablePlatformTouchEvent(WebCore::PlatformEvent::Type type, PlatformTouchPoint& point, double time)
- {
- m_type = type;
- m_touchPoints.append(point);
- m_timestamp = time;
- }
-
- BuildablePlatformTouchEvent(WebCore::PlatformEvent::Type type, PlatformTouchPoint& point)
- {
- m_type = type;
- m_touchPoints.append(point);
- m_timestamp = 100.;
- }
-};
-
-class GestureRecognizerTest : public testing::Test {
-public:
- GestureRecognizerTest() { }
-
-protected:
- virtual void SetUp() { }
- virtual void TearDown() { }
-};
-
-void SimulateAndTestFirstClick(InspectableGestureRecognizerChromium& gm)
-{
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000.);
- OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ((unsigned int)1, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000. + 0.7);
- OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- ASSERT_EQ((unsigned int)1, gestureEnd->size());
- ASSERT_EQ(PlatformEvent::GestureTap, (*gestureEnd)[0].type());
-}
-
-typedef OwnPtr<Vector<WebCore::PlatformGestureEvent> > Gestures;
-
-TEST_F(GestureRecognizerTest, hash)
-{
- InspectableGestureRecognizerChromium testGm;
- const unsigned FirstFinger = 0;
- const unsigned SecondFinger = 1;
-
- ASSERT_EQ(1 + 0, testGm.signature(GestureRecognizerChromium::NoGesture, FirstFinger, PlatformTouchPoint::TouchReleased, false));
-
- ASSERT_EQ(1 + ((8 | 1) << 1), testGm.signature(GestureRecognizerChromium::NoGesture, FirstFinger, PlatformTouchPoint::TouchPressed, true));
-
- ASSERT_EQ(1 + ((0x10000 | 2) << 1), testGm.signature(GestureRecognizerChromium::PendingSyntheticClick, FirstFinger, PlatformTouchPoint::TouchMoved, false));
-
- ASSERT_EQ(1 + (0x20000 << 1), testGm.signature(GestureRecognizerChromium::Scroll, FirstFinger, PlatformTouchPoint::TouchReleased, false));
-
- ASSERT_EQ(1 + ((0x20000 | 1) << 1), testGm.signature(GestureRecognizerChromium::Scroll, FirstFinger, PlatformTouchPoint::TouchPressed, false));
-
- ASSERT_EQ(1 + ((0x20000 | 0x10 | 8 | 1) << 1), testGm.signature(GestureRecognizerChromium::Scroll, SecondFinger, PlatformTouchPoint::TouchPressed, true));
-}
-
-TEST_F(GestureRecognizerTest, state)
-{
- InspectableGestureRecognizerChromium testGm;
-
- ASSERT_EQ(0, testGm.state());
- testGm.setStateTest(GestureRecognizerChromium::PendingSyntheticClick);
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, testGm.state());
-}
-
-TEST_F(GestureRecognizerTest, isInsideManhattanSquare)
-{
- InspectableGestureRecognizerChromium gm;
- BuildablePlatformTouchPoint p;
-
- ASSERT_EQ(0.0, gm.firstTouchPosition().x());
- ASSERT_EQ(0.0, gm.firstTouchPosition().y());
-
- p.setX(0.0);
- p.setY(19.999);
- ASSERT_TRUE(gm.isInsideManhattanSquare(p));
-
- p.setX(19.999);
- p.setY(0.0);
- ASSERT_TRUE(gm.isInsideManhattanSquare(p));
-
- p.setX(20.0);
- p.setY(0.0);
- ASSERT_FALSE(gm.isInsideManhattanSquare(p));
-
- p.setX(0.0);
- p.setY(20.0);
- ASSERT_FALSE(gm.isInsideManhattanSquare(p));
-
- p.setX(-20.0);
- p.setY(0.0);
- ASSERT_FALSE(gm.isInsideManhattanSquare(p));
-
- p.setX(0.0);
- p.setY(-20.0);
- ASSERT_FALSE(gm.isInsideManhattanSquare(p));
-}
-
-TEST_F(GestureRecognizerTest, isInClickTimeWindow)
-{
- InspectableGestureRecognizerChromium gm;
-
- gm.setFirstTouchTime(0.0);
- gm.setLastTouchTime(0.0);
- ASSERT_FALSE(gm.isInClickTimeWindow());
-
- gm.setFirstTouchTime(0.0);
- gm.setLastTouchTime(0.010001);
- ASSERT_TRUE(gm.isInClickTimeWindow());
-
- gm.setFirstTouchTime(0.0);
- gm.setLastTouchTime(0.8 - .00000001);
- ASSERT_TRUE(gm.isInClickTimeWindow());
-
- gm.setFirstTouchTime(0.0);
- gm.setLastTouchTime(0.80001);
- ASSERT_FALSE(gm.isInClickTimeWindow());
-}
-
-TEST_F(GestureRecognizerTest, addEdgeFunction)
-{
- InspectableGestureRecognizerChromium gm;
- gm.addEdgeFunction(GestureRecognizerChromium::Scroll, 0, PlatformTouchPoint::TouchReleased, true, reinterpret_cast<GestureRecognizerChromium::GestureTransitionFunction>(&InspectableGestureRecognizerChromium::stubEdgeFunction));
-
- ASSERT_EQ(reinterpret_cast<GestureRecognizerChromium::GestureTransitionFunction>(&InspectableGestureRecognizerChromium::stubEdgeFunction), gm.edgeFunction(gm.signature(GestureRecognizerChromium::Scroll, 0, PlatformTouchPoint::TouchReleased, true)));
-}
-
-TEST_F(GestureRecognizerTest, updateValues)
-{
- InspectableGestureRecognizerChromium gm;
-
- ASSERT_EQ(0.0, gm.firstTouchTime());
- ASSERT_EQ(0.0, gm.lastTouchTime());
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint p1(10, 11);
- gm.updateValues(1.1, p1);
-
- ASSERT_EQ(10, gm.firstTouchPosition().x());
- ASSERT_EQ(11, gm.firstTouchPosition().y());
- ASSERT_EQ(1.1, gm.firstTouchTime());
- ASSERT_EQ(0.0, gm.lastTouchTime() - gm.firstTouchTime());
-
- BuildablePlatformTouchPoint p2(13, 14);
- gm.setStateTest(GestureRecognizerChromium::PendingSyntheticClick);
- gm.updateValues(2.0, p2);
-
- ASSERT_EQ(10, gm.firstTouchPosition().x());
- ASSERT_EQ(11, gm.firstTouchPosition().y());
- ASSERT_EQ(1.1, gm.firstTouchTime());
- ASSERT_EQ(2.0 - 1.1, gm.lastTouchTime() - gm.firstTouchTime());
-
- BuildablePlatformTouchPoint p3(23, 34);
- gm.setStateTest(GestureRecognizerChromium::NoGesture);
- gm.updateValues(3.0, p3);
-
- ASSERT_EQ(23, gm.firstTouchPosition().x());
- ASSERT_EQ(34, gm.firstTouchPosition().y());
- ASSERT_EQ(3.0, gm.firstTouchTime());
- ASSERT_EQ(0.0, gm.lastTouchTime() - gm.firstTouchTime());
-}
-
-#if OS(WINDOWS)
-#define MAYBE_doubleTapGestureTest DISABLED_doubleTapGestureTest
-#else
-#define MAYBE_doubleTapGestureTest doubleTapGestureTest
-#endif
-
-TEST_F(GestureRecognizerTest, DISABLED_doubleTapGestureTest)
-{
- InspectableGestureRecognizerChromium gm;
- SimulateAndTestFirstClick(gm);
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000 + .5);
- Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ(1u, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved);
- BuildablePlatformTouchEvent moveEvent(WebCore::PlatformEvent::TouchMove, move, 1000 + .5 + .01);
- Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
- ASSERT_EQ(0u, gestureMove->size());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000 + .5 + .02);
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- ASSERT_EQ(2u, gestureEnd->size());
- ASSERT_EQ(PlatformEvent::GestureTap, (*gestureEnd)[0].type());
- ASSERT_EQ(PlatformEvent::GestureDoubleTap, (*gestureEnd)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-TEST_F(GestureRecognizerTest, doubleTapGestureIncompleteTest)
-{
- InspectableGestureRecognizerChromium gm;
- SimulateAndTestFirstClick(gm);
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000. + 0.7 + 0.01);
- Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ(1u, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
- BuildablePlatformTouchEvent moveEvent(WebCore::PlatformEvent::TouchMove, move, 1000. + 0.7 + 0.02);
- Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
- ASSERT_EQ(2u, gestureMove->size());
- ASSERT_EQ(PlatformEvent::GestureScrollBegin, (*gestureMove)[0].type());
- ASSERT_EQ(PlatformEvent::GestureScrollUpdate, (*gestureMove)[1].type());
- ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
-
- BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000. + 0.7 + 0.03);
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- ASSERT_EQ(1u, gestureEnd->size());
- ASSERT_EQ(PlatformEvent::GestureScrollEnd, (*gestureEnd)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-TEST_F(GestureRecognizerTest, doubleTapGestureIncompleteDueToSecondClickPositionTest)
-{
- InspectableGestureRecognizerChromium gm;
- SimulateAndTestFirstClick(gm);
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- IntPoint awayFromFirstClick(24, 26);
-
- BuildablePlatformTouchPoint press(awayFromFirstClick.x(), awayFromFirstClick.y(), PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000. + 0.7 + 0.01);
- Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ(1u, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint release(awayFromFirstClick.x(), awayFromFirstClick.y(), PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000. + 0.7 + 0.025);
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- ASSERT_EQ(1u, gestureEnd->size());
- ASSERT_EQ(PlatformEvent::GestureTap, (*gestureEnd)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-TEST_F(GestureRecognizerTest, tapDownWithoutTapGestureTest)
-{
- InspectableGestureRecognizerChromium gm;
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press);
- Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ(1u, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
- BuildablePlatformTouchEvent moveEvent(WebCore::PlatformEvent::TouchMove, move);
- Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
- for (unsigned int i = 0; i < gestureMove->size(); i++)
- ASSERT_NE(PlatformEvent::GestureTap, (*gestureMove)[i].type());
- ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
-
- BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release);
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- for (unsigned int i = 0; i < gestureEnd->size(); i++)
- ASSERT_NE(PlatformEvent::GestureTap, (*gestureEnd)[i].type());
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-TEST_F(GestureRecognizerTest, tapDownWithTapGestureTest)
-{
- InspectableGestureRecognizerChromium gm;
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000.);
- Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ(1u, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved);
- BuildablePlatformTouchEvent moveEvent(WebCore::PlatformEvent::TouchMove, move, 1000.);
- Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
- ASSERT_EQ(0u, gestureMove->size());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint release(10, 16, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000. + 0.011);
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- ASSERT_EQ(1u, gestureEnd->size());
- ASSERT_EQ(PlatformEvent::GestureTap, (*gestureEnd)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-
-TEST_F(GestureRecognizerTest, noDoubleTapGestureBecauseOfInterTouchIntervalTest)
-{
- InspectableGestureRecognizerChromium gm;
- SimulateAndTestFirstClick(gm);
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- // Values are from GestureRecognizerChromium.cpp
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000 + .8 + 10 + .1);
- Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ(1u, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint move(10, 16, PlatformTouchPoint::TouchMoved);
- BuildablePlatformTouchEvent moveEvent(WebCore::PlatformEvent::TouchMove, move, 1000 + .8 + 10 + .1 + .05);
- Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
- ASSERT_EQ(0u, gestureMove->size());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint release(11, 17, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000 + .8 + 10 + .1 + .02);
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- ASSERT_EQ(1u, gestureEnd->size());
- ASSERT_EQ(PlatformEvent::GestureTap, (*gestureEnd)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-
-
-TEST_F(GestureRecognizerTest, gestureScrollEvents)
-{
- InspectableGestureRecognizerChromium gm;
-
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000.);
- gm.processTouchEventForGestures(pressEvent, false);
-
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
- BuildablePlatformTouchEvent moveEvent(WebCore::PlatformEvent::TouchMove, move, 1000. + 0.2);
- Gestures gestureStart(gm.processTouchEventForGestures(moveEvent, false));
- bool scrollStarted = false, scrollUpdated = false;
- for (unsigned int i = 0; i < gestureStart->size(); i++) {
- switch ((*gestureStart)[i].type()) {
- case PlatformEvent::GestureScrollBegin:
- scrollStarted = true;
- break;
- case PlatformEvent::GestureScrollUpdate:
- scrollUpdated = true;
- break;
- default:
- ASSERT_TRUE(false);
- }
- }
-
- ASSERT_TRUE(scrollStarted);
- ASSERT_TRUE(scrollUpdated);
- ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
-
- BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000. + 0.2 + 0.2);
- bool scrollEnd = false;
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- for (unsigned int i = 0; i < gestureEnd->size(); i++) {
- switch ((*gestureEnd)[i].type()) {
- case PlatformEvent::GestureScrollEnd:
- scrollEnd = true;
- ASSERT_EQ((*gestureEnd)[i].deltaX(), 0);
- ASSERT_EQ((*gestureEnd)[i].deltaY(), 0);
- break;
- default:
- ASSERT_TRUE(false);
- }
- }
- ASSERT_TRUE(scrollEnd);
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-TEST_F(GestureRecognizerTest, flickGestureTest)
-{
- InspectableGestureRecognizerChromium gm;
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
- BuildablePlatformTouchEvent pressEvent(WebCore::PlatformEvent::TouchStart, press, 1000.);
- Gestures gestureStart(gm.processTouchEventForGestures(pressEvent, false));
- ASSERT_EQ((unsigned int)1, gestureStart->size());
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type());
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state());
-
- BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
- BuildablePlatformTouchEvent moveEvent(WebCore::PlatformEvent::TouchMove, move, 1000. + 0.02);
- Gestures gestureMove(gm.processTouchEventForGestures(moveEvent, false));
- bool scrollStarted = false, scrollUpdated = false;
- for (unsigned int i = 0; i < gestureMove->size(); i++) {
- switch ((*gestureMove)[i].type()) {
- case PlatformEvent::GestureScrollBegin:
- scrollStarted = true;
- break;
- case PlatformEvent::GestureScrollUpdate:
- scrollUpdated = true;
- break;
- default:
- ASSERT_TRUE(false);
- }
- }
-
- ASSERT_TRUE(scrollStarted);
- ASSERT_TRUE(scrollUpdated);
- ASSERT_EQ(GestureRecognizerChromium::Scroll, gm.state());
-
- BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
- BuildablePlatformTouchEvent releaseEvent(WebCore::PlatformEvent::TouchEnd, release, 1000. + 0.06);
- Gestures gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
- ASSERT_EQ((unsigned int) 1, gestureEnd->size());
- ASSERT_EQ(PlatformEvent::GestureScrollEnd, (*gestureEnd)[0].type());
- ASSERT_EQ((*gestureEnd)[0].deltaX(), 0);
- ASSERT_EQ((*gestureEnd)[0].deltaY(), 1750.);
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-}
-
-struct TouchPointAndEvent {
-public:
- TouchPointAndEvent(int x, int y, double timestamp, PlatformTouchPoint::State state, WebCore::PlatformEvent::Type type)
- : m_point(x, y, state)
- , m_event(type, m_point, timestamp)
- { }
- BuildablePlatformTouchPoint m_point;
- BuildablePlatformTouchEvent m_event;
-};
-
-class TouchSequence {
-public:
- TouchSequence(int n, ...) : m_n(n)
- {
- va_list args;
- va_start(args, n);
- ASSERT(n > 0);
- m_data = new TouchPointAndEvent*[n];
- for (int i = 0; i < n; ++i)
- m_data[i] = va_arg(args, TouchPointAndEvent*);
- va_end(args);
- }
- ~TouchSequence()
- {
- for (int i = 0; i < m_n; ++i)
- delete m_data[i];
- delete[] m_data;
- }
- int m_n;
- TouchPointAndEvent** m_data;
-};
-
-TEST_F(GestureRecognizerTest, sampleFlickSequenceGestureTest)
-{
- const int numberOfFlickSamples = 11;
- TouchSequence sampleFlickSequence[numberOfFlickSamples] =
- {
- TouchSequence(8,
- new TouchPointAndEvent(256, 348, 1308336245.407, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(254, 345, 1308336245.470, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(252, 336, 1308336245.488, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(242, 261, 1308336245.505, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(242, 179, 1308336245.521, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(255, 100, 1308336245.533, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(262, 74, 1308336245.549, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(262, 74, 1308336245.566, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(8,
- new TouchPointAndEvent(178, 339, 1308336266.180, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(177, 335, 1308336266.212, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(172, 314, 1308336266.226, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(160, 248, 1308336266.240, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(156, 198, 1308336266.251, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(166, 99, 1308336266.266, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(179, 41, 1308336266.280, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(179, 41, 1308336266.291, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(7,
- new TouchPointAndEvent(238, 386, 1308336272.068, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(237, 383, 1308336272.121, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(236, 374, 1308336272.138, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(223, 264, 1308336272.155, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(231, 166, 1308336272.173, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(243, 107, 1308336272.190, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(243, 107, 1308336272.202, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(10,
- new TouchPointAndEvent(334, 351, 1308336313.581, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(334, 348, 1308336313.694, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(335, 346, 1308336313.714, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(334, 343, 1308336313.727, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(332, 336, 1308336313.738, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(328, 316, 1308336313.753, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(317, 277, 1308336313.770, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(306, 243, 1308336313.784, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(292, 192, 1308336313.799, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(292, 192, 1308336313.815, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(14,
- new TouchPointAndEvent(92, 112, 1308336323.955, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(92, 115, 1308336324.056, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(91, 116, 1308336324.066, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(91, 117, 1308336324.074, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(90, 122, 1308336324.089, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(90, 129, 1308336324.102, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(89, 147, 1308336324.120, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(89, 163, 1308336324.135, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(89, 188, 1308336324.151, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(89, 213, 1308336324.169, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(89, 252, 1308336324.189, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(90, 283, 1308336324.204, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(91, 308, 1308336324.218, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(91, 308, 1308336324.230, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(5,
- new TouchPointAndEvent(55, 249, 1308336349.093, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(59, 249, 1308336349.179, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(66, 248, 1308336349.191, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(128, 253, 1308336349.208, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(128, 253, 1308336349.258, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(9,
- new TouchPointAndEvent(376, 290, 1308336353.071, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(373, 288, 1308336353.127, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(372, 287, 1308336353.140, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(353, 280, 1308336353.156, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(319, 271, 1308336353.171, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(264, 258, 1308336353.188, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(215, 251, 1308336353.200, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(151, 246, 1308336353.217, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(151, 246, 1308336353.231, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(5,
- new TouchPointAndEvent(60, 166, 1308336358.898, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(63, 166, 1308336358.944, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(68, 167, 1308336358.958, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(118, 179, 1308336358.971, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(118, 179, 1308336358.984, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(5,
- new TouchPointAndEvent(66, 318, 1308336362.996, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(70, 316, 1308336363.046, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(77, 314, 1308336363.058, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(179, 295, 1308336363.082, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(179, 295, 1308336363.096, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(11,
- new TouchPointAndEvent(345, 333, 1308336366.618, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(344, 330, 1308336366.664, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(343, 329, 1308336366.681, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(339, 324, 1308336366.694, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(332, 317, 1308336366.709, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(312, 300, 1308336366.728, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(279, 275, 1308336366.741, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(246, 251, 1308336366.752, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(198, 219, 1308336366.769, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(155, 196, 1308336366.783, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(155, 196, 1308336366.794, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- ),
- TouchSequence(7,
- new TouchPointAndEvent(333, 360, 1308336369.547, PlatformTouchPoint::TouchPressed, WebCore::PlatformEvent::TouchStart),
- new TouchPointAndEvent(332, 357, 1308336369.596, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(331, 353, 1308336369.661, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(326, 345, 1308336369.713, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(310, 323, 1308336369.748, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(250, 272, 1308336369.801, PlatformTouchPoint::TouchMoved, WebCore::PlatformEvent::TouchMove),
- new TouchPointAndEvent(250, 272, 1308336369.840, PlatformTouchPoint::TouchReleased, WebCore::PlatformEvent::TouchEnd)
- )
- };
-
- InspectableGestureRecognizerChromium gm;
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state());
-
- for (int i = 0; i < numberOfFlickSamples; ++i) {
- std::ostringstream failureMessageBuilder;
- failureMessageBuilder << "Failed on sample sequence " << i;
- std::string failureMessage = failureMessageBuilder.str();
-
- // There should be at least 3 events (TouchStart, TouchMove, TouchEnd) in every sequence
- ASSERT_GT(sampleFlickSequence[i].m_n, 3) << failureMessage;
-
- // First event (TouchStart) should produce a TouchDown gesture
- Gestures gestureStart(gm.processTouchEventForGestures(sampleFlickSequence[i].m_data[0]->m_event, false));
- ASSERT_EQ((unsigned int)1, gestureStart->size()) << failureMessage;
- ASSERT_EQ(PlatformEvent::GestureTapDown, (*gestureStart)[0].type()) << failureMessage;
- ASSERT_EQ(GestureRecognizerChromium::PendingSyntheticClick, gm.state()) << failureMessage;
-
- // Then we have a bunch of TouchMove events
- for (int j = 1; j < sampleFlickSequence[i].m_n - 1; ++j)
- gm.processTouchEventForGestures(sampleFlickSequence[i].m_data[j]->m_event, false);
-
- // Last event (TouchEnd) should generate a Flick gesture
- Gestures gestureEnd(gm.processTouchEventForGestures(sampleFlickSequence[i].m_data[sampleFlickSequence[i].m_n - 1]->m_event, false));
- ASSERT_EQ((unsigned int) 1, gestureEnd->size()) << failureMessage;
- ASSERT_EQ(PlatformEvent::GestureScrollEnd, (*gestureEnd)[0].type()) << failureMessage;
- double xVelocity = (*gestureEnd)[0].deltaX();
- double yVelocity = (*gestureEnd)[0].deltaY();
- double velocity = sqrt(xVelocity * xVelocity + yVelocity * yVelocity);
- ASSERT_GT(velocity, 550) << failureMessage;
- ASSERT_EQ(GestureRecognizerChromium::NoGesture, gm.state()) << failureMessage;
- }
-}
diff --git a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp
index 0ff539023..924b42d28 100644
--- a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp
+++ b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp
@@ -28,6 +28,7 @@
#include "BitmapImageSingleFrameSkia.h"
#include "GraphicsContext.h"
+#include "ImageBuffer.h"
#include "NativeImageSkia.h"
#include "SkCanvas.h"
#include <gtest/gtest.h>
@@ -57,6 +58,7 @@ TEST(PlatformContextSkiaTest, trackOpaqueTest)
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
bitmap.allocPixels();
+ bitmap.eraseColor(0);
SkCanvas canvas(bitmap);
PlatformContextSkia platformContext(&canvas);
@@ -111,6 +113,89 @@ TEST(PlatformContextSkiaTest, trackOpaqueTest)
EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
}
+TEST(PlatformContextSkiaTest, trackOpaqueClipTest)
+{
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+ bitmap.allocPixels();
+ SkCanvas canvas(bitmap);
+
+ PlatformContextSkia platformContext(&canvas);
+ platformContext.setTrackOpaqueRegion(true);
+ GraphicsContext context(&platformContext);
+
+ Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+ Color alpha(0.0f, 0.0f, 0.0f, 0.0f);
+
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
+
+ context.clearRect(FloatRect(10, 10, 90, 90));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+ context.save();
+ context.clip(FloatRect(0, 0, 10, 10));
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
+ context.restore();
+
+ context.clearRect(FloatRect(10, 10, 90, 90));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+ context.save();
+ context.clip(FloatRect(20, 20, 10, 10));
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(20, 20, 10, 10), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
+
+ context.clearRect(FloatRect(10, 10, 90, 90));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+ // The intersection of the two clips becomes empty.
+ context.clip(FloatRect(30, 20, 10, 10));
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
+ context.restore();
+
+ context.clearRect(FloatRect(10, 10, 90, 90));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+ Path path;
+ path.moveTo(FloatPoint(0, 0));
+ path.addLineTo(FloatPoint(100, 0));
+
+ // Non-rectangular clips just cause the paint to be considered non-opaque.
+ context.save();
+ context.clipPath(path, RULE_EVENODD);
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
+ context.restore();
+
+ // Another non-rectangular clip.
+ context.save();
+ context.clip(IntRect(30, 30, 20, 20));
+ context.clipOut(IntRect(30, 30, 10, 10));
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
+ context.restore();
+
+ OwnPtr<ImageBuffer> alphaImage = ImageBuffer::create(IntSize(100, 100));
+ alphaImage->context()->fillRect(IntRect(0, 0, 100, 100), alpha, ColorSpaceDeviceRGB);
+
+ // Clipping with a non-opaque Image (there is no way to mark an ImageBuffer as opaque today).
+ context.save();
+ context.clipToImageBuffer(alphaImage.get(), FloatRect(30, 30, 10, 10));
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
+ context.restore();
+}
+
TEST(PlatformContextSkiaTest, trackOpaqueJoinTest)
{
SkBitmap bitmap;
@@ -175,6 +260,7 @@ TEST(PlatformContextSkiaTest, trackOpaqueLineTest)
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
bitmap.allocPixels();
+ bitmap.eraseColor(0);
SkCanvas canvas(bitmap);
PlatformContextSkia platformContext(&canvas);
@@ -414,6 +500,7 @@ TEST(PlatformContextSkiaTest, trackOpaqueOvalTest)
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200);
bitmap.allocPixels();
+ bitmap.eraseColor(0);
SkCanvas canvas(bitmap);
PlatformContextSkia platformContext(&canvas);
@@ -461,4 +548,73 @@ TEST(PlatformContextSkiaTest, trackOpaqueOvalTest)
EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect());
}
+TEST(PlatformContextSkiaTest, layerTransformTranslateOpaqueTest)
+{
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+ bitmap.allocPixels();
+ bitmap.eraseColor(0);
+ SkCanvas canvas(bitmap);
+ AffineTransform transform;
+ transform.translate(10, 10);
+
+ PlatformContextSkia platformContext(&canvas);
+ platformContext.setTrackOpaqueRegion(true);
+ platformContext.setOpaqueRegionTransform(transform);
+ GraphicsContext context(&platformContext);
+
+ Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(20, 20, 90, 90), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, transform.inverse().mapRect(platformContext.opaqueRegion().asRect()));
+
+ context.clearRect(FloatRect(10, 10, 90, 90));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+ context.translate(30, 30);
+
+ context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(50, 50, 90, 90), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, transform.inverse().mapRect(platformContext.opaqueRegion().asRect()));
+
+ context.clearRect(FloatRect(10, 10, 90, 90));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+}
+
+TEST(PlatformContextSkiaTest, layerTransformScaleOpaqueTest)
+{
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, 400, 400);
+ bitmap.allocPixels();
+ bitmap.eraseColor(0);
+ SkCanvas canvas(bitmap);
+ AffineTransform transform;
+ transform.scale(2);
+
+ PlatformContextSkia platformContext(&canvas);
+ platformContext.setTrackOpaqueRegion(true);
+ platformContext.setOpaqueRegionTransform(transform);
+ GraphicsContext context(&platformContext);
+
+ Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
+
+ context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(40, 40, 20, 20), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, transform.inverse().mapRect(platformContext.opaqueRegion().asRect()));
+
+ context.clearRect(FloatRect(20, 20, 10, 10));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+
+ context.scale(FloatSize(2, 1));
+ context.translate(0, 10);
+
+ context.fillRect(FloatRect(20, 20, 10, 10), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
+ EXPECT_EQ_RECT(IntRect(80, 60, 40, 20), platformContext.opaqueRegion().asRect());
+ EXPECT_PIXELS_MATCH(bitmap, transform.inverse().mapRect(platformContext.opaqueRegion().asRect()));
+
+ context.clearRect(FloatRect(20, 20, 10, 10));
+ EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect());
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/PopupMenuTest.cpp b/Source/WebKit/chromium/tests/PopupMenuTest.cpp
index b56fe7db7..f053ca410 100644
--- a/Source/WebKit/chromium/tests/PopupMenuTest.cpp
+++ b/Source/WebKit/chromium/tests/PopupMenuTest.cpp
@@ -100,8 +100,8 @@ public:
virtual PopupMenuStyle menuStyle() const { return itemStyle(0); }
virtual int clientInsetLeft() const { return 0; }
virtual int clientInsetRight() const { return 0; }
- virtual int clientPaddingLeft() const { return 0; }
- virtual int clientPaddingRight() const { return 0; }
+ virtual LayoutUnit clientPaddingLeft() const { return 0; }
+ virtual LayoutUnit clientPaddingRight() const { return 0; }
virtual int listSize() const { return 10; }
virtual int selectedIndex() const { return m_selectIndex; }
virtual void popupDidHide() { }
diff --git a/Source/WebKit/chromium/tests/TextureManagerTest.cpp b/Source/WebKit/chromium/tests/TextureManagerTest.cpp
index 6fe616c24..3b576af99 100644
--- a/Source/WebKit/chromium/tests/TextureManagerTest.cpp
+++ b/Source/WebKit/chromium/tests/TextureManagerTest.cpp
@@ -24,6 +24,7 @@
#include "config.h"
+#include "ManagedTexture.h"
#include "TextureManager.h"
#include <gtest/gtest.h>
@@ -64,8 +65,7 @@ public:
bool requestTexture(TextureManager* manager, TextureToken token)
{
- unsigned textureId;
- bool result = manager->requestTexture(token, m_textureSize, m_textureFormat, textureId);
+ bool result = manager->requestTexture(token, m_textureSize, m_textureFormat);
if (result)
manager->allocateTexture(&m_fakeTextureAllocator, token);
return result;
@@ -116,9 +116,17 @@ TEST_F(TextureManagerTest, requestTextureExceedingPreferredLimit)
tokens[i] = textureManager->getToken();
EXPECT_TRUE(requestTexture(textureManager.get(), tokens[i]));
EXPECT_TRUE(textureManager->hasTexture(tokens[i]));
- textureManager->unprotectTexture(tokens[i]);
}
+ textureManager->unprotectTexture(tokens[4]);
+ textureManager->unprotectTexture(tokens[5]);
+
+ // These textures should be valid before the reduceMemoryToLimit call.
+ EXPECT_TRUE(textureManager->hasTexture(tokens[0]));
+ EXPECT_TRUE(textureManager->hasTexture(tokens[2]));
+
+ textureManager->reduceMemoryToLimit(texturesMemorySize(preferredTextures));
+
EXPECT_FALSE(textureManager->hasTexture(tokens[0]));
EXPECT_TRUE(textureManager->hasTexture(tokens[1]));
EXPECT_TRUE(textureManager->isProtected(tokens[1]));
@@ -243,4 +251,50 @@ TEST_F(TextureManagerTest, setPreferredMemoryLimitBytes)
EXPECT_EQ(texturesMemorySize(preferredTextures), textureManager->preferredMemoryLimitBytes());
}
+TEST_F(TextureManagerTest, textureManagerDestroyedBeforeManagedTexture)
+{
+ OwnPtr<TextureManager> textureManager = createTextureManager(1, 1);
+ OwnPtr<ManagedTexture> managedTexture = ManagedTexture::create(textureManager.get());
+
+ IntSize size(50, 50);
+ unsigned format = GraphicsContext3D::RGBA;
+
+ // Texture is initially invalid, but we should be able to reserve.
+ EXPECT_FALSE(managedTexture->isValid(size, format));
+ EXPECT_TRUE(managedTexture->reserve(size, format));
+ EXPECT_TRUE(managedTexture->isValid(size, format));
+
+ textureManager.clear();
+
+ // Deleting the manager should invalidate the texture and reservation attempts should fail.
+ EXPECT_FALSE(managedTexture->isValid(size, format));
+ EXPECT_FALSE(managedTexture->reserve(size, format));
+}
+
+TEST_F(TextureManagerTest, textureMovedToNewManager)
+{
+ OwnPtr<TextureManager> textureManagerOne = createTextureManager(1, 1);
+ OwnPtr<TextureManager> textureManagerTwo = createTextureManager(1, 1);
+ OwnPtr<ManagedTexture> managedTexture = ManagedTexture::create(textureManagerOne.get());
+
+ IntSize size(50, 50);
+ unsigned format = GraphicsContext3D::RGBA;
+
+ // Texture is initially invalid, but we should be able to reserve.
+ EXPECT_FALSE(managedTexture->isValid(size, format));
+ EXPECT_TRUE(managedTexture->reserve(size, format));
+ EXPECT_TRUE(managedTexture->isValid(size, format));
+
+ // Setting to the same manager should be a no-op.
+ managedTexture->setTextureManager(textureManagerOne.get());
+ EXPECT_TRUE(managedTexture->isValid(size, format));
+
+ // Setting to a different manager should invalidate the texture.
+ managedTexture->setTextureManager(textureManagerTwo.get());
+
+ EXPECT_FALSE(managedTexture->isValid(size, format));
+ EXPECT_TRUE(managedTexture->reserve(size, format));
+ EXPECT_TRUE(managedTexture->isValid(size, format));
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
index b0350db49..fcd3878a6 100644
--- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
@@ -60,13 +60,24 @@ class FakeLayerTextureUpdater : public LayerTextureUpdater {
public:
class Texture : public LayerTextureUpdater::Texture {
public:
- Texture(PassOwnPtr<ManagedTexture> texture) : LayerTextureUpdater::Texture(texture) { }
+ Texture(FakeLayerTextureUpdater* layer, PassOwnPtr<ManagedTexture> texture)
+ : LayerTextureUpdater::Texture(texture)
+ , m_layer(layer)
+ {
+ }
virtual ~Texture() { }
- virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect&, const IntRect&) { }
+ virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect&, const IntRect&) { m_layer->updateRect(); }
+
+ private:
+ FakeLayerTextureUpdater* m_layer;
};
- FakeLayerTextureUpdater() : m_prepareCount(0) { }
+ FakeLayerTextureUpdater()
+ : m_prepareCount(0)
+ , m_updateCount(0)
+ {
+ }
virtual ~FakeLayerTextureUpdater() { }
// Sets the rect to invalidate during the next call to prepareToUpdate(). After the next
@@ -77,17 +88,23 @@ public:
int prepareCount() const { return m_prepareCount; }
void clearPrepareCount() { m_prepareCount = 0; }
+ // Number of times updateRect has been invoked.
+ int updateCount() const { return m_updateCount; }
+ void clearUpdateCount() { m_updateCount = 0; }
+ void updateRect() { m_updateCount++; }
+
void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; }
// Last rect passed to prepareToUpdate().
const IntRect& lastUpdateRect() const { return m_lastUpdateRect; }
- virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(ManagedTexture::create(manager))); }
+ virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(this, ManagedTexture::create(manager))); }
virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; }
virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect);
private:
int m_prepareCount;
+ int m_updateCount;
IntRect m_rectToInvalidate;
IntRect m_lastUpdateRect;
IntRect m_opaquePaintRect;
@@ -155,13 +172,13 @@ public:
}
private:
- virtual void createTextureUpdater(const CCLayerTreeHost*) { }
-
virtual LayerTextureUpdater* textureUpdater() const
{
return m_fakeTextureUpdater.get();
}
+ virtual void createTextureUpdaterIfNeeded() { }
+
RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater;
TextureManager* m_textureManager;
};
@@ -428,8 +445,12 @@ TEST(TiledLayerChromiumTest, skipsDrawGetsReset)
IntSize contentBounds(300, 300);
IntRect contentRect(IntPoint::zero(), contentBounds);
- RefPtr<FakeTiledLayerChromium> rootLayer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager()));
- RefPtr<FakeTiledLayerChromium> childLayer = adoptRef(new FakeTiledLayerChromium(ccLayerTreeHost->contentsTextureManager()));
+ // We have enough memory for only one of the two layers.
+ int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
+ OwnPtr<TextureManager> textureManager = TextureManager::create(memoryLimit, memoryLimit, memoryLimit);
+
+ RefPtr<FakeTiledLayerChromium> rootLayer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+ RefPtr<FakeTiledLayerChromium> childLayer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
rootLayer->addChild(childLayer);
rootLayer->setBounds(contentBounds);
@@ -439,15 +460,12 @@ TEST(TiledLayerChromiumTest, skipsDrawGetsReset)
rootLayer->invalidateRect(contentRect);
childLayer->invalidateRect(contentRect);
- // We have enough memory for only one of the two layers.
- int memoryLimit = 4 * 300 * 300; // 4 bytes per pixel.
-
FakeTextureAllocator textureAllocator;
CCTextureUpdater updater(&textureAllocator);
ccLayerTreeHost->setRootLayer(rootLayer);
ccLayerTreeHost->setViewportSize(IntSize(300, 300));
- ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimit);
+ textureManager->setMaxMemoryLimitBytes(memoryLimit);
ccLayerTreeHost->updateLayers();
ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
@@ -456,12 +474,11 @@ TEST(TiledLayerChromiumTest, skipsDrawGetsReset)
EXPECT_FALSE(childLayer->skipsDraw());
ccLayerTreeHost->commitComplete();
+ textureManager->unprotectAllTextures(); // CCLayerTreeHost::commitComplete() normally does this, but since we're mocking out the manager we have to do it.
// Remove the child layer.
rootLayer->removeAllChildren();
- // Need to set the max limit again as it gets overwritten by updateLayers().
- ccLayerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(memoryLimit);
ccLayerTreeHost->updateLayers();
EXPECT_FALSE(rootLayer->skipsDraw());
@@ -564,4 +581,88 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion)
EXPECT_EQ(0u, occluded.rects().size());
}
+TEST(TiledLayerChromiumTest, resizeToSmaller)
+{
+ OwnPtr<TextureManager> textureManager = TextureManager::create(60*1024*1024, 60*1024*1024, 1024);
+ RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+
+ layer->setBounds(IntSize(700, 700));
+ layer->invalidateRect(IntRect(0, 0, 700, 700));
+ layer->prepareToUpdate(IntRect(0, 0, 700, 700));
+
+ layer->setBounds(IntSize(200, 200));
+ layer->invalidateRect(IntRect(0, 0, 200, 200));
+}
+
+TEST(TiledLayerChromiumTest, partialUpdates)
+{
+ CCSettings settings;
+ settings.maxPartialTextureUpdates = 4;
+ // Initialize without threading support.
+ WebKit::WebCompositor::initialize(0);
+ FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient;
+ RefPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLayerTreeHostClient, settings);
+
+ // Create one 500 x 300 tiled layer.
+ IntSize contentBounds(300, 200);
+ IntRect contentRect(IntPoint::zero(), contentBounds);
+
+ OwnPtr<TextureManager> textureManager = TextureManager::create(60*1024*1024, 60*1024*1024, 1024);
+ RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
+ layer->setBounds(contentBounds);
+ layer->setPosition(FloatPoint(150, 150));
+ layer->invalidateRect(contentRect);
+
+ FakeTextureAllocator textureAllocator;
+ CCTextureUpdater updater(&textureAllocator);
+
+ ccLayerTreeHost->setRootLayer(layer);
+ ccLayerTreeHost->setViewportSize(IntSize(300, 200));
+
+ // Full update of all 6 tiles.
+ ccLayerTreeHost->updateLayers();
+ ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
+ updater.update(0, 4);
+ EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
+ EXPECT_TRUE(updater.hasMoreUpdates());
+ layer->fakeLayerTextureUpdater()->clearUpdateCount();
+ updater.update(0, 4);
+ EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
+ EXPECT_FALSE(updater.hasMoreUpdates());
+ layer->fakeLayerTextureUpdater()->clearUpdateCount();
+ ccLayerTreeHost->commitComplete();
+
+ // Full update of 3 tiles and partial update of 3 tiles.
+ layer->invalidateRect(IntRect(0, 0, 300, 150));
+ ccLayerTreeHost->updateLayers();
+ ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
+ updater.update(0, 4);
+ EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
+ EXPECT_TRUE(updater.hasMoreUpdates());
+ layer->fakeLayerTextureUpdater()->clearUpdateCount();
+ updater.update(0, 4);
+ EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
+ EXPECT_FALSE(updater.hasMoreUpdates());
+ layer->fakeLayerTextureUpdater()->clearUpdateCount();
+ ccLayerTreeHost->commitComplete();
+
+ // Partial update of 6 tiles.
+ layer->invalidateRect(IntRect(50, 50, 200, 100));
+ ccLayerTreeHost->updateLayers();
+ ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
+ updater.update(0, 4);
+ EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
+ EXPECT_TRUE(updater.hasMoreUpdates());
+ layer->fakeLayerTextureUpdater()->clearUpdateCount();
+ updater.update(0, 4);
+ EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
+ EXPECT_FALSE(updater.hasMoreUpdates());
+ layer->fakeLayerTextureUpdater()->clearUpdateCount();
+ ccLayerTreeHost->commitComplete();
+
+ ccLayerTreeHost->setRootLayer(0);
+ ccLayerTreeHost.clear();
+ WebKit::WebCompositor::shutdown();
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
index f207c06a2..ad5810524 100644
--- a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
+++ b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp
@@ -28,6 +28,9 @@
#include "WebCompositorInputHandlerImpl.h"
#include "WebCompositor.h"
+#include "WebCompositorInputHandlerClient.h"
+#include "WebInputEvent.h"
+#include "cc/CCInputHandler.h"
#include "cc/CCSingleThreadProxy.h"
#include <gtest/gtest.h>
@@ -38,6 +41,98 @@ using WebKit::WebCompositorInputHandlerImpl;
namespace {
+class MockInputHandlerClient : public WebCore::CCInputHandlerClient {
+ WTF_MAKE_NONCOPYABLE(MockInputHandlerClient);
+public:
+ MockInputHandlerClient()
+ : m_scrollStatus(ScrollStarted)
+ , m_pinchStarted(false)
+ , m_pinchEnded(false)
+ , m_pinchMagnification(0)
+ {
+ }
+ virtual ~MockInputHandlerClient() { }
+
+ void setScrollStatus(ScrollStatus status) { m_scrollStatus = status; }
+
+ bool pinchStarted() const { return m_pinchStarted; }
+ bool pinchEnded() const { return m_pinchEnded; }
+ float pinchMaginifcation() const { return m_pinchMagnification; }
+
+ void resetPinch()
+ {
+ m_pinchStarted = m_pinchEnded = false;
+ m_pinchMagnification = 0;
+ }
+
+private:
+ virtual void setNeedsRedraw() OVERRIDE { }
+ virtual ScrollStatus scrollBegin(const WebCore::IntPoint&) OVERRIDE
+ {
+ return m_scrollStatus;
+ }
+ virtual void scrollBy(const WebCore::IntSize&) OVERRIDE { }
+ virtual void scrollEnd() OVERRIDE { }
+
+ virtual bool haveWheelEventHandlers() OVERRIDE { return false; }
+ virtual void pinchGestureBegin() OVERRIDE
+ {
+ m_pinchStarted = true;
+ }
+ virtual void pinchGestureUpdate(float magnifyDelta, const WebCore::IntPoint& anchor) OVERRIDE
+ {
+ m_pinchMagnification = magnifyDelta;
+ }
+ virtual void pinchGestureEnd() OVERRIDE
+ {
+ m_pinchEnded = true;
+ }
+ virtual void startPageScaleAnimation(const WebCore::IntSize& targetPosition,
+ bool anchorPoint,
+ float pageScale,
+ double startTimeMs,
+ double durationMs) OVERRIDE { }
+
+ ScrollStatus m_scrollStatus;
+ bool m_pinchStarted;
+ bool m_pinchEnded;
+ float m_pinchMagnification;
+};
+
+class MockWebCompositorInputHandlerClient : public WebKit::WebCompositorInputHandlerClient {
+ WTF_MAKE_NONCOPYABLE(MockWebCompositorInputHandlerClient);
+public:
+ MockWebCompositorInputHandlerClient()
+ : m_handled(false)
+ , m_sendToWidget(false)
+ {
+ }
+ virtual ~MockWebCompositorInputHandlerClient() { }
+
+ void reset()
+ {
+ m_handled = false;
+ m_sendToWidget = false;
+ }
+
+ bool handled() const { return m_handled; }
+ bool sendToWidget() const { return m_sendToWidget; }
+
+private:
+ virtual void willShutdown() OVERRIDE { }
+ virtual void didHandleInputEvent() OVERRIDE
+ {
+ m_handled = true;
+ }
+ virtual void didNotHandleInputEvent(bool sendToWidget) OVERRIDE
+ {
+ m_sendToWidget = sendToWidget;
+ }
+
+ bool m_handled;
+ bool m_sendToWidget;
+};
+
TEST(WebCompositorInputHandlerImpl, fromIdentifier)
{
WebKit::WebCompositor::initialize(0);
@@ -53,13 +148,13 @@ TEST(WebCompositorInputHandlerImpl, fromIdentifier)
int compositorIdentifier = -1;
{
- OwnPtr<WebCompositorInputHandlerImpl> comp = WebCompositorInputHandlerImpl::create(0);
- compositorIdentifier = comp->identifier();
+ OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(0);
+ compositorIdentifier = inputHandler->identifier();
// The compositor we just created should be locatable.
- EXPECT_EQ(comp.get(), WebCompositorInputHandler::fromIdentifier(compositorIdentifier));
+ EXPECT_EQ(inputHandler.get(), WebCompositorInputHandler::fromIdentifier(compositorIdentifier));
// But nothing else.
- EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(comp->identifier() + 10));
+ EXPECT_EQ(0, WebCompositorInputHandler::fromIdentifier(inputHandler->identifier() + 10));
}
// After the compositor is destroyed, its entry should be removed from the map.
@@ -68,4 +163,122 @@ TEST(WebCompositorInputHandlerImpl, fromIdentifier)
WebKit::WebCompositor::shutdown();
}
+TEST(WebCompositorInputHandlerImpl, gestureScroll)
+{
+ WebKit::WebCompositor::initialize(0);
+#ifndef NDEBUG
+ // WebCompositorInputHandler APIs can only be called from the compositor thread.
+ WebCore::DebugScopedSetImplThread alwaysImplThread;
+#endif
+
+ MockInputHandlerClient mockInputHandler;
+ OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(&mockInputHandler);
+ MockWebCompositorInputHandlerClient mockClient;
+ inputHandler->setClient(&mockClient);
+
+ WebKit::WebGestureEvent gesture;
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollBegin;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollUpdate;
+ gesture.deltaY = 40;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollEnd;
+ gesture.deltaY = 0;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ mockInputHandler.setScrollStatus(WebCore::CCInputHandlerClient::ScrollFailed);
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollBegin;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_FALSE(mockClient.handled());
+ EXPECT_TRUE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollUpdate;
+ gesture.deltaY = 40;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_FALSE(mockClient.handled());
+ EXPECT_TRUE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ gesture.type = WebKit::WebInputEvent::GestureScrollEnd;
+ gesture.deltaY = 0;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_FALSE(mockClient.handled());
+ EXPECT_TRUE(mockClient.sendToWidget());
+ mockClient.reset();
+
+ inputHandler->setClient(0);
+
+ WebKit::WebCompositor::shutdown();
+}
+
+TEST(WebCompositorInputHandlerImpl, gesturePinch)
+{
+ WebKit::WebCompositor::initialize(0);
+#ifndef NDEBUG
+ // WebCompositorInputHandler APIs can only be called from the compositor thread.
+ WebCore::DebugScopedSetImplThread alwaysImplThread;
+#endif
+
+ MockInputHandlerClient mockInputHandler;
+ OwnPtr<WebCompositorInputHandlerImpl> inputHandler = WebCompositorInputHandlerImpl::create(&mockInputHandler);
+ MockWebCompositorInputHandlerClient mockClient;
+ inputHandler->setClient(&mockClient);
+
+ WebKit::WebGestureEvent gesture;
+
+ gesture.type = WebKit::WebInputEvent::GesturePinchBegin;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ EXPECT_TRUE(mockInputHandler.pinchStarted());
+ mockClient.reset();
+ mockInputHandler.resetPinch();
+
+ gesture.type = WebKit::WebInputEvent::GesturePinchUpdate;
+ gesture.deltaX = 1.5;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ EXPECT_FALSE(mockInputHandler.pinchEnded());
+ EXPECT_EQ(1.5, mockInputHandler.pinchMaginifcation());
+ mockClient.reset();
+ mockInputHandler.resetPinch();
+
+ gesture.type = WebKit::WebInputEvent::GesturePinchUpdate;
+ gesture.deltaX = 0.5;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ EXPECT_FALSE(mockInputHandler.pinchEnded());
+ EXPECT_EQ(0.5, mockInputHandler.pinchMaginifcation());
+ mockClient.reset();
+ mockInputHandler.resetPinch();
+
+ gesture.type = WebKit::WebInputEvent::GesturePinchEnd;
+ inputHandler->handleInputEvent(gesture);
+ EXPECT_TRUE(mockClient.handled());
+ EXPECT_FALSE(mockClient.sendToWidget());
+ EXPECT_TRUE(mockInputHandler.pinchEnded());
+ mockClient.reset();
+ mockInputHandler.resetPinch();
+
+ inputHandler->setClient(0);
+
+ WebKit::WebCompositor::shutdown();
+}
+
}
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp
index 06b26469a..b59001860 100644
--- a/Source/WebKit/chromium/tests/WebFrameTest.cpp
+++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp
@@ -381,7 +381,7 @@ TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds)
EXPECT_EQ(1, matchCount);
}
-TEST_F(WebFrameTest, DISABLED_FindInPage)
+TEST_F(WebFrameTest, FindInPage)
{
registerMockedHttpURLLoad("find.html");
WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find.html");