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

Side by Side Diff: ui/compositor/layer_owner_unittest.cc

Issue 1800393002: RecreateLayer should copy the transform as well. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « ui/compositor/layer_owner.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/compositor/layer_owner.h" 5 #include "ui/compositor/layer_owner.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/test/null_task_runner.h" 8 #include "base/test/null_task_runner.h"
9 #include "cc/animation/animation_player.h" 9 #include "cc/animation/animation_player.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 layer->SetLayerInverted(true); 151 layer->SetLayerInverted(true);
152 scoped_ptr<Layer> old_layer1 = owner.RecreateLayer(); 152 scoped_ptr<Layer> old_layer1 = owner.RecreateLayer();
153 EXPECT_EQ(old_layer1->layer_inverted(), owner.layer()->layer_inverted()); 153 EXPECT_EQ(old_layer1->layer_inverted(), owner.layer()->layer_inverted());
154 154
155 old_layer1->SetLayerInverted(false); 155 old_layer1->SetLayerInverted(false);
156 scoped_ptr<Layer> old_layer2 = owner.RecreateLayer(); 156 scoped_ptr<Layer> old_layer2 = owner.RecreateLayer();
157 EXPECT_EQ(old_layer2->layer_inverted(), owner.layer()->layer_inverted()); 157 EXPECT_EQ(old_layer2->layer_inverted(), owner.layer()->layer_inverted());
158 } 158 }
159 159
160 TEST(LayerOwnerTest, RecreateLayerWithTransform) {
161 LayerOwner owner;
162 Layer* layer = new Layer;
163 owner.SetLayer(layer);
164
165 gfx::Transform transform;
166 transform.Scale(2, 1);
167 transform.Translate(10, 5);
168
169 layer->SetTransform(transform);
170
171 scoped_ptr<Layer> old_layer1 = owner.RecreateLayer();
172 // Both new layer and original layer have the same transform.
173 EXPECT_EQ(transform, old_layer1->GetTargetTransform());
174 EXPECT_EQ(transform, owner.layer()->GetTargetTransform());
175
176 // But they're now separated, so changing the old layer's transform
177 // should not affect the owner's.
178 owner.layer()->SetTransform(gfx::Transform());
179 EXPECT_EQ(transform, old_layer1->GetTargetTransform());
180 scoped_ptr<Layer> old_layer2 = owner.RecreateLayer();
181 EXPECT_TRUE(old_layer2->GetTargetTransform().IsIdentity());
182 EXPECT_TRUE(owner.layer()->GetTargetTransform().IsIdentity());
183 }
184
160 TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) { 185 TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) {
161 LayerOwner owner; 186 LayerOwner owner;
162 Layer* layer = new Layer; 187 Layer* layer = new Layer;
163 owner.SetLayer(layer); 188 owner.SetLayer(layer);
164 189
165 compositor()->SetRootLayer(layer); 190 compositor()->SetRootLayer(layer);
166 191
167 scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); 192 scoped_ptr<Layer> layer_copy = owner.RecreateLayer();
168 193
169 EXPECT_EQ(compositor(), owner.layer()->GetCompositor()); 194 EXPECT_EQ(compositor(), owner.layer()->GetCompositor());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 299
275 layer->SetOpacity(0.5f); 300 layer->SetOpacity(0.5f);
276 301
277 scoped_refptr<cc::AnimationPlayer> player = 302 scoped_refptr<cc::AnimationPlayer> player =
278 layer->GetAnimator()->GetAnimationPlayerForTesting(); 303 layer->GetAnimator()->GetAnimationPlayerForTesting();
279 EXPECT_TRUE(player); 304 EXPECT_TRUE(player);
280 EXPECT_TRUE(player->animation_timeline()); 305 EXPECT_TRUE(player->animation_timeline());
281 } 306 }
282 307
283 } // namespace ui 308 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_owner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698