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

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: Pass the count to the callback. Created 3 years, 10 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"
(...skipping 12 matching lines...) Expand all
23 23
24 } // namespace 24 } // namespace
25 25
26 WindowServerTestImpl::WindowServerTestImpl(WindowServer* window_server) 26 WindowServerTestImpl::WindowServerTestImpl(WindowServer* window_server)
27 : window_server_(window_server) {} 27 : window_server_(window_server) {}
28 28
29 WindowServerTestImpl::~WindowServerTestImpl() {} 29 WindowServerTestImpl::~WindowServerTestImpl() {}
30 30
31 void WindowServerTestImpl::OnWindowPaint( 31 void WindowServerTestImpl::OnWindowPaint(
32 const std::string& name, 32 const std::string& name,
33 const EnsureClientHasDrawnWindowCallback& cb, 33 const EnsureClientHasDrawnRootWindowsCallback& cb,
34 ServerWindow* window) { 34 ServerWindow* window) {
35 WindowTree* tree = window_server_->GetTreeWithClientName(name); 35 WindowTree* tree = window_server_->GetTreeWithClientName(name);
36 if (!tree) 36 if (!tree)
37 return; 37 return;
38 if (tree->HasRoot(window) && WindowHasValidFrame(window)) { 38 if (tree->HasRoot(window) && WindowHasValidFrame(window)) {
39 cb.Run(true); 39 painted_window_roots_[name]++;
40 window_server_->SetPaintCallback(base::Callback<void(ServerWindow*)>()); 40 if (painted_window_roots_[name] == tree->roots().size()) {
41 painted_window_roots_.erase(name);
42 cb.Run(tree->roots().size());
43 window_server_->SetPaintCallback(base::Callback<void(ServerWindow*)>());
44 }
41 } 45 }
42 } 46 }
43 47
44 void WindowServerTestImpl::EnsureClientHasDrawnWindow( 48 void WindowServerTestImpl::EnsureClientHasDrawnRootWindows(
45 const std::string& client_name, 49 const std::string& client_name,
46 const EnsureClientHasDrawnWindowCallback& callback) { 50 const EnsureClientHasDrawnRootWindowsCallback& callback) {
51 if (painted_window_roots_.find(client_name) != painted_window_roots_.end()) {
52 LOG(ERROR) << "EnsureClientHasDrawnRootWindows is already being executed "
53 "for that client name.";
fwang 2017/02/24 08:51:15 This is maybe not a big concern for now (the funct
54 return;
55 }
56
57 painted_window_roots_[client_name] = 0;
47 WindowTree* tree = window_server_->GetTreeWithClientName(client_name); 58 WindowTree* tree = window_server_->GetTreeWithClientName(client_name);
48 if (tree) { 59 if (tree) {
49 for (const ServerWindow* window : tree->roots()) { 60 for (const ServerWindow* window : tree->roots()) {
50 if (WindowHasValidFrame(window)) { 61 if (WindowHasValidFrame(window)) {
51 callback.Run(true); 62 painted_window_roots_[client_name]++;
52 return;
53 } 63 }
54 } 64 }
65 if (painted_window_roots_[client_name] == tree->roots().size()) {
66 painted_window_roots_.erase(client_name);
67 callback.Run(tree->roots().size());
68 return;
69 }
55 } 70 }
56 71
57 window_server_->SetPaintCallback( 72 window_server_->SetPaintCallback(
58 base::Bind(&WindowServerTestImpl::OnWindowPaint, base::Unretained(this), 73 base::Bind(&WindowServerTestImpl::OnWindowPaint, base::Unretained(this),
59 client_name, std::move(callback))); 74 client_name, std::move(callback)));
60 } 75 }
61 76
62 } // namespace ws 77 } // namespace ws
63 } // namespace ui 78 } // 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