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" |
| 15 #include "ash/shelf/shelf_constants.h" | 16 #include "ash/shelf/shelf_constants.h" |
| 16 #include "ash/shelf/shelf_layout_manager.h" | 17 #include "ash/shelf/shelf_layout_manager.h" |
| 17 #include "ash/shelf/wm_shelf.h" | 18 #include "ash/shelf/wm_shelf.h" |
| 18 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 19 #include "ash/shell_observer.h" | 20 #include "ash/shell_observer.h" |
| 20 #include "ash/shell_port.h" | 21 #include "ash/shell_port.h" |
| 22 #include "ash/system/tray/system_tray_notifier.h" | |
| 21 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
| 24 #include "ash/test/shell_test_api.h" | |
| 25 #include "ash/test/test_accessibility_delegate.h" | |
| 22 #include "ash/test/test_session_controller_client.h" | 26 #include "ash/test/test_session_controller_client.h" |
| 23 #include "ash/test/wm_window_test_api.h" | 27 #include "ash/test/wm_window_test_api.h" |
| 28 #include "ash/test/workspace_controller_test_api.h" | |
| 24 #include "ash/wm/fullscreen_window_finder.h" | 29 #include "ash/wm/fullscreen_window_finder.h" |
| 25 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" | 30 #include "ash/wm/maximize_mode/maximize_mode_backdrop_delegate_impl.h" |
| 31 #include "ash/wm/overview/window_selector_controller.h" | |
| 26 #include "ash/wm/window_state.h" | 32 #include "ash/wm/window_state.h" |
| 27 #include "ash/wm/window_state_aura.h" | 33 #include "ash/wm/window_state_aura.h" |
| 28 #include "ash/wm/window_util.h" | 34 #include "ash/wm/window_util.h" |
| 29 #include "ash/wm/wm_event.h" | 35 #include "ash/wm/wm_event.h" |
| 36 #include "ash/wm/workspace/backdrop_delegate.h" | |
| 30 #include "ash/wm/workspace/workspace_window_resizer.h" | 37 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 31 #include "ash/wm_window.h" | 38 #include "ash/wm_window.h" |
| 32 #include "base/command_line.h" | 39 #include "base/command_line.h" |
| 33 #include "base/run_loop.h" | 40 #include "base/run_loop.h" |
| 41 #include "chromeos/audio/chromeos_sounds.h" | |
| 34 #include "ui/aura/client/aura_constants.h" | 42 #include "ui/aura/client/aura_constants.h" |
| 35 #include "ui/aura/client/focus_client.h" | 43 #include "ui/aura/client/focus_client.h" |
| 44 #include "ui/aura/test/test_window_delegate.h" | |
| 36 #include "ui/aura/window.h" | 45 #include "ui/aura/window.h" |
| 46 #include "ui/aura/window_targeter.h" | |
| 37 #include "ui/base/ui_base_switches.h" | 47 #include "ui/base/ui_base_switches.h" |
| 38 #include "ui/base/ui_base_types.h" | 48 #include "ui/base/ui_base_types.h" |
| 39 #include "ui/compositor/layer_type.h" | 49 #include "ui/compositor/layer_type.h" |
| 40 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 50 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 41 #include "ui/display/display.h" | 51 #include "ui/display/display.h" |
| 42 #include "ui/display/manager/display_manager.h" | 52 #include "ui/display/manager/display_manager.h" |
| 43 #include "ui/display/screen.h" | 53 #include "ui/display/screen.h" |
| 44 #include "ui/display/test/display_manager_test_api.h" | 54 #include "ui/display/test/display_manager_test_api.h" |
| 55 #include "ui/events/base_event_utils.h" | |
| 56 #include "ui/events/test/event_generator.h" | |
| 45 #include "ui/gfx/geometry/insets.h" | 57 #include "ui/gfx/geometry/insets.h" |
| 46 #include "ui/views/widget/widget.h" | 58 #include "ui/views/widget/widget.h" |
| 47 #include "ui/views/widget/widget_delegate.h" | 59 #include "ui/views/widget/widget_delegate.h" |
| 48 #include "ui/wm/core/window_util.h" | 60 #include "ui/wm/core/window_util.h" |
| 49 | 61 |
| 50 // NOTE: many of these tests use GlobalMinimumSizeLock. This is needed as the | 62 // 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 | 63 // 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. | 64 // windows, is not 0x0, so without this the tests fails. |
| 53 | 65 |
| 54 namespace ash { | 66 namespace ash { |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 | 953 |
| 942 void SetUp() override { | 954 void SetUp() override { |
| 943 AshTestBase::SetUp(); | 955 AshTestBase::SetUp(); |
| 944 UpdateDisplay("800x600"); | 956 UpdateDisplay("800x600"); |
| 945 default_container_ = Shell::GetPrimaryRootWindowController()->GetContainer( | 957 default_container_ = Shell::GetPrimaryRootWindowController()->GetContainer( |
| 946 kShellWindowId_DefaultContainer); | 958 kShellWindowId_DefaultContainer); |
| 947 } | 959 } |
| 948 | 960 |
| 949 // Turn the top window back drop on / off. | 961 // Turn the top window back drop on / off. |
| 950 void ShowTopWindowBackdrop(bool show) { | 962 void ShowTopWindowBackdrop(bool show) { |
| 951 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop; | 963 std::unique_ptr<BackdropDelegate> backdrop; |
| 952 if (show) { | 964 if (show) { |
| 953 backdrop.reset( | 965 backdrop = base::MakeUnique<MaximizeModeBackdropDelegateImpl>(); |
| 954 new WorkspaceBackdropDelegate(WmWindow::Get(default_container_))); | |
| 955 } | 966 } |
| 956 GetWorkspaceLayoutManager(default_container_) | 967 GetWorkspaceLayoutManager(default_container_) |
| 957 ->SetMaximizeBackdropDelegate(std::move(backdrop)); | 968 ->SetBackdropDelegate(std::move(backdrop)); |
| 958 // Closing and / or opening can be a delayed operation. | 969 // Closing and / or opening can be a delayed operation. |
| 959 base::RunLoop().RunUntilIdle(); | 970 base::RunLoop().RunUntilIdle(); |
| 960 } | 971 } |
| 961 | 972 |
| 962 // Return the default container. | 973 // Return the default container. |
| 963 aura::Window* default_container() { return default_container_; } | 974 aura::Window* default_container() { return default_container_; } |
| 964 | 975 |
| 965 // Return the order of windows (top most first) as they are in the default | 976 // 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 | 977 // 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 | 978 // small one. The backdrop will be an X and unknown windows will be shown as |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 } // namespace | 1010 } // namespace |
| 1000 | 1011 |
| 1001 // Check that creating the BackDrop without destroying it does not lead into | 1012 // Check that creating the BackDrop without destroying it does not lead into |
| 1002 // a crash. | 1013 // a crash. |
| 1003 TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) { | 1014 TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) { |
| 1004 ShowTopWindowBackdrop(true); | 1015 ShowTopWindowBackdrop(true); |
| 1005 } | 1016 } |
| 1006 | 1017 |
| 1007 // Verify basic assumptions about the backdrop. | 1018 // Verify basic assumptions about the backdrop. |
| 1008 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { | 1019 TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) { |
| 1009 // Create a backdrop and see that there is one window (the backdrop) and | 1020 // THe background widget will be created when there is a window. |
|
James Cook
2017/05/15 21:57:39
nit: THe -> The
oshima
2017/05/16 08:22:09
Done.
| |
| 1010 // that the size is the same as the default container as well as that it is | |
| 1011 // not visible. | |
| 1012 ShowTopWindowBackdrop(true); | 1021 ShowTopWindowBackdrop(true); |
| 1013 ASSERT_EQ(1U, default_container()->children().size()); | 1022 ASSERT_EQ(0U, default_container()->children().size()); |
|
James Cook
2017/05/15 21:57:39
super-nit: 0u
oshima
2017/05/16 08:22:09
Done.
| |
| 1014 EXPECT_FALSE(default_container()->children()[0]->IsVisible()); | |
| 1015 | 1023 |
| 1016 { | 1024 { |
| 1017 // Add a window and make sure that the backdrop is the second child. | 1025 // Add a window and make sure that the backdrop is the second child. |
| 1018 std::unique_ptr<aura::Window> window( | 1026 std::unique_ptr<aura::Window> window( |
| 1019 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | 1027 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); |
| 1020 window->Show(); | 1028 window->Show(); |
| 1021 ASSERT_EQ(2U, default_container()->children().size()); | 1029 ASSERT_EQ(2U, default_container()->children().size()); |
| 1022 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); | 1030 EXPECT_TRUE(default_container()->children()[0]->IsVisible()); |
| 1023 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); | 1031 EXPECT_TRUE(default_container()->children()[1]->IsVisible()); |
| 1024 EXPECT_EQ(window.get(), default_container()->children()[1]); | 1032 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. | 1099 // Tests that when hidding the shelf, that the backdrop stays fullscreen. |
| 1092 TEST_F(WorkspaceLayoutManagerBackdropTest, | 1100 TEST_F(WorkspaceLayoutManagerBackdropTest, |
| 1093 ShelfVisibilityDoesNotChangesBounds) { | 1101 ShelfVisibilityDoesNotChangesBounds) { |
| 1094 WmShelf* shelf = GetPrimaryShelf(); | 1102 WmShelf* shelf = GetPrimaryShelf(); |
| 1095 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); | 1103 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 1096 ShowTopWindowBackdrop(true); | 1104 ShowTopWindowBackdrop(true); |
| 1097 RunAllPendingInMessageLoop(); | 1105 RunAllPendingInMessageLoop(); |
| 1098 const gfx::Size fullscreen_size = | 1106 const gfx::Size fullscreen_size = |
| 1099 display::Screen::GetScreen()->GetPrimaryDisplay().size(); | 1107 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 1100 | 1108 |
| 1109 std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); | |
| 1110 window->Show(); | |
| 1111 | |
| 1101 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 1112 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
| 1113 | |
| 1102 EXPECT_EQ(fullscreen_size, | 1114 EXPECT_EQ(fullscreen_size, |
| 1103 default_container()->children()[0]->bounds().size()); | 1115 default_container()->children()[0]->bounds().size()); |
| 1104 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1116 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1105 shelf_layout_manager->UpdateVisibilityState(); | 1117 shelf_layout_manager->UpdateVisibilityState(); |
| 1106 | 1118 |
| 1107 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children but | 1119 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children but |
| 1108 // the backdrop. | 1120 // the backdrop. |
| 1109 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1121 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1110 shelf_layout_manager->UpdateVisibilityState(); | 1122 shelf_layout_manager->UpdateVisibilityState(); |
| 1111 EXPECT_EQ(fullscreen_size, | 1123 EXPECT_EQ(fullscreen_size, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 // which alters the supplied bounds. | 1278 // which alters the supplied bounds. |
| 1267 window->SetBounds(keyboard_bounds()); | 1279 window->SetBounds(keyboard_bounds()); |
| 1268 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); | 1280 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); |
| 1269 wm::ActivateWindow(window.get()); | 1281 wm::ActivateWindow(window.get()); |
| 1270 | 1282 |
| 1271 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1283 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1272 ShowKeyboard(); | 1284 ShowKeyboard(); |
| 1273 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1285 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1274 } | 1286 } |
| 1275 | 1287 |
| 1288 TEST_F(WorkspaceLayoutManagerKeyboardTest, BackdropTest) { | |
|
James Cook
2017/05/15 21:57:39
Can you either move the backdrop tests to someplac
oshima
2017/05/16 08:22:09
This test already have tests for backdrop, and I'm
| |
| 1289 WorkspaceController* wc = | |
| 1290 test::ShellTestApi(Shell::Get()).workspace_controller(); | |
| 1291 test::WorkspaceControllerTestApi test_helper(wc); | |
| 1292 | |
| 1293 std::unique_ptr<aura::Window> window1( | |
| 1294 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | |
| 1295 window1->SetName("1"); | |
| 1296 window1->Show(); | |
| 1297 std::unique_ptr<aura::Window> window2( | |
| 1298 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | |
| 1299 window2->SetName("2"); | |
| 1300 window2->Show(); | |
| 1301 std::unique_ptr<aura::Window> window3( | |
| 1302 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | |
| 1303 window3->SetName("3"); | |
| 1304 window3->Show(); | |
| 1305 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1306 | |
| 1307 window2->SetProperty(aura::client::kHasBackdrop, true); | |
| 1308 aura::Window* backdrop = test_helper.GetBackdropWindow(); | |
| 1309 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
|
James Cook
2017/05/15 21:57:39
EXPECT_TRUE(backdrop)
oshima
2017/05/16 08:22:09
Done.
| |
| 1310 { | |
| 1311 aura::Window::Windows children = window1->parent()->children(); | |
| 1312 EXPECT_EQ(children[0], window1.get()); | |
| 1313 EXPECT_EQ(children[1], backdrop); | |
| 1314 EXPECT_EQ(children[2], window2.get()); | |
| 1315 EXPECT_EQ(children[3], window3.get()); | |
| 1316 } | |
| 1317 | |
| 1318 // Setting the property to the one below the backdrop window shouldn't change | |
| 1319 // the state. | |
| 1320 window1->SetProperty(aura::client::kHasBackdrop, true); | |
| 1321 { | |
| 1322 aura::Window::Windows children = window1->parent()->children(); | |
| 1323 EXPECT_EQ(children[0], window1.get()); | |
| 1324 EXPECT_EQ(children[1], backdrop); | |
| 1325 EXPECT_EQ(children[2], window2.get()); | |
| 1326 EXPECT_EQ(children[3], window3.get()); | |
| 1327 } | |
| 1328 | |
| 1329 // Setting the property to the top will move the backdrop up. | |
| 1330 window3->SetProperty(aura::client::kHasBackdrop, true); | |
| 1331 { | |
| 1332 aura::Window::Windows children = window1->parent()->children(); | |
| 1333 EXPECT_EQ(children[0], window1.get()); | |
| 1334 EXPECT_EQ(children[1], window2.get()); | |
| 1335 EXPECT_EQ(children[2], backdrop); | |
| 1336 EXPECT_EQ(children[3], window3.get()); | |
| 1337 } | |
| 1338 | |
| 1339 // Claring the property in the middle will not change the backdrop position. | |
|
James Cook
2017/05/15 21:57:39
Clearing
oshima
2017/05/16 08:22:09
Done.
| |
| 1340 window2->ClearProperty(aura::client::kHasBackdrop); | |
| 1341 { | |
| 1342 aura::Window::Windows children = window1->parent()->children(); | |
| 1343 EXPECT_EQ(children[0], window1.get()); | |
| 1344 EXPECT_EQ(children[1], window2.get()); | |
| 1345 EXPECT_EQ(children[2], backdrop); | |
| 1346 EXPECT_EQ(children[3], window3.get()); | |
| 1347 } | |
| 1348 | |
| 1349 // Claring the property on tpo will move the backdrop to bottom. | |
|
James Cook
2017/05/15 21:57:40
ditto, and tpo -> top
oshima
2017/05/16 08:22:09
Done.
| |
| 1350 window3->ClearProperty(aura::client::kHasBackdrop); | |
| 1351 { | |
| 1352 aura::Window::Windows children = window1->parent()->children(); | |
| 1353 EXPECT_EQ(children[0], backdrop); | |
| 1354 EXPECT_EQ(children[1], window1.get()); | |
| 1355 EXPECT_EQ(children[2], window2.get()); | |
| 1356 EXPECT_EQ(children[3], window3.get()); | |
| 1357 } | |
| 1358 | |
| 1359 // Toggle overview | |
|
James Cook
2017/05/15 21:57:39
super nit: end with .
oshima
2017/05/16 08:22:09
Done.
| |
| 1360 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1361 RunAllPendingInMessageLoop(); | |
| 1362 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1363 | |
| 1364 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1365 RunAllPendingInMessageLoop(); | |
| 1366 backdrop = test_helper.GetBackdropWindow(); | |
| 1367 EXPECT_TRUE(backdrop); | |
| 1368 { | |
| 1369 aura::Window::Windows children = window1->parent()->children(); | |
| 1370 EXPECT_EQ(children[0], backdrop); | |
| 1371 EXPECT_EQ(children[1], window1.get()); | |
| 1372 EXPECT_EQ(children[2], window2.get()); | |
| 1373 EXPECT_EQ(children[3], window3.get()); | |
| 1374 } | |
| 1375 | |
| 1376 wc->SetBackdropDelegate(base::MakeUnique<MaximizeModeBackdropDelegateImpl>()); | |
|
James Cook
2017/05/15 21:57:39
nit: Comment what you're testing here.
oshima
2017/05/16 08:22:09
Done.
| |
| 1377 { | |
| 1378 aura::Window::Windows children = window1->parent()->children(); | |
| 1379 EXPECT_EQ(children[0], window1.get()); | |
| 1380 EXPECT_EQ(children[1], window2.get()); | |
| 1381 EXPECT_EQ(children[2], backdrop); | |
| 1382 EXPECT_EQ(children[3], window3.get()); | |
| 1383 } | |
| 1384 | |
| 1385 // Toggle overview with the delegate | |
|
James Cook
2017/05/15 21:57:39
super nit: end with .
oshima
2017/05/16 08:22:09
Done.
| |
| 1386 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1387 RunAllPendingInMessageLoop(); | |
| 1388 EXPECT_FALSE(test_helper.GetBackdropWindow()); | |
| 1389 Shell::Get()->window_selector_controller()->ToggleOverview(); | |
| 1390 RunAllPendingInMessageLoop(); | |
| 1391 backdrop = test_helper.GetBackdropWindow(); | |
| 1392 { | |
| 1393 aura::Window::Windows children = window1->parent()->children(); | |
| 1394 EXPECT_EQ(children[0], window1.get()); | |
| 1395 EXPECT_EQ(children[1], window2.get()); | |
| 1396 EXPECT_EQ(children[2], backdrop); | |
| 1397 EXPECT_EQ(children[3], window3.get()); | |
| 1398 } | |
| 1399 | |
| 1400 // Removing the delegate will move the backdrop back to window1. | |
| 1401 std::unique_ptr<BackdropDelegate> no_delegate; | |
| 1402 wc->SetBackdropDelegate(std::move(no_delegate)); | |
| 1403 { | |
| 1404 aura::Window::Windows children = window1->parent()->children(); | |
| 1405 EXPECT_EQ(children[0], backdrop); | |
| 1406 EXPECT_EQ(children[1], window1.get()); | |
| 1407 EXPECT_EQ(children[2], window2.get()); | |
| 1408 EXPECT_EQ(children[3], window3.get()); | |
| 1409 } | |
| 1410 } | |
| 1411 | |
| 1412 TEST_F(WorkspaceLayoutManagerKeyboardTest, SpokenFeedbackFullscreenBackground) { | |
| 1413 constexpr int kNoSoundKey = -1; | |
| 1414 | |
| 1415 WorkspaceController* wc = | |
| 1416 test::ShellTestApi(Shell::Get()).workspace_controller(); | |
| 1417 test::WorkspaceControllerTestApi test_helper(wc); | |
| 1418 test::TestAccessibilityDelegate* accessibility_delegate = | |
| 1419 static_cast<test::TestAccessibilityDelegate*>( | |
| 1420 Shell::Get()->accessibility_delegate()); | |
| 1421 | |
| 1422 aura::test::TestWindowDelegate delegate; | |
| 1423 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( | |
| 1424 &delegate, 0, gfx::Rect(0, 0, 100, 100))); | |
| 1425 window->Show(); | |
| 1426 | |
| 1427 window->SetProperty(aura::client::kHasBackdrop, true); | |
| 1428 EXPECT_TRUE(test_helper.GetBackdropWindow()); | |
| 1429 | |
| 1430 ui::test::EventGenerator& generator = GetEventGenerator(); | |
| 1431 | |
| 1432 generator.MoveMouseTo(300, 300); | |
| 1433 generator.ClickLeftButton(); | |
| 1434 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1435 | |
| 1436 generator.MoveMouseRelativeTo(window.get(), 10, 10); | |
| 1437 generator.ClickLeftButton(); | |
| 1438 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1439 | |
| 1440 // Enable spoken feedback. | |
| 1441 Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 1442 ash::A11Y_NOTIFICATION_NONE); | |
| 1443 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1444 ash::A11Y_NOTIFICATION_NONE); | |
| 1445 EXPECT_TRUE( | |
| 1446 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()); | |
| 1447 | |
| 1448 generator.MoveMouseTo(300, 300); | |
| 1449 generator.ClickLeftButton(); | |
| 1450 EXPECT_EQ(chromeos::SOUND_VOLUME_ADJUST, | |
| 1451 accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1452 | |
| 1453 generator.MoveMouseRelativeTo(window.get(), 10, 10); | |
| 1454 generator.ClickLeftButton(); | |
| 1455 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1456 | |
| 1457 // Disable spoken feedback. Shadow underlay is restored. | |
| 1458 Shell::Get()->accessibility_delegate()->ToggleSpokenFeedback( | |
| 1459 A11Y_NOTIFICATION_NONE); | |
| 1460 Shell::Get()->system_tray_notifier()->NotifyAccessibilityModeChanged( | |
| 1461 A11Y_NOTIFICATION_NONE); | |
| 1462 EXPECT_FALSE( | |
| 1463 Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled()); | |
| 1464 | |
| 1465 generator.MoveMouseTo(300, 300); | |
| 1466 generator.ClickLeftButton(); | |
| 1467 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1468 | |
| 1469 generator.MoveMouseTo(70, 70); | |
| 1470 generator.ClickLeftButton(); | |
| 1471 EXPECT_EQ(kNoSoundKey, accessibility_delegate->GetPlayedEarconAndReset()); | |
| 1472 } | |
|
James Cook
2017/05/15 21:57:39
Thanks for adding the test coverage!
| |
| 1473 | |
| 1276 } // namespace ash | 1474 } // namespace ash |
| OLD | NEW |