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 "ui/views/view.h" | 5 #include "ui/views/view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 5005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5016 TEST_F(ViewObserverTest, ChildViewReordered) { | 5016 TEST_F(ViewObserverTest, ChildViewReordered) { |
5017 std::unique_ptr<View> view = NewView(); | 5017 std::unique_ptr<View> view = NewView(); |
5018 std::unique_ptr<View> child_view = NewView(); | 5018 std::unique_ptr<View> child_view = NewView(); |
5019 std::unique_ptr<View> child_view2 = NewView(); | 5019 std::unique_ptr<View> child_view2 = NewView(); |
5020 view->AddChildView(child_view.get()); | 5020 view->AddChildView(child_view.get()); |
5021 view->AddChildView(child_view2.get()); | 5021 view->AddChildView(child_view2.get()); |
5022 view->ReorderChildView(child_view2.get(), 0); | 5022 view->ReorderChildView(child_view2.get(), 0); |
5023 EXPECT_EQ(child_view2.get(), view_reordered()); | 5023 EXPECT_EQ(child_view2.get(), view_reordered()); |
5024 } | 5024 } |
5025 | 5025 |
5026 // Validates that if a child of a ScrollView adds a layer, then a layer | |
5027 // is added to the ScrollView's viewport. | |
5028 TEST_F(ViewObserverTest, ScrollViewChildAddLayerTest) { | |
5029 ScrollView* scroll_view = new ScrollView(); | |
sky
2017/04/18 15:35:48
Declare this on the stack, otherwise you're going
ananta
2017/04/18 22:22:39
Changed to unique_ptr
| |
5030 scroll_view->SetContents(new View()); | |
5031 EXPECT_TRUE(scroll_view->contents_viewport()->layer() == nullptr); | |
sky
2017/04/18 15:35:48
EXPECT_FALSE(scroll_view->contents_viewport()->lay
ananta
2017/04/18 22:22:39
Done.
| |
5032 | |
5033 std::unique_ptr<View> child_view = NewView(); | |
5034 scroll_view->AddChildView(child_view.get()); | |
5035 child_view->SetBounds(0, 0, 100, 100); | |
5036 child_view->SetPaintToLayer(ui::LAYER_TEXTURED); | |
5037 | |
5038 EXPECT_TRUE(scroll_view->contents_viewport()->layer() != nullptr); | |
sky
2017/04/18 15:35:48
EXPECT_TRUE(scroll_view->contents_viewport()->laye
ananta
2017/04/18 22:22:39
Done.
| |
5039 scroll_view->RemoveChildView(child_view.get()); | |
5040 } | |
5041 | |
5026 } // namespace views | 5042 } // namespace views |
OLD | NEW |