touch_exploration_manager_unittest.cc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/accessibility/chromevox/touch_exploration_manager.h"
  5. #include "ash/accessibility/test_accessibility_controller_client.h"
  6. #include "ash/root_window_controller.h"
  7. #include "ash/shell.h"
  8. #include "ash/test/ash_test_base.h"
  9. #include "chromeos/ash/components/audio/cras_audio_handler.h"
  10. #include "ui/accessibility/ax_enums.mojom.h"
  11. namespace ash {
  12. using TouchExplorationManagerTest = AshTestBase;
  13. TEST_F(TouchExplorationManagerTest, AdjustSound) {
  14. RootWindowController* controller = Shell::GetPrimaryRootWindowController();
  15. TouchExplorationManager touch_exploration_manager(controller);
  16. auto* audio_handler = CrasAudioHandler::Get();
  17. touch_exploration_manager.SetOutputLevel(10);
  18. EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 10);
  19. EXPECT_FALSE(audio_handler->IsOutputMuted());
  20. touch_exploration_manager.SetOutputLevel(100);
  21. EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 100);
  22. EXPECT_FALSE(audio_handler->IsOutputMuted());
  23. touch_exploration_manager.SetOutputLevel(0);
  24. EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0);
  25. EXPECT_TRUE(audio_handler->IsOutputMuted());
  26. touch_exploration_manager.SetOutputLevel(-10);
  27. EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0);
  28. EXPECT_TRUE(audio_handler->IsOutputMuted());
  29. }
  30. TEST_F(TouchExplorationManagerTest, HandleAccessibilityGesture) {
  31. RootWindowController* controller = Shell::GetPrimaryRootWindowController();
  32. TouchExplorationManager touch_exploration_manager(controller);
  33. TestAccessibilityControllerClient client;
  34. touch_exploration_manager.HandleAccessibilityGesture(
  35. ax::mojom::Gesture::kClick, gfx::PointF());
  36. EXPECT_EQ(ax::mojom::Gesture::kClick, client.last_a11y_gesture());
  37. touch_exploration_manager.HandleAccessibilityGesture(
  38. ax::mojom::Gesture::kSwipeLeft1, gfx::PointF());
  39. EXPECT_EQ(ax::mojom::Gesture::kSwipeLeft1, client.last_a11y_gesture());
  40. }
  41. } // namespace ash