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

Unified Diff: cc/CCLayerTreeHostImplTest.cpp

Issue 10916279: Chromium compositor change implementing page-scale driven pinch-zoom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Change m_unpinchedViewportSize and remove unnecessary >1 page scale clamping. Created 8 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
Index: cc/CCLayerTreeHostImplTest.cpp
===================================================================
--- cc/CCLayerTreeHostImplTest.cpp (revision 159486)
+++ cc/CCLayerTreeHostImplTest.cpp (working copy)
@@ -50,13 +50,21 @@
namespace {
-class CCLayerTreeHostImplTest : public testing::Test, public CCLayerTreeHostImplClient {
+class CCLayerTreeHostImplTest : public testing::TestWithParam<bool>,
+ /* public ::testing::WithParamInterface<bool>,*/
jamesr 2012/10/03 19:48:57 hm, what's this? leftovers?
Jeff Timanus 2012/10/03 20:56:04 Yes. Old cruft. Removed.
+ public CCLayerTreeHostImplClient {
public:
CCLayerTreeHostImplTest()
: m_onCanDrawStateChangedCalled(false)
, m_didRequestCommit(false)
, m_didRequestRedraw(false)
{
+ }
+
+ virtual void SetUp()
+ {
+
+ CCSettings::setPageScalePinchZoomEnabled(GetParam());
CCLayerTreeSettings settings;
settings.minimumOcclusionTrackingSize = IntSize();
@@ -65,6 +73,11 @@
m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10));
}
+ virtual void TearDown()
+ {
+ CCSettings::reset();
+ }
+
virtual void didLoseContextOnImplThread() OVERRIDE { }
virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
virtual void onVSyncParametersChanged(double, double) OVERRIDE { }
@@ -182,7 +195,7 @@
virtual bool makeContextCurrent() { return false; }
};
-TEST_F(CCLayerTreeHostImplTest, notifyIfCanDrawChanged)
+TEST_P(CCLayerTreeHostImplTest, notifyIfCanDrawChanged)
{
// Note: It is not possible to disable the renderer once it has been set,
// so we do not need to test that disabling the renderer notifies us
@@ -229,7 +242,7 @@
m_onCanDrawStateChangedCalled = false;
}
-TEST_F(CCLayerTreeHostImplTest, scrollDeltaNoLayers)
+TEST_P(CCLayerTreeHostImplTest, scrollDeltaNoLayers)
{
ASSERT_FALSE(m_hostImpl->rootLayer());
@@ -237,7 +250,7 @@
ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
}
-TEST_F(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
+TEST_P(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
{
{
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
@@ -263,7 +276,7 @@
expectClearedScrollDeltasRecursive(root);
}
-TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
+TEST_P(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
{
IntPoint scrollPosition(20, 30);
IntSize scrollDelta(11, -15);
@@ -296,7 +309,7 @@
EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
}
-TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
+TEST_P(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
{
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
@@ -309,13 +322,13 @@
EXPECT_TRUE(m_didRequestCommit);
}
-TEST_F(CCLayerTreeHostImplTest, scrollWithoutRootLayer)
+TEST_P(CCLayerTreeHostImplTest, scrollWithoutRootLayer)
{
// We should not crash when trying to scroll an empty layer tree.
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollIgnored);
}
-TEST_F(CCLayerTreeHostImplTest, scrollWithoutRenderer)
+TEST_P(CCLayerTreeHostImplTest, scrollWithoutRenderer)
{
CCLayerTreeSettings settings;
m_hostImpl = CCLayerTreeHostImpl::create(settings, this);
@@ -330,7 +343,7 @@
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollIgnored);
}
-TEST_F(CCLayerTreeHostImplTest, replaceTreeWhileScrolling)
+TEST_P(CCLayerTreeHostImplTest, replaceTreeWhileScrolling)
{
const int scrollLayerId = 1;
@@ -352,7 +365,7 @@
expectContains(*scrollInfo, scrollLayerId, scrollDelta);
}
-TEST_F(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
+TEST_P(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
{
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
@@ -364,7 +377,7 @@
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
}
-TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers)
+TEST_P(CCLayerTreeHostImplTest, wheelEventHandlers)
{
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
@@ -380,7 +393,7 @@
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollStarted);
}
-TEST_F(CCLayerTreeHostImplTest, shouldScrollOnMainThread)
+TEST_P(CCLayerTreeHostImplTest, shouldScrollOnMainThread)
{
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
@@ -393,7 +406,7 @@
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollOnMainThread);
}
-TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionBasic)
+TEST_P(CCLayerTreeHostImplTest, nonFastScrollableRegionBasic)
{
setupScrollAndContentsLayers(IntSize(200, 200));
m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100));
@@ -415,7 +428,7 @@
m_hostImpl->scrollEnd();
}
-TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
+TEST_P(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
{
setupScrollAndContentsLayers(IntSize(200, 200));
m_hostImpl->setViewportSize(IntSize(100, 100), IntSize(100, 100));
@@ -434,7 +447,7 @@
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollOnMainThread);
}
-TEST_F(CCLayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor)
+TEST_P(CCLayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor)
{
setupScrollAndContentsLayers(IntSize(100, 100));
@@ -452,8 +465,13 @@
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75));
}
-TEST_F(CCLayerTreeHostImplTest, pinchGesture)
+TEST_P(CCLayerTreeHostImplTest, implPinchZoom)
{
+ // This test is specific to the page-scale based pinch zoom.
+ if (!CCSettings::pageScalePinchZoomEnabled())
jamesr 2012/10/03 19:48:57 not sure I grok this with line 474 - it looks like
Jeff Timanus 2012/10/03 20:56:04 This is a good catch. Previous patches (before I
+ return;
+
+ CCSettings::setPageScalePinchZoomEnabled(true);
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
initializeRendererAndDrawFrame();
@@ -461,12 +479,67 @@
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
ASSERT(scrollLayer);
- const float minPageScale = 0.5, maxPageScale = 4;
+ const float minPageScale = 1, maxPageScale = 4;
+ const WebTransformationMatrix identityScaleTransform;
+ // The impl-based pinch zoome should not adjust the max scroll position.
+ {
+ m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
+ scrollLayer->setImplTransform(identityScaleTransform);
+ scrollLayer->setScrollDelta(IntSize());
+
+ float pageScaleDelta = 2;
+ m_hostImpl->pinchGestureBegin();
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
+ m_hostImpl->pinchGestureEnd();
+ EXPECT_TRUE(m_didRequestRedraw);
+ EXPECT_TRUE(m_didRequestCommit);
+
+ OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
+ EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
+
+ EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50));
+ }
+
+ // Scrolling after a pinch gesture should always be in local space. The scroll deltas do not
+ // have the page scale factor applied.
+ {
+ m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
+ scrollLayer->setImplTransform(identityScaleTransform);
+ scrollLayer->setScrollDelta(IntSize());
+
+ float pageScaleDelta = 2;
+ m_hostImpl->pinchGestureBegin();
+ m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
+ m_hostImpl->pinchGestureEnd();
+
+ IntSize scrollDelta(0, 10);
+ EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
+ m_hostImpl->scrollBy(IntPoint(), scrollDelta);
+ m_hostImpl->scrollEnd();
+
+ OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
+ expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollDelta);
+ }
+}
+
+TEST_P(CCLayerTreeHostImplTest, pinchGesture)
+{
+ setupScrollAndContentsLayers(IntSize(100, 100));
+ m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
+ initializeRendererAndDrawFrame();
+
+ CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
+ ASSERT(scrollLayer);
+
+ const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5;
+ const float maxPageScale = 4;
+ const WebTransformationMatrix identityScaleTransform;
+
// Basic pinch zoom in gesture
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 2;
@@ -483,7 +556,7 @@
// Zoom-in clamping
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 10;
@@ -498,7 +571,7 @@
// Zoom-out clamping
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
scrollLayer->setScrollPosition(IntPoint(50, 50));
@@ -510,14 +583,18 @@
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
- // Pushed to (0,0) via clamping against contents layer size.
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
+ if (!CCSettings::pageScalePinchZoomEnabled()) {
+ // Pushed to (0,0) via clamping against contents layer size.
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
+ } else {
+ EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
+ }
}
// Two-finger panning
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
scrollLayer->setScrollPosition(IntPoint(20, 20));
@@ -533,7 +610,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation)
+TEST_P(CCLayerTreeHostImplTest, pageScaleAnimation)
{
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
@@ -542,16 +619,18 @@
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
ASSERT(scrollLayer);
- const float minPageScale = 0.5, maxPageScale = 4;
+ const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5;
+ const float maxPageScale = 4;
const double startTime = 1;
const double duration = 0.1;
const double halfwayThroughAnimation = startTime + duration / 2;
const double endTime = startTime + duration;
+ const WebTransformationMatrix identityScaleTransform;
// Non-anchor zoom-in
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollPosition(IntPoint(50, 50));
m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration);
@@ -568,7 +647,7 @@
// Anchor zoom-out
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollPosition(IntPoint(50, 50));
m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration);
@@ -583,7 +662,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
+TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZooming)
{
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
@@ -592,7 +671,8 @@
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
ASSERT(scrollLayer);
- const float minPageScale = 0.5, maxPageScale = 4;
+ const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5;
+ const float maxPageScale = 4;
// Pinch zoom in.
{
@@ -612,7 +692,11 @@
m_hostImpl->pinchGestureEnd();
scrollInfo = m_hostImpl->processScrollDeltas();
EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ if (!CCSettings::pageScalePinchZoomEnabled()) {
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ } else {
+ EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
+ }
}
// Pinch zoom out.
@@ -626,18 +710,28 @@
// Since we are pinch zooming out, we should get an update to zoom all
// the way out to the minimum page scale.
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0));
+ if (!CCSettings::pageScalePinchZoomEnabled()) {
+ EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0));
+ } else {
+ EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
+ EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
+ }
// Once the gesture ends, we get the final scroll and page scale values.
m_hostImpl->pinchGestureEnd();
scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8));
+ if (CCSettings::pageScalePinchZoomEnabled()) {
+ EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ } else {
+ EXPECT_EQ(scrollInfo->pageScaleDelta, zoomOutDelta);
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(8, 8));
+ }
}
}
-TEST_F(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPageScale)
+TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPageScale)
{
setupScrollAndContentsLayers(IntSize(100, 100));
m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
@@ -646,7 +740,8 @@
CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
ASSERT(scrollLayer);
- const float minPageScale = 0.5, maxPageScale = 4;
+ const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5;
+ const float maxPageScale = 4;
const double startTime = 1;
const double duration = 0.1;
const double halfwayThroughAnimation = startTime + duration / 2;
@@ -661,9 +756,15 @@
// animation.
m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation);
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
- EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
- expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ if (!CCSettings::pageScalePinchZoomEnabled()) {
+ EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
+ expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
+ } else {
+ EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
+ EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
+ }
+
// Scrolling during the animation is ignored.
const IntSize scrollDelta(0, 10);
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
@@ -724,7 +825,7 @@
bool m_willDrawCalled;
};
-TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer)
+TEST_P(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer)
{
// The root layer is always drawn, so run this test on a child layer that
// will be masked out by the root layer's bounds.
@@ -769,7 +870,7 @@
EXPECT_FALSE(layer->visibleContentRect().isEmpty());
}
-TEST_F(CCLayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer)
+TEST_P(CCLayerTreeHostImplTest, willDrawNotCalledOnOccludedLayer)
{
IntSize bigSize(1000, 1000);
m_hostImpl->setViewportSize(bigSize, bigSize);
@@ -804,7 +905,7 @@
EXPECT_TRUE(topLayer->didDrawCalled());
}
-TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers)
+TEST_P(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers)
{
m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(m_hostImpl->rootLayer());
@@ -856,7 +957,7 @@
}
};
-TEST_F(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard)
+TEST_P(CCLayerTreeHostImplTest, prepareToDrawFailsWhenAnimationUsesCheckerboard)
{
// When the texture is not missing, we draw as usual.
m_hostImpl->setRootLayer(DidDrawCheckLayer::create(1));
@@ -897,7 +998,7 @@
m_hostImpl->didDrawAllLayers(frame);
}
-TEST_F(CCLayerTreeHostImplTest, scrollRootIgnored)
+TEST_P(CCLayerTreeHostImplTest, scrollRootIgnored)
{
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
root->setScrollable(false);
@@ -910,7 +1011,7 @@
EXPECT_FALSE(m_didRequestCommit);
}
-TEST_F(CCLayerTreeHostImplTest, scrollNonCompositedRoot)
+TEST_P(CCLayerTreeHostImplTest, scrollNonCompositedRoot)
{
// Test the configuration where a non-composited root layer is embedded in a
// scrollable outer layer.
@@ -944,7 +1045,7 @@
EXPECT_TRUE(m_didRequestCommit);
}
-TEST_F(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
+TEST_P(CCLayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
{
IntSize surfaceSize(10, 10);
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
@@ -962,7 +1063,7 @@
EXPECT_TRUE(m_didRequestCommit);
}
-TEST_F(CCLayerTreeHostImplTest, scrollMissesChild)
+TEST_P(CCLayerTreeHostImplTest, scrollMissesChild)
{
IntSize surfaceSize(10, 10);
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
@@ -977,7 +1078,7 @@
EXPECT_FALSE(m_didRequestCommit);
}
-TEST_F(CCLayerTreeHostImplTest, scrollMissesBackfacingChild)
+TEST_P(CCLayerTreeHostImplTest, scrollMissesBackfacingChild)
{
IntSize surfaceSize(10, 10);
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
@@ -1000,7 +1101,7 @@
EXPECT_FALSE(m_didRequestCommit);
}
-TEST_F(CCLayerTreeHostImplTest, scrollBlockedByContentLayer)
+TEST_P(CCLayerTreeHostImplTest, scrollBlockedByContentLayer)
{
IntSize surfaceSize(10, 10);
OwnPtr<CCLayerImpl> contentLayer = createScrollableLayer(1, surfaceSize);
@@ -1018,7 +1119,7 @@
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollOnMainThread);
}
-TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
+TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
{
IntSize surfaceSize(10, 10);
float pageScale = 2;
@@ -1037,8 +1138,10 @@
// Set new page scale from main thread.
m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale);
- // The scale should apply to the scroll delta.
- expectedScrollDelta.scale(pageScale);
+ if (!CCSettings::pageScalePinchZoomEnabled()) {
+ // The scale should apply to the scroll delta.
+ expectedScrollDelta.scale(pageScale);
+ }
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScrollDelta);
@@ -1046,10 +1149,10 @@
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1);
+ EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix());
}
-TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
+TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
{
IntSize surfaceSize(10, 10);
float pageScale = 2;
@@ -1070,6 +1173,7 @@
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, IntPoint());
m_hostImpl->pinchGestureEnd();
+ m_hostImpl->updateRootScrollLayerImplTransform();
// The scroll delta is not scaled because the main thread did not scale.
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -1079,14 +1183,20 @@
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side.
- EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), pageScale);
+ WebTransformationMatrix expectedScale;
+ expectedScale.scale(pageScale);
+ EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
}
-TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
+TEST_P(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
{
IntSize surfaceSize(10, 10);
float defaultPageScale = 1;
+ WebTransformationMatrix defaultPageScaleMatrix;
+
float newPageScale = 2;
+ WebTransformationMatrix newPageScaleMatrix;
+ newPageScaleMatrix.scale(newPageScale);
// Create a normal scrollable root layer and another scrollable child layer.
setupScrollAndContentsLayers(surfaceSize);
@@ -1101,11 +1211,12 @@
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint());
m_hostImpl->pinchGestureEnd();
+ m_hostImpl->updateRootScrollLayerImplTransform();
// The page scale delta should only be applied to the scrollable root layer.
- EXPECT_EQ(root->pageScaleDelta(), newPageScale);
- EXPECT_EQ(child->pageScaleDelta(), defaultPageScale);
- EXPECT_EQ(grandChild->pageScaleDelta(), defaultPageScale);
+ EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
+ EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
+ EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
// Make sure all the layers are drawn with the page scale delta applied, i.e., the page scale
// delta on the root layer is applied hierarchically.
@@ -1122,7 +1233,7 @@
EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale);
}
-TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
+TEST_P(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
{
IntSize surfaceSize(10, 10);
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
@@ -1148,8 +1259,12 @@
float pageScale = 2;
m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
- // The scale should apply to the scroll delta.
- expectedScrollDelta.scale(pageScale);
+ m_hostImpl->updateRootScrollLayerImplTransform();
+
+ if (!CCSettings::pageScalePinchZoomEnabled()) {
+ // The scale should apply to the scroll delta.
+ expectedScrollDelta.scale(pageScale);
+ }
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
@@ -1157,10 +1272,11 @@
EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- EXPECT_EQ(child->pageScaleDelta(), 1);
+ WebTransformationMatrix identityTransform;
+ EXPECT_EQ(child->implTransform(), WebTransformationMatrix());
}
-TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit)
+TEST_P(CCLayerTreeHostImplTest, scrollChildBeyondLimit)
{
// Scroll a child layer beyond its maximum scroll range and make sure the
// parent layer is scrolled on the axis on which the child was unable to
@@ -1197,7 +1313,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, scrollEventBubbling)
+TEST_P(CCLayerTreeHostImplTest, scrollEventBubbling)
{
// When we try to scroll a non-scrollable child layer, the scroll delta
// should be applied to one of its ancestors if possible.
@@ -1225,7 +1341,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, scrollBeforeRedraw)
+TEST_P(CCLayerTreeHostImplTest, scrollBeforeRedraw)
{
IntSize surfaceSize(10, 10);
m_hostImpl->setRootLayer(createScrollableLayer(1, surfaceSize));
@@ -1240,7 +1356,7 @@
EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted);
}
-TEST_F(CCLayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
+TEST_P(CCLayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
{
setupScrollAndContentsLayers(IntSize(100, 100));
@@ -1275,7 +1391,7 @@
expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScrollDelta);
}
-TEST_F(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
+TEST_P(CCLayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
{
setupScrollAndContentsLayers(IntSize(100, 100));
int childLayerId = 3;
@@ -1336,7 +1452,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, scrollScaledLayer)
+TEST_P(CCLayerTreeHostImplTest, scrollScaledLayer)
{
setupScrollAndContentsLayers(IntSize(100, 100));
@@ -1457,7 +1573,7 @@
CCResourceProvider::ResourceId m_resourceId;
};
-TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
+TEST_P(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers)
{
{
OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
@@ -1675,7 +1791,7 @@
}
-TEST_F(CCLayerTreeHostImplTest, viewportCovered)
+TEST_P(CCLayerTreeHostImplTest, viewportCovered)
{
m_hostImpl->initializeRenderer(createContext());
m_hostImpl->setBackgroundColor(SK_ColorGRAY);
@@ -1784,7 +1900,7 @@
// Only reshape when we know we are going to draw. Otherwise, the reshape
// can leave the window at the wrong size if we never draw and the proper
// viewport size is never set.
-TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw)
+TEST_P(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw)
{
OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create(adoptPtr(new ReshapeTrackerContext));
ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(ccContext->context3D());
@@ -1827,7 +1943,7 @@
// Make sure damage tracking propagates all the way to the graphics context,
// where it should request to swap only the subBuffer that is damaged.
-TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
+TEST_P(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
{
OwnPtr<CCGraphicsContext> ccContext = FakeWebCompositorOutputSurface::create(adoptPtr(new PartialSwapTrackerContext));
PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(ccContext->context3D());
@@ -1901,7 +2017,7 @@
EXPECT_EQ(expectedSwapRect.height(), actualSwapRect.height());
}
-TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface)
+TEST_P(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface)
{
CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
CCLayerImpl* child = new FakeDrawableCCLayerImpl(2);
@@ -2041,7 +2157,7 @@
}
};
-TEST_F(CCLayerTreeHostImplTest, noPartialSwap)
+TEST_P(CCLayerTreeHostImplTest, noPartialSwap)
{
OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new MockContext));
MockContext* mockContext = static_cast<MockContext*>(context->context3D());
@@ -2060,7 +2176,7 @@
Mock::VerifyAndClearExpectations(&mockContext);
}
-TEST_F(CCLayerTreeHostImplTest, partialSwap)
+TEST_P(CCLayerTreeHostImplTest, partialSwap)
{
OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new MockContext));
MockContext* mockContext = static_cast<MockContext*>(context->context3D());
@@ -2184,7 +2300,7 @@
return myHostImpl.release();
}
-TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap)
+TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap)
{
OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this);
@@ -2205,7 +2321,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap)
+TEST_P(CCLayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap)
{
OwnPtr<CCLayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this);
@@ -2248,7 +2364,7 @@
bool m_didLoseContextCalled;
};
-TEST_F(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers)
+TEST_P(CCLayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers)
{
m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1));
ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificationCheckLayer*>(m_hostImpl->rootLayer());
@@ -2270,7 +2386,7 @@
EXPECT_TRUE(layer2->didLoseContextCalled());
}
-TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost)
+TEST_P(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost)
{
CCLayerTreeSettings settings;
m_hostImpl = CCLayerTreeHostImpl::create(settings, this);
@@ -2294,7 +2410,7 @@
unsigned m_succeedCount;
};
-TEST_F(CCLayerTreeHostImplTest, contextLostDuringInitialize)
+TEST_P(CCLayerTreeHostImplTest, contextLostDuringInitialize)
{
CCLayerTreeSettings settings;
m_hostImpl = CCLayerTreeHostImpl::create(settings, this);
@@ -2544,7 +2660,7 @@
return pass.Pass();
}
-TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
+TEST_P(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
{
int layerId = 1;
@@ -2731,7 +2847,7 @@
unsigned m_numTextures;
};
-TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)
+TEST_P(CCLayerTreeHostImplTest, layersFreeTextures)
{
OwnPtr<CCLayerImpl> rootLayer(CCLayerImpl::create(1));
rootLayer->setBounds(IntSize(10, 10));
@@ -2802,7 +2918,7 @@
MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset));
};
-TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground)
+TEST_P(CCLayerTreeHostImplTest, hasTransparentBackground)
{
OwnPtr<CCGraphicsContext> context = FakeWebCompositorOutputSurface::create(adoptPtr(new MockDrawQuadsToFillScreenContext));
MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(context->context3D());
@@ -2881,7 +2997,7 @@
using CCRendererGL::releaseRenderPassTextures;
};
-TEST_F(CCLayerTreeHostImplTest, textureCachingWithClipping)
+TEST_P(CCLayerTreeHostImplTest, textureCachingWithClipping)
{
CCSettings::setPartialSwapEnabled(true);
@@ -2978,7 +3094,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusion)
+TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusion)
{
CCSettings::setPartialSwapEnabled(false);
@@ -3094,7 +3210,7 @@
}
-TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
+TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
{
CCSettings::setPartialSwapEnabled(false);
@@ -3210,7 +3326,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
+TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
{
CCSettings::setPartialSwapEnabled(false);
@@ -3299,7 +3415,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
+TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
{
CCSettings::setPartialSwapEnabled(false);
@@ -3373,7 +3489,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
+TEST_P(CCLayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
{
CCSettings::setPartialSwapEnabled(true);
@@ -3486,7 +3602,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, textureCachingWithScissor)
+TEST_P(CCLayerTreeHostImplTest, textureCachingWithScissor)
{
CCSettings::setPartialSwapEnabled(false);
@@ -3593,7 +3709,7 @@
EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(childPassId));
}
-TEST_F(CCLayerTreeHostImplTest, surfaceTextureCaching)
+TEST_P(CCLayerTreeHostImplTest, surfaceTextureCaching)
{
CCSettings::setPartialSwapEnabled(true);
@@ -3754,7 +3870,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
+TEST_P(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
{
CCSettings::setPartialSwapEnabled(false);
@@ -3917,7 +4033,7 @@
}
}
-TEST_F(CCLayerTreeHostImplTest, releaseContentsTextureShouldTriggerCommit)
+TEST_P(CCLayerTreeHostImplTest, releaseContentsTextureShouldTriggerCommit)
{
m_hostImpl->releaseContentsTextures();
EXPECT_TRUE(m_didRequestCommit);
@@ -4232,7 +4348,7 @@
EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << testCase.name;
}
-TEST_F(CCLayerTreeHostImplTest, testRemoveRenderPasses)
+TEST_P(CCLayerTreeHostImplTest, testRemoveRenderPasses)
{
OwnPtr<CCGraphicsContext> context(createContext());
ASSERT_TRUE(context->context3D());
@@ -4250,4 +4366,8 @@
}
}
+INSTANTIATE_TEST_CASE_P(CCLayerTreeHostImplTests,
+ CCLayerTreeHostImplTest,
+ ::testing::Values(false, true));
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698