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

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: return Created 4 years, 1 month 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
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 mojo::Array<ui::mojom::WindowDataPtr> data_array(1); 158 mojo::Array<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 client::WindowTypeProperty* window_type_property =
170 child->GetProperty(client::kWindowTypeKey);
171 ASSERT_TRUE(window_type_property);
172 EXPECT_EQ(ui::mojom::WindowType::BUBBLE, window_type_property->type);
164 } 173 }
165 174
166 // Verifies a move from the server doesn't attempt signal the server. 175 // Verifies a move from the server doesn't attempt signal the server.
167 TEST_F(WindowTreeClientWmTest, MoveFromServerDoesntAddAgain) { 176 TEST_F(WindowTreeClientWmTest, MoveFromServerDoesntAddAgain) {
168 Window window1(nullptr); 177 Window window1(nullptr);
169 window1.Init(ui::LAYER_NOT_DRAWN); 178 window1.Init(ui::LAYER_NOT_DRAWN);
170 Window window2(nullptr); 179 Window window2(nullptr);
171 window2.Init(ui::LAYER_NOT_DRAWN); 180 window2.Init(ui::LAYER_NOT_DRAWN);
172 root_window()->AddChild(&window1); 181 root_window()->AddChild(&window1);
173 root_window()->AddChild(&window2); 182 root_window()->AddChild(&window2);
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 window1.Init(ui::LAYER_NOT_DRAWN); 1242 window1.Init(ui::LAYER_NOT_DRAWN);
1234 Window* window2 = new Window(nullptr); 1243 Window* window2 = new Window(nullptr);
1235 window2->Init(ui::LAYER_NOT_DRAWN); 1244 window2->Init(ui::LAYER_NOT_DRAWN);
1236 window1.AddChild(window2); 1245 window1.AddChild(window2);
1237 window_tree()->AckAllChanges(); 1246 window_tree()->AckAllChanges();
1238 window_tree_client()->OnWindowDeleted(server_id(window2)); 1247 window_tree_client()->OnWindowDeleted(server_id(window2));
1239 EXPECT_FALSE(window_tree()->has_change()); 1248 EXPECT_FALSE(window_tree()->has_change());
1240 } 1249 }
1241 1250
1242 } // namespace aura 1251 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698