Commit 5b1e551c authored by yilkal's avatar yilkal Committed by Commit Bot

Hide system tray items in chromeos when Kiosk Next is enabled.

Hidden items:
 1. Ime menu tray
 2. Overview button tray
 3. Palette tray
 4. Logout buton tray
 5. Virtual keyboard tray

Bug: 948955
Change-Id: I8ade734877dfeb6ef45e6516c86384328a1d052f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1622366
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664803}
parent 85bf8ed5
......@@ -9,6 +9,7 @@
#include "ash/keyboard/ash_keyboard_controller.h"
#include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/keyboard/virtual_keyboard_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/system_tray_client.h"
#include "ash/resources/vector_icons/vector_icons.h"
......@@ -337,6 +338,7 @@ ImeMenuTray::ImeMenuTray(Shelf* shelf)
is_emoji_enabled_(false),
is_handwriting_enabled_(false),
is_voice_enabled_(false),
is_enabled_(false),
weak_ptr_factory_(this) {
DCHECK(ime_controller_);
SetInkDropMode(InkDropMode::ON);
......@@ -433,6 +435,12 @@ bool ImeMenuTray::ShouldShowKeyboardToggle() const {
!Shell::Get()->accessibility_controller()->virtual_keyboard_enabled();
}
void ImeMenuTray::UpdateIconVisibility() {
bool visible =
is_enabled_ && !Shell::Get()->kiosk_next_shell_controller()->IsEnabled();
SetVisible(visible);
}
base::string16 ImeMenuTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
}
......@@ -494,7 +502,8 @@ void ImeMenuTray::OnIMERefresh() {
}
void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) {
SetVisible(is_activated);
is_enabled_ = is_activated;
UpdateIconVisibility();
if (is_activated)
UpdateTrayLabel();
else
......
......@@ -51,6 +51,8 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
// opt-in IME menu.
bool ShouldShowKeyboardToggle() const;
void UpdateIconVisibility();
// TrayBackgroundView:
base::string16 GetAccessibleNameForTray() override;
void HideBubbleWithView(const TrayBubbleView* bubble_view) override;
......@@ -104,6 +106,9 @@ class ASH_EXPORT ImeMenuTray : public TrayBackgroundView,
bool is_handwriting_enabled_;
bool is_voice_enabled_;
// Whether the IME menu has been enabled.
bool is_enabled_;
base::WeakPtrFactory<ImeMenuTray> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ImeMenuTray);
......
......@@ -4,10 +4,15 @@
#include "ash/system/ime_menu/ime_menu_tray.h"
#include <memory>
#include "ash/accelerators/accelerator_controller_impl.h"
#include "ash/accessibility/accessibility_controller.h"
#include "ash/ime/ime_controller.h"
#include "ash/ime/test_ime_controller_client.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/ash_features.h"
#include "ash/public/interfaces/ime_info.mojom.h"
#include "ash/shell.h"
#include "ash/system/ime_menu/ime_list_view.h"
......@@ -16,6 +21,7 @@
#include "ash/test/ash_test_base.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/ime/ime_bridge.h"
#include "ui/base/ime/text_input_flags.h"
......@@ -353,4 +359,32 @@ TEST_F(ImeMenuTrayTest, ShouldShowBottomButtonsSeperate) {
EXPECT_FALSE(IsVoiceEnabled());
}
class KioskNextImeMenuTest : public ImeMenuTrayTest {
public:
KioskNextImeMenuTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
ImeMenuTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextImeMenuTest);
};
TEST_F(KioskNextImeMenuTest, ImeMenuNotVisible) {
ASSERT_FALSE(IsVisible());
Shell::Get()->ime_controller()->ShowImeMenuOnShelf(true);
EXPECT_TRUE(IsVisible());
LogInKioskNextUser(GetSessionControllerClient());
EXPECT_FALSE(IsVisible());
}
} // namespace ash
......@@ -4,6 +4,7 @@
#include "ash/system/overview/overview_button_tray.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
......@@ -69,6 +70,25 @@ void OverviewButtonTray::SnapRippleToActivated() {
GetInkDrop()->SnapToActivated();
}
void OverviewButtonTray::UpdateIconVisibility() {
// The visibility of the OverviewButtonTray has diverged from
// OverviewController::CanSelect. The visibility of the button should
// not change during transient times in which CanSelect is false. Such as when
// a modal dialog is present.
SessionControllerImpl* session_controller =
Shell::Get()->session_controller();
bool kiosk_next = Shell::Get()->kiosk_next_shell_controller()->IsEnabled();
bool events_blocked = Shell::Get()
->tablet_mode_controller()
->AreInternalInputDeviceEventsBlocked();
bool active_session = session_controller->GetSessionState() ==
session_manager::SessionState::ACTIVE;
bool app_mode = session_controller->IsRunningInAppMode();
SetVisible(!kiosk_next && events_blocked && active_session && !app_mode);
}
void OverviewButtonTray::OnGestureEvent(ui::GestureEvent* event) {
Button::OnGestureEvent(event);
if (event->type() == ui::ET_GESTURE_LONG_PRESS) {
......@@ -172,19 +192,4 @@ const char* OverviewButtonTray::GetClassName() const {
return "OverviewButtonTray";
}
void OverviewButtonTray::UpdateIconVisibility() {
// The visibility of the OverviewButtonTray has diverged from
// OverviewController::CanSelect. The visibility of the button should
// not change during transient times in which CanSelect is false. Such as when
// a modal dialog is present.
SessionControllerImpl* session_controller =
Shell::Get()->session_controller();
SetVisible(Shell::Get()
->tablet_mode_controller()
->AreInternalInputDeviceEventsBlocked() &&
session_controller->GetSessionState() ==
session_manager::SessionState::ACTIVE &&
!session_controller->IsRunningInAppMode());
}
} // namespace ash
......@@ -48,6 +48,8 @@ class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView,
// Sets the ink drop ripple to ACTIVATED immediately with no animations.
void SnapRippleToActivated();
void UpdateIconVisibility();
// views::Button:
void OnGestureEvent(ui::GestureEvent* event) override;
......@@ -75,10 +77,6 @@ class ASH_EXPORT OverviewButtonTray : public TrayBackgroundView,
private:
friend class OverviewButtonTrayTest;
// Sets the icon to visible if tablet mode is enabled and
// OverviewController::CanSelect.
void UpdateIconVisibility();
// Weak pointer, will be parented by TrayContainer for its lifetime.
views::ImageView* icon_;
......
......@@ -4,8 +4,13 @@
#include "ash/system/overview/overview_button_tray.h"
#include <memory>
#include "ash/display/window_tree_host_manager.h"
#include "ash/kiosk_next/kiosk_next_shell_test_util.h"
#include "ash/kiosk_next/mock_kiosk_next_shell_client.h"
#include "ash/login_status.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/root_window_controller.h"
#include "ash/rotator/screen_rotation_animator.h"
......@@ -24,6 +29,7 @@
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "services/ws/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/aura/client/aura_constants.h"
......@@ -385,4 +391,33 @@ TEST_F(OverviewButtonTrayTest, LeaveTabletModeBecauseExternalMouse) {
EXPECT_TRUE(GetTray()->GetVisible());
}
class KioskNextOverviewTest : public OverviewButtonTrayTest {
public:
KioskNextOverviewTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
OverviewButtonTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextOverviewTest);
};
TEST_F(KioskNextOverviewTest, OverViewButtonHidden) {
TabletModeControllerTestApi().EnterTabletMode();
CreateUserSessions(1);
EXPECT_TRUE(GetTray()->GetVisible());
ClearLogin();
LogInKioskNextUser(GetSessionControllerClient());
EXPECT_FALSE(GetTray()->GetVisible());
}
} // namespace ash
......@@ -7,6 +7,7 @@
#include <memory>
#include "ash/accessibility/accessibility_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/stylus_utils.h"
#include "ash/public/cpp/system_tray_client.h"
......@@ -560,13 +561,10 @@ void PaletteTray::UpdateTrayIcon() {
void PaletteTray::OnPaletteEnabledPrefChanged() {
is_palette_enabled_ = pref_change_registrar_user_->prefs()->GetBoolean(
prefs::kEnableStylusTools);
if (!is_palette_enabled_) {
SetVisible(false);
if (!is_palette_enabled_)
palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE);
} else {
UpdateIconVisibility();
}
UpdateIconVisibility();
}
void PaletteTray::OnHasSeenStylusPrefChanged() {
......@@ -597,7 +595,8 @@ bool PaletteTray::HasSeenStylus() {
void PaletteTray::UpdateIconVisibility() {
SetVisible(HasSeenStylus() && is_palette_enabled_ &&
stylus_utils::HasStylusInput() && ShouldShowOnDisplay(this) &&
palette_utils::IsInUserSession());
palette_utils::IsInUserSession() &&
!Shell::Get()->kiosk_next_shell_controller()->IsEnabled());
}
} // namespace ash
......@@ -89,6 +89,9 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView,
PaletteInvocationMethod method) override;
void RecordPaletteModeCancellation(PaletteModeCancelType type) override;
// Sets the icon to visible if the palette can be used.
void UpdateIconVisibility();
private:
friend class PaletteTrayTestApi;
......@@ -112,9 +115,6 @@ class ASH_EXPORT PaletteTray : public TrayBackgroundView,
// Updates the tray icon from the palette tool manager.
void UpdateTrayIcon();
// Sets the icon to visible if the palette can be used.
void UpdateIconVisibility();
// Called when the palette enabled pref has changed.
void OnPaletteEnabledPrefChanged();
......
......@@ -11,6 +11,9 @@
#include "ash/assistant/test/test_assistant_service.h"
#include "ash/highlighter/highlighter_controller.h"
#include "ash/highlighter/highlighter_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/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/stylus_utils.h"
......@@ -81,6 +84,8 @@ class PaletteTrayTest : public AshTestBase {
test_api_ = std::make_unique<PaletteTrayTestApi>(palette_tray_);
}
PaletteTray* palette_tray() { return palette_tray_; }
protected:
PrefService* active_user_pref_service() {
return Shell::Get()->session_controller()->GetActivePrefService();
......@@ -761,4 +766,29 @@ TEST_F(PaletteTrayNoSessionTestWithInternalStylus,
EXPECT_FALSE(external_tray->GetBubbleView());
}
class KioskNextPaletteTrayTest : public PaletteTrayTest {
public:
KioskNextPaletteTrayTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
PaletteTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextPaletteTrayTest);
};
TEST_F(KioskNextPaletteTrayTest, PaletteTrayHidden) {
LogInKioskNextUser(GetSessionControllerClient());
local_state_pref_service()->SetBoolean(prefs::kHasSeenStylus, true);
EXPECT_FALSE(palette_tray()->GetVisible());
}
} // namespace ash
......@@ -6,6 +6,7 @@
#include <memory>
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/ash_typography.h"
#include "ash/resources/vector_icons/vector_icons.h"
......@@ -65,6 +66,14 @@ void LogoutButtonTray::UpdateAfterShelfAlignmentChange() {
container_->UpdateAfterShelfAlignmentChange();
}
void LogoutButtonTray::UpdateVisibility() {
LoginStatus login_status = shelf_->GetStatusAreaWidget()->login_status();
SetVisible(show_logout_button_in_tray_ &&
login_status != LoginStatus::NOT_LOGGED_IN &&
login_status != LoginStatus::LOCKED &&
!Shell::Get()->kiosk_next_shell_controller()->IsEnabled());
}
void LogoutButtonTray::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK_EQ(button_, sender);
......@@ -124,13 +133,6 @@ void LogoutButtonTray::UpdateAfterLoginStatusChange() {
UpdateButtonTextAndImage();
}
void LogoutButtonTray::UpdateVisibility() {
LoginStatus login_status = shelf_->GetStatusAreaWidget()->login_status();
SetVisible(show_logout_button_in_tray_ &&
login_status != LoginStatus::NOT_LOGGED_IN &&
login_status != LoginStatus::LOCKED);
}
void LogoutButtonTray::UpdateButtonTextAndImage() {
LoginStatus login_status = shelf_->GetStatusAreaWidget()->login_status();
const base::string16 title =
......
......@@ -39,6 +39,8 @@ class ASH_EXPORT LogoutButtonTray : public views::View,
void UpdateAfterLoginStatusChange();
void UpdateAfterShelfAlignmentChange();
void UpdateVisibility();
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
const char* GetClassName() const override;
......@@ -54,7 +56,6 @@ class ASH_EXPORT LogoutButtonTray : public views::View,
private:
void UpdateShowLogoutButtonInTray();
void UpdateLogoutDialogDuration();
void UpdateVisibility();
void UpdateButtonTextAndImage();
Shelf* const shelf_;
......
......@@ -4,6 +4,11 @@
#include "ash/system/session/logout_button_tray.h"
#include <memory>
#include "ash/kiosk_next/kiosk_next_shell_test_util.h"
#include "ash/kiosk_next/mock_kiosk_next_shell_client.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h"
......@@ -16,6 +21,7 @@
#include "ash/test_shell_delegate.h"
#include "base/macros.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/prefs/pref_service.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/controls/button/md_text_button.h"
......@@ -36,6 +42,12 @@ class LogoutButtonTrayTest : public NoSessionAshTestBase {
SimulateUserLogin(kUserEmail);
}
LogoutButtonTray* logout_button_tray() {
return Shell::GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->logout_button_tray_for_testing();
}
PrefService* pref_service() {
return Shell::Get()->session_controller()->GetUserPrefServiceForUser(
AccountId::FromUserEmail(kUserEmail));
......@@ -47,9 +59,8 @@ class LogoutButtonTrayTest : public NoSessionAshTestBase {
TEST_F(LogoutButtonTrayTest, Visibility) {
// Button is not visible before login.
LogoutButtonTray* button = Shell::GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->logout_button_tray_for_testing();
LogoutButtonTray* button = logout_button_tray();
ASSERT_TRUE(button);
EXPECT_FALSE(button->GetVisible());
......@@ -77,9 +88,8 @@ TEST_F(LogoutButtonTrayTest, ButtonPressed) {
constexpr char kUserEmail[] = "user1@test.com";
constexpr char kUserAction[] = "DemoMode.ExitFromShelf";
LogoutButtonTray* const tray = Shell::GetPrimaryRootWindowController()
->GetStatusAreaWidget()
->logout_button_tray_for_testing();
LogoutButtonTray* const tray = logout_button_tray();
ASSERT_TRUE(tray);
views::MdTextButton* const button = tray->button_for_test();
TestSessionControllerClient* const session_client =
......@@ -132,5 +142,30 @@ TEST_F(LogoutButtonTrayTest, ButtonPressed) {
->confirm_logout_count_for_test());
}
class KioskNextLogoutButtonTrayTest : public LogoutButtonTrayTest {
public:
KioskNextLogoutButtonTrayTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
LogoutButtonTrayTest::SetUp();
client_ = BindMockKioskNextShellClient();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextLogoutButtonTrayTest);
};
TEST_F(KioskNextLogoutButtonTrayTest, LogoutButtonHidden) {
ClearLogin();
LogInKioskNextUser(GetSessionControllerClient());
pref_service()->SetBoolean(prefs::kShowLogoutButtonInTray, true);
EXPECT_FALSE(logout_button_tray()->GetVisible());
}
} // namespace
} // namespace ash
......@@ -4,6 +4,7 @@
#include "ash/system/status_area_widget.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
......@@ -37,6 +38,7 @@ StatusAreaWidget::StatusAreaWidget(aura::Window* status_container, Shelf* shelf)
Init(params);
set_focus_on_creation(false);
SetContentsView(status_area_widget_delegate_);
Shell::Get()->kiosk_next_shell_controller()->AddObserver(this);
}
void StatusAreaWidget::Initialize() {
......@@ -97,6 +99,8 @@ StatusAreaWidget::~StatusAreaWidget() {
logout_button_tray_.reset();
overview_button_tray_.reset();
Shell::Get()->kiosk_next_shell_controller()->RemoveObserver(this);
// All child tray views have been removed.
DCHECK(GetContentsView()->children().empty());
}
......@@ -190,6 +194,14 @@ bool StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
return true;
}
void StatusAreaWidget::OnKioskNextEnabled() {
ime_menu_tray_->UpdateIconVisibility();
overview_button_tray_->UpdateIconVisibility();
palette_tray_->UpdateIconVisibility();
virtual_keyboard_tray_->UpdateIconVisibility();
logout_button_tray_->UpdateVisibility();
}
void StatusAreaWidget::OnMouseEvent(ui::MouseEvent* event) {
// Clicking anywhere except the virtual keyboard tray icon should hide the
// virtual keyboard.
......
......@@ -6,6 +6,7 @@
#define ASH_SYSTEM_STATUS_AREA_WIDGET_H_
#include "ash/ash_export.h"
#include "ash/kiosk_next/kiosk_next_shell_observer.h"
#include "ash/login_status.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf_background_animator_observer.h"
......@@ -34,7 +35,8 @@ class VirtualKeyboardTray;
// so that it can be shown in cases where the rest of the shelf is hidden (e.g.
// on secondary monitors at the login screen).
class ASH_EXPORT StatusAreaWidget : public views::Widget,
public ShelfBackgroundAnimatorObserver {
public ShelfBackgroundAnimatorObserver,
public KioskNextShellObserver {
public:
StatusAreaWidget(aura::Window* status_container, Shelf* shelf);
~StatusAreaWidget() override;
......@@ -99,6 +101,9 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget,
const ui::NativeTheme* GetNativeTheme() const override;
bool OnNativeWidgetActivationChanged(bool active) override;
// KioskNextShellObserver:
void OnKioskNextEnabled() override;
// TODO(jamescook): Introduce a test API instead of these methods.
LogoutButtonTray* logout_button_tray_for_testing() {
return logout_button_tray_.get();
......
......@@ -8,6 +8,7 @@
#include "ash/accessibility/accessibility_controller.h"
#include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/kiosk_next/kiosk_next_shell_controller.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h"
......@@ -91,9 +92,7 @@ bool VirtualKeyboardTray::PerformAction(const ui::Event& event) {
}
void VirtualKeyboardTray::OnAccessibilityStatusChanged() {
bool new_enabled =
Shell::Get()->accessibility_controller()->virtual_keyboard_enabled();
SetVisible(new_enabled);
UpdateIconVisibility();
}
void VirtualKeyboardTray::OnKeyboardVisibilityStateChanged(
......@@ -124,4 +123,11 @@ void VirtualKeyboardTray::UpdateIcon() {
gfx::Insets(vertical_padding, horizontal_padding)));
}
void VirtualKeyboardTray::UpdateIconVisibility() {
bool visible =
Shell::Get()->accessibility_controller()->virtual_keyboard_enabled() &&
!Shell::Get()->kiosk_next_shell_controller()->IsEnabled();
SetVisible(visible);
}
} // namespace ash
......@@ -46,6 +46,8 @@ class VirtualKeyboardTray : public TrayBackgroundView,
// views::View:
const char* GetClassName() const override;
void UpdateIconVisibility();
private:
// Updates the icon UI.
void UpdateIcon();
......
......@@ -4,15 +4,25 @@
#include "ash/system/virtual_keyboard/virtual_keyboard_tray.h"
#include <memory>
#include "ash/keyboard/ui/keyboard_controller.h"
#include "ash/keyboard/ui/keyboard_util.h"
#include "ash/keyboard/ui/test/keyboard_test_util.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/ash_features.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/keyboard/keyboard_switches.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/status_area_widget_test_helper.h"
#include "ash/test/ash_test_base.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/test/scoped_feature_list.h"
#include "components/prefs/pref_service.h"
namespace ash {
......@@ -57,4 +67,42 @@ TEST_F(VirtualKeyboardTrayTest, PerformActionTogglesVirtualKeyboard) {
ASSERT_TRUE(keyboard::WaitUntilHidden());
}
class KioskNextVirtualKeyboardTest : public AshTestBase {
public:
KioskNextVirtualKeyboardTest() {
scoped_feature_list_.InitAndEnableFeature(features::kKioskNextShell);
}
void SetUp() override {
set_start_session(false);
AshTestBase::SetUp();
client_ = BindMockKioskNextShellClient();
}
void EnableVirtualKeyboardForActiveUser() {
PrefService* pref_service =
Shell::Get()->session_controller()->GetActivePrefService();
pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, true);
}
VirtualKeyboardTray* tray() {
StatusAreaWidget* status =
StatusAreaWidgetTestHelper::GetStatusAreaWidget();
return status->virtual_keyboard_tray_for_testing();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<MockKioskNextShellClient> client_;
DISALLOW_COPY_AND_ASSIGN(KioskNextVirtualKeyboardTest);
};
TEST_F(KioskNextVirtualKeyboardTest, VirtualKeyboardTrayHidden) {
LogInKioskNextUser(GetSessionControllerClient());
EnableVirtualKeyboardForActiveUser();
EXPECT_FALSE(tray()->GetVisible());
}
} // 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