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

Side by Side Diff: cc/layer_unittest.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch for landing Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/math_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer.h" 5 #include "cc/layer.h"
6 6
7 #include "cc/keyframed_animation_curve.h" 7 #include "cc/keyframed_animation_curve.h"
8 #include "cc/layer_impl.h" 8 #include "cc/layer_impl.h"
9 #include "cc/layer_painter.h" 9 #include "cc/layer_painter.h"
10 #include "cc/layer_tree_host.h" 10 #include "cc/layer_tree_host.h"
11 #include "cc/math_util.h"
11 #include "cc/single_thread_proxy.h" 12 #include "cc/single_thread_proxy.h"
12 #include "cc/thread.h" 13 #include "cc/thread.h"
13 #include "cc/test/fake_layer_tree_host_client.h" 14 #include "cc/test/fake_layer_tree_host_client.h"
14 #include "cc/test/geometry_test_utils.h" 15 #include "cc/test/geometry_test_utils.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include <public/WebTransformationMatrix.h> 18 #include "ui/gfx/transform.h"
18 19
19 using namespace WebKitTests; 20 using namespace WebKitTests;
20 using WebKit::WebTransformationMatrix;
21 using ::testing::Mock; 21 using ::testing::Mock;
22 using ::testing::_; 22 using ::testing::_;
23 using ::testing::AtLeast; 23 using ::testing::AtLeast;
24 using ::testing::AnyNumber; 24 using ::testing::AnyNumber;
25 25
26 #define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCom mit, codeToTest) do { \ 26 #define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCom mit, codeToTest) do { \
27 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedS etNeedsCommit)); \ 27 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedS etNeedsCommit)); \
28 codeToTest; \ 28 codeToTest; \
29 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); \ 29 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); \
30 } while (0) 30 } while (0)
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 scoped_refptr<Layer> dummyLayer = Layer::create(); // just a dummy layer for this test case. 498 scoped_refptr<Layer> dummyLayer = Layer::create(); // just a dummy layer for this test case.
499 499
500 // sanity check of initial test condition 500 // sanity check of initial test condition
501 EXPECT_FALSE(testLayer->needsDisplay()); 501 EXPECT_FALSE(testLayer->needsDisplay());
502 502
503 // Test properties that should not call needsDisplay and needsCommit when ch anged. 503 // Test properties that should not call needsDisplay and needsCommit when ch anged.
504 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleContent Rect(gfx::Rect(0, 0, 40, 50))); 504 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleContent Rect(gfx::Rect(0, 0, 40, 50)));
505 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUseLCDText(tru e)); 505 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUseLCDText(tru e));
506 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0. 5)); 506 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0. 5));
507 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0 )); 507 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0 ));
508 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform( WebTransformationMatrix())); 508 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform( gfx::Transform()));
509 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTra nsform(WebTransformationMatrix())); 509 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTra nsform(gfx::Transform()));
510 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableConten tRect(gfx::Rect(4, 5, 6, 7))); 510 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableConten tRect(gfx::Rect(4, 5, 6, 7)));
511 EXPECT_FALSE(testLayer->needsDisplay()); 511 EXPECT_FALSE(testLayer->needsDisplay());
512 512
513 // Next, test properties that should call setNeedsCommit (but not setNeedsDi splay) 513 // Next, test properties that should call setNeedsCommit (but not setNeedsDi splay)
514 // All properties need to be set to new values in order for setNeedsCommit t o be called. 514 // All properties need to be set to new values in order for setNeedsCommit t o be called.
515 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPoint(gf x::PointF(1.23f, 4.56f))); 515 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPoint(gf x::PointF(1.23f, 4.56f)));
516 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPointZ(0 .7f)); 516 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPointZ(0 .7f));
517 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColo r(SK_ColorLTGRAY)); 517 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColo r(SK_ColorLTGRAY));
518 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMasksToBounds( true)); 518 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMasksToBounds( true));
519 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMaskLayer(dumm yLayer.get())); 519 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMaskLayer(dumm yLayer.get()));
520 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5)); 520 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5));
521 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsOpaque (true)); 521 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsOpaque (true));
522 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(gfx:: PointF(4, 9))); 522 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(gfx:: PointF(4, 9)));
523 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(d ummyLayer.get())); 523 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(d ummyLayer.get()));
524 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransf orm(WebTransformationMatrix(0, 0, 0, 0, 0, 0))); 524 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransf orm(MathUtil::createGfxTransform(0, 0, 0, 0, 0, 0)));
525 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(tru e)); 525 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(tru e));
526 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOn MainThread(true)); 526 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setShouldScrollOn MainThread(true));
527 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrolla bleRegion(gfx::Rect(1, 1, 2, 2))); 527 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNonFastScrolla bleRegion(gfx::Rect(1, 1, 2, 2)));
528 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEvent Handlers(true)); 528 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEvent Handlers(true));
529 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollOffset(g fx::Vector2d(10, 10))); 529 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollOffset(g fx::Vector2d(10, 10)));
530 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(WebT ransformationMatrix(0, 0, 0, 0, 0, 0))); 530 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(Math Util::createGfxTransform(0, 0, 0, 0, 0, 0)));
531 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(fa lse)); 531 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(fa lse));
532 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Tes t Layer")); 532 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDebugName("Tes t Layer"));
533 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboa rdForMissingTiles(!testLayer->drawCheckerboardForMissingTiles())); 533 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDrawCheckerboa rdForMissingTiles(!testLayer->drawCheckerboardForMissingTiles()));
534 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setForceRenderSur face(true)); 534 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setForceRenderSur face(true));
535 535
536 // The above tests should not have caused a change to the needsDisplay flag. 536 // The above tests should not have caused a change to the needsDisplay flag.
537 EXPECT_FALSE(testLayer->needsDisplay()); 537 EXPECT_FALSE(testLayer->needsDisplay());
538 538
539 // Test properties that should call setNeedsDisplay and setNeedsCommit 539 // Test properties that should call setNeedsDisplay and setNeedsCommit
540 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(gfx::Si ze(5, 10))); 540 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(gfx::Si ze(5, 10)));
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 scoped_refptr<MockLayer> layer(new MockLayer); 809 scoped_refptr<MockLayer> layer(new MockLayer);
810 EXPECT_FALSE(layer->needsDisplay()); 810 EXPECT_FALSE(layer->needsDisplay());
811 layer->setBounds(gfx::Size(0, 10)); 811 layer->setBounds(gfx::Size(0, 10));
812 EXPECT_FALSE(layer->needsDisplay()); 812 EXPECT_FALSE(layer->needsDisplay());
813 layer->setBounds(gfx::Size(10, 10)); 813 layer->setBounds(gfx::Size(10, 10));
814 EXPECT_TRUE(layer->needsDisplay()); 814 EXPECT_TRUE(layer->needsDisplay());
815 } 815 }
816 816
817 } // namespace 817 } // namespace
818 } // namespace cc 818 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/math_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698