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

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

Issue 2633233003: aura-mus: Implement stacking in DesktopWindowTreeHostMus. (Closed)
Patch Set: Reword comment. Created 3 years, 11 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/change_completion_waiter.h ('k') | ui/aura/test/mus/test_window_tree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/test/mus/change_completion_waiter.cc
diff --git a/ui/aura/test/mus/change_completion_waiter.cc b/ui/aura/test/mus/change_completion_waiter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db1e31ce65cc7bd4d25d4c62780b32b2cc82b483
--- /dev/null
+++ b/ui/aura/test/mus/change_completion_waiter.cc
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/test/mus/change_completion_waiter.h"
+
+#include "base/callback.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/aura/mus/in_flight_change.h"
+#include "ui/aura/mus/window_tree_client.h"
+
+namespace aura {
+namespace test {
+
+ChangeCompletionWaiter::ChangeCompletionWaiter(WindowTreeClient* client,
+ ChangeType type,
+ bool success)
+ : state_(WaitState::NOT_STARTED),
+ client_(client),
+ type_(type),
+ success_(success) {
+ client->AddTestObserver(this);
+}
+
+ChangeCompletionWaiter::~ChangeCompletionWaiter() {
+ client_->RemoveTestObserver(this);
+}
+
+void ChangeCompletionWaiter::Wait() {
+ if (state_ != WaitState::RECEIVED) {
+ quit_closure_ = run_loop_.QuitClosure();
+ run_loop_.Run();
+ }
+}
+
+void ChangeCompletionWaiter::OnChangeStarted(uint32_t change_id,
+ aura::ChangeType type) {
+ if (state_ == WaitState::NOT_STARTED && type == type_) {
+ state_ = WaitState::WAITING;
+ change_id_ = change_id;
+ }
+}
+
+void ChangeCompletionWaiter::OnChangeCompleted(uint32_t change_id,
+ aura::ChangeType type,
+ bool success) {
+ if (state_ == WaitState::WAITING && change_id_ == change_id) {
+ EXPECT_EQ(success_, success);
+ state_ = WaitState::RECEIVED;
+ if (quit_closure_)
+ quit_closure_.Run();
+ }
+}
+
+} // namespace test
+} // namespace aura
« no previous file with comments | « ui/aura/test/mus/change_completion_waiter.h ('k') | ui/aura/test/mus/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698