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

Side by Side Diff: ui/aura/test/aura_test_base.h

Issue 2445163002: Make aura work with mus (Closed)
Patch Set: NON_EXPORTED_BASE_CLASS Created 4 years, 1 month 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 | « ui/aura/test/aura_mus_test_base.cc ('k') | ui/aura/test/aura_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_AURA_TEST_AURA_TEST_BASE_H_ 5 #ifndef UI_AURA_TEST_AURA_TEST_BASE_H_
6 #define UI_AURA_TEST_AURA_TEST_BASE_H_ 6 #define UI_AURA_TEST_AURA_TEST_BASE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/aura/mus/window_manager_delegate.h"
13 #include "ui/aura/mus/window_tree_client_delegate.h"
12 #include "ui/aura/test/aura_test_helper.h" 14 #include "ui/aura/test/aura_test_helper.h"
13 15
16 namespace ui {
17 namespace mojom {
18 class WindowTreeClient;
19 }
20 }
21
14 namespace aura { 22 namespace aura {
15 class Window; 23 class Window;
16 class WindowDelegate; 24 class WindowDelegate;
25 class WindowManagerDelegate;
26 class WindowTreeClientDelegate;
27
17 namespace test { 28 namespace test {
18 29
19 // A base class for aura unit tests. 30 // A base class for aura unit tests.
20 // TODO(beng): Instances of this test will create and own a RootWindow. 31 // TODO(beng): Instances of this test will create and own a RootWindow.
21 class AuraTestBase : public testing::Test { 32 class AuraTestBase : public testing::Test,
33 public WindowTreeClientDelegate,
34 public WindowManagerDelegate {
22 public: 35 public:
23 AuraTestBase(); 36 AuraTestBase();
24 ~AuraTestBase() override; 37 ~AuraTestBase() override;
25 38
26 // testing::Test: 39 // testing::Test:
27 void SetUp() override; 40 void SetUp() override;
28 void TearDown() override; 41 void TearDown() override;
29 42
30 // Creates a normal window parented to |parent|. 43 // Creates a normal window parented to |parent|.
31 aura::Window* CreateNormalWindow(int id, Window* parent, 44 aura::Window* CreateNormalWindow(int id, Window* parent,
32 aura::WindowDelegate* delegate); 45 aura::WindowDelegate* delegate);
33 46
34 protected: 47 protected:
48 void set_window_manager_delegate(
49 WindowManagerDelegate* window_manager_delegate) {
50 window_manager_delegate_ = window_manager_delegate;
51 }
52
53 void set_window_tree_client_delegate(
54 WindowTreeClientDelegate* window_tree_client_delegate) {
55 window_tree_client_delegate_ = window_tree_client_delegate;
56 }
57
58 // Turns on mus. Must be called before SetUp().
59 void EnableMus();
60
35 void RunAllPendingInMessageLoop(); 61 void RunAllPendingInMessageLoop();
36 62
37 void ParentWindow(Window* window); 63 void ParentWindow(Window* window);
38 64
39 // A convenience function for dispatching an event to |dispatcher()|. 65 // A convenience function for dispatching an event to |dispatcher()|.
40 // Returns whether |event| was handled. 66 // Returns whether |event| was handled.
41 bool DispatchEventUsingWindowDispatcher(ui::Event* event); 67 bool DispatchEventUsingWindowDispatcher(ui::Event* event);
42 68
43 Window* root_window() { return helper_->root_window(); } 69 Window* root_window() { return helper_->root_window(); }
44 WindowTreeHost* host() { return helper_->host(); } 70 WindowTreeHost* host() { return helper_->host(); }
45 ui::EventProcessor* event_processor() { return helper_->event_processor(); } 71 ui::EventProcessor* event_processor() { return helper_->event_processor(); }
46 TestScreen* test_screen() { return helper_->test_screen(); } 72 TestScreen* test_screen() { return helper_->test_screen(); }
47 73
74 TestWindowTree* window_tree() { return helper_->window_tree(); }
75 WindowTreeClient* window_tree_client_impl() {
76 return helper_->window_tree_client();
77 }
78 ui::mojom::WindowTreeClient* window_tree_client();
79
80 // Resets the PropertyConverter.
81 void SetPropertyConverter(std::unique_ptr<PropertyConverter> helper);
82
83 // WindowTreeClientDelegate:
84 void OnEmbed(Window* root) override;
85 void OnUnembed(Window* root) override;
86 void OnEmbedRootDestroyed(Window* root) override;
87 void OnLostConnection(WindowTreeClient* client) override;
88 void OnPointerEventObserved(const ui::PointerEvent& event,
89 Window* target) override;
90
91 // WindowManagerDelegate:
92 void SetWindowManagerClient(WindowManagerClient* client) override;
93 bool OnWmSetBounds(Window* window, gfx::Rect* bounds) override;
94 bool OnWmSetProperty(
95 Window* window,
96 const std::string& name,
97 std::unique_ptr<std::vector<uint8_t>>* new_data) override;
98 Window* OnWmCreateTopLevelWindow(
99 std::map<std::string, std::vector<uint8_t>>* properties) override;
100 void OnWmClientJankinessChanged(const std::set<Window*>& client_windows,
101 bool janky) override;
102 void OnWmNewDisplay(Window* window, const display::Display& display) override;
103 void OnWmDisplayRemoved(Window* window) override;
104 void OnWmDisplayModified(const display::Display& display) override;
105 ui::mojom::EventResult OnAccelerator(uint32_t id,
106 const ui::Event& event) override;
107 void OnWmPerformMoveLoop(Window* window,
108 ui::mojom::MoveLoopSource source,
109 const gfx::Point& cursor_location,
110 const base::Callback<void(bool)>& on_done) override;
111 void OnWmCancelMoveLoop(Window* window) override;
112 client::FocusClient* GetFocusClient() override;
113 client::CaptureClient* GetCaptureClient() override;
114 PropertyConverter* GetPropertyConverter() override;
115
48 private: 116 private:
49 bool setup_called_; 117 // Only used for mus. Both are are initialized to this, but may be reset.
50 bool teardown_called_; 118 WindowManagerDelegate* window_manager_delegate_;
119 WindowTreeClientDelegate* window_tree_client_delegate_;
120
121 bool use_mus_ = false;
122 bool setup_called_ = false;
123 bool teardown_called_ = false;
51 base::MessageLoopForUI message_loop_; 124 base::MessageLoopForUI message_loop_;
125 std::unique_ptr<PropertyConverter> property_converter_;
52 std::unique_ptr<AuraTestHelper> helper_; 126 std::unique_ptr<AuraTestHelper> helper_;
53 127
54 DISALLOW_COPY_AND_ASSIGN(AuraTestBase); 128 DISALLOW_COPY_AND_ASSIGN(AuraTestBase);
55 }; 129 };
56 130
57 } // namespace test 131 } // namespace test
58 } // namespace aura 132 } // namespace aura
59 133
60 #endif // UI_AURA_TEST_AURA_TEST_BASE_H_ 134 #endif // UI_AURA_TEST_AURA_TEST_BASE_H_
OLDNEW
« no previous file with comments | « ui/aura/test/aura_mus_test_base.cc ('k') | ui/aura/test/aura_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698