Commit c17feb22 authored by Xiaodan Zhu's avatar Xiaodan Zhu Committed by Commit Bot

Add alert for entering/exiting tablet mode

Bug: 1010200
Change-Id: Ie3d552b6108c491e12510fb32f544a0d0f938453
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2353548Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarMin Chen <minch@chromium.org>
Commit-Queue: Xiaodan Zhu <zxdan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799345}
parent 71d94d64
...@@ -26,7 +26,9 @@ void TestAccessibilityControllerClient::TriggerAccessibilityAlert( ...@@ -26,7 +26,9 @@ void TestAccessibilityControllerClient::TriggerAccessibilityAlert(
} }
void TestAccessibilityControllerClient::TriggerAccessibilityAlertWithMessage( void TestAccessibilityControllerClient::TriggerAccessibilityAlertWithMessage(
const std::string& message) {} const std::string& message) {
last_alert_message_ = message;
}
void TestAccessibilityControllerClient::PlayEarcon(int32_t sound_key) { void TestAccessibilityControllerClient::PlayEarcon(int32_t sound_key) {
sound_key_ = sound_key; sound_key_ = sound_key;
......
...@@ -49,10 +49,11 @@ class TestAccessibilityControllerClient : public AccessibilityControllerClient { ...@@ -49,10 +49,11 @@ class TestAccessibilityControllerClient : public AccessibilityControllerClient {
int select_to_speak_change_change_requests() const { int select_to_speak_change_change_requests() const {
return select_to_speak_state_change_requests_; return select_to_speak_state_change_requests_;
} }
const std::string& last_alert_message() const { return last_alert_message_; }
private: private:
AccessibilityAlert last_a11y_alert_ = AccessibilityAlert::NONE; AccessibilityAlert last_a11y_alert_ = AccessibilityAlert::NONE;
std::string last_alert_message_;
int32_t sound_key_ = -1; int32_t sound_key_ = -1;
bool is_dictation_active_ = false; bool is_dictation_active_ = false;
......
...@@ -2660,6 +2660,13 @@ Here are some things you can try to get started. ...@@ -2660,6 +2660,13 @@ Here are some things you can try to get started.
<message name="IDS_ASH_SCREEN_CAPTURE_BUTTON_DELETE" desc="The delete button label for the screen capture notificaiton."> <message name="IDS_ASH_SCREEN_CAPTURE_BUTTON_DELETE" desc="The delete button label for the screen capture notificaiton.">
Delete Delete
</message> </message>
<!-- Switch Between TABLET/LAPTOP MODE-->
<message name="IDS_ASH_SWITCH_TO_TABLET_MODE" desc="Alert of switching to tablet mode.">
Switch to tablet mode
</message>
<message name="IDS_ASH_SWITCH_TO_LAPTOP_MODE" desc="Alert of switching to laptop mode.">
Switch to laptop mode
</message>
</messages> </messages>
</release> </release>
</grit> </grit>
f80e905aa5f4885c58b0194719c231045d4b4b74
\ No newline at end of file
e88fae42cb9817f6de8b9ff7c52aa898e8f6f57b
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/metrics_util.h" #include "ash/public/cpp/metrics_util.h"
#include "ash/public/cpp/shelf_config.h" #include "ash/public/cpp/shelf_config.h"
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/wm/overview/overview_controller.h" #include "ash/wm/overview/overview_controller.h"
#include "ash/wm/splitview/split_view_utils.h" #include "ash/wm/splitview/split_view_utils.h"
#include "ash/wm/tablet_mode/internal_input_devices_event_blocker.h" #include "ash/wm/tablet_mode/internal_input_devices_event_blocker.h"
...@@ -42,6 +44,7 @@ ...@@ -42,6 +44,7 @@
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/base/accelerators/accelerator.h" #include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/layer_animation_sequence.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
...@@ -1329,6 +1332,11 @@ bool TabletModeController::UpdateUiTabletState() { ...@@ -1329,6 +1332,11 @@ bool TabletModeController::UpdateUiTabletState() {
return false; return false;
SetTabletModeEnabledInternal(should_be_in_tablet_mode); SetTabletModeEnabledInternal(should_be_in_tablet_mode);
Shell::Get()
->accessibility_controller()
->TriggerAccessibilityAlertWithMessage(l10n_util::GetStringUTF8(
should_be_in_tablet_mode ? IDS_ASH_SWITCH_TO_TABLET_MODE
: IDS_ASH_SWITCH_TO_LAPTOP_MODE));
return true; return true;
} }
......
...@@ -11,10 +11,13 @@ ...@@ -11,10 +11,13 @@
#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/accessibility/accessibility_controller_impl.h"
#include "ash/accessibility/test_accessibility_controller_client.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/app_list/views/app_list_view.h" #include "ash/app_list/views/app_list_view.h"
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/public/cpp/accessibility_controller.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_features.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
...@@ -24,6 +27,7 @@ ...@@ -24,6 +27,7 @@
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/wm/overview/overview_controller.h" #include "ash/wm/overview/overview_controller.h"
#include "ash/wm/overview/overview_wallpaper_controller.h" #include "ash/wm/overview/overview_wallpaper_controller.h"
...@@ -46,6 +50,7 @@ ...@@ -46,6 +50,7 @@
#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/base/hit_test.h" #include "ui/base/hit_test.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/compositor/layer_animator.h" #include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/test/test_utils.h" #include "ui/compositor/test/test_utils.h"
...@@ -723,6 +728,20 @@ TEST_P(TabletModeControllerTest, VerticalHingeUnstableAnglesTest) { ...@@ -723,6 +728,20 @@ TEST_P(TabletModeControllerTest, VerticalHingeUnstableAnglesTest) {
} }
} }
// Verify that the Alert Message will be triggered when switching between tablet
// mode and laptop mode.
TEST_P(TabletModeControllerTest, AlertInAndOutTabletMode) {
TestAccessibilityControllerClient client;
SetTabletMode(true);
EXPECT_TRUE(l10n_util::GetStringUTF8(IDS_ASH_SWITCH_TO_TABLET_MODE) ==
client.last_alert_message());
SetTabletMode(false);
EXPECT_TRUE(l10n_util::GetStringUTF8(IDS_ASH_SWITCH_TO_LAPTOP_MODE) ==
client.last_alert_message());
}
// Tests that when a TabletModeController is created that cached tablet mode // Tests that when a TabletModeController is created that cached tablet mode
// state will trigger a mode update. // state will trigger a mode update.
class TabletModeControllerInitedFromPowerManagerClientTest class TabletModeControllerInitedFromPowerManagerClientTest
......
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