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

Side by Side Diff: cc/layer_unittest.cc

Issue 11361223: cc: Remove cc::settings, move them to LayerTreeSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-unittests 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 | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/scheduler.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/settings.h"
12 #include "cc/single_thread_proxy.h" 11 #include "cc/single_thread_proxy.h"
13 #include "cc/thread.h" 12 #include "cc/thread.h"
14 #include "cc/test/fake_layer_tree_host_client.h" 13 #include "cc/test/fake_layer_tree_host_client.h"
15 #include "cc/test/geometry_test_utils.h" 14 #include "cc/test/geometry_test_utils.h"
16 #include "cc/test/test_common.h"
17 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
19 #include <public/WebTransformationMatrix.h> 17 #include <public/WebTransformationMatrix.h>
20 18
21 using namespace WebKitTests; 19 using namespace WebKitTests;
22 using WebKit::WebTransformationMatrix; 20 using WebKit::WebTransformationMatrix;
23 using ::testing::Mock; 21 using ::testing::Mock;
24 using ::testing::_; 22 using ::testing::_;
25 using ::testing::AtLeast; 23 using ::testing::AtLeast;
26 using ::testing::AnyNumber; 24 using ::testing::AnyNumber;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 implLayer->resetAllChangeTrackingForSubtree(); 559 implLayer->resetAllChangeTrackingForSubtree();
562 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5))); 560 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)));
563 testLayer->pushPropertiesTo(implLayer.get()); 561 testLayer->pushPropertiesTo(implLayer.get());
564 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)), impl Layer->updateRect()); 562 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5, 5)), impl Layer->updateRect());
565 } 563 }
566 564
567 class FakeLayerImplTreeHost : public LayerTreeHost { 565 class FakeLayerImplTreeHost : public LayerTreeHost {
568 public: 566 public:
569 static scoped_ptr<FakeLayerImplTreeHost> create() 567 static scoped_ptr<FakeLayerImplTreeHost> create()
570 { 568 {
571 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); 569 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost(LayerTr eeSettings()));
572 // 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. 570 // 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.
573 host->initialize(scoped_ptr<Thread>(NULL)); 571 host->initialize(scoped_ptr<Thread>(NULL));
574 return host.Pass(); 572 return host.Pass();
575 } 573 }
576 574
577 private: 575 private:
578 FakeLayerImplTreeHost() 576 FakeLayerImplTreeHost(const LayerTreeSettings& settings)
579 : LayerTreeHost(&m_client, LayerTreeSettings()) 577 : LayerTreeHost(&m_client, settings)
580 { 578 {
581 } 579 }
582 580
583 FakeLayerImplTreeHostClient m_client; 581 FakeLayerImplTreeHostClient m_client;
584 }; 582 };
585 583
586 void assertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) 584 void assertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host)
587 { 585 {
588 EXPECT_EQ(host, layer->layerTreeHost()); 586 EXPECT_EQ(host, layer->layerTreeHost());
589 587
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 return layer->addAnimation(animation.Pass()); 767 return layer->addAnimation(animation.Pass());
770 } 768 }
771 769
772 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) 770 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost)
773 { 771 {
774 // Currently, WebCore assumes that animations will be started immediately / very soon 772 // Currently, WebCore assumes that animations will be started immediately / very soon
775 // if a composited layer's addAnimation() returns true. However, without a l ayerTreeHost, 773 // if a composited layer's addAnimation() returns true. However, without a l ayerTreeHost,
776 // layers cannot actually animate yet. So, to prevent violating this WebCore assumption, 774 // layers cannot actually animate yet. So, to prevent violating this WebCore assumption,
777 // the animation should not be accepted if the layer doesn't already have a layerTreeHost. 775 // the animation should not be accepted if the layer doesn't already have a layerTreeHost.
778 776
779 ScopedSettings scopedSettings;
780 Settings::setAcceleratedAnimationEnabled(true);
781
782 scoped_refptr<Layer> layer = Layer::create(); 777 scoped_refptr<Layer> layer = Layer::create();
783 778
784 // Case 1: without a layerTreeHost, the animation should not be accepted. 779 // Case 1: without a layerTreeHost, the animation should not be accepted.
785 EXPECT_FALSE(addTestAnimation(layer.get())); 780 EXPECT_FALSE(addTestAnimation(layer.get()));
786 781
787 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e()); 782 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e());
788 layerTreeHost->setRootLayer(layer.get()); 783 layerTreeHost->setRootLayer(layer.get());
789 layer->setLayerTreeHost(layerTreeHost.get()); 784 layer->setLayerTreeHost(layerTreeHost.get());
790 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); 785 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get());
791 786
(...skipping 16 matching lines...) Expand all
808 scoped_refptr<MockLayer> layer(new MockLayer); 803 scoped_refptr<MockLayer> layer(new MockLayer);
809 EXPECT_FALSE(layer->needsDisplay()); 804 EXPECT_FALSE(layer->needsDisplay());
810 layer->setBounds(gfx::Size(0, 10)); 805 layer->setBounds(gfx::Size(0, 10));
811 EXPECT_FALSE(layer->needsDisplay()); 806 EXPECT_FALSE(layer->needsDisplay());
812 layer->setBounds(gfx::Size(10, 10)); 807 layer->setBounds(gfx::Size(10, 10));
813 EXPECT_TRUE(layer->needsDisplay()); 808 EXPECT_TRUE(layer->needsDisplay());
814 } 809 }
815 810
816 } // namespace 811 } // namespace
817 } // namespace cc 812 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_unittest.cc ('k') | cc/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698