| 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 "components/exo/sub_surface.h" | 5 #include "components/exo/sub_surface.h" |
| 6 #include "components/exo/surface.h" | 6 #include "components/exo/surface.h" |
| 7 #include "components/exo/test/exo_test_base.h" | 7 #include "components/exo/test/exo_test_base.h" |
| 8 #include "components/exo/test/exo_test_helper.h" | 8 #include "components/exo/test/exo_test_helper.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 TEST_F(SubSurfaceTest, PlaceAbove) { | 37 TEST_F(SubSurfaceTest, PlaceAbove) { |
| 38 scoped_ptr<Surface> parent(new Surface); | 38 scoped_ptr<Surface> parent(new Surface); |
| 39 scoped_ptr<Surface> surface1(new Surface); | 39 scoped_ptr<Surface> surface1(new Surface); |
| 40 scoped_ptr<Surface> surface2(new Surface); | 40 scoped_ptr<Surface> surface2(new Surface); |
| 41 scoped_ptr<Surface> non_sibling_surface(new Surface); | 41 scoped_ptr<Surface> non_sibling_surface(new Surface); |
| 42 scoped_ptr<SubSurface> sub_surface1( | 42 scoped_ptr<SubSurface> sub_surface1( |
| 43 new SubSurface(surface1.get(), parent.get())); | 43 new SubSurface(surface1.get(), parent.get())); |
| 44 scoped_ptr<SubSurface> sub_surface2( | 44 scoped_ptr<SubSurface> sub_surface2( |
| 45 new SubSurface(surface2.get(), parent.get())); | 45 new SubSurface(surface2.get(), parent.get())); |
| 46 | 46 |
| 47 ASSERT_EQ(2, parent->child_count()); | 47 ASSERT_EQ(2u, parent->children().size()); |
| 48 EXPECT_EQ(surface1.get(), parent->child_at(0)); | 48 EXPECT_EQ(surface1.get(), parent->children()[0]); |
| 49 EXPECT_EQ(surface2.get(), parent->child_at(1)); | 49 EXPECT_EQ(surface2.get(), parent->children()[1]); |
| 50 | 50 |
| 51 sub_surface2->PlaceAbove(parent.get()); | 51 sub_surface2->PlaceAbove(parent.get()); |
| 52 sub_surface1->PlaceAbove(non_sibling_surface.get()); // Invalid | 52 sub_surface1->PlaceAbove(non_sibling_surface.get()); // Invalid |
| 53 sub_surface1->PlaceAbove(surface1.get()); // Invalid | 53 sub_surface1->PlaceAbove(surface1.get()); // Invalid |
| 54 sub_surface1->PlaceAbove(surface2.get()); | 54 sub_surface1->PlaceAbove(surface2.get()); |
| 55 | 55 |
| 56 // Nothing should have changed as Commit() is required for new stacking | 56 // Nothing should have changed as Commit() is required for new stacking |
| 57 // order to take effect. | 57 // order to take effect. |
| 58 EXPECT_EQ(surface1.get(), parent->child_at(0)); | 58 EXPECT_EQ(surface1.get(), parent->children()[0]); |
| 59 EXPECT_EQ(surface2.get(), parent->child_at(1)); | 59 EXPECT_EQ(surface2.get(), parent->children()[1]); |
| 60 | 60 |
| 61 parent->Commit(); | 61 parent->Commit(); |
| 62 | 62 |
| 63 // surface1 should now be stacked above surface2. | 63 // surface1 should now be stacked above surface2. |
| 64 EXPECT_EQ(surface2.get(), parent->child_at(0)); | 64 EXPECT_EQ(surface2.get(), parent->children()[0]); |
| 65 EXPECT_EQ(surface1.get(), parent->child_at(1)); | 65 EXPECT_EQ(surface1.get(), parent->children()[1]); |
| 66 } | 66 } |
| 67 | 67 |
| 68 TEST_F(SubSurfaceTest, PlaceBelow) { | 68 TEST_F(SubSurfaceTest, PlaceBelow) { |
| 69 scoped_ptr<Surface> parent(new Surface); | 69 scoped_ptr<Surface> parent(new Surface); |
| 70 scoped_ptr<Surface> surface1(new Surface); | 70 scoped_ptr<Surface> surface1(new Surface); |
| 71 scoped_ptr<Surface> surface2(new Surface); | 71 scoped_ptr<Surface> surface2(new Surface); |
| 72 scoped_ptr<Surface> non_sibling_surface(new Surface); | 72 scoped_ptr<Surface> non_sibling_surface(new Surface); |
| 73 scoped_ptr<SubSurface> sub_surface1( | 73 scoped_ptr<SubSurface> sub_surface1( |
| 74 new SubSurface(surface1.get(), parent.get())); | 74 new SubSurface(surface1.get(), parent.get())); |
| 75 scoped_ptr<SubSurface> sub_surface2( | 75 scoped_ptr<SubSurface> sub_surface2( |
| 76 new SubSurface(surface2.get(), parent.get())); | 76 new SubSurface(surface2.get(), parent.get())); |
| 77 | 77 |
| 78 ASSERT_EQ(2, parent->child_count()); | 78 ASSERT_EQ(2u, parent->children().size()); |
| 79 EXPECT_EQ(surface1.get(), parent->child_at(0)); | 79 EXPECT_EQ(surface1.get(), parent->children()[0]); |
| 80 EXPECT_EQ(surface2.get(), parent->child_at(1)); | 80 EXPECT_EQ(surface2.get(), parent->children()[1]); |
| 81 | 81 |
| 82 sub_surface2->PlaceBelow(parent.get()); // Invalid | 82 sub_surface2->PlaceBelow(parent.get()); // Invalid |
| 83 sub_surface2->PlaceBelow(non_sibling_surface.get()); // Invalid | 83 sub_surface2->PlaceBelow(non_sibling_surface.get()); // Invalid |
| 84 sub_surface1->PlaceBelow(surface2.get()); | 84 sub_surface1->PlaceBelow(surface2.get()); |
| 85 sub_surface2->PlaceBelow(surface1.get()); | 85 sub_surface2->PlaceBelow(surface1.get()); |
| 86 | 86 |
| 87 // Nothing should have changed as Commit() is required for new stacking | 87 // Nothing should have changed as Commit() is required for new stacking |
| 88 // order to take effect. | 88 // order to take effect. |
| 89 EXPECT_EQ(surface1.get(), parent->child_at(0)); | 89 EXPECT_EQ(surface1.get(), parent->children()[0]); |
| 90 EXPECT_EQ(surface2.get(), parent->child_at(1)); | 90 EXPECT_EQ(surface2.get(), parent->children()[1]); |
| 91 | 91 |
| 92 parent->Commit(); | 92 parent->Commit(); |
| 93 | 93 |
| 94 // surface1 should now be stacked above surface2. | 94 // surface1 should now be stacked above surface2. |
| 95 EXPECT_EQ(surface2.get(), parent->child_at(0)); | 95 EXPECT_EQ(surface2.get(), parent->children()[0]); |
| 96 EXPECT_EQ(surface1.get(), parent->child_at(1)); | 96 EXPECT_EQ(surface1.get(), parent->children()[1]); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST_F(SubSurfaceTest, SetCommitBehavior) { | 99 TEST_F(SubSurfaceTest, SetCommitBehavior) { |
| 100 scoped_ptr<Surface> parent(new Surface); | 100 scoped_ptr<Surface> parent(new Surface); |
| 101 scoped_ptr<Surface> child(new Surface); | 101 scoped_ptr<Surface> child(new Surface); |
| 102 scoped_ptr<Surface> grandchild(new Surface); | 102 scoped_ptr<Surface> grandchild(new Surface); |
| 103 scoped_ptr<SubSurface> child_sub_surface( | 103 scoped_ptr<SubSurface> child_sub_surface( |
| 104 new SubSurface(child.get(), parent.get())); | 104 new SubSurface(child.get(), parent.get())); |
| 105 scoped_ptr<SubSurface> grandchild_sub_surface( | 105 scoped_ptr<SubSurface> grandchild_sub_surface( |
| 106 new SubSurface(grandchild.get(), child.get())); | 106 new SubSurface(grandchild.get(), child.get())); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 133 grandchild_sub_surface->SetPosition(position2); | 133 grandchild_sub_surface->SetPosition(position2); |
| 134 child->Commit(); | 134 child->Commit(); |
| 135 | 135 |
| 136 // A Commit() call on child should be sufficient for the position of | 136 // A Commit() call on child should be sufficient for the position of |
| 137 // grandchild to take effect when synchronous is disabled. | 137 // grandchild to take effect when synchronous is disabled. |
| 138 EXPECT_EQ(position2.ToString(), grandchild->bounds().origin().ToString()); | 138 EXPECT_EQ(position2.ToString(), grandchild->bounds().origin().ToString()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| 142 } // namespace exo | 142 } // namespace exo |
| OLD | NEW |