Commit 1e5ae9d2 authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Invoke the passed callback of setMode() surely.

Currently we don't call the passed callback of
virtualKeyboardPrivate.setMode() when the virtual keyboard is already
hidden.
We should invoke the passed callback immediately if the virtual
keyboard is hidden because the container type is changed immediately.

Bug: 810253
Test: Modified an unit test and followed the steps described in the linked bug.
Change-Id: Icae6a31fbd1ad11699d43cdc5cea03a4070484c9
Reviewed-on: https://chromium-review.googlesource.com/941281Reviewed-by: default avatarBlake O'Hare <blakeo@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540001}
parent 1f850372
......@@ -786,13 +786,18 @@ void KeyboardController::SetContainerType(
return;
}
queued_container_type_ =
std::make_unique<QueuedContainerType>(this, type, std::move(callback));
if (state_ == KeyboardControllerState::SHOWN) {
// Keyboard is already shown. Hiding the keyboard at first then switching
// container type.
queued_container_type_ =
std::make_unique<QueuedContainerType>(this, type, std::move(callback));
HideKeyboard(HIDE_REASON_AUTOMATIC);
} else {
// Keyboard is hidden. Switching the container type immediately and invoking
// the passed callback now.
SetContainerBehaviorInternal(type);
DCHECK(GetActiveContainerType() == type);
std::move(callback).Run(true /* change_successful */);
}
}
......
......@@ -753,7 +753,7 @@ TEST_F(KeyboardControllerAnimationTest, ContainerAnimation) {
SetModeCallbackInvocationCounter invocation_counter;
controller()->SetContainerType(ContainerType::FLOATING,
invocation_counter.GetInvocationCallback());
EXPECT_EQ(0, invocation_counter.invocation_count_for_status(true));
EXPECT_EQ(1, invocation_counter.invocation_count_for_status(true));
EXPECT_EQ(0, invocation_counter.invocation_count_for_status(false));
ShowKeyboard();
RunAnimationForLayer(layer);
......
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