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

Side by Side Diff: ui/gfx/compositor/layer_unittest.cc

Issue 8136005: Makes visbility inherited. That is, in order for a window to be (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/compositor/layer.cc ('k') | views/view_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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/canvas_skia.h" 9 #include "ui/gfx/canvas_skia.h"
10 #include "ui/gfx/compositor/compositor_observer.h" 10 #include "ui/gfx/compositor/compositor_observer.h"
11 #include "ui/gfx/compositor/layer.h" 11 #include "ui/gfx/compositor/layer.h"
12 #include "ui/gfx/compositor/test_compositor.h" 12 #include "ui/gfx/compositor/test_compositor.h"
13 #include "ui/gfx/compositor/test_compositor_host.h" 13 #include "ui/gfx/compositor/test_compositor_host.h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 namespace { 17 namespace {
18 18
19 // Use 19 // There are three test classes in here that configure the Compositor and
20 // Layer's slightly differently:
21 // - LayerWithNullDelegateTest uses TestCompositor and NullLayerDelegate as the
22 // LayerDelegate. This is typically the base class you want to use.
23 // - LayerWithDelegateTest uses TestCompositor and does not set a LayerDelegate
24 // on the delegates.
20 // - LayerWithRealCompositorTest when a real compositor is required for testing. 25 // - LayerWithRealCompositorTest when a real compositor is required for testing.
21 // - Slow because they bring up a window. 26 // - Slow because they bring up a window and run the real compositor. This
22 // 27 // is typically not what you want.
23 // - LayerWithDelegateTest for testing functionality of the LayerDelegate.
24 // - LayerWithNullDelegateTest for testing all other functionality.
25
26 class LayerWithRealCompositorTest : public testing::Test { 28 class LayerWithRealCompositorTest : public testing::Test {
27 public: 29 public:
28 LayerWithRealCompositorTest() {} 30 LayerWithRealCompositorTest() {}
29 virtual ~LayerWithRealCompositorTest() {} 31 virtual ~LayerWithRealCompositorTest() {}
30 32
31 // Overridden from testing::Test: 33 // Overridden from testing::Test:
32 virtual void SetUp() OVERRIDE { 34 virtual void SetUp() OVERRIDE {
33 const gfx::Rect host_bounds(10, 10, 500, 500); 35 const gfx::Rect host_bounds(10, 10, 500, 500);
34 window_.reset(TestCompositorHost::Create(host_bounds)); 36 window_.reset(TestCompositorHost::Create(host_bounds));
35 window_->Show(); 37 window_->Show();
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 EXPECT_TRUE(NULL != l121->texture()); 618 EXPECT_TRUE(NULL != l121->texture());
617 EXPECT_TRUE(NULL != l122->texture()); 619 EXPECT_TRUE(NULL != l122->texture());
618 620
619 // Toggling l2's visibility should drop all sub-layer textures. 621 // Toggling l2's visibility should drop all sub-layer textures.
620 l12->SetVisible(false); 622 l12->SetVisible(false);
621 EXPECT_EQ(NULL, l12->texture()); 623 EXPECT_EQ(NULL, l12->texture());
622 EXPECT_EQ(NULL, l121->texture()); 624 EXPECT_EQ(NULL, l121->texture());
623 EXPECT_EQ(NULL, l122->texture()); 625 EXPECT_EQ(NULL, l122->texture());
624 } 626 }
625 627
628 // Various visibile/drawn assertions.
629 TEST_F(LayerWithNullDelegateTest, Visibility) {
630 scoped_ptr<Layer> l1(new Layer(NULL, Layer::LAYER_HAS_TEXTURE));
631 scoped_ptr<Layer> l2(new Layer(NULL, Layer::LAYER_HAS_TEXTURE));
632 scoped_ptr<Layer> l3(new Layer(NULL, Layer::LAYER_HAS_TEXTURE));
633 l1->Add(l2.get());
634 l2->Add(l3.get());
635
636 NullLayerDelegate delegate;
637 l1->set_delegate(&delegate);
638 l2->set_delegate(&delegate);
639 l3->set_delegate(&delegate);
640
641 // Layers should initially be drawn.
642 EXPECT_TRUE(l1->IsDrawn());
643 EXPECT_TRUE(l2->IsDrawn());
644 EXPECT_TRUE(l3->IsDrawn());
645
646 compositor()->SetRootLayer(l1.get());
647
648 Draw();
649
650 l1->SetVisible(false);
651 EXPECT_FALSE(l1->IsDrawn());
652 EXPECT_FALSE(l2->IsDrawn());
653 EXPECT_FALSE(l3->IsDrawn());
654
655 l3->SetVisible(false);
656 EXPECT_FALSE(l1->IsDrawn());
657 EXPECT_FALSE(l2->IsDrawn());
658 EXPECT_FALSE(l3->IsDrawn());
659
660 l1->SetVisible(true);
661 EXPECT_TRUE(l1->IsDrawn());
662 EXPECT_TRUE(l2->IsDrawn());
663 EXPECT_FALSE(l3->IsDrawn());
664 }
665
626 } // namespace ui 666 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer.cc ('k') | views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698