OLD | NEW |
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/wm/core/window_util.h" | 5 #include "ui/wm/core/window_util.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include <memory> |
| 8 |
8 #include "ui/aura/test/aura_test_base.h" | 9 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/aura/test/test_windows.h" | 10 #include "ui/aura/test/test_windows.h" |
10 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
11 #include "ui/compositor/layer.h" | 12 #include "ui/compositor/layer.h" |
12 #include "ui/compositor/layer_tree_owner.h" | 13 #include "ui/compositor/layer_tree_owner.h" |
13 | 14 |
14 namespace wm { | 15 namespace wm { |
15 | 16 |
16 typedef aura::test::AuraTestBase WindowUtilTest; | 17 typedef aura::test::AuraTestBase WindowUtilTest; |
17 | 18 |
18 // Test if the recreate layers does not recreate layers that have | 19 // Test if the recreate layers does not recreate layers that have |
19 // already been acquired. | 20 // already been acquired. |
20 TEST_F(WindowUtilTest, RecreateLayers) { | 21 TEST_F(WindowUtilTest, RecreateLayers) { |
21 scoped_ptr<aura::Window> window1( | 22 std::unique_ptr<aura::Window> window1( |
22 aura::test::CreateTestWindowWithId(0, NULL)); | 23 aura::test::CreateTestWindowWithId(0, NULL)); |
23 scoped_ptr<aura::Window> window11( | 24 std::unique_ptr<aura::Window> window11( |
24 aura::test::CreateTestWindowWithId(1, window1.get())); | 25 aura::test::CreateTestWindowWithId(1, window1.get())); |
25 scoped_ptr<aura::Window> window12( | 26 std::unique_ptr<aura::Window> window12( |
26 aura::test::CreateTestWindowWithId(2, window1.get())); | 27 aura::test::CreateTestWindowWithId(2, window1.get())); |
27 | 28 |
28 ASSERT_EQ(2u, window1->layer()->children().size()); | 29 ASSERT_EQ(2u, window1->layer()->children().size()); |
29 | 30 |
30 scoped_ptr<ui::Layer> acquired(window11->AcquireLayer()); | 31 std::unique_ptr<ui::Layer> acquired(window11->AcquireLayer()); |
31 EXPECT_TRUE(acquired.get()); | 32 EXPECT_TRUE(acquired.get()); |
32 EXPECT_EQ(acquired.get(), window11->layer()); | 33 EXPECT_EQ(acquired.get(), window11->layer()); |
33 | 34 |
34 scoped_ptr<ui::LayerTreeOwner> tree = | 35 std::unique_ptr<ui::LayerTreeOwner> tree = wm::RecreateLayers(window1.get()); |
35 wm::RecreateLayers(window1.get()); | |
36 | 36 |
37 // The detached layer should not have the layer that has | 37 // The detached layer should not have the layer that has |
38 // already been detached. | 38 // already been detached. |
39 ASSERT_EQ(1u, tree->root()->children().size()); | 39 ASSERT_EQ(1u, tree->root()->children().size()); |
40 // Child layer is new instance. | 40 // Child layer is new instance. |
41 EXPECT_NE(window11->layer(), tree->root()->children()[0]); | 41 EXPECT_NE(window11->layer(), tree->root()->children()[0]); |
42 EXPECT_NE(window12->layer(), tree->root()->children()[0]); | 42 EXPECT_NE(window12->layer(), tree->root()->children()[0]); |
43 | 43 |
44 // The original window should have both. | 44 // The original window should have both. |
45 ASSERT_EQ(2u, window1->layer()->children().size()); | 45 ASSERT_EQ(2u, window1->layer()->children().size()); |
46 EXPECT_EQ(window11->layer(), window1->layer()->children()[0]); | 46 EXPECT_EQ(window11->layer(), window1->layer()->children()[0]); |
47 EXPECT_EQ(window12->layer(), window1->layer()->children()[1]); | 47 EXPECT_EQ(window12->layer(), window1->layer()->children()[1]); |
48 | 48 |
49 // Delete the window before the acquired layer is deleted. | 49 // Delete the window before the acquired layer is deleted. |
50 window11.reset(); | 50 window11.reset(); |
51 } | 51 } |
52 } // namespace wm | 52 } // namespace wm |
OLD | NEW |