Commit 75401d49 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

shelf: Provide the correct work area for auto hide.

Test: added test
Bug: 1077922
Change-Id: Id596f604a24e230c818fa81c930782c9fa4841eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227289Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774421}
parent 94e0ab24
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "ash/shelf/hotseat_widget.h"
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/app_list/test/app_list_test_helper.h" #include "ash/app_list/test/app_list_test_helper.h"
#include "ash/assistant/assistant_controller_impl.h" #include "ash/assistant/assistant_controller_impl.h"
...@@ -18,6 +17,7 @@ ...@@ -18,6 +17,7 @@
#include "ash/public/cpp/test/assistant_test_api.h" #include "ash/public/cpp/test/assistant_test_api.h"
#include "ash/public/cpp/test/shell_test_api.h" #include "ash/public/cpp/test/shell_test_api.h"
#include "ash/shelf/home_button.h" #include "ash/shelf/home_button.h"
#include "ash/shelf/hotseat_widget.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_app_button.h" #include "ash/shelf/shelf_app_button.h"
#include "ash/shelf/shelf_focus_cycler.h" #include "ash/shelf/shelf_focus_cycler.h"
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include "ash/wm/overview/overview_controller.h" #include "ash/wm/overview/overview_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h" #include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
#include "ash/wm/work_area_insets.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
...@@ -1527,6 +1529,43 @@ TEST_P(HotseatWidgetTest, ToFromTabletModeWithWindowChangesWorkArea) { ...@@ -1527,6 +1529,43 @@ TEST_P(HotseatWidgetTest, ToFromTabletModeWithWindowChangesWorkArea) {
EXPECT_EQ(2, counter.count()); EXPECT_EQ(2, counter.count());
} }
// Tests that the work area changes when fullscreening the active window or
// autohiding the shelf.
TEST_P(HotseatWidgetTest, ShelfVisibilityChangeChangesWorkArea) {
UpdateDisplay("800x603");
TabletModeControllerTestApi().EnterTabletMode();
auto window = AshTestBase::CreateTestWindow(gfx::Rect(400, 400));
// The expected work area is 3 pixels smaller to leave space to swipe the auto
// hide shelf up.
const gfx::Rect expected_auto_hide_work_area(800, 600);
const gfx::Rect expected_in_app_work_area(
800, 603 - ShelfConfig::Get()->in_app_shelf_size());
auto get_work_area = []() -> gfx::Rect {
return WorkAreaInsets::ForWindow(Shell::GetPrimaryRootWindow())
->user_work_area_bounds();
};
DisplayWorkAreaChangeCounter counter;
WMEvent toggle_fullscreen(WM_EVENT_TOGGLE_FULLSCREEN);
WindowState::Get(window.get())->OnWMEvent(&toggle_fullscreen);
EXPECT_EQ(expected_auto_hide_work_area, get_work_area());
EXPECT_EQ(1, counter.count());
WindowState::Get(window.get())->OnWMEvent(&toggle_fullscreen);
EXPECT_EQ(expected_in_app_work_area, get_work_area());
EXPECT_EQ(2, counter.count());
GetPrimaryShelf()->SetAutoHideBehavior(ShelfAutoHideBehavior::kAlways);
EXPECT_EQ(expected_auto_hide_work_area, get_work_area());
EXPECT_EQ(3, counter.count());
GetPrimaryShelf()->SetAutoHideBehavior(ShelfAutoHideBehavior::kNever);
EXPECT_EQ(expected_in_app_work_area, get_work_area());
EXPECT_EQ(4, counter.count());
}
// Tests that the hotseat is flush with the bottom of the screen when in // Tests that the hotseat is flush with the bottom of the screen when in
// clamshell mode and the shelf is oriented on the bottom. // clamshell mode and the shelf is oriented on the bottom.
TEST_P(HotseatWidgetTest, HotseatFlushWithScreenBottomInClamshell) { TEST_P(HotseatWidgetTest, HotseatFlushWithScreenBottomInClamshell) {
......
...@@ -1633,8 +1633,11 @@ void ShelfLayoutManager::CalculateTargetBoundsAndUpdateWorkArea() { ...@@ -1633,8 +1633,11 @@ void ShelfLayoutManager::CalculateTargetBoundsAndUpdateWorkArea() {
gfx::Rect shelf_bounds_for_workarea_calculation = gfx::Rect shelf_bounds_for_workarea_calculation =
shelf_->shelf_widget()->GetTargetBounds(); shelf_->shelf_widget()->GetTargetBounds();
// When the hotseat is enabled, only use the in-app shelf bounds when // When the hotseat is enabled, only use the in-app shelf bounds when
// calculating the work area. This prevents windows resizing unnecessarily. // calculating the work area. This prevents windows resizing unnecessarily. If
if (IsHotseatEnabled()) { // the shelf is not visible then use the regular calculations. Note that on
// the home screen, the shelf is deemed visible as it is visible with a
// transparent background.
if (IsHotseatEnabled() && IsVisible()) {
shelf_bounds_for_workarea_calculation = shelf_bounds_for_workarea_calculation =
GetIdealBoundsForWorkAreaCalculation(); GetIdealBoundsForWorkAreaCalculation();
} }
......
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