Index: ui/aura/test/mus/test_window_tree.h |
diff --git a/services/ui/public/cpp/tests/test_window_tree.h b/ui/aura/test/mus/test_window_tree.h |
similarity index 64% |
copy from services/ui/public/cpp/tests/test_window_tree.h |
copy to ui/aura/test/mus/test_window_tree.h |
index 7bab30a1a3b5c6c5270725e28c1f422393f8b83e..2e789c9c78c40778dcbf6b1933a76c75a9a5ea5e 100644 |
--- a/services/ui/public/cpp/tests/test_window_tree.h |
+++ b/ui/aura/test/mus/test_window_tree.h |
@@ -2,8 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_ |
-#define SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_ |
+#ifndef UI_AURA_TEST_MUS_TEST_WINDOW_TREE_H_ |
+#define UI_AURA_TEST_MUS_TEST_WINDOW_TREE_H_ |
#include <stdint.h> |
@@ -12,25 +12,71 @@ |
#include "base/macros.h" |
#include "services/ui/public/interfaces/window_tree.mojom.h" |
-namespace ui { |
+namespace aura { |
-// Testing WindowTree implementation. |
-class TestWindowTree : public mojom::WindowTree { |
+enum class WindowTreeChangeType { |
+ BOUNDS, |
+ // Used for both set and release capture. |
+ CAPTURE, |
+ FOCUS, |
+ NEW_TOP_LEVEL, |
+ NEW_WINDOW, |
+ PROPERTY, |
+ VISIBLE, |
+ |
+ // This covers all cases that aren't used in tests. |
+ OTHER, |
+}; |
+ |
+// WindowTree implementation for tests. TestWindowTree maintains a list of all |
+// calls that take a change_id and are expected to be acked back to the client. |
+// Various functions are provided to respond to the changes. |
+class TestWindowTree : public ui::mojom::WindowTree { |
public: |
TestWindowTree(); |
~TestWindowTree() override; |
- // Returns the most recent change_id supplied to one of the WindowTree |
- // functions. Returns false if one of the WindowTree functions has not been |
- // invoked since the last GetAndClearChangeId(). |
- bool GetAndClearChangeId(uint32_t* change_id); |
+ void set_client(ui::mojom::WindowTreeClient* client) { client_ = client; } |
uint32_t window_id() const { return window_id_; } |
bool WasEventAcked(uint32_t event_id) const; |
+ mojo::Array<uint8_t> GetLastPropertyValue(); |
+ |
+ mojo::Map<mojo::String, mojo::Array<uint8_t>> GetLastNewWindowProperties(); |
+ |
+ // True if at least one function has been called that takes a change id. |
+ bool has_change() const { return !changes_.empty(); } |
+ |
+ // Acks all changes with a value of true. |
+ void AckAllChanges(); |
+ |
+ // Returns false if there are no, or more than one, changes of the specified |
+ // type. If there is only one of the matching type it is acked with a result |
+ // of |result| and true is returned. |
+ bool AckSingleChangeOfType(WindowTreeChangeType type, bool result); |
+ |
+ // Same as AckSingleChangeOfType(), but doesn't fail if there is more than |
+ // one change of the specified type. |
+ bool AckFirstChangeOfType(WindowTreeChangeType type, bool result); |
+ |
+ void AckAllChangesOfType(WindowTreeChangeType type, bool result); |
+ |
+ bool GetAndRemoveFirstChangeOfType(WindowTreeChangeType type, |
+ uint32_t* change_id); |
+ |
private: |
- // mojom::WindowTree: |
+ struct Change { |
+ WindowTreeChangeType type; |
+ uint32_t id; |
+ }; |
+ |
+ void OnChangeReceived( |
+ uint32_t change_id, |
+ WindowTreeChangeType type = WindowTreeChangeType::OTHER); |
+ |
+ // ui::mojom::WindowTree: |
void NewWindow( |
uint32_t change_id, |
uint32_t window_id, |
@@ -61,9 +107,11 @@ class TestWindowTree : public mojom::WindowTree { |
float opacity) override; |
void AttachCompositorFrameSink( |
uint32_t window_id, |
- mojom::CompositorFrameSinkType type, |
+ ui::mojom::CompositorFrameSinkType type, |
mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> surface, |
cc::mojom::MojoCompositorFrameSinkClientPtr client) override; |
+ void OnWindowSurfaceDetached(uint32_t window_id, |
+ const cc::SurfaceSequence& sequence) override; |
void AddWindow(uint32_t change_id, uint32_t parent, uint32_t child) override; |
void RemoveWindowFromParent(uint32_t change_id, uint32_t window_id) override; |
void AddTransientWindow(uint32_t change_id, |
@@ -75,7 +123,7 @@ class TestWindowTree : public mojom::WindowTree { |
void ReorderWindow(uint32_t change_id, |
uint32_t window_id, |
uint32_t relative_window_id, |
- mojom::OrderDirection direction) override; |
+ ui::mojom::OrderDirection direction) override; |
void GetWindowTree(uint32_t window_id, |
const GetWindowTreeCallback& callback) override; |
void SetCapture(uint32_t change_id, uint32_t window_id) override; |
@@ -83,7 +131,7 @@ class TestWindowTree : public mojom::WindowTree { |
void StartPointerWatcher(bool want_moves) override; |
void StopPointerWatcher() override; |
void Embed(uint32_t window_id, |
- mojom::WindowTreeClientPtr client, |
+ ui::mojom::WindowTreeClientPtr client, |
uint32_t flags, |
const EmbedCallback& callback) override; |
void SetFocus(uint32_t change_id, uint32_t window_id) override; |
@@ -100,10 +148,10 @@ class TestWindowTree : public mojom::WindowTree { |
void OnWindowInputEventAck(uint32_t event_id, |
ui::mojom::EventResult result) override; |
void GetWindowManagerClient( |
- mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) |
- override; |
- void GetCursorLocationMemory(const GetCursorLocationMemoryCallback& callback) |
+ mojo::AssociatedInterfaceRequest<ui::mojom::WindowManagerClient> internal) |
override; |
+ void GetCursorLocationMemory( |
+ const GetCursorLocationMemoryCallback& callback) override; |
void PerformDragDrop(uint32_t change_id, |
uint32_t source_window_id, |
mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data, |
@@ -111,20 +159,24 @@ class TestWindowTree : public mojom::WindowTree { |
void CancelDragDrop(uint32_t window_id) override; |
void PerformWindowMove(uint32_t change_id, |
uint32_t window_id, |
- mojom::MoveLoopSource source, |
+ ui::mojom::MoveLoopSource source, |
const gfx::Point& cursor_location) override; |
void CancelWindowMove(uint32_t window_id) override; |
- void OnWindowSurfaceDetached(uint32_t window_id, |
- const cc::SurfaceSequence& sequence) override; |
- bool got_change_; |
- uint32_t change_id_; |
std::set<uint32_t> acked_events_; |
- uint32_t window_id_; |
+ uint32_t window_id_ = 0u; |
+ |
+ mojo::Array<uint8_t> last_property_value_; |
+ |
+ std::vector<Change> changes_; |
+ |
+ ui::mojom::WindowTreeClient* client_; |
+ |
+ mojo::Map<mojo::String, mojo::Array<uint8_t>> last_new_window_properties_; |
DISALLOW_COPY_AND_ASSIGN(TestWindowTree); |
}; |
-} // namespace ui |
+} // namespace aura |
-#endif // SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_ |
+#endif // UI_AURA_TEST_MUS_TEST_WINDOW_TREE_H_ |