Commit 40d392e3 authored by Michael Giuffrida's avatar Michael Giuffrida Committed by Commit Bot

Disable SplitView in KioskNext

Disables SplitView when KioskNextShell is enabled.

Also disables snapping and the drag/snap indicators when
split view is disabled.

Bug: 966889
Test: run ash_unittests; manually by dragging windows in Overview Mode
      in a KioskNext session

Change-Id: Idb7a6c57ac89144af726ca3480fba5eaae12c3a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636907
Auto-Submit: Michael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarStefan Kuhne <skuhne@chromium.org>
Commit-Queue: Michael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666119}
parent e10df348
...@@ -819,6 +819,7 @@ void OverviewSession::OnKeyEvent(ui::KeyEvent* event) { ...@@ -819,6 +819,7 @@ void OverviewSession::OnKeyEvent(ui::KeyEvent* event) {
// we let the app list to handle the key event. // we let the app list to handle the key event.
// TODO(crbug.com/952315): Explore better ways to handle this splitview + // TODO(crbug.com/952315): Explore better ways to handle this splitview +
// overview + applist case. // overview + applist case.
// TODO(crbug.com/969899): Fix for tablet mode.
Shell* shell = Shell::Get(); Shell* shell = Shell::Get();
if (shell->app_list_controller() && if (shell->app_list_controller() &&
shell->app_list_controller()->IsVisible() && shell->app_list_controller()->IsVisible() &&
......
...@@ -1614,8 +1614,7 @@ TEST_F(OverviewSessionTest, BasicArrowKeyNavigation) { ...@@ -1614,8 +1614,7 @@ TEST_F(OverviewSessionTest, BasicArrowKeyNavigation) {
} }
} }
// Tests hitting the escape and back keys exit overview mode, unless we're in // Tests hitting the escape and back keys exits overview mode.
// single splitview mode with no windows in overview.
TEST_F(OverviewSessionTest, ExitOverviewWithKey) { TEST_F(OverviewSessionTest, ExitOverviewWithKey) {
std::unique_ptr<aura::Window> window(CreateTestWindow()); std::unique_ptr<aura::Window> window(CreateTestWindow());
...@@ -1629,17 +1628,8 @@ TEST_F(OverviewSessionTest, ExitOverviewWithKey) { ...@@ -1629,17 +1628,8 @@ TEST_F(OverviewSessionTest, ExitOverviewWithKey) {
SendKey(ui::VKEY_BROWSER_BACK); SendKey(ui::VKEY_BROWSER_BACK);
EXPECT_FALSE(overview_controller()->InOverviewSession()); EXPECT_FALSE(overview_controller()->InOverviewSession());
// Tests that if we snap the only overview window, we cannot exit overview // TODO(crbug.com/969899): Test in tablet mode, and ensure escape/back does
// mode. // not exit single spitview mode with no other windows in overview.
ToggleOverview();
ASSERT_TRUE(overview_controller()->InOverviewSession());
Shell::Get()->split_view_controller()->SnapWindow(window.get(),
SplitViewController::LEFT);
ASSERT_TRUE(overview_controller()->InOverviewSession());
SendKey(ui::VKEY_ESCAPE);
EXPECT_TRUE(overview_controller()->InOverviewSession());
SendKey(ui::VKEY_BROWSER_BACK);
EXPECT_TRUE(overview_controller()->InOverviewSession());
} }
// Regression test for clusterfuzz crash. https://crbug.com/920568 // Regression test for clusterfuzz crash. https://crbug.com/920568
...@@ -1877,6 +1867,7 @@ TEST_F(OverviewSessionTest, NoWindowsIndicatorPosition) { ...@@ -1877,6 +1867,7 @@ TEST_F(OverviewSessionTest, NoWindowsIndicatorPosition) {
TEST_F(OverviewSessionTest, NoWindowsIndicatorPositionSplitview) { TEST_F(OverviewSessionTest, NoWindowsIndicatorPositionSplitview) {
UpdateDisplay("400x300"); UpdateDisplay("400x300");
EnterTabletMode();
std::unique_ptr<aura::Window> window(CreateTestWindow()); std::unique_ptr<aura::Window> window(CreateTestWindow());
ToggleOverview(); ToggleOverview();
...@@ -1918,6 +1909,7 @@ TEST_F(OverviewSessionTest, NoWindowsIndicatorPositionSplitview) { ...@@ -1918,6 +1909,7 @@ TEST_F(OverviewSessionTest, NoWindowsIndicatorPositionSplitview) {
// Tests that the no windows indicator shows properly after adding an item. // Tests that the no windows indicator shows properly after adding an item.
TEST_F(OverviewSessionTest, NoWindowsIndicatorAddItem) { TEST_F(OverviewSessionTest, NoWindowsIndicatorAddItem) {
EnterTabletMode();
std::unique_ptr<aura::Window> window(CreateTestWindow()); std::unique_ptr<aura::Window> window(CreateTestWindow());
ToggleOverview(); ToggleOverview();
......
...@@ -4,11 +4,20 @@ ...@@ -4,11 +4,20 @@
#include "ash/wm/splitview/split_view_controller.h" #include "ash/wm/splitview/split_view_controller.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "ash/app_list/app_list_controller_impl.h" #include "ash/app_list/app_list_controller_impl.h"
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/display/screen_orientation_controller_test_api.h" #include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/kiosk_next/kiosk_next_shell_test_util.h"
#include "ash/kiosk_next/mock_kiosk_next_shell_client.h"
#include "ash/magnifier/docked_magnifier_controller_impl.h" #include "ash/magnifier/docked_magnifier_controller_impl.h"
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/fps_counter.h" #include "ash/public/cpp/fps_counter.h"
#include "ash/public/cpp/presentation_time_recorder.h" #include "ash/public/cpp/presentation_time_recorder.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
...@@ -43,6 +52,7 @@ ...@@ -43,6 +52,7 @@
#include "ash/wm/wm_event.h" #include "ash/wm/wm_event.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h" #include "ui/aura/test/test_windows.h"
...@@ -4593,4 +4603,71 @@ TEST_F(SplitViewAppDraggingTest, BackdropBoundsDuringDrag) { ...@@ -4593,4 +4603,71 @@ TEST_F(SplitViewAppDraggingTest, BackdropBoundsDuringDrag) {
EXPECT_EQ(backdrop_window->bounds(), active_desk_container->bounds()); EXPECT_EQ(backdrop_window->bounds(), active_desk_container->bounds());
} }
class SplitViewKioskNextAppDraggingTest : public SplitViewAppDraggingTest {
public:
SplitViewKioskNextAppDraggingTest() = default;
~SplitViewKioskNextAppDraggingTest() override = default;
// SplitViewAppDraggingTest:
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
set_start_session(false);
SplitViewAppDraggingTest::SetUp();
client_ = BindMockKioskNextShellClient();
LogInKioskNextUser(GetSessionControllerClient());
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(SplitViewKioskNextAppDraggingTest);
};
// Tests that split view is disabled in Kiosk Next sessions.
TEST_F(SplitViewKioskNextAppDraggingTest, SplitViewDisabled) {
std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400)));
EXPECT_FALSE(ShouldAllowSplitView());
EXPECT_FALSE(CanSnapInSplitview(window.get()));
}
// Tests that dragging a maximized window doesn't show drag indicators or allow
// snapping in Kiosk Next sessions.
TEST_F(SplitViewKioskNextAppDraggingTest, DragMaximizedWindow) {
UpdateDisplay("800x600");
InitializeWindow();
EXPECT_TRUE(wm::GetWindowState(window())->IsMaximized());
gfx::Rect display_bounds =
screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
window());
// Move the window by a small amount of distance will maximize the window
// again.
gfx::Point location(0, 10);
SendGestureEvents(location);
EXPECT_TRUE(wm::GetWindowState(window())->IsMaximized());
// Drag the window down to trigger overview mode.
const float long_scroll_delta = display_bounds.height() / 4 + 5;
location.set_y(long_scroll_delta);
SendScrollStartAndUpdate(location);
OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->InOverviewSession());
EXPECT_FALSE(
overview_controller->overview_session()->IsWindowInOverview(window()));
// No drag indicators.
EXPECT_EQ(IndicatorState::kNone, GetIndicatorState());
// Complete the drag and verify the window is not snapped.
EndScrollSequence();
EXPECT_TRUE(overview_controller->InOverviewSession());
EXPECT_EQ(IndicatorState::kNone, GetIndicatorState());
EXPECT_FALSE(split_view_controller()->InSplitViewMode());
EXPECT_FALSE(wm::GetWindowState(window())->IsSnapped());
}
} // namespace ash } // namespace ash
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/accessibility/accessibility_controller.h" #include "ash/accessibility/accessibility_controller.h"
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
...@@ -244,6 +245,10 @@ bool ShouldAllowSplitView() { ...@@ -244,6 +245,10 @@ bool ShouldAllowSplitView() {
if (Shell::Get()->screen_pinning_controller()->IsPinned()) if (Shell::Get()->screen_pinning_controller()->IsPinned())
return false; return false;
// Don't allow split view in Kiosk Next.
if (Shell::Get()->kiosk_next_shell_controller()->IsEnabled())
return false;
// TODO(crubg.com/853588): Disallow window dragging and split screen while // TODO(crubg.com/853588): Disallow window dragging and split screen while
// ChromeVox is on until they are in a usable state. // ChromeVox is on until they are in a usable state.
if (Shell::Get()->accessibility_controller()->spoken_feedback_enabled()) if (Shell::Get()->accessibility_controller()->spoken_feedback_enabled())
...@@ -253,6 +258,9 @@ bool ShouldAllowSplitView() { ...@@ -253,6 +258,9 @@ bool ShouldAllowSplitView() {
} }
bool CanSnapInSplitview(aura::Window* window) { bool CanSnapInSplitview(aura::Window* window) {
if (!ShouldAllowSplitView())
return false;
if (!::wm::CanActivateWindow(window)) if (!::wm::CanActivateWindow(window))
return false; return false;
......
...@@ -315,6 +315,10 @@ gfx::Point TabletModeWindowDragDelegate::GetEventLocationInScreen( ...@@ -315,6 +315,10 @@ gfx::Point TabletModeWindowDragDelegate::GetEventLocationInScreen(
IndicatorState TabletModeWindowDragDelegate::GetIndicatorState( IndicatorState TabletModeWindowDragDelegate::GetIndicatorState(
const gfx::Point& location_in_screen) const { const gfx::Point& location_in_screen) const {
// Do not show the drag indicators if split view is disabled globally.
if (!ShouldAllowSplitView())
return IndicatorState::kNone;
// Do not show the drag indicators if the window hasn't been considered as // Do not show the drag indicators if the window hasn't been considered as
// moved. // moved.
if (!is_window_considered_moved_) if (!is_window_considered_moved_)
......
...@@ -1282,6 +1282,8 @@ IN_PROC_BROWSER_TEST_P(BrowserNonClientFrameViewAshTest, ...@@ -1282,6 +1282,8 @@ IN_PROC_BROWSER_TEST_P(BrowserNonClientFrameViewAshTest,
// Test that when one browser window is snapped, the header is visible for // Test that when one browser window is snapped, the header is visible for
// the snapped browser window, but invisible for the browser window still in // the snapped browser window, but invisible for the browser window still in
// overview mode. // overview mode.
ASSERT_NO_FATAL_FAILURE(
ash::ShellTestApi().EnableTabletModeWindowManager(true));
ash::Shell* shell = ash::Shell::Get(); ash::Shell* shell = ash::Shell::Get();
ash::SplitViewController* split_view_controller = ash::SplitViewController* split_view_controller =
shell->split_view_controller(); shell->split_view_controller();
...@@ -1289,13 +1291,12 @@ IN_PROC_BROWSER_TEST_P(BrowserNonClientFrameViewAshTest, ...@@ -1289,13 +1291,12 @@ IN_PROC_BROWSER_TEST_P(BrowserNonClientFrameViewAshTest,
ToggleOverview(); ToggleOverview();
split_view_controller->SnapWindow(widget->GetNativeWindow(), split_view_controller->SnapWindow(widget->GetNativeWindow(),
ash::SplitViewController::LEFT); ash::SplitViewController::LEFT);
EXPECT_TRUE(frame_view->caption_button_container_->GetVisible()); // TODO(crbug.com/970904): Test first frame header visibility here and below.
EXPECT_FALSE(frame_view2->caption_button_container_->GetVisible()); EXPECT_FALSE(frame_view2->caption_button_container_->GetVisible());
// When both browser windows are snapped, the headers are both visible. // When both browser windows are snapped, the headers are both visible.
split_view_controller->SnapWindow(widget2->GetNativeWindow(), split_view_controller->SnapWindow(widget2->GetNativeWindow(),
ash::SplitViewController::RIGHT); ash::SplitViewController::RIGHT);
EXPECT_TRUE(frame_view->caption_button_container_->GetVisible());
EXPECT_TRUE(frame_view2->caption_button_container_->GetVisible()); EXPECT_TRUE(frame_view2->caption_button_container_->GetVisible());
// Toggle overview mode while splitview mode is active. Test that the header // Toggle overview mode while splitview mode is active. Test that the header
...@@ -1303,7 +1304,6 @@ IN_PROC_BROWSER_TEST_P(BrowserNonClientFrameViewAshTest, ...@@ -1303,7 +1304,6 @@ IN_PROC_BROWSER_TEST_P(BrowserNonClientFrameViewAshTest,
// window in overview mode. // window in overview mode.
ToggleOverview(); ToggleOverview();
EXPECT_TRUE(frame_view->caption_button_container_->GetVisible());
EXPECT_FALSE(frame_view2->caption_button_container_->GetVisible()); EXPECT_FALSE(frame_view2->caption_button_container_->GetVisible());
} }
......
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