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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 // WindowTreeClientWmTest with --enable-surface-synchronization. | 107 // WindowTreeClientWmTest with --enable-surface-synchronization. |
108 class WindowTreeClientWmTestSurfaceSync : public WindowTreeClientWmTest { | 108 class WindowTreeClientWmTestSurfaceSync : public WindowTreeClientWmTest { |
109 public: | 109 public: |
110 WindowTreeClientWmTestSurfaceSync() {} | 110 WindowTreeClientWmTestSurfaceSync() {} |
111 ~WindowTreeClientWmTestSurfaceSync() override {} | 111 ~WindowTreeClientWmTestSurfaceSync() override {} |
112 | 112 |
113 // WindowTreeClientWmTest: | 113 // WindowTreeClientWmTest: |
114 void SetUp() override { | 114 void SetUp() override { |
115 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 115 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
116 cc::switches::kEnableSurfaceSynchronization); | 116 cc::switches::kEnableSurfaceSynchronization); |
117 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
118 switches::kForceDeviceScaleFactor, "2"); | |
sadrul
2017/05/09 15:04:59
This makes all tests run in high-dpi. Can you crea
Fady Samuel
2017/05/30 21:30:08
Done.
| |
117 WindowTreeClientWmTest::SetUp(); | 119 WindowTreeClientWmTest::SetUp(); |
118 } | 120 } |
119 | 121 |
120 private: | 122 private: |
121 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientWmTestSurfaceSync); | 123 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientWmTestSurfaceSync); |
122 }; | 124 }; |
123 | 125 |
124 // WindowTreeClientWmTest with --force-device-scale-factor=2. | 126 // WindowTreeClientWmTest with --force-device-scale-factor=2. |
125 class WindowTreeClientWmTestHighDPI : public WindowTreeClientWmTest { | 127 class WindowTreeClientWmTestHighDPI : public WindowTreeClientWmTest { |
126 public: | 128 public: |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds | 214 // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds |
213 // when their sizes change. | 215 // when their sizes change. |
214 window.SetProperty(aura::client::kEmbedType, | 216 window.SetProperty(aura::client::kEmbedType, |
215 aura::client::WindowEmbedType::EMBED_IN_OWNER); | 217 aura::client::WindowEmbedType::EMBED_IN_OWNER); |
216 window.Init(ui::LAYER_NOT_DRAWN); | 218 window.Init(ui::LAYER_NOT_DRAWN); |
217 | 219 |
218 // The window will allocate a cc::LocalSurfaceId once it has a bounds. | 220 // The window will allocate a cc::LocalSurfaceId once it has a bounds. |
219 WindowMus* window_mus = WindowMus::Get(&window); | 221 WindowMus* window_mus = WindowMus::Get(&window); |
220 ASSERT_NE(nullptr, window_mus); | 222 ASSERT_NE(nullptr, window_mus); |
221 EXPECT_FALSE(window_mus->GetLocalSurfaceId().is_valid()); | 223 EXPECT_FALSE(window_mus->GetLocalSurfaceId().is_valid()); |
222 const gfx::Rect new_bounds(gfx::Rect(0, 0, 100, 100)); | 224 gfx::Rect new_bounds(gfx::Rect(0, 0, 100, 100)); |
223 ASSERT_NE(new_bounds, window.bounds()); | 225 ASSERT_NE(new_bounds, window.bounds()); |
224 window.SetBounds(new_bounds); | 226 window.SetBounds(new_bounds); |
225 EXPECT_EQ(new_bounds, window.bounds()); | 227 EXPECT_EQ(new_bounds, window.bounds()); |
226 EXPECT_TRUE(window_mus->GetLocalSurfaceId().is_valid()); | 228 EXPECT_TRUE(window_mus->GetLocalSurfaceId().is_valid()); |
227 | 229 |
228 // An ClientSurfaceEmbedder isn't created UNTIL the window has a bounds and | 230 // An ClientSurfaceEmbedder isn't created UNTIL the window has a bounds and |
229 // a valid FrameSinkId. | 231 // a valid FrameSinkId. |
230 WindowPortMus* window_port_mus = WindowPortMus::Get(&window); | 232 WindowPortMus* window_port_mus = WindowPortMus::Get(&window); |
231 ASSERT_NE(nullptr, window_port_mus); | 233 ASSERT_NE(nullptr, window_port_mus); |
232 EXPECT_EQ(nullptr, window_port_mus->client_surface_embedder()); | 234 EXPECT_EQ(nullptr, window_port_mus->client_surface_embedder()); |
233 | 235 |
234 // Now that the window has a valid FrameSinkId, it can embed the client in a | 236 // Now that the window has a valid FrameSinkId, it can embed the client in a |
235 // CompositorFrame. | 237 // CompositorFrame. |
236 window_tree_client()->OnFrameSinkIdAllocated(server_id(&window), | 238 window_tree_client()->OnFrameSinkIdAllocated(server_id(&window), |
237 cc::FrameSinkId(1, 1)); | 239 cc::FrameSinkId(1, 1)); |
238 ClientSurfaceEmbedder* client_surface_embedder = | 240 ClientSurfaceEmbedder* client_surface_embedder = |
239 window_port_mus->client_surface_embedder(); | 241 window_port_mus->client_surface_embedder(); |
240 ASSERT_NE(nullptr, client_surface_embedder); | 242 ASSERT_NE(nullptr, client_surface_embedder); |
241 | 243 |
242 // Until the fallback surface fills the window, we will have gutter. | 244 // Until the fallback surface fills the window, we will have gutter. |
243 ui::Layer* right_gutter = client_surface_embedder->RightGutterForTesting(); | 245 { |
244 ASSERT_NE(nullptr, right_gutter); | 246 ui::Layer* right_gutter = client_surface_embedder->RightGutterForTesting(); |
245 EXPECT_EQ(gfx::Rect(100, 100), right_gutter->bounds()); | 247 ASSERT_NE(nullptr, right_gutter); |
246 // We don't have a bottom gutter if the fallback surface size is (0, 0) as the | 248 EXPECT_EQ(gfx::Rect(100, 100), right_gutter->bounds()); |
247 // right gutter will fill the whole area. | 249 // We don't have a bottom gutter if the fallback surface size is (0, 0) as |
248 ASSERT_EQ(nullptr, client_surface_embedder->BottomGutterForTesting()); | 250 // the right gutter will fill the whole area. |
251 ASSERT_EQ(nullptr, client_surface_embedder->BottomGutterForTesting()); | |
252 } | |
249 | 253 |
250 // When a SurfaceInfo arrives from the window server, we use it as the | 254 // When a SurfaceInfo arrives from the window server, we use it as the |
251 // fallback SurfaceInfo. Here we issue the PrimarySurfaceInfo back to the | 255 // fallback SurfaceInfo. Here we issue the PrimarySurfaceInfo back to the |
252 // client lib. This should cause the gutter to go away, eliminating overdraw. | 256 // client lib. This should cause the gutter to go away, eliminating overdraw. |
253 window_tree_client()->OnWindowSurfaceChanged( | 257 window_tree_client()->OnWindowSurfaceChanged( |
254 server_id(&window), window_port_mus->PrimarySurfaceInfoForTesting()); | 258 server_id(&window), window_port_mus->PrimarySurfaceInfoForTesting()); |
255 | 259 |
256 // The gutter is gone. | 260 // The gutter is gone. |
257 ASSERT_EQ(nullptr, client_surface_embedder->BottomGutterForTesting()); | 261 ASSERT_EQ(nullptr, client_surface_embedder->BottomGutterForTesting()); |
258 ASSERT_EQ(nullptr, client_surface_embedder->RightGutterForTesting()); | 262 ASSERT_EQ(nullptr, client_surface_embedder->RightGutterForTesting()); |
263 | |
264 // Resize again: we should have gutter. | |
265 new_bounds.SetRect(0, 0, 150, 150); | |
266 ASSERT_NE(new_bounds, window.bounds()); | |
267 window.SetBounds(new_bounds); | |
268 ASSERT_NE(nullptr, client_surface_embedder->BottomGutterForTesting()); | |
269 ASSERT_NE(nullptr, client_surface_embedder->RightGutterForTesting()); | |
270 | |
271 // Until the fallback surface fills the window, we will have gutter. | |
272 { | |
273 ui::Layer* right_gutter = client_surface_embedder->RightGutterForTesting(); | |
274 ASSERT_NE(nullptr, right_gutter); | |
275 EXPECT_EQ(gfx::Rect(100, 0, 50, 150), right_gutter->bounds()); | |
276 | |
277 ui::Layer* bottom_gutter = | |
278 client_surface_embedder->BottomGutterForTesting(); | |
279 ASSERT_NE(nullptr, bottom_gutter); | |
280 EXPECT_EQ(gfx::Rect(0, 100, 100, 50), bottom_gutter->bounds()); | |
281 } | |
259 } | 282 } |
260 | 283 |
261 // Verifies that the cc::LocalSurfaceId generated by an embedder changes when | 284 // Verifies that the cc::LocalSurfaceId generated by an embedder changes when |
262 // the size changes, but not when the position changes. | 285 // the size changes, but not when the position changes. |
263 TEST_F(WindowTreeClientWmTest, SetBoundsLocalSurfaceIdChanges) { | 286 TEST_F(WindowTreeClientWmTest, SetBoundsLocalSurfaceIdChanges) { |
264 ASSERT_EQ(base::nullopt, window_tree()->last_local_surface_id()); | 287 ASSERT_EQ(base::nullopt, window_tree()->last_local_surface_id()); |
265 Window window(nullptr); | 288 Window window(nullptr); |
266 // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds | 289 // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds |
267 // when their sizes change. | 290 // when their sizes change. |
268 window.SetProperty(aura::client::kEmbedType, | 291 window.SetProperty(aura::client::kEmbedType, |
(...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2404 window_tree()->GetEventResult(event_id)); | 2427 window_tree()->GetEventResult(event_id)); |
2405 EXPECT_TRUE(window_delegate1.got_move()); | 2428 EXPECT_TRUE(window_delegate1.got_move()); |
2406 EXPECT_FALSE(window_delegate2.got_move()); | 2429 EXPECT_FALSE(window_delegate2.got_move()); |
2407 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, | 2430 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, |
2408 event_location_in_dip.y() + 30); | 2431 event_location_in_dip.y() + 30); |
2409 EXPECT_EQ(transformed_event_location_in_dip, | 2432 EXPECT_EQ(transformed_event_location_in_dip, |
2410 window_delegate1.last_event_location()); | 2433 window_delegate1.last_event_location()); |
2411 } | 2434 } |
2412 | 2435 |
2413 } // namespace aura | 2436 } // namespace aura |
OLD | NEW |