OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mash/wm/layout_manager.h" | 5 #include "mash/wm/layout_manager.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "components/mus/public/cpp/tests/test_window.h" | 10 #include "components/mus/public/cpp/tests/test_window.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 | 12 |
11 namespace mash { | 13 namespace mash { |
12 namespace wm { | 14 namespace wm { |
13 | 15 |
14 class TestLayoutManager : public LayoutManager { | 16 class TestLayoutManager : public LayoutManager { |
15 public: | 17 public: |
16 explicit TestLayoutManager(mus::Window* window) | 18 explicit TestLayoutManager(mus::Window* window) |
(...skipping 12 matching lines...) Expand all Loading... |
29 layout_called_ = true; | 31 layout_called_ = true; |
30 } | 32 } |
31 | 33 |
32 bool layout_called_; | 34 bool layout_called_; |
33 | 35 |
34 DISALLOW_COPY_AND_ASSIGN(TestLayoutManager); | 36 DISALLOW_COPY_AND_ASSIGN(TestLayoutManager); |
35 }; | 37 }; |
36 | 38 |
37 // Tests that owning window can be destroyed before the layout manager. | 39 // Tests that owning window can be destroyed before the layout manager. |
38 TEST(LayoutManagerTest, OwningWindowDestroyedFirst) { | 40 TEST(LayoutManagerTest, OwningWindowDestroyedFirst) { |
39 scoped_ptr<mus::TestWindow> parent(new mus::TestWindow(1)); | 41 std::unique_ptr<mus::TestWindow> parent(new mus::TestWindow(1)); |
40 mus::TestWindow child(2); | 42 mus::TestWindow child(2); |
41 TestLayoutManager layout_manager(parent.get()); | 43 TestLayoutManager layout_manager(parent.get()); |
42 parent->AddChild(&child); | 44 parent->AddChild(&child); |
43 EXPECT_TRUE(layout_manager.GetAndResetLayoutCalled()); | 45 EXPECT_TRUE(layout_manager.GetAndResetLayoutCalled()); |
44 parent.reset(); | 46 parent.reset(); |
45 child.SetBounds(gfx::Rect(100, 200)); | 47 child.SetBounds(gfx::Rect(100, 200)); |
46 } | 48 } |
47 | 49 |
48 // Tests that the layout manager can be destroyed before the owning window. | 50 // Tests that the layout manager can be destroyed before the owning window. |
49 TEST(LayoutManagerTest, LayoutManagerDestroyedFirst) { | 51 TEST(LayoutManagerTest, LayoutManagerDestroyedFirst) { |
50 mus::TestWindow parent(1); | 52 mus::TestWindow parent(1); |
51 mus::TestWindow child(2); | 53 mus::TestWindow child(2); |
52 scoped_ptr<TestLayoutManager> layout_manager(new TestLayoutManager(&parent)); | 54 std::unique_ptr<TestLayoutManager> layout_manager( |
| 55 new TestLayoutManager(&parent)); |
53 parent.AddChild(&child); | 56 parent.AddChild(&child); |
54 EXPECT_TRUE(layout_manager->GetAndResetLayoutCalled()); | 57 EXPECT_TRUE(layout_manager->GetAndResetLayoutCalled()); |
55 | 58 |
56 parent.SetBounds(gfx::Rect(100, 200)); | 59 parent.SetBounds(gfx::Rect(100, 200)); |
57 EXPECT_TRUE(layout_manager->GetAndResetLayoutCalled()); | 60 EXPECT_TRUE(layout_manager->GetAndResetLayoutCalled()); |
58 | 61 |
59 layout_manager.reset(); | 62 layout_manager.reset(); |
60 parent.SetBounds(gfx::Rect(200, 100)); | 63 parent.SetBounds(gfx::Rect(200, 100)); |
61 } | 64 } |
62 | 65 |
63 } // namespace wm | 66 } // namespace wm |
64 } // namespace mash | 67 } // namespace mash |
OLD | NEW |