| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/accessibility_delegate.h" | |
| 11 #include "ash/public/cpp/config.h" | 10 #include "ash/public/cpp/config.h" |
| 12 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
| 13 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 14 #include "ash/screen_util.h" | 13 #include "ash/screen_util.h" |
| 15 #include "ash/session/session_controller.h" | 14 #include "ash/session/session_controller.h" |
| 16 #include "ash/shared/app_types.h" | |
| 17 #include "ash/shelf/shelf_constants.h" | 15 #include "ash/shelf/shelf_constants.h" |
| 18 #include "ash/shelf/shelf_layout_manager.h" | 16 #include "ash/shelf/shelf_layout_manager.h" |
| 19 #include "ash/shelf/wm_shelf.h" | 17 #include "ash/shelf/wm_shelf.h" |
| 20 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 21 #include "ash/shell_observer.h" | 19 #include "ash/shell_observer.h" |
| 22 #include "ash/shell_port.h" | 20 #include "ash/shell_port.h" |
| 23 #include "ash/system/tray/system_tray_notifier.h" | |
| 24 #include "ash/test/ash_test_base.h" | 21 #include "ash/test/ash_test_base.h" |
| 25 #include "ash/test/shell_test_api.h" | |
| 26 #include "ash/test/test_accessibility_delegate.h" | |
| 27 #include "ash/test/test_session_controller_client.h" | 22 #include "ash/test/test_session_controller_client.h" |
| 28 #include "ash/test/wm_window_test_api.h" | 23 #include "ash/test/wm_window_test_api.h" |
| 29 #include "ash/test/workspace_controller_test_api.h" | |
| 30 #include "ash/wm/fullscreen_window_finder.h" | 24 #include "ash/wm/fullscreen_window_finder.h" |
| 31 #include "ash/wm/maximize_mode/maximize_mode_backdrop_delegate_impl.h" | 25 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" |
| 32 #include "ash/wm/overview/window_selector_controller.h" | |
| 33 #include "ash/wm/window_state.h" | 26 #include "ash/wm/window_state.h" |
| 34 #include "ash/wm/window_state_aura.h" | 27 #include "ash/wm/window_state_aura.h" |
| 35 #include "ash/wm/window_util.h" | 28 #include "ash/wm/window_util.h" |
| 36 #include "ash/wm/wm_event.h" | 29 #include "ash/wm/wm_event.h" |
| 37 #include "ash/wm/workspace/backdrop_delegate.h" | |
| 38 #include "ash/wm/workspace/workspace_window_resizer.h" | 30 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 39 #include "ash/wm_window.h" | 31 #include "ash/wm_window.h" |
| 40 #include "base/command_line.h" | 32 #include "base/command_line.h" |
| 41 #include "base/run_loop.h" | 33 #include "base/run_loop.h" |
| 42 #include "chromeos/audio/chromeos_sounds.h" | |
| 43 #include "ui/aura/client/aura_constants.h" | 34 #include "ui/aura/client/aura_constants.h" |
| 44 #include "ui/aura/client/focus_client.h" | 35 #include "ui/aura/client/focus_client.h" |
| 45 #include "ui/aura/test/test_window_delegate.h" | |
| 46 #include "ui/aura/window.h" | 36 #include "ui/aura/window.h" |
| 47 #include "ui/aura/window_targeter.h" | |
| 48 #include "ui/base/ui_base_switches.h" | 37 #include "ui/base/ui_base_switches.h" |
| 49 #include "ui/base/ui_base_types.h" | 38 #include "ui/base/ui_base_types.h" |
| 50 #include "ui/compositor/layer_type.h" | 39 #include "ui/compositor/layer_type.h" |
| 51 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 40 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 52 #include "ui/display/display.h" | 41 #include "ui/display/display.h" |
| 53 #include "ui/display/manager/display_manager.h" | 42 #include "ui/display/manager/display_manager.h" |
| 54 #include "ui/display/screen.h" | 43 #include "ui/display/screen.h" |
| 55 #include "ui/display/test/display_manager_test_api.h" | 44 #include "ui/display/test/display_manager_test_api.h" |
| 56 #include "ui/events/base_event_utils.h" | |
| 57 #include "ui/events/test/event_generator.h" | |
| 58 #include "ui/gfx/geometry/insets.h" | 45 #include "ui/gfx/geometry/insets.h" |
| 59 #include "ui/views/widget/widget.h" | 46 #include "ui/views/widget/widget.h" |
| 60 #include "ui/views/widget/widget_delegate.h" | 47 #include "ui/views/widget/widget_delegate.h" |
| 61 #include "ui/wm/core/window_util.h" | 48 #include "ui/wm/core/window_util.h" |
| 62 | 49 |
| 63 // NOTE: many of these tests use GlobalMinimumSizeLock. This is needed as the | 50 // NOTE: many of these tests use GlobalMinimumSizeLock. This is needed as the |
| 64 // tests assume a minimum size of 0x0. In mash the minimum size, for top-level | 51 // tests assume a minimum size of 0x0. In mash the minimum size, for top-level |
| 65 // windows, is not 0x0, so without this the tests fails. | 52 // windows, is not 0x0, so without this the tests fails. |
| 66 | 53 |
| 67 namespace ash { | 54 namespace ash { |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 | 941 |
| 955 void SetUp() override { | 942 void SetUp() override { |
| 956 AshTestBase::SetUp(); | 943 AshTestBase::SetUp(); |
| 957 UpdateDisplay("800x600"); | 944 UpdateDisplay("800x600"); |
| 958 default_container_ = Shell::GetPrimaryRootWindowController()->GetContainer( | 945 default_container_ = Shell::GetPrimaryRootWindowController()->GetContainer( |
| 959 kShellWindowId_DefaultContainer); | 946 kShellWindowId_DefaultContainer); |
| 960 } | 947 } |
| 961 | 948 |
| 962 // Turn the top window back drop on / off. | 949 // Turn the top window back drop on / off. |
| 963 void ShowTopWindowBackdrop(bool show) { | 950 void ShowTopWindowBackdrop(bool show) { |
| 964 std::unique_ptr<BackdropDelegate> backdrop; | 951 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop; |
| 965 if (show) { | 952 if (show) { |
| 966 backdrop = base::MakeUnique<MaximizeModeBackdropDelegateImpl>(); | 953 backdrop.reset( |
| 954 new WorkspaceBackdropDelegate(WmWindow::Get(default_container_))); |
| 967 } | 955 } |
| 968 GetWorkspaceLayoutManager(default_container_) | 956 GetWorkspaceLayoutManager(default_container_) |
| 969 ->SetBackdropDelegate(std::move(backdrop)); | 957 ->SetMaximizeBackdropDelegate(std::move(backdrop)); |
| 970 // Closing and / or opening can be a delayed operation. | 958 // Closing and / or opening can be a delayed operation. |
| 971 base::RunLoop().RunUntilIdle(); | 959 base::RunLoop().RunUntilIdle(); |
| 972 } | 960 } |
| 973 | 961 |
| 974 // Return the default container. | 962 // Return the default container. |
| 975 aura::Window* default_container() { return default_container_; } | 963 aura::Window* default_container() { return default_container_; } |
| 976 | 964 |
| 977 // Return the order of windows (top most first) as they are in the default | 965 // Return the order of windows (top most first) as they are in the default |
| 978 // container. If the window is visible it will be a big letter, otherwise a | 966 // container. If the window is visible it will be a big letter, otherwise a |
| 979 // small one. The backdrop will be an X and unknown windows will be shown as | 967 // small one. The backdrop will be an X and unknown windows will be shown as |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1001 return result; | 989 return result; |
| 1002 } | 990 } |
| 1003 | 991 |
| 1004 private: | 992 private: |
| 1005 // The default container. | 993 // The default container. |
| 1006 aura::Window* default_container_; | 994 aura::Window* default_container_; |
| 1007 | 995 |
| 1008 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerBackdropTest); | 996 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerBackdropTest); |
| 1009 }; | 997 }; |
| 1010 | 998 |
| 1011 constexpr int kNoSoundKey = -1; | |
| 1012 | |
| 1013 } // namespace | 999 } // namespace |
| 1014 | 1000 |
| 1015 // Check that creating the BackDrop without destroying it does not lead into | 1001 // Check that creating the BackDrop without destroying it does not lead into |
| 1016 // a crash. | 1002 // a crash. |
| 1017 TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) { | 1003 TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) { |
| 1018 ShowTopWindowBackdrop(true); | 1004 ShowTopWindowBackdrop(true); |
| 1019 } | 1005 } |
| 1020 | 1006 |
| 1021 // Verify basic assumptions about the backdrop. | 1007 // Verify basic assumptions about the backdrop. |
| 1022 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { | 1008 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { |
| 1023 // The background widget will be created when there is a window. | 1009 // Create a backdrop and see that there is one window (the backdrop) and |
| 1010 // that the size is the same as the default container as well as that it is |
| 1011 // not visible. |
| 1024 ShowTopWindowBackdrop(true); | 1012 ShowTopWindowBackdrop(true); |
| 1025 ASSERT_EQ(0u, default_container()->children().size()); | 1013 ASSERT_EQ(1U, default_container()->children().size()); |
| 1014 EXPECT_FALSE(default_container()->children()[0]->IsVisible()); |
| 1026 | 1015 |
| 1027 { | 1016 { |
| 1028 // Add a window and make sure that the backdrop is the second child. | 1017 // Add a window and make sure that the backdrop is the second child. |
| 1029 std::unique_ptr<aura::Window> window( | 1018 std::unique_ptr<aura::Window> window( |
| 1030 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 1019 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 1031 window->Show(); | 1020 window->Show(); |
| 1032 ASSERT_EQ(2U, default_container()->children().size()); | 1021 ASSERT_EQ(2U, default_container()->children().size()); |
| 1033 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); | 1022 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); |
| 1034 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); | 1023 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); |
| 1035 EXPECT_EQ(window.get(), default_container()->children()[1]); | 1024 EXPECT_EQ(window.get(), default_container()->children()[1]); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 // Tests that when hidding the shelf, that the backdrop stays fullscreen. | 1091 // Tests that when hidding the shelf, that the backdrop stays fullscreen. |
| 1103 TEST_F(WorkspaceLayoutManagerBackdropTest, | 1092 TEST_F(WorkspaceLayoutManagerBackdropTest, |
| 1104 ShelfVisibilityDoesNotChangesBounds) { | 1093 ShelfVisibilityDoesNotChangesBounds) { |
| 1105 WmShelf* shelf = GetPrimaryShelf(); | 1094 WmShelf* shelf = GetPrimaryShelf(); |
| 1106 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); | 1095 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 1107 ShowTopWindowBackdrop(true); | 1096 ShowTopWindowBackdrop(true); |
| 1108 RunAllPendingInMessageLoop(); | 1097 RunAllPendingInMessageLoop(); |
| 1109 const gfx::Size fullscreen_size = | 1098 const gfx::Size fullscreen_size = |
| 1110 display::Screen::GetScreen()->GetPrimaryDisplay().size(); | 1099 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 1111 | 1100 |
| 1112 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | |
| 1113 window->Show(); | |
| 1114 | |
| 1115 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 1101 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| 1116 | |
| 1117 EXPECT_EQ(fullscreen_size, | 1102 EXPECT_EQ(fullscreen_size, |
| 1118 default_container()->children()[0]->bounds().size()); | 1103 default_container()->children()[0]->bounds().size()); |
| 1119 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1104 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1120 shelf_layout_manager->UpdateVisibilityState(); | 1105 shelf_layout_manager->UpdateVisibilityState(); |
| 1121 | 1106 |
| 1122 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children but | 1107 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children but |
| 1123 // the backdrop. | 1108 // the backdrop. |
| 1124 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1109 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1125 shelf_layout_manager->UpdateVisibilityState(); | 1110 shelf_layout_manager->UpdateVisibilityState(); |
| 1126 EXPECT_EQ(fullscreen_size, | 1111 EXPECT_EQ(fullscreen_size, |
| 1127 default_container()->children()[0]->bounds().size()); | 1112 default_container()->children()[0]->bounds().size()); |
| 1128 | 1113 |
| 1129 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1114 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1130 shelf_layout_manager->UpdateVisibilityState(); | 1115 shelf_layout_manager->UpdateVisibilityState(); |
| 1131 EXPECT_EQ(fullscreen_size, | 1116 EXPECT_EQ(fullscreen_size, |
| 1132 default_container()->children()[0]->bounds().size()); | 1117 default_container()->children()[0]->bounds().size()); |
| 1133 } | 1118 } |
| 1134 | 1119 |
| 1135 TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropTest) { | |
| 1136 WorkspaceController* wc = | |
| 1137 test::ShellTestApi(Shell::Get()).workspace_controller(); | |
| 1138 test::WorkspaceControllerTestApi test_helper(wc); | |
| 1139 | |
| 1140 std::unique_ptr<aura::Window> window1( | |
| 1141 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | |
| 1142 window1->SetName("1"); | |
| 1143 window1->Show(); | |
| 1144 std::unique_ptr<aura::Window> window2( | |
| 1145 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | |
| 1146 window2->SetName("2"); | |
| 1147 window2->Show(); | |
| 1148 std::unique_ptr<aura::Window> window3( | |
| 1149 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | |
| 1150 window3->SetName("3"); | |
| 1151 window3->Show(); | |
| 1152 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1153 | |
| 1154 window2->SetProperty(aura::client::kHasBackdrop, true); | |
| 1155 aura::Window* backdrop = test_helper.GetBackdropWindow(); | |
| 1156 EXPECT_TRUE(backdrop); | |
| 1157 { | |
| 1158 aura::Window::Windows children = window1->parent()->children(); | |
| 1159 EXPECT_EQ(children[0], window1.get()); | |
| 1160 EXPECT_EQ(children[1], backdrop); | |
| 1161 EXPECT_EQ(children[2], window2.get()); | |
| 1162 EXPECT_EQ(children[3], window3.get()); | |
| 1163 } | |
| 1164 | |
| 1165 // Setting the property to the one below the backdrop window shouldn't change | |
| 1166 // the state. | |
| 1167 window1->SetProperty(aura::client::kHasBackdrop, true); | |
| 1168 { | |
| 1169 aura::Window::Windows children = window1->parent()->children(); | |
| 1170 EXPECT_EQ(children[0], window1.get()); | |
| 1171 EXPECT_EQ(children[1], backdrop); | |
| 1172 EXPECT_EQ(children[2], window2.get()); | |
| 1173 EXPECT_EQ(children[3], window3.get()); | |
| 1174 } | |
| 1175 | |
| 1176 // Setting the property to the top will move the backdrop up. | |
| 1177 window3->SetProperty(aura::client::kHasBackdrop, true); | |
| 1178 { | |
| 1179 aura::Window::Windows children = window1->parent()->children(); | |
| 1180 EXPECT_EQ(children[0], window1.get()); | |
| 1181 EXPECT_EQ(children[1], window2.get()); | |
| 1182 EXPECT_EQ(children[2], backdrop); | |
| 1183 EXPECT_EQ(children[3], window3.get()); | |
| 1184 } | |
| 1185 | |
| 1186 // Clearing the property in the middle will not change the backdrop position. | |
| 1187 window2->ClearProperty(aura::client::kHasBackdrop); | |
| 1188 { | |
| 1189 aura::Window::Windows children = window1->parent()->children(); | |
| 1190 EXPECT_EQ(children[0], window1.get()); | |
| 1191 EXPECT_EQ(children[1], window2.get()); | |
| 1192 EXPECT_EQ(children[2], backdrop); | |
| 1193 EXPECT_EQ(children[3], window3.get()); | |
| 1194 } | |
| 1195 | |
| 1196 // Clearing the property on top will move the backdrop to bottom. | |
| 1197 window3->ClearProperty(aura::client::kHasBackdrop); | |
| 1198 { | |
| 1199 aura::Window::Windows children = window1->parent()->children(); | |
| 1200 EXPECT_EQ(children[0], backdrop); | |
| 1201 EXPECT_EQ(children[1], window1.get()); | |
| 1202 EXPECT_EQ(children[2], window2.get()); | |
| 1203 EXPECT_EQ(children[3], window3.get()); | |
| 1204 } | |
| 1205 | |
| 1206 // Toggle overview. | |
| 1207 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1208 RunAllPendingInMessageLoop(); | |
| 1209 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1210 | |
| 1211 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1212 RunAllPendingInMessageLoop(); | |
| 1213 backdrop = test_helper.GetBackdropWindow(); | |
| 1214 EXPECT_TRUE(backdrop); | |
| 1215 { | |
| 1216 aura::Window::Windows children = window1->parent()->children(); | |
| 1217 EXPECT_EQ(children[0], backdrop); | |
| 1218 EXPECT_EQ(children[1], window1.get()); | |
| 1219 EXPECT_EQ(children[2], window2.get()); | |
| 1220 EXPECT_EQ(children[3], window3.get()); | |
| 1221 } | |
| 1222 | |
| 1223 // Enabling the backdrop delegate for maximized mode will put the | |
| 1224 // backdrop on the top most window. | |
| 1225 ShowTopWindowBackdrop(true); | |
| 1226 { | |
| 1227 aura::Window::Windows children = window1->parent()->children(); | |
| 1228 EXPECT_EQ(children[0], window1.get()); | |
| 1229 EXPECT_EQ(children[1], window2.get()); | |
| 1230 EXPECT_EQ(children[2], backdrop); | |
| 1231 EXPECT_EQ(children[3], window3.get()); | |
| 1232 } | |
| 1233 | |
| 1234 // Toggle overview with the delegate. | |
| 1235 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1236 RunAllPendingInMessageLoop(); | |
| 1237 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1238 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1239 RunAllPendingInMessageLoop(); | |
| 1240 backdrop = test_helper.GetBackdropWindow(); | |
| 1241 { | |
| 1242 aura::Window::Windows children = window1->parent()->children(); | |
| 1243 EXPECT_EQ(children[0], window1.get()); | |
| 1244 EXPECT_EQ(children[1], window2.get()); | |
| 1245 EXPECT_EQ(children[2], backdrop); | |
| 1246 EXPECT_EQ(children[3], window3.get()); | |
| 1247 } | |
| 1248 | |
| 1249 // Removing the delegate will move the backdrop back to window1. | |
| 1250 ShowTopWindowBackdrop(false); | |
| 1251 { | |
| 1252 aura::Window::Windows children = window1->parent()->children(); | |
| 1253 EXPECT_EQ(children[0], backdrop); | |
| 1254 EXPECT_EQ(children[1], window1.get()); | |
| 1255 EXPECT_EQ(children[2], window2.get()); | |
| 1256 EXPECT_EQ(children[3], window3.get()); | |
| 1257 } | |
| 1258 } | |
| 1259 | |
| 1260 TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackFullscreenBackground) { | |
| 1261 WorkspaceController* wc = | |
| 1262 test::ShellTestApi(Shell::Get()).workspace_controller(); | |
| 1263 test::WorkspaceControllerTestApi test_helper(wc); | |
| 1264 test::TestAccessibilityDelegate* accessibility_delegate = | |
| 1265 static_cast<test::TestAccessibilityDelegate*>( | |
| 1266 Shell::Get()->accessibility_delegate()); | |
| 1267 | |
| 1268 aura::test::TestWindowDelegate delegate; | |
| 1269 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | |
| 1270 &delegate, 0, gfx::Rect(0, 0, 100, 100))); | |
| 1271 window->Show(); | |
| 1272 | |
| 1273 window->SetProperty(aura::client::kHasBackdrop, true); | |
| 1274 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
| 1275 | |
| 1276 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1277 | |
| 1278 generator.MoveMouseTo(300, 300); | |
| 1279 generator.ClickLeftButton(); | |
| 1280 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1281 | |
| 1282 generator.MoveMouseRelativeTo(window.get(), 10, 10); | |
| 1283 generator.ClickLeftButton(); | |
| 1284 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1285 | |
| 1286 // Enable spoken feedback. | |
| 1287 Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 1288 ash::A11Y_NOTIFICATION_NONE); | |
| 1289 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1290 ash::A11Y_NOTIFICATION_NONE); | |
| 1291 EXPECT_TRUE( | |
| 1292 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()); | |
| 1293 | |
| 1294 generator.MoveMouseTo(300, 300); | |
| 1295 generator.ClickLeftButton(); | |
| 1296 EXPECT_EQ(chromeos::SOUND_VOLUME_ADJUST, | |
| 1297 accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1298 | |
| 1299 generator.MoveMouseRelativeTo(window.get(), 10, 10); | |
| 1300 generator.ClickLeftButton(); | |
| 1301 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1302 | |
| 1303 // Disable spoken feedback. Shadow underlay is restored. | |
| 1304 Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 1305 A11Y_NOTIFICATION_NONE); | |
| 1306 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1307 A11Y_NOTIFICATION_NONE); | |
| 1308 EXPECT_FALSE( | |
| 1309 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()); | |
| 1310 | |
| 1311 generator.MoveMouseTo(300, 300); | |
| 1312 generator.ClickLeftButton(); | |
| 1313 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1314 | |
| 1315 generator.MoveMouseTo(70, 70); | |
| 1316 generator.ClickLeftButton(); | |
| 1317 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1318 } | |
| 1319 | |
| 1320 TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackForArc) { | |
| 1321 WorkspaceController* wc = | |
| 1322 test::ShellTestApi(Shell::Get()).workspace_controller(); | |
| 1323 test::WorkspaceControllerTestApi test_helper(wc); | |
| 1324 test::TestAccessibilityDelegate* accessibility_delegate = | |
| 1325 static_cast<test::TestAccessibilityDelegate*>( | |
| 1326 Shell::Get()->accessibility_delegate()); | |
| 1327 | |
| 1328 accessibility_delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | |
| 1329 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1330 A11Y_NOTIFICATION_NONE); | |
| 1331 EXPECT_TRUE(accessibility_delegate->IsSpokenFeedbackEnabled()); | |
| 1332 | |
| 1333 aura::test::TestWindowDelegate delegate; | |
| 1334 std::unique_ptr<aura::Window> window_arc(CreateTestWindowInShellWithDelegate( | |
| 1335 &delegate, 0, gfx::Rect(0, 0, 100, 100))); | |
| 1336 window_arc->Show(); | |
| 1337 std::unique_ptr<aura::Window> window_nonarc( | |
| 1338 CreateTestWindowInShellWithDelegate(&delegate, 0, | |
| 1339 gfx::Rect(0, 0, 100, 100))); | |
| 1340 window_nonarc->Show(); | |
| 1341 | |
| 1342 window_arc->SetProperty(aura::client::kAppType, | |
| 1343 static_cast<int>(ash::AppType::ARC_APP)); | |
| 1344 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1345 | |
| 1346 // ARC window will have a backdrop only when it's active. | |
| 1347 wm::ActivateWindow(window_arc.get()); | |
| 1348 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
| 1349 | |
| 1350 wm::ActivateWindow(window_nonarc.get()); | |
| 1351 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1352 | |
| 1353 wm::ActivateWindow(window_arc.get()); | |
| 1354 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
| 1355 | |
| 1356 // Make sure that clicking the backdrop window will play sound. | |
| 1357 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1358 generator.MoveMouseTo(300, 300); | |
| 1359 generator.ClickLeftButton(); | |
| 1360 EXPECT_EQ(chromeos::SOUND_VOLUME_ADJUST, | |
| 1361 accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1362 | |
| 1363 generator.MoveMouseTo(70, 70); | |
| 1364 generator.ClickLeftButton(); | |
| 1365 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1366 } | |
| 1367 | |
| 1368 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { | 1120 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { |
| 1369 public: | 1121 public: |
| 1370 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} | 1122 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} |
| 1371 ~WorkspaceLayoutManagerKeyboardTest() override {} | 1123 ~WorkspaceLayoutManagerKeyboardTest() override {} |
| 1372 | 1124 |
| 1373 void SetUp() override { | 1125 void SetUp() override { |
| 1374 AshTestBase::SetUp(); | 1126 AshTestBase::SetUp(); |
| 1375 UpdateDisplay("800x600"); | 1127 UpdateDisplay("800x600"); |
| 1376 aura::Window* default_container = | 1128 aura::Window* default_container = |
| 1377 Shell::GetPrimaryRootWindowController()->GetContainer( | 1129 Shell::GetPrimaryRootWindowController()->GetContainer( |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 window->SetBounds(keyboard_bounds()); | 1267 window->SetBounds(keyboard_bounds()); |
| 1516 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); | 1268 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); |
| 1517 wm::ActivateWindow(window.get()); | 1269 wm::ActivateWindow(window.get()); |
| 1518 | 1270 |
| 1519 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1271 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1520 ShowKeyboard(); | 1272 ShowKeyboard(); |
| 1521 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1273 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1522 } | 1274 } |
| 1523 | 1275 |
| 1524 } // namespace ash | 1276 } // namespace ash |
| OLD | NEW |