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

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

Powered by Google App Engine
This is Rietveld 408576698