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

Side by Side Diff: cc/layer_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month 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
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/nine_patch_layer_impl_unittest.cc » ('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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer.h" 7 #include "cc/layer.h"
8 8
9 #include "cc/keyframed_animation_curve.h" 9 #include "cc/keyframed_animation_curve.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
11 #include "cc/layer_painter.h" 11 #include "cc/layer_painter.h"
12 #include "cc/layer_tree_host.h" 12 #include "cc/layer_tree_host.h"
13 #include "cc/settings.h" 13 #include "cc/settings.h"
14 #include "cc/single_thread_proxy.h" 14 #include "cc/single_thread_proxy.h"
15 #include "cc/thread.h"
15 #include "cc/test/fake_layer_tree_host_client.h" 16 #include "cc/test/fake_layer_tree_host_client.h"
16 #include "cc/test/geometry_test_utils.h" 17 #include "cc/test/geometry_test_utils.h"
17 #include "cc/test/test_common.h" 18 #include "cc/test/test_common.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include <public/WebTransformationMatrix.h> 21 #include <public/WebTransformationMatrix.h>
21 22
22 using namespace cc; 23 using namespace cc;
23 using namespace WebKitTests; 24 using namespace WebKitTests;
24 using WebKit::WebTransformationMatrix; 25 using WebKit::WebTransformationMatrix;
25 using ::testing::Mock; 26 using ::testing::Mock;
26 using ::testing::_; 27 using ::testing::_;
27 using ::testing::AtLeast; 28 using ::testing::AtLeast;
28 using ::testing::AnyNumber; 29 using ::testing::AnyNumber;
29 30
30 #define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCom mit, codeToTest) do { \ 31 #define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCom mit, codeToTest) do { \
31 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedS etNeedsCommit)); \ 32 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedS etNeedsCommit)); \
32 codeToTest; \ 33 codeToTest; \
33 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); \ 34 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); \
34 } while (0) 35 } while (0)
35 36
36 namespace { 37 namespace {
37 38
38 class MockLayerImplTreeHost : public LayerTreeHost { 39 class MockLayerImplTreeHost : public LayerTreeHost {
39 public: 40 public:
40 MockLayerImplTreeHost() 41 MockLayerImplTreeHost()
41 : LayerTreeHost(&m_fakeClient, LayerTreeSettings()) 42 : LayerTreeHost(&m_fakeClient, LayerTreeSettings())
42 { 43 {
43 initialize(); 44 initialize(scoped_ptr<Thread>(NULL));
44 } 45 }
45 46
46 MOCK_METHOD0(setNeedsCommit, void()); 47 MOCK_METHOD0(setNeedsCommit, void());
47 48
48 private: 49 private:
49 FakeLayerImplTreeHostClient m_fakeClient; 50 FakeLayerImplTreeHostClient m_fakeClient;
50 }; 51 };
51 52
52 class MockLayerPainter : public LayerPainter { 53 class MockLayerPainter : public LayerPainter {
53 public: 54 public:
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // The above tests should not have caused a change to the needsDisplay flag. 522 // The above tests should not have caused a change to the needsDisplay flag.
522 EXPECT_FALSE(testLayer->needsDisplay()); 523 EXPECT_FALSE(testLayer->needsDisplay());
523 524
524 // Test properties that should call setNeedsDisplay and setNeedsCommit 525 // Test properties that should call setNeedsDisplay and setNeedsCommit
525 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(gfx::Si ze(5, 10))); 526 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(gfx::Si ze(5, 10)));
526 EXPECT_TRUE(testLayer->needsDisplay()); 527 EXPECT_TRUE(testLayer->needsDisplay());
527 } 528 }
528 529
529 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) 530 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect)
530 { 531 {
531 DebugScopedSetImplThread setImplThread;
532
533 scoped_refptr<Layer> testLayer = Layer::create(); 532 scoped_refptr<Layer> testLayer = Layer::create();
534 scoped_ptr<LayerImpl> implLayer = LayerImpl::create(1); 533 scoped_ptr<LayerImpl> implLayer = LayerImpl::create(1);
535 534
536 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5))); 535 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5)));
537 testLayer->pushPropertiesTo(implLayer.get()); 536 testLayer->pushPropertiesTo(implLayer.get());
538 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5)), implLayer- >updateRect()); 537 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5)), implLayer- >updateRect());
539 538
540 // The LayerImpl's updateRect should be accumulated here, since we did not d o anything to clear it. 539 // The LayerImpl's updateRect should be accumulated here, since we did not d o anything to clear it.
541 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5))); 540 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)));
542 testLayer->pushPropertiesTo(implLayer.get()); 541 testLayer->pushPropertiesTo(implLayer.get());
543 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(15, 15)), implLaye r->updateRect()); 542 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(15, 15)), implLaye r->updateRect());
544 543
545 // If we do clear the LayerImpl side, then the next updateRect should be fre sh without accumulation. 544 // If we do clear the LayerImpl side, then the next updateRect should be fre sh without accumulation.
546 implLayer->resetAllChangeTrackingForSubtree(); 545 implLayer->resetAllChangeTrackingForSubtree();
547 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5))); 546 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)));
548 testLayer->pushPropertiesTo(implLayer.get()); 547 testLayer->pushPropertiesTo(implLayer.get());
549 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)), impl Layer->updateRect()); 548 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)), impl Layer->updateRect());
550 } 549 }
551 550
552 class FakeLayerImplTreeHost : public LayerTreeHost { 551 class FakeLayerImplTreeHost : public LayerTreeHost {
553 public: 552 public:
554 static scoped_ptr<FakeLayerImplTreeHost> create() 553 static scoped_ptr<FakeLayerImplTreeHost> create()
555 { 554 {
556 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); 555 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost);
557 // The initialize call will fail, since our client doesn't provide a val id GraphicsContext3D, but it doesn't matter in the tests that use this fake so i gnore the return value. 556 // The initialize call will fail, since our client doesn't provide a val id GraphicsContext3D, but it doesn't matter in the tests that use this fake so i gnore the return value.
558 host->initialize(); 557 host->initialize(scoped_ptr<Thread>(NULL));
559 return host.Pass(); 558 return host.Pass();
560 } 559 }
561 560
562 private: 561 private:
563 FakeLayerImplTreeHost() 562 FakeLayerImplTreeHost()
564 : LayerTreeHost(&m_client, LayerTreeSettings()) 563 : LayerTreeHost(&m_client, LayerTreeSettings())
565 { 564 {
566 } 565 }
567 566
568 FakeLayerImplTreeHostClient m_client; 567 FakeLayerImplTreeHostClient m_client;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 scoped_refptr<MockLayer> layer(new MockLayer); 792 scoped_refptr<MockLayer> layer(new MockLayer);
794 EXPECT_FALSE(layer->needsDisplay()); 793 EXPECT_FALSE(layer->needsDisplay());
795 layer->setBounds(gfx::Size(0, 10)); 794 layer->setBounds(gfx::Size(0, 10));
796 EXPECT_FALSE(layer->needsDisplay()); 795 EXPECT_FALSE(layer->needsDisplay());
797 layer->setBounds(gfx::Size(10, 10)); 796 layer->setBounds(gfx::Size(10, 10));
798 EXPECT_TRUE(layer->needsDisplay()); 797 EXPECT_TRUE(layer->needsDisplay());
799 } 798 }
800 799
801 800
802 } // anonymous namespace 801 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/nine_patch_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698