| 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" |
| 10 #include "ash/public/cpp/config.h" | 11 #include "ash/public/cpp/config.h" |
| 11 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
| 12 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 13 #include "ash/screen_util.h" | 14 #include "ash/screen_util.h" |
| 14 #include "ash/session/session_controller.h" | 15 #include "ash/session/session_controller.h" |
| 16 #include "ash/shared/app_types.h" |
| 15 #include "ash/shelf/shelf_constants.h" | 17 #include "ash/shelf/shelf_constants.h" |
| 16 #include "ash/shelf/shelf_layout_manager.h" | 18 #include "ash/shelf/shelf_layout_manager.h" |
| 17 #include "ash/shelf/wm_shelf.h" | 19 #include "ash/shelf/wm_shelf.h" |
| 18 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 19 #include "ash/shell_observer.h" | 21 #include "ash/shell_observer.h" |
| 20 #include "ash/shell_port.h" | 22 #include "ash/shell_port.h" |
| 23 #include "ash/system/tray/system_tray_notifier.h" |
| 21 #include "ash/test/ash_test_base.h" | 24 #include "ash/test/ash_test_base.h" |
| 25 #include "ash/test/shell_test_api.h" |
| 26 #include "ash/test/test_accessibility_delegate.h" |
| 22 #include "ash/test/test_session_controller_client.h" | 27 #include "ash/test/test_session_controller_client.h" |
| 23 #include "ash/test/wm_window_test_api.h" | 28 #include "ash/test/wm_window_test_api.h" |
| 29 #include "ash/test/workspace_controller_test_api.h" |
| 24 #include "ash/wm/fullscreen_window_finder.h" | 30 #include "ash/wm/fullscreen_window_finder.h" |
| 25 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" | 31 #include "ash/wm/maximize_mode/maximize_mode_backdrop_delegate_impl.h" |
| 32 #include "ash/wm/overview/window_selector_controller.h" |
| 26 #include "ash/wm/window_state.h" | 33 #include "ash/wm/window_state.h" |
| 27 #include "ash/wm/window_state_aura.h" | 34 #include "ash/wm/window_state_aura.h" |
| 28 #include "ash/wm/window_util.h" | 35 #include "ash/wm/window_util.h" |
| 29 #include "ash/wm/wm_event.h" | 36 #include "ash/wm/wm_event.h" |
| 37 #include "ash/wm/workspace/backdrop_delegate.h" |
| 30 #include "ash/wm/workspace/workspace_window_resizer.h" | 38 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 31 #include "ash/wm_window.h" | 39 #include "ash/wm_window.h" |
| 32 #include "base/command_line.h" | 40 #include "base/command_line.h" |
| 33 #include "base/run_loop.h" | 41 #include "base/run_loop.h" |
| 42 #include "chromeos/audio/chromeos_sounds.h" |
| 34 #include "ui/aura/client/aura_constants.h" | 43 #include "ui/aura/client/aura_constants.h" |
| 35 #include "ui/aura/client/focus_client.h" | 44 #include "ui/aura/client/focus_client.h" |
| 45 #include "ui/aura/test/test_window_delegate.h" |
| 36 #include "ui/aura/window.h" | 46 #include "ui/aura/window.h" |
| 47 #include "ui/aura/window_targeter.h" |
| 37 #include "ui/base/ui_base_switches.h" | 48 #include "ui/base/ui_base_switches.h" |
| 38 #include "ui/base/ui_base_types.h" | 49 #include "ui/base/ui_base_types.h" |
| 39 #include "ui/compositor/layer_type.h" | 50 #include "ui/compositor/layer_type.h" |
| 40 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 51 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 41 #include "ui/display/display.h" | 52 #include "ui/display/display.h" |
| 42 #include "ui/display/manager/display_manager.h" | 53 #include "ui/display/manager/display_manager.h" |
| 43 #include "ui/display/screen.h" | 54 #include "ui/display/screen.h" |
| 44 #include "ui/display/test/display_manager_test_api.h" | 55 #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" |
| 45 #include "ui/gfx/geometry/insets.h" | 58 #include "ui/gfx/geometry/insets.h" |
| 46 #include "ui/views/widget/widget.h" | 59 #include "ui/views/widget/widget.h" |
| 47 #include "ui/views/widget/widget_delegate.h" | 60 #include "ui/views/widget/widget_delegate.h" |
| 48 #include "ui/wm/core/window_util.h" | 61 #include "ui/wm/core/window_util.h" |
| 49 | 62 |
| 50 // NOTE: many of these tests use GlobalMinimumSizeLock. This is needed as the | 63 // NOTE: many of these tests use GlobalMinimumSizeLock. This is needed as the |
| 51 // tests assume a minimum size of 0x0. In mash the minimum size, for top-level | 64 // tests assume a minimum size of 0x0. In mash the minimum size, for top-level |
| 52 // windows, is not 0x0, so without this the tests fails. | 65 // windows, is not 0x0, so without this the tests fails. |
| 53 | 66 |
| 54 namespace ash { | 67 namespace ash { |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 954 |
| 942 void SetUp() override { | 955 void SetUp() override { |
| 943 AshTestBase::SetUp(); | 956 AshTestBase::SetUp(); |
| 944 UpdateDisplay("800x600"); | 957 UpdateDisplay("800x600"); |
| 945 default_container_ = Shell::GetPrimaryRootWindowController()->GetContainer( | 958 default_container_ = Shell::GetPrimaryRootWindowController()->GetContainer( |
| 946 kShellWindowId_DefaultContainer); | 959 kShellWindowId_DefaultContainer); |
| 947 } | 960 } |
| 948 | 961 |
| 949 // Turn the top window back drop on / off. | 962 // Turn the top window back drop on / off. |
| 950 void ShowTopWindowBackdrop(bool show) { | 963 void ShowTopWindowBackdrop(bool show) { |
| 951 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop; | 964 std::unique_ptr<BackdropDelegate> backdrop; |
| 952 if (show) { | 965 if (show) { |
| 953 backdrop.reset( | 966 backdrop = base::MakeUnique<MaximizeModeBackdropDelegateImpl>(); |
| 954 new WorkspaceBackdropDelegate(WmWindow::Get(default_container_))); | |
| 955 } | 967 } |
| 956 GetWorkspaceLayoutManager(default_container_) | 968 GetWorkspaceLayoutManager(default_container_) |
| 957 ->SetMaximizeBackdropDelegate(std::move(backdrop)); | 969 ->SetBackdropDelegate(std::move(backdrop)); |
| 958 // Closing and / or opening can be a delayed operation. | 970 // Closing and / or opening can be a delayed operation. |
| 959 base::RunLoop().RunUntilIdle(); | 971 base::RunLoop().RunUntilIdle(); |
| 960 } | 972 } |
| 961 | 973 |
| 962 // Return the default container. | 974 // Return the default container. |
| 963 aura::Window* default_container() { return default_container_; } | 975 aura::Window* default_container() { return default_container_; } |
| 964 | 976 |
| 965 // Return the order of windows (top most first) as they are in the default | 977 // Return the order of windows (top most first) as they are in the default |
| 966 // container. If the window is visible it will be a big letter, otherwise a | 978 // container. If the window is visible it will be a big letter, otherwise a |
| 967 // small one. The backdrop will be an X and unknown windows will be shown as | 979 // small one. The backdrop will be an X and unknown windows will be shown as |
| (...skipping 21 matching lines...) Expand all Loading... |
| 989 return result; | 1001 return result; |
| 990 } | 1002 } |
| 991 | 1003 |
| 992 private: | 1004 private: |
| 993 // The default container. | 1005 // The default container. |
| 994 aura::Window* default_container_; | 1006 aura::Window* default_container_; |
| 995 | 1007 |
| 996 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerBackdropTest); | 1008 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerBackdropTest); |
| 997 }; | 1009 }; |
| 998 | 1010 |
| 1011 constexpr int kNoSoundKey = -1; |
| 1012 |
| 999 } // namespace | 1013 } // namespace |
| 1000 | 1014 |
| 1001 // Check that creating the BackDrop without destroying it does not lead into | 1015 // Check that creating the BackDrop without destroying it does not lead into |
| 1002 // a crash. | 1016 // a crash. |
| 1003 TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) { | 1017 TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) { |
| 1004 ShowTopWindowBackdrop(true); | 1018 ShowTopWindowBackdrop(true); |
| 1005 } | 1019 } |
| 1006 | 1020 |
| 1007 // Verify basic assumptions about the backdrop. | 1021 // Verify basic assumptions about the backdrop. |
| 1008 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { | 1022 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { |
| 1009 // Create a backdrop and see that there is one window (the backdrop) and | 1023 // The background widget will be created when there is a window. |
| 1010 // that the size is the same as the default container as well as that it is | |
| 1011 // not visible. | |
| 1012 ShowTopWindowBackdrop(true); | 1024 ShowTopWindowBackdrop(true); |
| 1013 ASSERT_EQ(1U, default_container()->children().size()); | 1025 ASSERT_EQ(0u, default_container()->children().size()); |
| 1014 EXPECT_FALSE(default_container()->children()[0]->IsVisible()); | |
| 1015 | 1026 |
| 1016 { | 1027 { |
| 1017 // Add a window and make sure that the backdrop is the second child. | 1028 // Add a window and make sure that the backdrop is the second child. |
| 1018 std::unique_ptr<aura::Window> window( | 1029 std::unique_ptr<aura::Window> window( |
| 1019 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 1030 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 1020 window->Show(); | 1031 window->Show(); |
| 1021 ASSERT_EQ(2U, default_container()->children().size()); | 1032 ASSERT_EQ(2U, default_container()->children().size()); |
| 1022 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); | 1033 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); |
| 1023 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); | 1034 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); |
| 1024 EXPECT_EQ(window.get(), default_container()->children()[1]); | 1035 EXPECT_EQ(window.get(), default_container()->children()[1]); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 // Tests that when hidding the shelf, that the backdrop stays fullscreen. | 1102 // Tests that when hidding the shelf, that the backdrop stays fullscreen. |
| 1092 TEST_F(WorkspaceLayoutManagerBackdropTest, | 1103 TEST_F(WorkspaceLayoutManagerBackdropTest, |
| 1093 ShelfVisibilityDoesNotChangesBounds) { | 1104 ShelfVisibilityDoesNotChangesBounds) { |
| 1094 WmShelf* shelf = GetPrimaryShelf(); | 1105 WmShelf* shelf = GetPrimaryShelf(); |
| 1095 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); | 1106 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 1096 ShowTopWindowBackdrop(true); | 1107 ShowTopWindowBackdrop(true); |
| 1097 RunAllPendingInMessageLoop(); | 1108 RunAllPendingInMessageLoop(); |
| 1098 const gfx::Size fullscreen_size = | 1109 const gfx::Size fullscreen_size = |
| 1099 display::Screen::GetScreen()->GetPrimaryDisplay().size(); | 1110 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 1100 | 1111 |
| 1112 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 1113 window->Show(); |
| 1114 |
| 1101 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 1115 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| 1116 |
| 1102 EXPECT_EQ(fullscreen_size, | 1117 EXPECT_EQ(fullscreen_size, |
| 1103 default_container()->children()[0]->bounds().size()); | 1118 default_container()->children()[0]->bounds().size()); |
| 1104 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1119 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1105 shelf_layout_manager->UpdateVisibilityState(); | 1120 shelf_layout_manager->UpdateVisibilityState(); |
| 1106 | 1121 |
| 1107 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children but | 1122 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children but |
| 1108 // the backdrop. | 1123 // the backdrop. |
| 1109 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1124 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1110 shelf_layout_manager->UpdateVisibilityState(); | 1125 shelf_layout_manager->UpdateVisibilityState(); |
| 1111 EXPECT_EQ(fullscreen_size, | 1126 EXPECT_EQ(fullscreen_size, |
| 1112 default_container()->children()[0]->bounds().size()); | 1127 default_container()->children()[0]->bounds().size()); |
| 1113 | 1128 |
| 1114 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1129 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1115 shelf_layout_manager->UpdateVisibilityState(); | 1130 shelf_layout_manager->UpdateVisibilityState(); |
| 1116 EXPECT_EQ(fullscreen_size, | 1131 EXPECT_EQ(fullscreen_size, |
| 1117 default_container()->children()[0]->bounds().size()); | 1132 default_container()->children()[0]->bounds().size()); |
| 1118 } | 1133 } |
| 1119 | 1134 |
| 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 |
| 1120 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { | 1368 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { |
| 1121 public: | 1369 public: |
| 1122 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} | 1370 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} |
| 1123 ~WorkspaceLayoutManagerKeyboardTest() override {} | 1371 ~WorkspaceLayoutManagerKeyboardTest() override {} |
| 1124 | 1372 |
| 1125 void SetUp() override { | 1373 void SetUp() override { |
| 1126 AshTestBase::SetUp(); | 1374 AshTestBase::SetUp(); |
| 1127 UpdateDisplay("800x600"); | 1375 UpdateDisplay("800x600"); |
| 1128 aura::Window* default_container = | 1376 aura::Window* default_container = |
| 1129 Shell::GetPrimaryRootWindowController()->GetContainer( | 1377 Shell::GetPrimaryRootWindowController()->GetContainer( |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 window->SetBounds(keyboard_bounds()); | 1515 window->SetBounds(keyboard_bounds()); |
| 1268 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); | 1516 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); |
| 1269 wm::ActivateWindow(window.get()); | 1517 wm::ActivateWindow(window.get()); |
| 1270 | 1518 |
| 1271 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1519 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1272 ShowKeyboard(); | 1520 ShowKeyboard(); |
| 1273 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1521 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1274 } | 1522 } |
| 1275 | 1523 |
| 1276 } // namespace ash | 1524 } // namespace ash |
| OLD | NEW |