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

Unified Diff: ui/keyboard/keyboard_test_util.cc

Issue 2702933002: Add an end to end test: virtual keyboard opens on click of text input (Closed)
Patch Set: Updated the test so to simulate user's click. Created 3 years, 9 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/keyboard/keyboard_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/keyboard/keyboard_test_util.cc
diff --git a/ui/keyboard/keyboard_test_util.cc b/ui/keyboard/keyboard_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..85c7048e6f83e1a990529fbf0a0a82ba04716904
--- /dev/null
+++ b/ui/keyboard/keyboard_test_util.cc
@@ -0,0 +1,61 @@
+// 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/keyboard/keyboard_test_util.h"
+
+#include "base/run_loop.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_observer.h"
+#include "ui/keyboard/keyboard_controller.h"
+
+namespace {
+
+class WindowVisibilityChangeWaiter : public aura::WindowObserver {
+ public:
+ explicit WindowVisibilityChangeWaiter(aura::Window* window, bool wait_until)
+ : window_(window), wait_until_(wait_until) {
+ window_->AddObserver(this);
+ }
+ ~WindowVisibilityChangeWaiter() override { window_->RemoveObserver(this); }
+
+ void Wait() { run_loop_.Run(); }
+
+ private:
+ void OnWindowVisibilityChanged(aura::Window* window, bool visible) override {
+ if (window_ == window && visible == wait_until_) {
+ run_loop_.QuitWhenIdle();
+ }
+ }
+
+ aura::Window* window_;
+ base::RunLoop run_loop_;
+ bool const wait_until_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowVisibilityChangeWaiter);
+};
+
+bool WaitVisibilityChangesTo(bool visibility) {
+ aura::Window* keyboard_window =
+ keyboard::KeyboardController::GetInstance()
+ ->GetContainerWindowWithoutCreationForTest();
+ if (!keyboard_window)
+ return false;
+ WindowVisibilityChangeWaiter waiter(keyboard_window, visibility);
+ waiter.Wait();
+ return true;
+}
+
+} // namespace
+
+namespace keyboard {
+
+bool WaitUntilShown() {
+ return WaitVisibilityChangesTo(true);
+}
+
+bool WaitUntilHidden() {
+ return WaitVisibilityChangesTo(false);
+}
+
+} // namespace keyboard
« no previous file with comments | « ui/keyboard/keyboard_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698