Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: ui/views/view_unittest_aura.cc

Issue 2651753003: Wires up ShouldDescendIntoChildForEventHandling() for DesktopNativeWidgetAura (Closed)
Patch Set: improve comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/view.h" 5 #include "ui/views/view.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/compositor/layer.h" 10 #include "ui/compositor/layer.h"
(...skipping 25 matching lines...) Expand all
36 View* CreateViewWithLayer(const gfx::Rect& bounds, const char* layer_name) { 36 View* CreateViewWithLayer(const gfx::Rect& bounds, const char* layer_name) {
37 View* view = new View(); 37 View* view = new View();
38 view->SetBoundsRect(bounds); 38 view->SetBoundsRect(bounds);
39 view->SetPaintToLayer(); 39 view->SetPaintToLayer();
40 view->layer()->set_name(layer_name); 40 view->layer()->set_name(layer_name);
41 return view; 41 return view;
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
46 typedef ViewsTestBase ViewAuraTest; 46 class ViewAuraTest : public ViewsTestBase {
47 public:
48 ViewAuraTest() {}
49 ~ViewAuraTest() override {}
50
51 const View::Views& GetViewsWithLayers(Widget* widget) {
52 return widget->GetViewsWithLayers();
53 }
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(ViewAuraTest);
57 };
47 58
48 // Test that wm::RecreateLayers() recreates the layers for all child windows and 59 // Test that wm::RecreateLayers() recreates the layers for all child windows and
49 // all child views and that the z-order of the recreated layers matches that of 60 // all child views and that the z-order of the recreated layers matches that of
50 // the original layers. 61 // the original layers.
51 // Test hierarchy: 62 // Test hierarchy:
52 // w1 63 // w1
53 // +-- v1 64 // +-- v1
54 // +-- v2 (no layer) 65 // +-- v2 (no layer)
55 // +-- v3 (no layer) 66 // +-- v3 (no layer)
56 // +-- v4 67 // +-- v4
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ui::Layer* w1_layer = w1->GetNativeView()->layer(); 123 ui::Layer* w1_layer = w1->GetNativeView()->layer();
113 ASSERT_EQ("w1", w1_layer->name()); 124 ASSERT_EQ("w1", w1_layer->name());
114 ASSERT_EQ("v1 v4 w2 v7", ui::test::ChildLayerNamesAsString(*w1_layer)); 125 ASSERT_EQ("v1 v4 w2 v7", ui::test::ChildLayerNamesAsString(*w1_layer));
115 ui::Layer* w2_layer = w1_layer->children()[2]; 126 ui::Layer* w2_layer = w1_layer->children()[2];
116 ASSERT_EQ("v5", ui::test::ChildLayerNamesAsString(*w2_layer)); 127 ASSERT_EQ("v5", ui::test::ChildLayerNamesAsString(*w2_layer));
117 ui::Layer* v5_layer = w2_layer->children()[0]; 128 ui::Layer* v5_layer = w2_layer->children()[0];
118 ASSERT_EQ("v6", ui::test::ChildLayerNamesAsString(*v5_layer)); 129 ASSERT_EQ("v6", ui::test::ChildLayerNamesAsString(*v5_layer));
119 130
120 // Verify the value of Widget::GetRootLayers(). It should only include layers 131 // Verify the value of Widget::GetRootLayers(). It should only include layers
121 // from layer-backed Views descended from the Widget's root View. 132 // from layer-backed Views descended from the Widget's root View.
122 std::vector<ui::Layer*> old_w1_root_sublayers = w1->GetRootLayers(); 133 View::Views old_w1_views_with_layers = GetViewsWithLayers(w1);
123 ASSERT_EQ(3u, old_w1_root_sublayers.size()); 134 ASSERT_EQ(3u, old_w1_views_with_layers.size());
124 EXPECT_EQ(v1_layer, old_w1_root_sublayers[0]); 135 EXPECT_EQ(v1, old_w1_views_with_layers[0]);
125 EXPECT_EQ(v4_layer, old_w1_root_sublayers[1]); 136 EXPECT_EQ(v4, old_w1_views_with_layers[1]);
126 EXPECT_EQ(v7_layer, old_w1_root_sublayers[2]); 137 EXPECT_EQ(v7, old_w1_views_with_layers[2]);
127 138
128 { 139 {
129 std::unique_ptr<ui::LayerTreeOwner> cloned_owner( 140 std::unique_ptr<ui::LayerTreeOwner> cloned_owner(
130 wm::RecreateLayers(w1->GetNativeView())); 141 wm::RecreateLayers(w1->GetNativeView()));
131 EXPECT_EQ(w1_layer, cloned_owner->root()); 142 EXPECT_EQ(w1_layer, cloned_owner->root());
132 EXPECT_NE(w1_layer, w1->GetNativeView()->layer()); 143 EXPECT_NE(w1_layer, w1->GetNativeView()->layer());
133 144
134 // The old layers should still exist and have the same hierarchy. 145 // The old layers should still exist and have the same hierarchy.
135 ASSERT_EQ("w1", w1_layer->name()); 146 ASSERT_EQ("w1", w1_layer->name());
136 ASSERT_EQ("v1 v4 w2 v7", ui::test::ChildLayerNamesAsString(*w1_layer)); 147 ASSERT_EQ("v1 v4 w2 v7", ui::test::ChildLayerNamesAsString(*w1_layer));
(...skipping 30 matching lines...) Expand all
167 EXPECT_NE(v1_layer, v1_new_layer); 178 EXPECT_NE(v1_layer, v1_new_layer);
168 EXPECT_NE(v4_layer, v4_new_layer); 179 EXPECT_NE(v4_layer, v4_new_layer);
169 ui::Layer* w2_new_layer = w1_new_layer->children()[2]; 180 ui::Layer* w2_new_layer = w1_new_layer->children()[2];
170 ASSERT_EQ("v5", ui::test::ChildLayerNamesAsString(*w2_new_layer)); 181 ASSERT_EQ("v5", ui::test::ChildLayerNamesAsString(*w2_new_layer));
171 ui::Layer* v5_new_layer = w2_new_layer->children()[0]; 182 ui::Layer* v5_new_layer = w2_new_layer->children()[0];
172 ASSERT_EQ("v6", ui::test::ChildLayerNamesAsString(*v5_new_layer)); 183 ASSERT_EQ("v6", ui::test::ChildLayerNamesAsString(*v5_new_layer));
173 ui::Layer* v7_new_layer = w1_new_layer->children()[3]; 184 ui::Layer* v7_new_layer = w1_new_layer->children()[3];
174 ASSERT_EQ("v8 v9", ui::test::ChildLayerNamesAsString(*v7_new_layer)); 185 ASSERT_EQ("v8 v9", ui::test::ChildLayerNamesAsString(*v7_new_layer));
175 EXPECT_NE(v7_layer, v7_new_layer); 186 EXPECT_NE(v7_layer, v7_new_layer);
176 187
177 // Ensure Widget::GetRootLayers() is correctly updated. 188 // Ensure Widget::GetViewsWithLayers() is correctly updated.
178 std::vector<ui::Layer*> new_w1_root_sublayers = w1->GetRootLayers(); 189 View::Views new_w1_views_with_layers = GetViewsWithLayers(w1);
179 ASSERT_EQ(3u, new_w1_root_sublayers.size()); 190 ASSERT_EQ(3u, new_w1_views_with_layers.size());
180 EXPECT_EQ(v1_new_layer, new_w1_root_sublayers[0]); 191 EXPECT_EQ(v1, new_w1_views_with_layers[0]);
181 EXPECT_EQ(v4_new_layer, new_w1_root_sublayers[1]); 192 EXPECT_EQ(v4, new_w1_views_with_layers[1]);
182 EXPECT_EQ(v7_new_layer, new_w1_root_sublayers[2]); 193 EXPECT_EQ(v7, new_w1_views_with_layers[2]);
183 } 194 }
184 w1->CloseNow(); 195 w1->CloseNow();
185 } 196 }
186 197
187 } // namespace views 198 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698