Commit 24c580bd authored by yilkal's avatar yilkal Committed by Commit Bot

Remove KioskNext code from ScreenOrientation code.

Bug: 977019
Change-Id: I6ee062635834ee34a1e68c037c53c839b63d414f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1684509
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676193}
parent 9c595df2
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include "ash/accelerometer/accelerometer_reader.h" #include "ash/accelerometer/accelerometer_reader.h"
#include "ash/accelerometer/accelerometer_types.h" #include "ash/accelerometer/accelerometer_types.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/home_screen/home_screen_delegate.h"
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -610,26 +608,12 @@ void ScreenOrientationController::ApplyLockForActiveWindow() { ...@@ -610,26 +608,12 @@ void ScreenOrientationController::ApplyLockForActiveWindow() {
MruWindowTracker::WindowList mru_windows( MruWindowTracker::WindowList mru_windows(
shell->mru_window_tracker()->BuildMruWindowList(kActiveDesk)); shell->mru_window_tracker()->BuildMruWindowList(kActiveDesk));
bool has_visible_window = false;
for (auto* window : mru_windows) { for (auto* window : mru_windows) {
if (!window->TargetVisibility()) if (!window->TargetVisibility())
continue; continue;
has_visible_window = true;
if (ApplyLockForWindowIfPossible(window))
return;
}
// No visible MRU window means that the home screen might be showing. Check if (ApplyLockForWindowIfPossible(window))
// if it has an orientation lock.
if (!has_visible_window) {
DCHECK(shell->home_screen_controller()->IsHomeScreenAvailable());
const aura::Window* home_screen_window =
shell->home_screen_controller()->delegate()->GetHomeScreenWindow();
if (home_screen_window &&
shell->activation_client()->GetActiveWindow() == home_screen_window &&
ApplyLockForWindowIfPossible(home_screen_window)) {
return; return;
}
} }
LockRotationToOrientation(user_locked_orientation_); LockRotationToOrientation(user_locked_orientation_);
......
...@@ -11,11 +11,7 @@ ...@@ -11,11 +11,7 @@
#include "ash/accelerometer/accelerometer_types.h" #include "ash/accelerometer/accelerometer_types.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/home_screen/home_screen_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_test_util.h"
#include "ash/kiosk_next/mock_kiosk_next_shell_client.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/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/screen_layout_observer.h" #include "ash/system/screen_layout_observer.h"
...@@ -28,7 +24,6 @@ ...@@ -28,7 +24,6 @@
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/macros.h" #include "base/macros.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/window.h" #include "ui/aura/window.h"
#include "ui/compositor/layer_type.h" #include "ui/compositor/layer_type.h"
...@@ -754,207 +749,4 @@ TEST_F(ScreenOrientationControllerTest, UserRotationLock) { ...@@ -754,207 +749,4 @@ TEST_F(ScreenOrientationControllerTest, UserRotationLock) {
EXPECT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); EXPECT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation());
} }
// Test fixture for Kiosk Next Home's rotation lock.
class ScreenOrientationControllerKioskNextTest
: public ScreenOrientationControllerTest {
public:
ScreenOrientationControllerKioskNextTest() = default;
~ScreenOrientationControllerKioskNextTest() override = default;
// AshTestBase:
void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
::switches::kUseFirstDisplayAsInternal);
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
set_start_session(false);
AshTestBase::SetUp();
client_ = std::make_unique<MockKioskNextShellClient>();
}
void TearDown() override {
client_.reset();
home_screen_window_.reset();
AshTestBase::TearDown();
}
protected:
aura::Window* CreateHomeScreenWindow() {
home_screen_window_.reset(CreateAppWindowInShellWithId(0));
ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
ash::kShellWindowId_HomeScreenContainer)
->AddChild(home_screen_window_.get());
return home_screen_window_.get();
}
private:
std::unique_ptr<MockKioskNextShellClient> client_;
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<aura::Window> home_screen_window_;
DISALLOW_COPY_AND_ASSIGN(ScreenOrientationControllerKioskNextTest);
};
// Tests that the home screen can be inverted but not rotated to portrait.
TEST_F(ScreenOrientationControllerKioskNextTest,
LandscapeOrientationAllowsRotation) {
LogInKioskNextUser(GetSessionControllerClient());
aura::Window* home_screen_window = CreateHomeScreenWindow();
Shell::Get()->activation_client()->ActivateWindow(home_screen_window);
// The home screen window is rotation-locked to landscape.
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
EXPECT_TRUE(RotationLocked());
// Inverse of orientation is allowed.
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation());
// Display rotations in between are not allowed.
TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f));
EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation());
TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f));
EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation());
}
// Tests that app windows outside of the home screen follow normal orientation
// rules.
TEST_F(ScreenOrientationControllerKioskNextTest,
ActiveWindowChangesUpdateOrientation) {
LogInKioskNextUser(GetSessionControllerClient());
aura::Window* home_screen_window = CreateHomeScreenWindow();
Shell::Get()->activation_client()->ActivateWindow(home_screen_window);
// The home screen window is rotation-locked to landscape.
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
std::unique_ptr<aura::Window> child_window = CreateControlWindow();
std::unique_ptr<aura::Window> focus_window(CreateAppWindowInShellWithId(0));
// The rotation is unlocked when an app window is opened.
AddWindowAndActivateParent(child_window.get(), focus_window.get());
EXPECT_FALSE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f));
EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation());
// The rotation becomes locked again when returning to Home.
Shell::Get()->home_screen_controller()->GoHome(
display::Display::InternalDisplayId());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
}
TEST_F(ScreenOrientationControllerKioskNextTest,
ActiveWindowChangesUpdateLock) {
LogInKioskNextUser(GetSessionControllerClient());
aura::Window* home_screen_window = CreateHomeScreenWindow();
Shell::Get()->activation_client()->ActivateWindow(home_screen_window);
// The home screen window is rotation-locked to landscape.
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
std::unique_ptr<aura::Window> child_window = CreateControlWindow();
std::unique_ptr<aura::Window> focus_window(CreateAppWindowInShellWithId(0));
// An app window can specify its own lock.
Lock(child_window.get(), OrientationLockType::kPortrait);
AddWindowAndActivateParent(child_window.get(), focus_window.get());
EXPECT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation());
EXPECT_TRUE(RotationLocked());
// The rotation returns to landscape when returning to Home.
Shell::Get()->home_screen_controller()->GoHome(
display::Display::InternalDisplayId());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
}
// Tests that the active window removing a rotation lock doesn't affect the home
// screen window's lock.
TEST_F(ScreenOrientationControllerKioskNextTest,
ActiveWindowRemovesUpdateLock) {
LogInKioskNextUser(GetSessionControllerClient());
aura::Window* home_screen_window = CreateHomeScreenWindow();
Shell::Get()->activation_client()->ActivateWindow(home_screen_window);
// The home screen window is rotation-locked to landscape.
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
std::unique_ptr<aura::Window> child_window = CreateControlWindow();
std::unique_ptr<aura::Window> focus_window(CreateAppWindowInShellWithId(0));
// An app window can specify its own lock.
Lock(child_window.get(), OrientationLockType::kLandscape);
AddWindowAndActivateParent(child_window.get(), focus_window.get());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f));
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
// Returning home preserves the home screen lock, even after the previously
// active window drops its lock.
Shell::Get()->home_screen_controller()->GoHome(
display::Display::InternalDisplayId());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
Unlock(child_window.get());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
}
// Tests that a user rotation lock doesn't override the home screen window's
// orientation lock.
TEST_F(ScreenOrientationControllerKioskNextTest, UserRotationLock) {
LogInKioskNextUser(GetSessionControllerClient());
aura::Window* home_screen_window = CreateHomeScreenWindow();
::wm::ActivationClient* activation_client = Shell::Get()->activation_client();
activation_client->ActivateWindow(home_screen_window);
std::unique_ptr<aura::Window> child_window = CreateControlWindow();
std::unique_ptr<aura::Window> focus_window(CreateAppWindowInShellWithId(0));
// The rotation is unlocked when an app window is opened.
AddWindowAndActivateParent(child_window.get(), focus_window.get());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
EXPECT_FALSE(RotationLocked());
TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f));
EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation());
// The user can lock the rotation.
SetUserRotationLocked(true);
EXPECT_TRUE(UserRotationLocked());
EXPECT_TRUE(RotationLocked());
// Rotating the screen doesn't update the orientation while locked.
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation());
// The rotation returns to landscape when returning to Home.
Shell::Get()->home_screen_controller()->GoHome(
display::Display::InternalDisplayId());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
// The user rotation lock applies again when re-activating an app window.
activation_client->ActivateWindow(focus_window.get());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation());
// Removing the user rotation lock doesn't affect Home.
Shell::Get()->home_screen_controller()->GoHome(
display::Display::InternalDisplayId());
SetUserRotationLocked(false);
EXPECT_FALSE(UserRotationLocked());
EXPECT_TRUE(RotationLocked());
EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation());
}
} // namespace ash } // namespace ash
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