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 "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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 ASSERT_NE(nullptr, window_mus); | 216 ASSERT_NE(nullptr, window_mus); |
217 EXPECT_TRUE(window_mus->GetLocalSurfaceId().is_valid()); | 217 EXPECT_TRUE(window_mus->GetLocalSurfaceId().is_valid()); |
218 | 218 |
219 // Reverting the change should also revert the cc::LocalSurfaceId. | 219 // Reverting the change should also revert the cc::LocalSurfaceId. |
220 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(WindowTreeChangeType::BOUNDS, | 220 ASSERT_TRUE(window_tree()->AckSingleChangeOfType(WindowTreeChangeType::BOUNDS, |
221 false)); | 221 false)); |
222 EXPECT_EQ(original_bounds, window.bounds()); | 222 EXPECT_EQ(original_bounds, window.bounds()); |
223 EXPECT_FALSE(window_mus->GetLocalSurfaceId().is_valid()); | 223 EXPECT_FALSE(window_mus->GetLocalSurfaceId().is_valid()); |
224 } | 224 } |
225 | 225 |
| 226 // Verifies that a ClientSurfaceEmbedder is created for a window once it has |
| 227 // a bounds, a valid FrameSinkId and is visible. |
| 228 TEST_F(WindowTreeClientWmTest, ClientSurfaceEmbedderOnValidEmbedding) { |
| 229 Window window(nullptr); |
| 230 // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds |
| 231 // when their sizes change. |
| 232 window.SetProperty(aura::client::kEmbedType, |
| 233 aura::client::WindowEmbedType::EMBED_IN_OWNER); |
| 234 window.Init(ui::LAYER_NOT_DRAWN); |
| 235 |
| 236 const gfx::Rect new_bounds(gfx::Rect(0, 0, 100, 100)); |
| 237 ASSERT_NE(new_bounds, window.bounds()); |
| 238 window.SetBounds(new_bounds); |
| 239 EXPECT_EQ(new_bounds, window.bounds()); |
| 240 WindowMus* window_mus = WindowMus::Get(&window); |
| 241 ASSERT_NE(nullptr, window_mus); |
| 242 EXPECT_TRUE(window_mus->GetLocalSurfaceId().is_valid()); |
| 243 |
| 244 // An ClientSurfaceEmbedder isn't created UNTIL the window is visible and has |
| 245 // a valid FrameSinkId. |
| 246 WindowPortMus* window_port_mus = WindowPortMus::Get(&window); |
| 247 ASSERT_NE(nullptr, window_port_mus); |
| 248 EXPECT_EQ(nullptr, window_port_mus->client_surface_embedder()); |
| 249 |
| 250 // The window is now visible, but doesn't yet have a FrameSinkId. |
| 251 window.Show(); |
| 252 EXPECT_EQ(nullptr, window_port_mus->client_surface_embedder()); |
| 253 |
| 254 // Now that the window has a valid FrameSinkId, it can embed the client in a |
| 255 // CompositorFrame. |
| 256 window_tree_client()->OnFrameSinkIdAllocated(server_id(&window), |
| 257 cc::FrameSinkId(1, 1)); |
| 258 EXPECT_NE(nullptr, window_port_mus->client_surface_embedder()); |
| 259 } |
| 260 |
226 // Verifies that the cc::LocalSurfaceId generated by an embedder changes when | 261 // Verifies that the cc::LocalSurfaceId generated by an embedder changes when |
227 // the size changes, but not when the position changes. | 262 // the size changes, but not when the position changes. |
228 TEST_F(WindowTreeClientWmTest, SetBoundsLocalSurfaceIdChanges) { | 263 TEST_F(WindowTreeClientWmTest, SetBoundsLocalSurfaceIdChanges) { |
229 ASSERT_EQ(base::nullopt, window_tree()->last_local_surface_id()); | 264 ASSERT_EQ(base::nullopt, window_tree()->last_local_surface_id()); |
230 Window window(nullptr); | 265 Window window(nullptr); |
231 // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds | 266 // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds |
232 // when their sizes change. | 267 // when their sizes change. |
233 window.SetProperty(aura::client::kEmbedType, | 268 window.SetProperty(aura::client::kEmbedType, |
234 aura::client::WindowEmbedType::EMBED_IN_OWNER); | 269 aura::client::WindowEmbedType::EMBED_IN_OWNER); |
235 window.Init(ui::LAYER_NOT_DRAWN); | 270 window.Init(ui::LAYER_NOT_DRAWN); |
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2148 window_tree()->GetEventResult(event_id)); | 2183 window_tree()->GetEventResult(event_id)); |
2149 EXPECT_TRUE(window_delegate1.got_move()); | 2184 EXPECT_TRUE(window_delegate1.got_move()); |
2150 EXPECT_FALSE(window_delegate2.got_move()); | 2185 EXPECT_FALSE(window_delegate2.got_move()); |
2151 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, | 2186 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, |
2152 event_location_in_dip.y() + 30); | 2187 event_location_in_dip.y() + 30); |
2153 EXPECT_EQ(transformed_event_location_in_dip, | 2188 EXPECT_EQ(transformed_event_location_in_dip, |
2154 window_delegate1.last_event_location()); | 2189 window_delegate1.last_event_location()); |
2155 } | 2190 } |
2156 | 2191 |
2157 } // namespace aura | 2192 } // namespace aura |
OLD | NEW |