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
5 #include "ash/accessibility/touch_exploration_manager.h"
6
7 #include "ash/accessibility/test_accessibility_controller_client.h"
8 #include "ash/root_window_controller.h"
9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h"
11 #include "chromeos/audio/cras_audio_handler.h"
12 #include "ui/accessibility/ax_enums.mojom.h"
13
14 namespace ash {
15
16 using TouchExplorationManagerTest = AshTestBase;
17
TEST_F(TouchExplorationManagerTest,AdjustSound)18 TEST_F(TouchExplorationManagerTest, AdjustSound) {
19 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
20 TouchExplorationManager touch_exploration_manager(controller);
21 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get();
22
23 touch_exploration_manager.SetOutputLevel(10);
24 EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 10);
25 EXPECT_FALSE(audio_handler->IsOutputMuted());
26
27 touch_exploration_manager.SetOutputLevel(100);
28 EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 100);
29 EXPECT_FALSE(audio_handler->IsOutputMuted());
30
31 touch_exploration_manager.SetOutputLevel(0);
32 EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0);
33 EXPECT_TRUE(audio_handler->IsOutputMuted());
34
35 touch_exploration_manager.SetOutputLevel(-10);
36 EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0);
37 EXPECT_TRUE(audio_handler->IsOutputMuted());
38 }
39
TEST_F(TouchExplorationManagerTest,HandleAccessibilityGesture)40 TEST_F(TouchExplorationManagerTest, HandleAccessibilityGesture) {
41 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
42 TouchExplorationManager touch_exploration_manager(controller);
43 TestAccessibilityControllerClient client;
44
45 touch_exploration_manager.HandleAccessibilityGesture(
46 ax::mojom::Gesture::kClick, gfx::PointF());
47 EXPECT_EQ(ax::mojom::Gesture::kClick, client.last_a11y_gesture());
48
49 touch_exploration_manager.HandleAccessibilityGesture(
50 ax::mojom::Gesture::kSwipeLeft1, gfx::PointF());
51 EXPECT_EQ(ax::mojom::Gesture::kSwipeLeft1, client.last_a11y_gesture());
52 }
53
54 } // namespace ash
55