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

Side by Side Diff: services/ui/ws/window_server_test_base.h

Issue 2559703003: Converts WindowTreeClientTest to be in terms of aura (Closed)
Patch Set: feedback Created 4 years 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_UI_WS_WINDOW_SERVER_TEST_BASE_H_
6 #define SERVICES_UI_WS_WINDOW_SERVER_TEST_BASE_H_
7
8 #include <memory>
9 #include <set>
10
11 #include "base/macros.h"
12 #include "services/service_manager/public/cpp/interface_factory.h"
13 #include "services/ui/public/interfaces/window_tree.mojom.h"
14 #include "services/ui/ws/window_server_service_test_base.h"
15 #include "ui/aura/mus/property_converter.h"
16 #include "ui/aura/mus/window_manager_delegate.h"
17 #include "ui/aura/mus/window_tree_client_delegate.h"
18 #include "ui/display/screen_base.h"
19 #include "ui/wm/core/wm_state.h"
20
21 namespace aura {
22 class Env;
23 class MusContextFactory;
24 }
25
26 namespace ui {
27 class GpuService;
28
29 // WindowServerTestBase is a base class for use with shell tests that use
30 // WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed()
31 // has been invoked. window_manager() can be used to access the WindowServer
32 // established as part of SetUp().
33 class WindowServerTestBase
34 : public WindowServerServiceTestBase,
35 public aura::WindowTreeClientDelegate,
36 public aura::WindowManagerDelegate,
37 public service_manager::InterfaceFactory<mojom::WindowTreeClient> {
38 public:
39 WindowServerTestBase();
40 ~WindowServerTestBase() override;
41
42 // True if WindowTreeClientDelegate::OnLostConnection() was called.
43 bool window_tree_client_lost_connection() const {
44 return window_tree_client_lost_connection_;
45 }
46
47 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs.
48 // Returns true on success. Generally prefer running a RunLoop and
49 // explicitly quiting that, but use this for times when that is not possible.
50 static bool DoRunLoopWithTimeout() WARN_UNUSED_RESULT;
51
52 // Quits a run loop started by DoRunLoopWithTimeout(). Returns true on
53 // success, false if a RunLoop isn't running.
54 static bool QuitRunLoop() WARN_UNUSED_RESULT;
55
56 aura::WindowTreeClient* window_manager() { return window_manager_; }
57 aura::WindowManagerClient* window_manager_client() {
58 return window_manager_client_;
59 }
60
61 protected:
62 void set_window_manager_delegate(aura::WindowManagerDelegate* delegate) {
63 window_manager_delegate_ = delegate;
64 }
65
66 // Cleans up internal state then deletes |client|.
67 void DeleteWindowTreeClient(aura::WindowTreeClient* client);
68
69 // Returns the most WindowTreeClient that was created as the result of
msw 2016/12/08 19:07:41 wow, which one is the *most WindowTreeClient*? lol
sky 2016/12/12 18:35:59 Ha!
70 // InterfaceFactory<WindowTreeClient> being called. In other words the most
71 // recent WindowTreeClient created for an embed.
msw 2016/12/08 19:07:41 nit: "created as the result of a client embedding"
sky 2016/12/12 18:35:59 Done.
72 std::unique_ptr<aura::WindowTreeClient> ReleaseMostRecentClient();
73
74 // testing::Test:
75 void SetUp() override;
76 void TearDown() override;
77
78 // WindowServerServiceTestBase:
79 bool OnConnect(const service_manager::Identity& remote_identity,
80 service_manager::InterfaceRegistry* registry) override;
81
82 // WindowTreeClientDelegate:
83 void OnEmbed(
84 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override;
85 void OnLostConnection(aura::WindowTreeClient* client) override;
86 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override;
87 void OnPointerEventObserved(const ui::PointerEvent& event,
88 aura::Window* target) override;
89 aura::client::CaptureClient* GetCaptureClient() override;
90 aura::PropertyConverter* GetPropertyConverter() override;
91
92 // WindowManagerDelegate:
93 void SetWindowManagerClient(aura::WindowManagerClient* client) override;
94 bool OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) override;
95 bool OnWmSetProperty(
96 aura::Window* window,
97 const std::string& name,
98 std::unique_ptr<std::vector<uint8_t>>* new_data) override;
99 aura::Window* OnWmCreateTopLevelWindow(
100 ui::mojom::WindowType window_type,
101 std::map<std::string, std::vector<uint8_t>>* properties) override;
102 void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows,
103 bool not_responding) override;
104 void OnWmWillCreateDisplay(const display::Display& display) override;
105 void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host,
106 const display::Display& display) override;
107 void OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) override;
108 void OnWmDisplayModified(const display::Display& display) override;
109 mojom::EventResult OnAccelerator(uint32_t accelerator_id,
110 const ui::Event& event) override;
111 void OnWmPerformMoveLoop(aura::Window* window,
112 mojom::MoveLoopSource source,
113 const gfx::Point& cursor_location,
114 const base::Callback<void(bool)>& on_done) override;
115 void OnWmCancelMoveLoop(aura::Window* window) override;
116 void OnWmSetClientArea(
117 aura::Window* window,
118 const gfx::Insets& insets,
119 const std::vector<gfx::Rect>& additional_client_areas) override;
120
121 // InterfaceFactory<WindowTreeClient>:
122 void Create(const service_manager::Identity& remote_identity,
123 mojo::InterfaceRequest<mojom::WindowTreeClient> request) override;
124
125 private:
126 // Removes |window_tree_host| from |window_tree_hosts_| and deletes it.
127 // Returns true on success, and false if not found, in which case
128 // |window_tree_host| is not deleted.
129 bool DeleteWindowTreeHost(aura::WindowTreeHostMus* window_tree_host);
130
131 std::unique_ptr<aura::Env> env_;
132 ::wm::WMState wm_state_;
133 display::ScreenBase screen_;
134 aura::PropertyConverter property_converter_;
135
136 std::unique_ptr<GpuService> gpu_service_;
137 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_;
138
139 std::vector<std::unique_ptr<aura::WindowTreeClient>> window_tree_clients_;
140
141 std::vector<std::unique_ptr<aura::WindowTreeHostMus>> window_tree_hosts_;
142
143 // The window server connection held by the window manager (app running at
144 // the root window).
145 aura::WindowTreeClient* window_manager_ = nullptr;
146
147 // A test can override the WM-related behaviour by installing its own
148 // WindowManagerDelegate during the test.
149 aura::WindowManagerDelegate* window_manager_delegate_ = nullptr;
150
151 aura::WindowManagerClient* window_manager_client_ = nullptr;
152
153 bool window_tree_client_lost_connection_ = false;
154
155 DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase);
156 };
157
158 } // namespace ui
159
160 #endif // SERVICES_UI_WS_WINDOW_SERVER_TEST_BASE_H_
OLDNEW
« no previous file with comments | « services/ui/ws/window_server_service_test_base.cc ('k') | services/ui/ws/window_server_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698