Commit a55a1b5d authored by Taiju Tsuiki's avatar Taiju Tsuiki Committed by Commit Bot

Revert "Introduce explicit state to keyboard_controller."

This reverts commit 1fd2f73e.

Reason for revert:
This CL causes a compile failure.
The failure log is:
https://build.chromium.org/p/chromium/builders/Win/builds/56026

c:\b\c\b\win_archive\src\ui\keyboard\keyboard_test_util.cc(54): warning C4373: '`anonymous-namespace'::ControllerStateChangeWaiter::OnStateChanged': virtual function overrides 'keyboard::KeyboardControllerObserver::OnStateChanged', previous versions of the compiler did not override when parameters only differed by const/volatile qualifiers
c:\b\c\b\win_archive\src\ui\keyboard\keyboard_controller_observer.h(34): note: see declaration of 'keyboard::KeyboardControllerObserver::OnStateChanged'

Original change's description:
> Introduce explicit state to keyboard_controller.
> 
> Bug: 719905
> Change-Id: I14a1ee6b8e66c4f4c98ea4957dde7a7e0d75aad3
> Reviewed-on: https://chromium-review.googlesource.com/516866
> Commit-Queue: Keigo Oka <oka@chromium.org>
> Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
> Reviewed-by: Yuichiro Hanada <yhanada@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#478568}

TBR=oshima@chromium.org,bshe@chromium.org,oka@chromium.org,yhanada@chromium.org
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 719905

Change-Id: I14143cde82fa85757be72ee9aed622577fd40dd7
Reviewed-on: https://chromium-review.googlesource.com/530732Reviewed-by: default avatarTaiju Tsuiki <tzik@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#478572}
parent e799795e
......@@ -1483,7 +1483,6 @@ test("ash_unittests") {
"//ui/gfx/geometry",
"//ui/gl:test_support",
"//ui/keyboard",
"//ui/keyboard:test_support",
"//ui/message_center",
"//ui/resources",
"//ui/strings",
......
......@@ -21,7 +21,6 @@
#include "ui/keyboard/content/keyboard_constants.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_test_util.h"
#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
......@@ -220,56 +219,3 @@ IN_PROC_BROWSER_TEST_F(VirtualKeyboardAppWindowTest,
.height(),
ime_window_visible_height);
}
class VirtualKeyboardStateTest : public InProcessBrowserTest {
public:
VirtualKeyboardStateTest() {}
~VirtualKeyboardStateTest() override {}
// Ensure that the virtual keyboard is enabled.
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(keyboard::switches::kEnableVirtualKeyboard);
}
private:
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardStateTest);
};
IN_PROC_BROWSER_TEST_F(VirtualKeyboardStateTest, OpenTwice) {
auto* controller = keyboard::KeyboardController::GetInstance();
EXPECT_EQ(controller->GetStateForTest(),
keyboard::KeyboardControllerState::INITIAL);
// Call ShowKeyboard twice. The second call should has no effect.
controller->ShowKeyboard(false);
EXPECT_EQ(controller->GetStateForTest(),
keyboard::KeyboardControllerState::LOADING_EXTENSION);
controller->ShowKeyboard(false);
EXPECT_EQ(controller->GetStateForTest(),
keyboard::KeyboardControllerState::LOADING_EXTENSION);
WaitControllerStateChangesTo(keyboard::KeyboardControllerState::SHOWN);
EXPECT_EQ(controller->GetStateForTest(),
keyboard::KeyboardControllerState::SHOWN);
}
IN_PROC_BROWSER_TEST_F(VirtualKeyboardStateTest, OpenAndCloseAndOpen) {
auto* controller = keyboard::KeyboardController::GetInstance();
controller->ShowKeyboard(false);
// Need to wait the extension to be loaded. Hence LOADING_EXTENSION.
EXPECT_EQ(controller->GetStateForTest(),
keyboard::KeyboardControllerState::LOADING_EXTENSION);
WaitControllerStateChangesTo(keyboard::KeyboardControllerState::SHOWN);
controller->HideKeyboard(keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
EXPECT_EQ(controller->GetStateForTest(),
keyboard::KeyboardControllerState::HIDING);
WaitControllerStateChangesTo(keyboard::KeyboardControllerState::HIDDEN);
controller->ShowKeyboard(false);
// The extension already has been loaded. Hence SHOWING.
EXPECT_EQ(controller->GetStateForTest(),
keyboard::KeyboardControllerState::SHOWING);
WaitControllerStateChangesTo(keyboard::KeyboardControllerState::SHOWN);
}
This diff is collapsed.
......@@ -46,26 +46,6 @@ enum KeyboardMode {
FLOATING,
};
// Represents the current state of the keyboard managed by the controller.
enum class KeyboardControllerState {
UNKNOWN = 0,
// Keyboard is shown.
SHOWN,
// Keyboard is being shown via animation.
SHOWING,
// Waiting for an extension to be loaded and then move to SHOWING.
LOADING_EXTENSION,
// Keyboard is still shown, but will move to HIDING in a short period, or if
// an input element gets focused again, will move to SHOWN.
WILL_HIDE,
// Keyboard is being hidden via animation.
HIDING,
// Keyboard is hidden, but has shown at least once.
HIDDEN,
// Keyboard has never been shown.
INITIAL,
};
// Provides control of the virtual keyboard, including providing a container
// and controlling visibility.
class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
......@@ -152,8 +132,6 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
return current_keyboard_bounds_;
}
KeyboardControllerState GetStateForTest() const { return state_; }
private:
// For access to Observer methods for simulation.
friend class KeyboardControllerTest;
......@@ -191,12 +169,6 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// display.
void AdjustKeyboardBounds();
// Validates the state transition. Called from ChangeState.
void CheckStateTransition(KeyboardControllerState prev,
KeyboardControllerState next);
// Changes the current state with validating the transition.
void ChangeState(KeyboardControllerState state);
std::unique_ptr<KeyboardUI> ui_;
KeyboardLayoutDelegate* layout_delegate_;
std::unique_ptr<aura::Window> container_;
......@@ -217,8 +189,6 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
// The currently used keyboard position.
gfx::Rect current_keyboard_bounds_;
KeyboardControllerState state_;
static KeyboardController* instance_;
base::WeakPtrFactory<KeyboardController> weak_factory_;
......
......@@ -5,7 +5,6 @@
#ifndef UI_KEYBOARD_KEYBOARD_CONTROLLER_OBSERVER_H_
#define UI_KEYBOARD_KEYBOARD_CONTROLLER_OBSERVER_H_
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_export.h"
namespace gfx {
......@@ -27,11 +26,8 @@ class KEYBOARD_EXPORT KeyboardControllerObserver {
virtual void OnKeyboardClosed() = 0;
// Called when the keyboard has been hidden and the hiding animation finished
// successfully. This is same as |state| == HIDDEN on OnStateChanged.
// successfully
virtual void OnKeyboardHidden() {}
// When state changed.
virtual void OnStateChanged(const KeyboardControllerState state) {}
};
} // namespace keyboard
......
......@@ -8,7 +8,6 @@
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_controller_observer.h"
namespace {
......@@ -36,34 +35,6 @@ class WindowVisibilityChangeWaiter : public aura::WindowObserver {
DISALLOW_COPY_AND_ASSIGN(WindowVisibilityChangeWaiter);
};
class ControllerStateChangeWaiter
: public keyboard::KeyboardControllerObserver {
public:
explicit ControllerStateChangeWaiter(keyboard::KeyboardControllerState state)
: controller_(keyboard::KeyboardController::GetInstance()),
state_(state) {
controller_->AddObserver(this);
}
~ControllerStateChangeWaiter() override { controller_->RemoveObserver(this); }
void Wait() { run_loop_.Run(); }
private:
void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override {}
void OnKeyboardClosed() override {}
void OnStateChanged(keyboard::KeyboardControllerState state) override {
if (state == state_) {
run_loop_.QuitWhenIdle();
}
}
base::RunLoop run_loop_;
keyboard::KeyboardController* controller_;
keyboard::KeyboardControllerState state_;
DISALLOW_COPY_AND_ASSIGN(ControllerStateChangeWaiter);
};
bool WaitVisibilityChangesTo(bool visibility) {
aura::Window* keyboard_window =
keyboard::KeyboardController::GetInstance()
......@@ -87,9 +58,4 @@ bool WaitUntilHidden() {
return WaitVisibilityChangesTo(false);
}
void WaitControllerStateChangesTo(KeyboardControllerState state) {
ControllerStateChangeWaiter waiter(state);
waiter.Wait();
}
} // namespace keyboard
......@@ -5,8 +5,6 @@
#ifndef UI_KEYBOARD_KEYBOARD_TEST_UTIL_
#define UI_KEYBOARD_KEYBOARD_TEST_UTIL_
#include "ui/keyboard/keyboard_controller.h"
namespace keyboard {
// Waits until the keyboard is shown. Return false if there is no keyboard
......@@ -17,9 +15,6 @@ bool WaitUntilShown();
// window created.
bool WaitUntilHidden();
// Waits until the keyboard state is changed to the given state.
void WaitControllerStateChangesTo(KeyboardControllerState state);
} // namespace keyboard
#endif // UI_KEYBOARD_KEYBOARD_TEST_UTIL_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment