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

Unified Diff: ui/aura/test/mus/test_window_tree.cc

Issue 2445163002: Make aura work with mus (Closed)
Patch Set: NON_EXPORTED_BASE_CLASS Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/test/mus/test_window_tree.h ('k') | ui/aura/test/mus/test_window_tree_client_setup.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/test/mus/test_window_tree.cc
diff --git a/services/ui/public/cpp/tests/test_window_tree.cc b/ui/aura/test/mus/test_window_tree.cc
similarity index 57%
copy from services/ui/public/cpp/tests/test_window_tree.cc
copy to ui/aura/test/mus/test_window_tree.cc
index f344aec9d1207846a2093e3d0250f5198b24cd19..0a4a32414bfccb3478f2f2206b112fe70ae1c521 100644
--- a/services/ui/public/cpp/tests/test_window_tree.cc
+++ b/ui/aura/test/mus/test_window_tree.cc
@@ -2,52 +2,119 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "services/ui/public/cpp/tests/test_window_tree.h"
+#include "ui/aura/test/mus/test_window_tree.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace ui {
+namespace aura {
-TestWindowTree::TestWindowTree()
- : got_change_(false), change_id_(0), window_id_(0u) {}
+TestWindowTree::TestWindowTree() {}
TestWindowTree::~TestWindowTree() {}
-bool TestWindowTree::GetAndClearChangeId(uint32_t* change_id) {
- if (!got_change_)
+bool TestWindowTree::WasEventAcked(uint32_t event_id) const {
+ return acked_events_.count(event_id);
+}
+
+mojo::Array<uint8_t> TestWindowTree::GetLastPropertyValue() {
+ return std::move(last_property_value_);
+}
+
+mojo::Map<mojo::String, mojo::Array<uint8_t>>
+TestWindowTree::GetLastNewWindowProperties() {
+ return std::move(last_new_window_properties_);
+}
+
+void TestWindowTree::AckAllChanges() {
+ while (!changes_.empty()) {
+ client_->OnChangeCompleted(changes_[0].id, true);
+ changes_.erase(changes_.begin());
+ }
+}
+
+bool TestWindowTree::AckSingleChangeOfType(WindowTreeChangeType type,
+ bool result) {
+ auto match = changes_.end();
+ for (auto iter = changes_.begin(); iter != changes_.end(); ++iter) {
+ if (iter->type == type) {
+ if (match == changes_.end())
+ match = iter;
+ else
+ return false;
+ }
+ }
+ if (match == changes_.end())
return false;
+ const uint32_t change_id = match->id;
+ changes_.erase(match);
+ client_->OnChangeCompleted(change_id, result);
+ return true;
+}
- if (change_id)
- *change_id = change_id_;
- got_change_ = false;
+bool TestWindowTree::AckFirstChangeOfType(WindowTreeChangeType type,
+ bool result) {
+ uint32_t change_id;
+ if (!GetAndRemoveFirstChangeOfType(type, &change_id))
+ return false;
+ client_->OnChangeCompleted(change_id, result);
return true;
}
-bool TestWindowTree::WasEventAcked(uint32_t event_id) const {
- return acked_events_.count(event_id);
+void TestWindowTree::AckAllChangesOfType(WindowTreeChangeType type,
+ bool result) {
+ for (size_t i = 0; i < changes_.size();) {
+ if (changes_[i].type != type) {
+ ++i;
+ continue;
+ }
+ const uint32_t change_id = changes_[i].id;
+ changes_.erase(changes_.begin() + i);
+ client_->OnChangeCompleted(change_id, result);
+ }
+}
+
+bool TestWindowTree::GetAndRemoveFirstChangeOfType(WindowTreeChangeType type,
+ uint32_t* change_id) {
+ for (auto iter = changes_.begin(); iter != changes_.end(); ++iter) {
+ if (iter->type != type)
+ continue;
+ *change_id = iter->id;
+ changes_.erase(iter);
+ return true;
+ }
+ return false;
+}
+
+void TestWindowTree::OnChangeReceived(uint32_t change_id,
+ WindowTreeChangeType type) {
+ changes_.push_back({type, change_id});
}
void TestWindowTree::NewWindow(
uint32_t change_id,
uint32_t window_id,
- mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) {}
+ mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) {
+ last_new_window_properties_ = std::move(properties);
+ OnChangeReceived(change_id, WindowTreeChangeType::NEW_WINDOW);
+}
void TestWindowTree::NewTopLevelWindow(
uint32_t change_id,
uint32_t window_id,
mojo::Map<mojo::String, mojo::Array<uint8_t>> properties) {
- got_change_ = true;
- change_id_ = change_id;
+ last_new_window_properties_ = std::move(properties);
window_id_ = window_id;
+ OnChangeReceived(change_id, WindowTreeChangeType::NEW_TOP_LEVEL);
}
-void TestWindowTree::DeleteWindow(uint32_t change_id, uint32_t window_id) {}
+void TestWindowTree::DeleteWindow(uint32_t change_id, uint32_t window_id) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::SetWindowBounds(uint32_t change_id,
uint32_t window_id,
const gfx::Rect& bounds) {
- got_change_ = true;
- change_id_ = change_id;
+ OnChangeReceived(change_id, WindowTreeChangeType::BOUNDS);
}
void TestWindowTree::SetClientArea(
@@ -64,67 +131,76 @@ void TestWindowTree::SetCanAcceptDrops(uint32_t window_id, bool accepts_drops) {
void TestWindowTree::SetWindowVisibility(uint32_t change_id,
uint32_t window_id,
bool visible) {
- got_change_ = true;
- change_id_ = change_id;
+ OnChangeReceived(change_id, WindowTreeChangeType::VISIBLE);
}
void TestWindowTree::SetWindowProperty(uint32_t change_id,
uint32_t window_id,
const mojo::String& name,
mojo::Array<uint8_t> value) {
- got_change_ = true;
- change_id_ = change_id;
+ last_property_value_ = std::move(value);
+ OnChangeReceived(change_id, WindowTreeChangeType::PROPERTY);
}
void TestWindowTree::SetWindowOpacity(uint32_t change_id,
uint32_t window_id,
float opacity) {
- got_change_ = true;
- change_id_ = change_id;
+ OnChangeReceived(change_id);
}
void TestWindowTree::AttachCompositorFrameSink(
uint32_t window_id,
- mojom::CompositorFrameSinkType type,
+ ui::mojom::CompositorFrameSinkType type,
mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> surface,
cc::mojom::MojoCompositorFrameSinkClientPtr client) {}
+void TestWindowTree::OnWindowSurfaceDetached(
+ uint32_t window_id,
+ const cc::SurfaceSequence& sequence) {}
+
void TestWindowTree::AddWindow(uint32_t change_id,
uint32_t parent,
- uint32_t child) {}
+ uint32_t child) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::RemoveWindowFromParent(uint32_t change_id,
- uint32_t window_id) {}
+ uint32_t window_id) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::AddTransientWindow(uint32_t change_id,
uint32_t window_id,
- uint32_t transient_window_id) {}
+ uint32_t transient_window_id) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::RemoveTransientWindowFromParent(
uint32_t change_id,
- uint32_t transient_window_id) {}
+ uint32_t transient_window_id) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::SetModal(uint32_t change_id, uint32_t window_id) {
- got_change_ = true;
- change_id_ = change_id;
+ OnChangeReceived(change_id);
}
void TestWindowTree::ReorderWindow(uint32_t change_id,
uint32_t window_id,
uint32_t relative_window_id,
- mojom::OrderDirection direction) {}
+ ui::mojom::OrderDirection direction) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::GetWindowTree(uint32_t window_id,
const GetWindowTreeCallback& callback) {}
void TestWindowTree::SetCapture(uint32_t change_id, uint32_t window_id) {
- got_change_ = true;
- change_id_ = change_id;
+ OnChangeReceived(change_id, WindowTreeChangeType::CAPTURE);
}
void TestWindowTree::ReleaseCapture(uint32_t change_id, uint32_t window_id) {
- got_change_ = true;
- change_id_ = change_id;
+ OnChangeReceived(change_id, WindowTreeChangeType::CAPTURE);
}
void TestWindowTree::StartPointerWatcher(bool want_moves) {}
@@ -132,13 +208,12 @@ void TestWindowTree::StartPointerWatcher(bool want_moves) {}
void TestWindowTree::StopPointerWatcher() {}
void TestWindowTree::Embed(uint32_t window_id,
- mojom::WindowTreeClientPtr client,
+ ui::mojom::WindowTreeClientPtr client,
uint32_t flags,
const EmbedCallback& callback) {}
void TestWindowTree::SetFocus(uint32_t change_id, uint32_t window_id) {
- got_change_ = true;
- change_id_ = change_id;
+ OnChangeReceived(change_id, WindowTreeChangeType::FOCUS);
}
void TestWindowTree::SetCanFocus(uint32_t window_id, bool can_focus) {}
@@ -148,7 +223,9 @@ void TestWindowTree::SetCanAcceptEvents(uint32_t window_id,
void TestWindowTree::SetPredefinedCursor(uint32_t change_id,
uint32_t window_id,
- ui::mojom::Cursor cursor_id) {}
+ ui::mojom::Cursor cursor_id) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::SetWindowTextInputState(uint32_t window_id,
mojo::TextInputStatePtr state) {}
@@ -164,7 +241,8 @@ void TestWindowTree::OnWindowInputEventAck(uint32_t event_id,
}
void TestWindowTree::GetWindowManagerClient(
- mojo::AssociatedInterfaceRequest<mojom::WindowManagerClient> internal) {}
+ mojo::AssociatedInterfaceRequest<ui::mojom::WindowManagerClient> internal) {
+}
void TestWindowTree::GetCursorLocationMemory(
const GetCursorLocationMemoryCallback& callback) {
@@ -175,19 +253,19 @@ void TestWindowTree::PerformDragDrop(
uint32_t change_id,
uint32_t source_window_id,
mojo::Map<mojo::String, mojo::Array<uint8_t>> drag_data,
- uint32_t drag_operation) {}
+ uint32_t drag_operation) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::CancelDragDrop(uint32_t window_id) {}
void TestWindowTree::PerformWindowMove(uint32_t change_id,
uint32_t window_id,
- mojom::MoveLoopSource source,
- const gfx::Point& cursor_location) {}
+ ui::mojom::MoveLoopSource source,
+ const gfx::Point& cursor_location) {
+ OnChangeReceived(change_id);
+}
void TestWindowTree::CancelWindowMove(uint32_t window_id) {}
-void TestWindowTree::OnWindowSurfaceDetached(
- uint32_t window_id,
- const cc::SurfaceSequence& sequence) {}
-
-} // namespace ui
+} // namespace aura
« no previous file with comments | « ui/aura/test/mus/test_window_tree.h ('k') | ui/aura/test/mus/test_window_tree_client_setup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698