Commit 841533cc authored by Anqing Zhao's avatar Anqing Zhao Committed by Commit Bot

Force the shelf hidden in the Web Kiosk session

To fulfill the requirement of accessibility settings page (secondary
window in the Web Kiosk session), the fullscreen mechanism was replaced
from using ash::WindowPinType::kTrustedPinned to SHOW_STATE_FULLSCREEN.
See: https://chromium-review.googlesource.com/c/chromium/src/+/2170227.

But this change introduced the visible shelf which should always be
hidden. In this CL, one new conditional is added to forcedly hidden it
based on the new mechanism.

Bug: 1102359
Change-Id: I30c6b2f71089e924c6b8751c943cce1c4ce994b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359131
Commit-Queue: Anqing Zhao <anqing@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarAnatoliy Potapchuk <apotapchuk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799254}
parent 71a81f19
......@@ -513,6 +513,8 @@ void ShelfLayoutManager::UpdateVisibilityState() {
SetState(SHELF_VISIBLE);
} else if (Shell::Get()->screen_pinning_controller()->IsPinned()) {
SetState(SHELF_HIDDEN);
} else if (Shell::Get()->session_controller()->IsRunningInAppMode()) {
SetState(SHELF_HIDDEN);
} else {
// TODO(zelidrag): Verify shelf drag animation still shows on the device
// when we are in ShelfAutoHideBehavior::kAlwaysHidden.
......
......@@ -214,6 +214,13 @@ class ShelfLayoutManagerTest : public ShelfLayoutManagerTestBase,
ShelfLayoutManagerTestBase::SetUp();
}
void SetUpKioskSession() {
SessionInfo info;
info.is_running_in_app_mode = true;
info.state = session_manager::SessionState::ACTIVE;
Shell::Get()->session_controller()->SetSessionInfo(info);
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
......@@ -779,6 +786,44 @@ TEST_P(ShelfLayoutManagerTest, StatusAreaMoveWithSwipeOnAutoHiddenShelf) {
GetWidgetOffsetFromBottom(shelf->status_area_widget()));
}
// Checks that the shelf keeps hidden during the Kiosk mode.
TEST_P(ShelfLayoutManagerTest, HiddenShelfInKioskMode_FullScreen) {
SetUpKioskSession();
// Create a window and make it full screen; the shelf should be hidden.
aura::Window* window = CreateTestWindow();
window->SetBounds(gfx::Rect(0, 0, 100, 100));
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
window->SetProperty(kHideShelfWhenFullscreenKey, false);
window->Show();
wm::ActivateWindow(window);
GetAppListTestHelper()->CheckVisibility(false);
EXPECT_EQ(SHELF_HIDDEN, GetPrimaryShelf()->GetVisibilityState());
EXPECT_EQ(WorkspaceWindowState::kFullscreen, GetWorkspaceWindowState());
SwipeUpOnShelf();
EXPECT_EQ(SHELF_HIDDEN, GetPrimaryShelf()->GetVisibilityState());
}
// Checks that the shelf keeps hidden during the Kiosk mode. (Some windows might
// not be fullscreen, e.g., the a11y setting window.)
TEST_P(ShelfLayoutManagerTest, HiddenShelfInKioskMode_Default) {
SetUpKioskSession();
// Create a default window; the shelf should be hidden.
aura::Window* window = CreateTestWindow();
window->SetBounds(gfx::Rect(0, 0, 100, 100));
window->SetProperty(kHideShelfWhenFullscreenKey, false);
window->Show();
wm::ActivateWindow(window);
GetAppListTestHelper()->CheckVisibility(false);
EXPECT_EQ(SHELF_HIDDEN, GetPrimaryShelf()->GetVisibilityState());
EXPECT_EQ(WorkspaceWindowState::kDefault, GetWorkspaceWindowState());
SwipeUpOnShelf();
EXPECT_EQ(SHELF_HIDDEN, GetPrimaryShelf()->GetVisibilityState());
}
TEST_P(ShelfLayoutManagerTest,
NavigationWidgetDoesNotMoveWithoutAutoHiddenShelf) {
Shelf* shelf = GetPrimaryShelf();
......
......@@ -10,6 +10,8 @@
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "ash/public/cpp/keyboard/keyboard_switches.h"
#include "ash/public/cpp/login_screen_test_api.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_test_api.h"
#include "ash/public/cpp/wallpaper_controller_observer.h"
#include "base/barrier_closure.h"
#include "base/bind.h"
......@@ -124,6 +126,7 @@
#include "ui/aura/window.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/page_transition_types.h"
#include "ui/events/test/event_generator.h"
namespace em = enterprise_management;
......@@ -877,6 +880,40 @@ IN_PROC_BROWSER_TEST_F(KioskTest, VirtualKeyboardFeaturesEnabledByDefault) {
EXPECT_TRUE(config.voice_input);
}
IN_PROC_BROWSER_TEST_F(KioskTest, HiddenShelf) {
ExtensionTestMessageListener app_window_loaded_listener("appWindowLoaded",
false);
StartAppLaunchFromLoginScreen(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE);
EXPECT_TRUE(app_window_loaded_listener.WaitUntilSatisfied());
// The shelf should be hidden at the beginning.
EXPECT_FALSE(ash::ShelfTestApi().IsVisible());
// Simulate the swipe-up gesture.
Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
ASSERT_TRUE(app_profile);
extensions::AppWindowRegistry* app_window_registry =
extensions::AppWindowRegistry::Get(app_profile);
extensions::AppWindow* app_window =
apps::AppWindowWaiter(app_window_registry, test_app_id()).Wait();
ASSERT_TRUE(app_window);
gfx::NativeWindow window = app_window->GetNativeWindow()->GetRootWindow();
const gfx::Rect display_bounds = window->bounds();
const gfx::Point start_point = gfx::Point(
display_bounds.width() / 4,
display_bounds.bottom() - ash::ShelfConfig::Get()->shelf_size() / 2);
gfx::Point end_point(start_point.x(), start_point.y() - 80);
ui::test::EventGenerator event_generator(window);
event_generator.GestureScrollSequence(
start_point, end_point, base::TimeDelta::FromMilliseconds(500), 4);
// The shelf should be still hidden after the gesture.
EXPECT_FALSE(ash::ShelfTestApi().IsVisible());
}
IN_PROC_BROWSER_TEST_F(KioskTest, ZoomSupport) {
ExtensionTestMessageListener app_window_loaded_listener("appWindowLoaded",
false);
......
......@@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "ash/public/cpp/login_screen_test_api.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_test_api.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/chromeos/login/kiosk_launch_controller.h"
......@@ -15,6 +17,8 @@
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/common/web_application_info.h"
#include "components/account_id/account_id.h"
......@@ -22,6 +26,7 @@
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/test/event_generator.h"
namespace chromeos {
......@@ -222,4 +227,31 @@ IN_PROC_BROWSER_TEST_F(WebKioskTest,
KioskSessionInitializedWaiter().Wait();
}
// The shelf should be forcedly hidden in the web kiosk session.
IN_PROC_BROWSER_TEST_F(WebKioskTest, HiddenShelf) {
SetOnline(true);
PrepareAppLaunch();
LaunchApp();
KioskSessionInitializedWaiter().Wait();
// The shelf should be hidden at the beginning.
EXPECT_FALSE(ash::ShelfTestApi().IsVisible());
// Simulate the swipe-up gesture.
EXPECT_EQ(BrowserList::GetInstance()->size(), 1U);
BrowserWindow* browser_window = BrowserList::GetInstance()->get(0)->window();
gfx::NativeWindow window = browser_window->GetNativeWindow()->GetRootWindow();
const gfx::Rect display_bounds = window->bounds();
const gfx::Point start_point = gfx::Point(
display_bounds.width() / 4,
display_bounds.bottom() - ash::ShelfConfig::Get()->shelf_size() / 2);
gfx::Point end_point(start_point.x(), start_point.y() - 80);
ui::test::EventGenerator event_generator(window);
event_generator.GestureScrollSequence(
start_point, end_point, base::TimeDelta::FromMilliseconds(500), 4);
// The shelf should be still hidden after the gesture.
EXPECT_FALSE(ash::ShelfTestApi().IsVisible());
}
} // namespace chromeos
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