OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 6 #include "base/bind.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1337 compositor()->SetScaleAndSize(2.f, gfx::Size(1000, 1000)); | 1337 compositor()->SetScaleAndSize(2.f, gfx::Size(1000, 1000)); |
1338 EXPECT_EQ(child->cc_layer()->bounds().ToString(), | 1338 EXPECT_EQ(child->cc_layer()->bounds().ToString(), |
1339 gfx::Size(20, 20).ToString()); | 1339 gfx::Size(20, 20).ToString()); |
1340 | 1340 |
1341 // Low-DPI content on hi-DPI layer. | 1341 // Low-DPI content on hi-DPI layer. |
1342 child->SetDelegatedFrame(MakeFrameData(gfx::Size(10, 10)), gfx::Size(10, 10)); | 1342 child->SetDelegatedFrame(MakeFrameData(gfx::Size(10, 10)), gfx::Size(10, 10)); |
1343 EXPECT_EQ(child->cc_layer()->bounds().ToString(), | 1343 EXPECT_EQ(child->cc_layer()->bounds().ToString(), |
1344 gfx::Size(20, 20).ToString()); | 1344 gfx::Size(20, 20).ToString()); |
1345 } | 1345 } |
1346 | 1346 |
1347 TEST_F(LayerWithDelegateTest, ExternalContent) { | |
1348 scoped_ptr<Layer> root(CreateNoTextureLayer(gfx::Rect(0, 0, 1000, 1000))); | |
1349 scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED)); | |
1350 | |
1351 child->SetBounds(gfx::Rect(0, 0, 10, 10)); | |
1352 child->SetVisible(true); | |
1353 root->Add(child.get()); | |
1354 | |
1355 // The layer is already showing painted content, so the cc layer won't change. | |
1356 cc::Layer* before = child->cc_layer(); | |
piman
2013/10/01 21:21:45
Make |before| a scoped_refptr<cc::Layer>. If the l
danakj
2013/10/01 22:37:19
Oh, right. Done.
| |
1357 child->SetShowPaintedContent(); | |
1358 EXPECT_TRUE(child->cc_layer()); | |
1359 EXPECT_EQ(before, child->cc_layer()); | |
1360 | |
1361 // Showing delegated content changes the underlying cc layer. | |
1362 before = child->cc_layer(); | |
1363 child->SetDelegatedFrame(MakeFrameData(gfx::Size(10, 10)), gfx::Size(10, 10)); | |
1364 EXPECT_TRUE(child->cc_layer()); | |
1365 EXPECT_NE(before, child->cc_layer()); | |
1366 | |
1367 // Changing to painted content should change the underlying cc layer. | |
1368 before = child->cc_layer(); | |
1369 child->SetShowPaintedContent(); | |
1370 EXPECT_TRUE(child->cc_layer()); | |
1371 EXPECT_NE(before, child->cc_layer()); | |
1372 } | |
1373 | |
1347 // Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation. | 1374 // Tests Layer::AddThreadedAnimation and Layer::RemoveThreadedAnimation. |
1348 TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) { | 1375 TEST_F(LayerWithRealCompositorTest, AddRemoveThreadedAnimations) { |
1349 scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED)); | 1376 scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED)); |
1350 scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED)); | 1377 scoped_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED)); |
1351 scoped_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED)); | 1378 scoped_ptr<Layer> l2(CreateLayer(LAYER_TEXTURED)); |
1352 | 1379 |
1353 l1->SetAnimator(LayerAnimator::CreateImplicitAnimator()); | 1380 l1->SetAnimator(LayerAnimator::CreateImplicitAnimator()); |
1354 l2->SetAnimator(LayerAnimator::CreateImplicitAnimator()); | 1381 l2->SetAnimator(LayerAnimator::CreateImplicitAnimator()); |
1355 | 1382 |
1356 EXPECT_FALSE(l1->HasPendingThreadedAnimations()); | 1383 EXPECT_FALSE(l1->HasPendingThreadedAnimations()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1406 l1->SetOpacity(0.5f); | 1433 l1->SetOpacity(0.5f); |
1407 | 1434 |
1408 // Change l1's cc::Layer. | 1435 // Change l1's cc::Layer. |
1409 l1->SwitchCCLayerForTest(); | 1436 l1->SwitchCCLayerForTest(); |
1410 | 1437 |
1411 // Ensure that the opacity animation completed. | 1438 // Ensure that the opacity animation completed. |
1412 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); | 1439 EXPECT_FLOAT_EQ(l1->opacity(), 0.5f); |
1413 } | 1440 } |
1414 | 1441 |
1415 } // namespace ui | 1442 } // namespace ui |
OLD | NEW |