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

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

Issue 8400059: Revert 107715 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « ui/gfx/compositor/layer_delegate.h ('k') | ui/gfx/compositor/test_layer_animation_delegate.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 (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/layer_animation_sequence.h"
13 #include "ui/gfx/compositor/test_compositor.h" 12 #include "ui/gfx/compositor/test_compositor.h"
14 #include "ui/gfx/compositor/test_compositor_host.h" 13 #include "ui/gfx/compositor/test_compositor_host.h"
15 14
16 namespace ui { 15 namespace ui {
17 16
18 namespace { 17 namespace {
19 18
20 // There are three test classes in here that configure the Compositor and 19 // There are three test classes in here that configure the Compositor and
21 // Layer's slightly differently: 20 // Layer's slightly differently:
22 // - LayerWithNullDelegateTest uses TestCompositor and NullLayerDelegate as the 21 // - LayerWithNullDelegateTest uses TestCompositor and NullLayerDelegate as the
(...skipping 12 matching lines...) Expand all
35 set_delegate(this); 34 set_delegate(this);
36 } 35 }
37 36
38 virtual ~ColoredLayer() { } 37 virtual ~ColoredLayer() { }
39 38
40 // Overridden from LayerDelegate: 39 // Overridden from LayerDelegate:
41 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { 40 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
42 canvas->GetSkCanvas()->drawColor(color_); 41 canvas->GetSkCanvas()->drawColor(color_);
43 } 42 }
44 43
45 virtual void OnLayerAnimationEnded( 44 virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE {
46 const LayerAnimationSequence* animation) OVERRIDE {
47 } 45 }
48 46
49 private: 47 private:
50 SkColor color_; 48 SkColor color_;
51 }; 49 };
52 50
53 class LayerWithRealCompositorTest : public testing::Test { 51 class LayerWithRealCompositorTest : public testing::Test {
54 public: 52 public:
55 LayerWithRealCompositorTest() {} 53 LayerWithRealCompositorTest() {}
56 virtual ~LayerWithRealCompositorTest() {} 54 virtual ~LayerWithRealCompositorTest() {}
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 125
128 // Overridden from LayerDelegate: 126 // Overridden from LayerDelegate:
129 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { 127 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
130 SkBitmap contents = canvas->AsCanvasSkia()->ExtractBitmap(); 128 SkBitmap contents = canvas->AsCanvasSkia()->ExtractBitmap();
131 paint_size_ = gfx::Size(contents.width(), contents.height()); 129 paint_size_ = gfx::Size(contents.width(), contents.height());
132 canvas->FillRectInt(colors_.at(color_index_), 0, 0, 130 canvas->FillRectInt(colors_.at(color_index_), 0, 0,
133 contents.width(), 131 contents.width(),
134 contents.height()); 132 contents.height());
135 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); 133 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size());
136 } 134 }
137 virtual void OnLayerAnimationEnded( 135 virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE {
138 const LayerAnimationSequence* animation) OVERRIDE {
139 } 136 }
140 137
141 private: 138 private:
142 std::vector<SkColor> colors_; 139 std::vector<SkColor> colors_;
143 int color_index_; 140 int color_index_;
144 gfx::Size paint_size_; 141 gfx::Size paint_size_;
145 142
146 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); 143 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate);
147 }; 144 };
148 145
149 // LayerDelegate that verifies that a layer was asked to update its canvas. 146 // LayerDelegate that verifies that a layer was asked to update its canvas.
150 class DrawTreeLayerDelegate : public LayerDelegate { 147 class DrawTreeLayerDelegate : public LayerDelegate {
151 public: 148 public:
152 DrawTreeLayerDelegate() : painted_(false) {} 149 DrawTreeLayerDelegate() : painted_(false) {}
153 virtual ~DrawTreeLayerDelegate() {} 150 virtual ~DrawTreeLayerDelegate() {}
154 151
155 void Reset() { 152 void Reset() {
156 painted_ = false; 153 painted_ = false;
157 } 154 }
158 155
159 bool painted() const { return painted_; } 156 bool painted() const { return painted_; }
160 157
161 private: 158 private:
162 // Overridden from LayerDelegate: 159 // Overridden from LayerDelegate:
163 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { 160 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
164 painted_ = true; 161 painted_ = true;
165 } 162 }
166 virtual void OnLayerAnimationEnded( 163 virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE {
167 const LayerAnimationSequence* animation) OVERRIDE {
168 } 164 }
169 165
170 bool painted_; 166 bool painted_;
171 167
172 DISALLOW_COPY_AND_ASSIGN(DrawTreeLayerDelegate); 168 DISALLOW_COPY_AND_ASSIGN(DrawTreeLayerDelegate);
173 }; 169 };
174 170
175 // The simplest possible layer delegate. Does nothing. 171 // The simplest possible layer delegate. Does nothing.
176 class NullLayerDelegate : public LayerDelegate { 172 class NullLayerDelegate : public LayerDelegate {
177 public: 173 public:
178 NullLayerDelegate() {} 174 NullLayerDelegate() {}
179 virtual ~NullLayerDelegate() {} 175 virtual ~NullLayerDelegate() {}
180 176
181 private: 177 private:
182 // Overridden from LayerDelegate: 178 // Overridden from LayerDelegate:
183 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { 179 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE {
184 } 180 }
185 virtual void OnLayerAnimationEnded( 181 virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE {
186 const LayerAnimationSequence* animation) OVERRIDE {
187 } 182 }
188 183
189 DISALLOW_COPY_AND_ASSIGN(NullLayerDelegate); 184 DISALLOW_COPY_AND_ASSIGN(NullLayerDelegate);
190 }; 185 };
191 186
192 } 187 }
193 188
194 #if defined(OS_WIN) 189 #if defined(OS_WIN)
195 // These are disabled on windows as they don't run correctly on the buildbot. 190 // These are disabled on windows as they don't run correctly on the buildbot.
196 // Reenable once we move to the real compositor. 191 // Reenable once we move to the real compositor.
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 l1->SetVisible(true); 896 l1->SetVisible(true);
902 EXPECT_TRUE(l1->IsDrawn()); 897 EXPECT_TRUE(l1->IsDrawn());
903 EXPECT_TRUE(l2->IsDrawn()); 898 EXPECT_TRUE(l2->IsDrawn());
904 EXPECT_FALSE(l3->IsDrawn()); 899 EXPECT_FALSE(l3->IsDrawn());
905 #if defined(USE_WEBKIT_COMPOSITOR) 900 #if defined(USE_WEBKIT_COMPOSITOR)
906 EXPECT_EQ(1.f, l1->web_layer().opacity()); 901 EXPECT_EQ(1.f, l1->web_layer().opacity());
907 #endif 902 #endif
908 } 903 }
909 904
910 } // namespace ui 905 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer_delegate.h ('k') | ui/gfx/compositor/test_layer_animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698