Commit 19a9595b authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Fix the issue that AppListView is moved downward in tablet mode

AppListView's bounds are stored as the property called
kVirtualKeyboardRestoreBoundsKey when the search box is activated in
clamshell mode. When the tablet mode is turned on, this property
is still kept in AppListView's native window. As a result, when closing
the virtual keyboard in tablet mode, the native window's bounds are
restored. It explains why we can see that AppListView is moved downward
when dismissing the virtual keyboard.

In tablet mode, AppListView should not be moved because of the virtual
keyboard visibility. So in this CL, clear that property when tablet
mode is turned on.

Test: ash_unittests
Bug: 944133
Change-Id: I714ebd50448a995f77bae759f6282efc8adc6df1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1538983
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644445}
parent 4845b51d
...@@ -73,6 +73,10 @@ void DismissAppListNow() { ...@@ -73,6 +73,10 @@ void DismissAppListNow() {
base::TimeTicks::Now()); base::TimeTicks::Now());
} }
aura::Window* GetAppListViewNativeWindow() {
return GetAppListView()->get_fullscreen_widget_for_test()->GetNativeView();
}
} // namespace } // namespace
class AppListControllerImplTest : public AshTestBase { class AppListControllerImplTest : public AshTestBase {
...@@ -188,28 +192,51 @@ TEST_F(AppListControllerImplTest, CheckAppListViewBoundsWhenVKeyboardEnabled) { ...@@ -188,28 +192,51 @@ TEST_F(AppListControllerImplTest, CheckAppListViewBoundsWhenVKeyboardEnabled) {
// Show the AppListView again. Check the following things: // Show the AppListView again. Check the following things:
// (1) Virtual keyboard does not show. // (1) Virtual keyboard does not show.
// (2) AppListView is in PEEKING state. // (2) AppListView is in PEEKING state.
// (3) AppListView's bounds are the same with the preferred bounds for // (3) AppListView's bounds are the same as the preferred bounds for
// the PEEKING state. // the PEEKING state.
ShowAppListNow(); ShowAppListNow();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(app_list::AppListViewState::PEEKING, EXPECT_EQ(app_list::AppListViewState::PEEKING,
GetAppListView()->app_list_state()); GetAppListView()->app_list_state());
EXPECT_EQ(nullptr, GetVirtualKeyboardWindow()); EXPECT_EQ(nullptr, GetVirtualKeyboardWindow());
gfx::Rect current_app_list_bounds_in_screen = EXPECT_EQ(GetAppListView()->GetPreferredWidgetBoundsForState(
GetAppListView() app_list::AppListViewState::PEEKING),
->get_fullscreen_widget_for_test() GetAppListViewNativeWindow()->bounds());
->GetNativeView() }
->GetBoundsInScreen();
gfx::Rect expected_app_list_bounds_in_parent = // Verifies that in tablet mode, the AppListView has correct bounds when the
GetAppListView()->GetPreferredWidgetBoundsForState( // virtual keyboard is dismissed (see https://crbug.com/944133).
app_list::AppListViewState::PEEKING); TEST_F(AppListControllerImplTest, CheckAppListViewBoundsWhenDismissVKeyboard) {
Shell::Get()->ash_keyboard_controller()->SetEnableFlag(
// The expected bounds are in the parent coordinate. But it should still be keyboard::mojom::KeyboardEnableFlag::kShelfEnabled);
// the same with the AppListView's bounds in screen coordinate. Because the
// parent window of the AppListView should have the same size with the display // Show the AppListView and click on the search box with mouse so the
// root window. // VirtualKeyboard is shown. Wait until the virtual keyboard shows.
EXPECT_EQ(expected_app_list_bounds_in_parent, ShowAppListNow();
current_app_list_bounds_in_screen); GetSearchBoxView()->SetSearchBoxActive(true, ui::ET_MOUSE_PRESSED);
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(GetVirtualKeyboardWindow()->IsVisible());
// Turn on the tablet mode. The virtual keyboard should still show.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
EXPECT_TRUE(IsTabletMode());
EXPECT_TRUE(GetVirtualKeyboardWindow()->IsVisible());
// Close the virtual keyboard. Wait until it is hidden.
Shell::Get()->ash_keyboard_controller()->HideKeyboard(
mojom::HideReason::kUser);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, GetVirtualKeyboardWindow());
// Check the following things:
// (1) AppListView's state is FULLSCREEN_SEARCH
// (2) AppListView's bounds are the same as the preferred bounds for
// the FULLSCREEN_SEARCH state.
EXPECT_EQ(app_list::AppListViewState::FULLSCREEN_SEARCH,
GetAppListView()->app_list_state());
EXPECT_EQ(GetAppListView()->GetPreferredWidgetBoundsForState(
app_list::AppListViewState::FULLSCREEN_SEARCH),
GetAppListViewNativeWindow()->bounds());
} }
class AppListControllerImplMetricsTest : public AshTestBase { class AppListControllerImplMetricsTest : public AshTestBase {
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h" #include "ui/views/widget/widget_observer.h"
#include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/ime_util_chromeos.h"
#include "ui/wm/core/shadow_types.h" #include "ui/wm/core/shadow_types.h"
using ash::ColorProfileType; using ash::ColorProfileType;
...@@ -1244,6 +1245,13 @@ void AppListView::OnTabletModeChanged(bool started) { ...@@ -1244,6 +1245,13 @@ void AppListView::OnTabletModeChanged(bool started) {
? AppListViewState::FULLSCREEN_SEARCH ? AppListViewState::FULLSCREEN_SEARCH
: AppListViewState::FULLSCREEN_ALL_APPS); : AppListViewState::FULLSCREEN_ALL_APPS);
// In tablet mode, AppListView should not be moved because of the change in
// virtual keyboard's visibility.
if (started) {
fullscreen_widget_->GetNativeView()->ClearProperty(
wm::kVirtualKeyboardRestoreBoundsKey);
}
// Update background color opacity. // Update background color opacity.
SetBackgroundShieldColor(); SetBackgroundShieldColor();
......
...@@ -35,6 +35,8 @@ class AnimationMetricsReporter; ...@@ -35,6 +35,8 @@ class AnimationMetricsReporter;
namespace ash { namespace ash {
FORWARD_DECLARE_TEST(AppListControllerImplTest, FORWARD_DECLARE_TEST(AppListControllerImplTest,
CheckAppListViewBoundsWhenVKeyboardEnabled); CheckAppListViewBoundsWhenVKeyboardEnabled);
FORWARD_DECLARE_TEST(AppListControllerImplTest,
CheckAppListViewBoundsWhenDismissVKeyboard);
} }
namespace app_list { namespace app_list {
...@@ -302,6 +304,8 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -302,6 +304,8 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
private: private:
FRIEND_TEST_ALL_PREFIXES(ash::AppListControllerImplTest, FRIEND_TEST_ALL_PREFIXES(ash::AppListControllerImplTest,
CheckAppListViewBoundsWhenVKeyboardEnabled); CheckAppListViewBoundsWhenVKeyboardEnabled);
FRIEND_TEST_ALL_PREFIXES(ash::AppListControllerImplTest,
CheckAppListViewBoundsWhenDismissVKeyboard);
// A widget observer that is responsible for keeping the AppListView state up // A widget observer that is responsible for keeping the AppListView state up
// to date on closing. // to date on closing.
......
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