Chromium Code Reviews| 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 // Clearning the property in the middle will not change the backdrop position. | |
|
James Cook
2017/05/16 15:12:15
Clearing
oshima
2017/05/17 07:44:34
Done.
| |
| 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 // Clearning 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 wc->SetBackdropDelegate(base::MakeUnique<MaximizeModeBackdropDelegateImpl>()); | |
| 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 std::unique_ptr<BackdropDelegate> no_delegate; | |
| 1251 wc->SetBackdropDelegate(std::move(no_delegate)); | |
| 1252 { | |
| 1253 aura::Window::Windows children = window1->parent()->children(); | |
| 1254 EXPECT_EQ(children[0], backdrop); | |
| 1255 EXPECT_EQ(children[1], window1.get()); | |
| 1256 EXPECT_EQ(children[2], window2.get()); | |
| 1257 EXPECT_EQ(children[3], window3.get()); | |
| 1258 } | |
| 1259 } | |
| 1260 | |
| 1261 TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackFullscreenBackground) { | |
| 1262 WorkspaceController* wc = | |
| 1263 test::ShellTestApi(Shell::Get()).workspace_controller(); | |
| 1264 test::WorkspaceControllerTestApi test_helper(wc); | |
| 1265 test::TestAccessibilityDelegate* accessibility_delegate = | |
| 1266 static_cast<test::TestAccessibilityDelegate*>( | |
| 1267 Shell::Get()->accessibility_delegate()); | |
| 1268 | |
| 1269 aura::test::TestWindowDelegate delegate; | |
| 1270 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | |
| 1271 &delegate, 0, gfx::Rect(0, 0, 100, 100))); | |
| 1272 window->Show(); | |
| 1273 | |
| 1274 window->SetProperty(aura::client::kHasBackdrop, true); | |
| 1275 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
| 1276 | |
| 1277 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1278 | |
| 1279 generator.MoveMouseTo(300, 300); | |
| 1280 generator.ClickLeftButton(); | |
| 1281 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1282 | |
| 1283 generator.MoveMouseRelativeTo(window.get(), 10, 10); | |
| 1284 generator.ClickLeftButton(); | |
| 1285 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1286 | |
| 1287 // Enable spoken feedback. | |
| 1288 Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 1289 ash::A11Y_NOTIFICATION_NONE); | |
| 1290 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1291 ash::A11Y_NOTIFICATION_NONE); | |
| 1292 EXPECT_TRUE( | |
| 1293 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()); | |
| 1294 | |
| 1295 generator.MoveMouseTo(300, 300); | |
| 1296 generator.ClickLeftButton(); | |
| 1297 EXPECT_EQ(chromeos::SOUND_VOLUME_ADJUST, | |
| 1298 accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1299 | |
| 1300 generator.MoveMouseRelativeTo(window.get(), 10, 10); | |
| 1301 generator.ClickLeftButton(); | |
| 1302 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1303 | |
| 1304 // Disable spoken feedback. Shadow underlay is restored. | |
| 1305 Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 1306 A11Y_NOTIFICATION_NONE); | |
| 1307 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1308 A11Y_NOTIFICATION_NONE); | |
| 1309 EXPECT_FALSE( | |
| 1310 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()); | |
| 1311 | |
| 1312 generator.MoveMouseTo(300, 300); | |
| 1313 generator.ClickLeftButton(); | |
| 1314 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1315 | |
| 1316 generator.MoveMouseTo(70, 70); | |
| 1317 generator.ClickLeftButton(); | |
| 1318 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1319 } | |
| 1320 | |
| 1321 TEST_F(WorkspaceLayoutManagerBackdropTest, SpokenFeedbackForArc) { | |
| 1322 WorkspaceController* wc = | |
| 1323 test::ShellTestApi(Shell::Get()).workspace_controller(); | |
| 1324 test::WorkspaceControllerTestApi test_helper(wc); | |
| 1325 test::TestAccessibilityDelegate* accessibility_delegate = | |
| 1326 static_cast<test::TestAccessibilityDelegate*>( | |
| 1327 Shell::Get()->accessibility_delegate()); | |
| 1328 | |
| 1329 accessibility_delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | |
| 1330 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1331 A11Y_NOTIFICATION_NONE); | |
| 1332 EXPECT_TRUE(accessibility_delegate->IsSpokenFeedbackEnabled()); | |
| 1333 | |
| 1334 aura::test::TestWindowDelegate delegate; | |
| 1335 std::unique_ptr<aura::Window> window_arc(CreateTestWindowInShellWithDelegate( | |
| 1336 &delegate, 0, gfx::Rect(0, 0, 100, 100))); | |
| 1337 window_arc->Show(); | |
| 1338 std::unique_ptr<aura::Window> window_nonarc( | |
| 1339 CreateTestWindowInShellWithDelegate(&delegate, 0, | |
| 1340 gfx::Rect(0, 0, 100, 100))); | |
| 1341 window_nonarc->Show(); | |
| 1342 | |
| 1343 window_arc->SetProperty(aura::client::kAppType, | |
| 1344 static_cast<int>(ash::AppType::ARC_APP)); | |
| 1345 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1346 | |
| 1347 // ARC window will have a backdrop only when it's active. | |
| 1348 wm::ActivateWindow(window_arc.get()); | |
| 1349 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
| 1350 | |
| 1351 wm::ActivateWindow(window_nonarc.get()); | |
| 1352 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1353 | |
| 1354 wm::ActivateWindow(window_arc.get()); | |
| 1355 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
| 1356 | |
| 1357 // Make sure that clicking the backdrop window will play sound. | |
| 1358 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1359 generator.MoveMouseTo(300, 300); | |
| 1360 generator.ClickLeftButton(); | |
| 1361 EXPECT_EQ(chromeos::SOUND_VOLUME_ADJUST, | |
| 1362 accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1363 | |
| 1364 generator.MoveMouseTo(70, 70); | |
| 1365 generator.ClickLeftButton(); | |
| 1366 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1367 } | |
| 1368 | |
| 1120 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { | 1369 class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase { |
| 1121 public: | 1370 public: |
| 1122 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} | 1371 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} |
| 1123 ~WorkspaceLayoutManagerKeyboardTest() override {} | 1372 ~WorkspaceLayoutManagerKeyboardTest() override {} |
| 1124 | 1373 |
| 1125 void SetUp() override { | 1374 void SetUp() override { |
| 1126 AshTestBase::SetUp(); | 1375 AshTestBase::SetUp(); |
| 1127 UpdateDisplay("800x600"); | 1376 UpdateDisplay("800x600"); |
| 1128 aura::Window* default_container = | 1377 aura::Window* default_container = |
| 1129 Shell::GetPrimaryRootWindowController()->GetContainer( | 1378 Shell::GetPrimaryRootWindowController()->GetContainer( |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1267 window->SetBounds(keyboard_bounds()); | 1516 window->SetBounds(keyboard_bounds()); |
| 1268 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); | 1517 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); |
| 1269 wm::ActivateWindow(window.get()); | 1518 wm::ActivateWindow(window.get()); |
| 1270 | 1519 |
| 1271 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1520 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1272 ShowKeyboard(); | 1521 ShowKeyboard(); |
| 1273 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1522 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1274 } | 1523 } |
| 1275 | 1524 |
| 1276 } // namespace ash | 1525 } // namespace ash |
| OLD | NEW |