| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/window_server_test_impl.h" | 5 #include "services/ui/ws/window_server_test_impl.h" |
| 6 | 6 |
| 7 #include "services/ui/public/interfaces/window_tree.mojom.h" | 7 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 8 #include "services/ui/ws/server_window.h" | 8 #include "services/ui/ws/server_window.h" |
| 9 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" | 9 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
| 10 #include "services/ui/ws/window_server.h" | 10 #include "services/ui/ws/window_server.h" |
| 11 #include "services/ui/ws/window_tree.h" | 11 #include "services/ui/ws/window_tree.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 namespace ws { | 14 namespace ws { |
| 15 | 15 |
| 16 namespace { | |
| 17 | |
| 18 bool WindowHasValidFrame(const ServerWindow* window) { | |
| 19 const ServerWindowCompositorFrameSinkManager* manager = | |
| 20 window->compositor_frame_sink_manager(); | |
| 21 return manager && !manager->GetLatestFrameSize().IsEmpty(); | |
| 22 } | |
| 23 | |
| 24 } // namespace | |
| 25 | |
| 26 WindowServerTestImpl::WindowServerTestImpl(WindowServer* window_server) | 16 WindowServerTestImpl::WindowServerTestImpl(WindowServer* window_server) |
| 27 : window_server_(window_server) {} | 17 : window_server_(window_server) {} |
| 28 | 18 |
| 29 WindowServerTestImpl::~WindowServerTestImpl() {} | 19 WindowServerTestImpl::~WindowServerTestImpl() {} |
| 30 | 20 |
| 31 void WindowServerTestImpl::OnWindowPaint( | 21 void WindowServerTestImpl::OnWindowPaint( |
| 32 const std::string& name, | 22 const std::string& name, |
| 33 const EnsureClientHasDrawnWindowCallback& cb, | 23 const EnsureClientHasDrawnWindowCallback& cb, |
| 34 ServerWindow* window) { | 24 ServerWindow* window) { |
| 35 WindowTree* tree = window_server_->GetTreeWithClientName(name); | 25 WindowTree* tree = window_server_->GetTreeWithClientName(name); |
| 36 if (!tree) | 26 if (!tree) |
| 37 return; | 27 return; |
| 38 if (tree->HasRoot(window) && WindowHasValidFrame(window)) { | 28 if (tree->HasRoot(window) && window->compositor_frame_sink_manager()) { |
| 39 cb.Run(true); | 29 cb.Run(true); |
| 40 window_server_->SetPaintCallback(base::Callback<void(ServerWindow*)>()); | 30 window_server_->SetPaintCallback(base::Callback<void(ServerWindow*)>()); |
| 41 } | 31 } |
| 42 } | 32 } |
| 43 | 33 |
| 44 void WindowServerTestImpl::EnsureClientHasDrawnWindow( | 34 void WindowServerTestImpl::EnsureClientHasDrawnWindow( |
| 45 const std::string& client_name, | 35 const std::string& client_name, |
| 46 const EnsureClientHasDrawnWindowCallback& callback) { | 36 const EnsureClientHasDrawnWindowCallback& callback) { |
| 47 WindowTree* tree = window_server_->GetTreeWithClientName(client_name); | 37 WindowTree* tree = window_server_->GetTreeWithClientName(client_name); |
| 48 if (tree) { | 38 if (tree) { |
| 49 for (const ServerWindow* window : tree->roots()) { | 39 for (const ServerWindow* window : tree->roots()) { |
| 50 if (WindowHasValidFrame(window)) { | 40 if (window->compositor_frame_sink_manager()) { |
| 51 callback.Run(true); | 41 callback.Run(true); |
| 52 return; | 42 return; |
| 53 } | 43 } |
| 54 } | 44 } |
| 55 } | 45 } |
| 56 | 46 |
| 57 window_server_->SetPaintCallback( | 47 window_server_->SetPaintCallback( |
| 58 base::Bind(&WindowServerTestImpl::OnWindowPaint, base::Unretained(this), | 48 base::Bind(&WindowServerTestImpl::OnWindowPaint, base::Unretained(this), |
| 59 client_name, std::move(callback))); | 49 client_name, std::move(callback))); |
| 60 } | 50 } |
| 61 | 51 |
| 62 } // namespace ws | 52 } // namespace ws |
| 63 } // namespace ui | 53 } // namespace ui |
| OLD | NEW |