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

Unified Diff: ui/views/mus/desktop_window_tree_host_mus_unittest.cc

Issue 2633233003: aura-mus: Implement stacking in DesktopWindowTreeHostMus. (Closed)
Patch Set: Add access policy for CanStackAtTop. 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
Index: ui/views/mus/desktop_window_tree_host_mus_unittest.cc
diff --git a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
index 74ed9522f0f158176d4889a892fd37df63ca7669..c09debffb7392daa60a3f2c12b02a0ffd3ba3545 100644
--- a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
+++ b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
@@ -9,7 +9,10 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "ui/aura/client/cursor_client.h"
+#include "ui/aura/mus/in_flight_change.h"
#include "ui/aura/window.h"
+#include "ui/views/mus/mus_client_test_observer.h"
+#include "ui/views/mus/test_utils.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -102,6 +105,43 @@ class ExpectsNullCursorClientDuringTearDown : public aura::WindowObserver {
DISALLOW_COPY_AND_ASSIGN(ExpectsNullCursorClientDuringTearDown);
};
+class WaitForChangeCompletor : public test::MusClientTestObserver {
+ public:
+ WaitForChangeCompletor(aura::ChangeType type, bool success)
+ : type_(type), success_(success), received_(false) {
+ test::MusClientTestApi::SetChangeTestObserver(this);
+ }
+
+ ~WaitForChangeCompletor() override {
+ test::MusClientTestApi::SetChangeTestObserver(nullptr);
+ }
+
+ void Wait() {
+ if (!received_) {
+ quit_closure_ = run_loop_.QuitClosure();
+ run_loop_.Run();
+ }
+ }
+
+ private:
+ // test::MusClientTestObserver:
+ void OnChangeCompleted(aura::ChangeType type, bool success) override {
+ if (type == type_ && success == success_) {
sky 2017/01/20 16:36:10 One potential problem with this pattern is that if
Elliot Glaysher 2017/01/20 22:31:02 Moved this to ui/aura/test/mus/, and made it liste
+ received_ = true;
+ if (quit_closure_)
+ quit_closure_.Run();
+ }
+ }
+
+ base::RunLoop run_loop_;
+ aura::ChangeType type_;
+ bool success_;
+ bool received_;
+ base::Closure quit_closure_;
+
+ DISALLOW_COPY_AND_ASSIGN(WaitForChangeCompletor);
+};
+
TEST_F(DesktopWindowTreeHostMusTest, Visibility) {
std::unique_ptr<Widget> widget(CreateWidget(nullptr));
EXPECT_FALSE(widget->IsVisible());
@@ -147,4 +187,32 @@ TEST_F(DesktopWindowTreeHostMusTest, CursorClientDuringTearDown) {
widget.reset();
}
+TEST_F(DesktopWindowTreeHostMusTest, StackAtTop) {
+ std::unique_ptr<Widget> widget1(CreateWidget(nullptr));
+ widget1->Show();
+
+ std::unique_ptr<Widget> widget2(CreateWidget(nullptr));
+ widget2->Show();
+
+ WaitForChangeCompletor waiter(aura::ChangeType::REORDER, true);
+ widget1->StackAtTop();
+ waiter.Wait();
+
+ // Other than the signal that our StackAtTop() succeeded, we don't have any
+ // pieces of public data that we can check. If we actually stopped waiting,
+ // count that as success.
+}
+
+TEST_F(DesktopWindowTreeHostMusTest, StackAtTopAlreadyOnTop) {
+ std::unique_ptr<Widget> widget1(CreateWidget(nullptr));
+ widget1->Show();
+
+ std::unique_ptr<Widget> widget2(CreateWidget(nullptr));
+ widget2->Show();
+
+ WaitForChangeCompletor waiter(aura::ChangeType::REORDER, true);
+ widget2->StackAtTop();
+ waiter.Wait();
+}
+
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698