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

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2514243002: Propagates window type properties during aura-mus window creation (Closed)
Patch Set: merge Created 4 years 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/aura/mus/window_tree_client.cc ('k') | ui/aura/test/aura_test_base.h » ('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 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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "mojo/common/common_type_converters.h" 12 #include "mojo/common/common_type_converters.h"
13 #include "services/ui/public/cpp/property_type_converters.h" 13 #include "services/ui/public/cpp/property_type_converters.h"
14 #include "services/ui/public/interfaces/window_manager.mojom.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/aura/client/aura_constants.h" 16 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/client/capture_client.h" 17 #include "ui/aura/client/capture_client.h"
17 #include "ui/aura/client/capture_client_observer.h" 18 #include "ui/aura/client/capture_client_observer.h"
18 #include "ui/aura/client/focus_client.h" 19 #include "ui/aura/client/focus_client.h"
19 #include "ui/aura/client/transient_window_client.h" 20 #include "ui/aura/client/transient_window_client.h"
20 #include "ui/aura/mus/property_converter.h" 21 #include "ui/aura/mus/property_converter.h"
21 #include "ui/aura/mus/window_mus.h" 22 #include "ui/aura/mus/window_mus.h"
22 #include "ui/aura/mus/window_tree_client_delegate.h" 23 #include "ui/aura/mus/window_tree_client_delegate.h"
23 #include "ui/aura/mus/window_tree_client_observer.h" 24 #include "ui/aura/mus/window_tree_client_observer.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Verifies properties passed in OnWindowHierarchyChanged() make there way to 141 // Verifies properties passed in OnWindowHierarchyChanged() make there way to
141 // the new window. 142 // the new window.
142 TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) { 143 TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) {
143 RegisterTestProperties(GetPropertyConverter()); 144 RegisterTestProperties(GetPropertyConverter());
144 window_tree()->AckAllChanges(); 145 window_tree()->AckAllChanges();
145 const Id child_window_id = server_id(root_window()) + 11; 146 const Id child_window_id = server_id(root_window()) + 11;
146 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New(); 147 ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
147 const uint8_t server_test_property1_value = 91; 148 const uint8_t server_test_property1_value = 91;
148 data->properties[kTestPropertyServerKey1] = 149 data->properties[kTestPropertyServerKey1] =
149 ConvertToPropertyTransportValue(server_test_property1_value); 150 ConvertToPropertyTransportValue(server_test_property1_value);
151 data->properties[ui::mojom::WindowManager::kWindowType_Property] =
152 mojo::ConvertTo<std::vector<uint8_t>>(
153 static_cast<int32_t>(ui::mojom::WindowType::BUBBLE));
150 data->parent_id = server_id(root_window()); 154 data->parent_id = server_id(root_window());
151 data->window_id = child_window_id; 155 data->window_id = child_window_id;
152 data->bounds = gfx::Rect(1, 2, 3, 4); 156 data->bounds = gfx::Rect(1, 2, 3, 4);
153 data->visible = false; 157 data->visible = false;
154 std::vector<ui::mojom::WindowDataPtr> data_array(1); 158 std::vector<ui::mojom::WindowDataPtr> data_array(1);
155 data_array[0] = std::move(data); 159 data_array[0] = std::move(data);
156 ASSERT_TRUE(root_window()->children().empty()); 160 ASSERT_TRUE(root_window()->children().empty());
157 window_tree_client()->OnWindowHierarchyChanged( 161 window_tree_client()->OnWindowHierarchyChanged(
158 child_window_id, 0, server_id(root_window()), std::move(data_array)); 162 child_window_id, 0, server_id(root_window()), std::move(data_array));
159 ASSERT_FALSE(window_tree()->has_change()); 163 ASSERT_FALSE(window_tree()->has_change());
160 ASSERT_EQ(1u, root_window()->children().size()); 164 ASSERT_EQ(1u, root_window()->children().size());
161 Window* child = root_window()->children()[0]; 165 Window* child = root_window()->children()[0];
162 EXPECT_FALSE(child->TargetVisibility()); 166 EXPECT_FALSE(child->TargetVisibility());
163 EXPECT_EQ(server_test_property1_value, child->GetProperty(kTestPropertyKey1)); 167 EXPECT_EQ(server_test_property1_value, child->GetProperty(kTestPropertyKey1));
168 EXPECT_EQ(child->type(), ui::wm::WINDOW_TYPE_POPUP);
169 EXPECT_EQ(ui::mojom::WindowType::BUBBLE,
170 child->GetProperty(client::kWindowTypeKey));
164 } 171 }
165 172
166 // Verifies a move from the server doesn't attempt signal the server. 173 // Verifies a move from the server doesn't attempt signal the server.
167 TEST_F(WindowTreeClientWmTest, MoveFromServerDoesntAddAgain) { 174 TEST_F(WindowTreeClientWmTest, MoveFromServerDoesntAddAgain) {
168 Window window1(nullptr); 175 Window window1(nullptr);
169 window1.Init(ui::LAYER_NOT_DRAWN); 176 window1.Init(ui::LAYER_NOT_DRAWN);
170 Window window2(nullptr); 177 Window window2(nullptr);
171 window2.Init(ui::LAYER_NOT_DRAWN); 178 window2.Init(ui::LAYER_NOT_DRAWN);
172 root_window()->AddChild(&window1); 179 root_window()->AddChild(&window1);
173 root_window()->AddChild(&window2); 180 root_window()->AddChild(&window2);
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 // Make |w1| the first child and ensure a REORDER was scheduled. 1005 // Make |w1| the first child and ensure a REORDER was scheduled.
999 root_window()->StackChildAtBottom(w1); 1006 root_window()->StackChildAtBottom(w1);
1000 EXPECT_EQ(w1, root_window()->children()[0]); 1007 EXPECT_EQ(w1, root_window()->children()[0]);
1001 EXPECT_EQ(w2, root_window()->children()[1]); 1008 EXPECT_EQ(w2, root_window()->children()[1]);
1002 EXPECT_EQ(w3, root_window()->children()[2]); 1009 EXPECT_EQ(w3, root_window()->children()[2]);
1003 EXPECT_TRUE(window_tree()->AckSingleChangeOfType( 1010 EXPECT_TRUE(window_tree()->AckSingleChangeOfType(
1004 WindowTreeChangeType::REORDER, true)); 1011 WindowTreeChangeType::REORDER, true));
1005 EXPECT_EQ(0u, window_tree()->number_of_changes()); 1012 EXPECT_EQ(0u, window_tree()->number_of_changes());
1006 1013
1007 // Try stacking |w2| above |w3|. This should be disallowed as that would 1014 // Try stacking |w2| above |w3|. This should be disallowed as that would
1008 // result in placing |w2| above its transient parent. 1015 // result in placing |w2| above its transient child.
1009 root_window()->StackChildAbove(w2, w3); 1016 root_window()->StackChildAbove(w2, w3);
1010 EXPECT_EQ(w1, root_window()->children()[0]); 1017 EXPECT_EQ(w1, root_window()->children()[0]);
1011 EXPECT_EQ(w2, root_window()->children()[1]); 1018 EXPECT_EQ(w2, root_window()->children()[1]);
1012 EXPECT_EQ(w3, root_window()->children()[2]); 1019 EXPECT_EQ(w3, root_window()->children()[2]);
1013 // NOTE: even though the order didn't change, internally the order was 1020 // NOTE: even though the order didn't change, internally the order was
1014 // changed and then changed back. That is the StackChildAbove() call really 1021 // changed and then changed back. That is the StackChildAbove() call really
1015 // succeeded, but then TransientWindowManager reordered the windows back to 1022 // succeeded, but then TransientWindowManager reordered the windows back to
1016 // a valid configuration. We expect only one REORDER here as the second 1023 // a valid configuration. We expect only one REORDER here as the second
1017 // results from TransientWindowManager and we assume the server applied it as 1024 // results from TransientWindowManager and we assume the server applied it as
1018 // well. 1025 // well.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 window1.Init(ui::LAYER_NOT_DRAWN); 1355 window1.Init(ui::LAYER_NOT_DRAWN);
1349 Window* window2 = new Window(nullptr); 1356 Window* window2 = new Window(nullptr);
1350 window2->Init(ui::LAYER_NOT_DRAWN); 1357 window2->Init(ui::LAYER_NOT_DRAWN);
1351 window1.AddChild(window2); 1358 window1.AddChild(window2);
1352 window_tree()->AckAllChanges(); 1359 window_tree()->AckAllChanges();
1353 window_tree_client()->OnWindowDeleted(server_id(window2)); 1360 window_tree_client()->OnWindowDeleted(server_id(window2));
1354 EXPECT_FALSE(window_tree()->has_change()); 1361 EXPECT_FALSE(window_tree()->has_change());
1355 } 1362 }
1356 1363
1357 } // namespace aura 1364 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698