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

Side by Side Diff: services/ui/ws/window_server_test_impl.cc

Issue 2715533005: Make mus_demo_unittests work with multiple root windows (Closed)
Patch Set: Add a unit test for multiple windows. Created 3 years, 9 months 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 | « services/ui/ws/window_server_test_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 WindowServerTestImpl::WindowServerTestImpl(WindowServer* window_server) 16 WindowServerTestImpl::WindowServerTestImpl(WindowServer* window_server)
17 : window_server_(window_server) {} 17 : window_server_(window_server) {}
18 18
19 WindowServerTestImpl::~WindowServerTestImpl() {} 19 WindowServerTestImpl::~WindowServerTestImpl() {}
20 20
21 void WindowServerTestImpl::OnWindowPaint( 21 void WindowServerTestImpl::OnWindowPaint(
22 const std::string& name, 22 const std::string& name,
23 const EnsureClientHasDrawnWindowCallback& cb, 23 const EnsureClientHasDrawnRootWindowsCallback& cb,
24 ServerWindow* window) { 24 ServerWindow* window) {
25 WindowTree* tree = window_server_->GetTreeWithClientName(name); 25 WindowTree* tree = window_server_->GetTreeWithClientName(name);
26 if (!tree) 26 if (!tree)
27 return; 27 return;
28 if (tree->HasRoot(window) && window->compositor_frame_sink_manager()) { 28 if (tree->HasRoot(window) && window->compositor_frame_sink_manager()) {
29 cb.Run(true); 29 painted_window_roots_[name]++;
30 window_server_->SetPaintCallback(base::Callback<void(ServerWindow*)>()); 30 if (painted_window_roots_[name] == tree->roots().size()) {
31 painted_window_roots_.erase(name);
32 cb.Run(tree->roots().size());
33 window_server_->SetPaintCallback(base::Callback<void(ServerWindow*)>());
34 }
31 } 35 }
32 } 36 }
33 37
34 void WindowServerTestImpl::EnsureClientHasDrawnWindow( 38 void WindowServerTestImpl::EnsureClientHasDrawnRootWindows(
35 const std::string& client_name, 39 const std::string& client_name,
36 const EnsureClientHasDrawnWindowCallback& callback) { 40 const EnsureClientHasDrawnRootWindowsCallback& callback) {
41 if (painted_window_roots_.find(client_name) != painted_window_roots_.end()) {
42 LOG(ERROR) << "EnsureClientHasDrawnRootWindows is already being executed "
43 "for that client name.";
44 callback.Run(0);
fwang 2017/03/01 17:24:34 I added this for completeness, although it's actua
45 return;
46 }
47
48 painted_window_roots_[client_name] = 0;
37 WindowTree* tree = window_server_->GetTreeWithClientName(client_name); 49 WindowTree* tree = window_server_->GetTreeWithClientName(client_name);
38 if (tree) { 50 if (tree) {
39 for (const ServerWindow* window : tree->roots()) { 51 for (const ServerWindow* window : tree->roots()) {
40 if (window->compositor_frame_sink_manager()) { 52 if (window->compositor_frame_sink_manager()) {
41 callback.Run(true); 53 painted_window_roots_[client_name]++;
42 return;
43 } 54 }
44 } 55 }
56 if (painted_window_roots_[client_name] == tree->roots().size()) {
57 painted_window_roots_.erase(client_name);
58 callback.Run(tree->roots().size());
59 return;
60 }
45 } 61 }
46 62
47 window_server_->SetPaintCallback( 63 window_server_->SetPaintCallback(
48 base::Bind(&WindowServerTestImpl::OnWindowPaint, base::Unretained(this), 64 base::Bind(&WindowServerTestImpl::OnWindowPaint, base::Unretained(this),
49 client_name, std::move(callback))); 65 client_name, std::move(callback)));
50 } 66 }
51 67
52 } // namespace ws 68 } // namespace ws
53 } // namespace ui 69 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_server_test_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698