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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ui/keyboard/keyboard_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/keyboard/keyboard_test_util.h"
6
7 #include "base/run_loop.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura/window_observer.h"
10 #include "ui/keyboard/keyboard_controller.h"
11
12 namespace {
13
14 class WindowVisibilityChangeWaiter : public aura::WindowObserver {
15 public:
16 explicit WindowVisibilityChangeWaiter(aura::Window* window, bool wait_until)
17 : window_(window), wait_until_(wait_until) {
18 window_->AddObserver(this);
19 }
20 ~WindowVisibilityChangeWaiter() override { window_->RemoveObserver(this); }
21
22 void Wait() { run_loop_.Run(); }
23
24 private:
25 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override {
26 if (window_ == window && visible == wait_until_) {
27 run_loop_.QuitWhenIdle();
28 }
29 }
30
31 aura::Window* window_;
32 base::RunLoop run_loop_;
33 bool const wait_until_;
34
35 DISALLOW_COPY_AND_ASSIGN(WindowVisibilityChangeWaiter);
36 };
37
38 bool WaitVisibilityChangesTo(bool visibility) {
39 aura::Window* keyboard_window =
40 keyboard::KeyboardController::GetInstance()
41 ->GetContainerWindowWithoutCreationForTest();
42 if (!keyboard_window)
43 return false;
44 WindowVisibilityChangeWaiter waiter(keyboard_window, visibility);
45 waiter.Wait();
46 return true;
47 }
48
49 } // namespace
50
51 namespace keyboard {
52
53 bool WaitUntilShown() {
54 return WaitVisibilityChangesTo(true);
55 }
56
57 bool WaitUntilHidden() {
58 return WaitVisibilityChangesTo(false);
59 }
60
61 } // namespace keyboard
OLDNEW
« 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