[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 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 | |
James Cook | d333292 | 2018-03-09 15:54:13 | [diff] [blame] | 5 | #include "ash/accessibility/touch_exploration_manager.h" |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 6 | |
Qiang Xu | 9e12fa76 | 2017-12-19 03:27:49 | [diff] [blame] | 7 | #include "ash/accessibility/accessibility_controller.h" |
| 8 | #include "ash/accessibility/test_accessibility_controller_client.h" |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 9 | #include "ash/root_window_controller.h" |
| 10 | #include "ash/shell.h" |
| 11 | #include "ash/test/ash_test_base.h" |
| 12 | #include "chromeos/audio/cras_audio_handler.h" |
Qiang Xu | c4b0575 | 2018-02-13 20:10:28 | [diff] [blame] | 13 | #include "ui/accessibility/ax_enums.mojom.h" |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 14 | |
| 15 | namespace ash { |
| 16 | |
James Cook | d333292 | 2018-03-09 15:54:13 | [diff] [blame] | 17 | using TouchExplorationManagerTest = AshTestBase; |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 18 | |
James Cook | d333292 | 2018-03-09 15:54:13 | [diff] [blame] | 19 | TEST_F(TouchExplorationManagerTest, AdjustSound) { |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 20 | RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
James Cook | d333292 | 2018-03-09 15:54:13 | [diff] [blame] | 21 | TouchExplorationManager touch_exploration_manager(controller); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 22 | chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get(); |
[email protected] | 7d48759 | 2014-07-24 03:54:50 | [diff] [blame] | 23 | |
| 24 | touch_exploration_manager.SetOutputLevel(10); |
| 25 | EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 10); |
| 26 | EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 27 | |
| 28 | touch_exploration_manager.SetOutputLevel(100); |
| 29 | EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 100); |
| 30 | EXPECT_FALSE(audio_handler->IsOutputMuted()); |
| 31 | |
| 32 | touch_exploration_manager.SetOutputLevel(0); |
| 33 | EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0); |
| 34 | EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 35 | |
| 36 | touch_exploration_manager.SetOutputLevel(-10); |
| 37 | EXPECT_EQ(audio_handler->GetOutputVolumePercent(), 0); |
| 38 | EXPECT_TRUE(audio_handler->IsOutputMuted()); |
| 39 | } |
| 40 | |
James Cook | d333292 | 2018-03-09 15:54:13 | [diff] [blame] | 41 | TEST_F(TouchExplorationManagerTest, HandleAccessibilityGesture) { |
Qiang Xu | 9e12fa76 | 2017-12-19 03:27:49 | [diff] [blame] | 42 | RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
James Cook | d333292 | 2018-03-09 15:54:13 | [diff] [blame] | 43 | TouchExplorationManager touch_exploration_manager(controller); |
Qiang Xu | 9e12fa76 | 2017-12-19 03:27:49 | [diff] [blame] | 44 | AccessibilityController* a11y_controller = |
| 45 | Shell::Get()->accessibility_controller(); |
| 46 | TestAccessibilityControllerClient client; |
| 47 | a11y_controller->SetClient(client.CreateInterfacePtrAndBind()); |
| 48 | |
Dominic Mazzoni | dcef1b73 | 2018-01-26 17:57:04 | [diff] [blame] | 49 | touch_exploration_manager.HandleAccessibilityGesture( |
| 50 | ax::mojom::Gesture::kClick); |
Qiang Xu | 9e12fa76 | 2017-12-19 03:27:49 | [diff] [blame] | 51 | a11y_controller->FlushMojoForTest(); |
Qiang Xu | c4b0575 | 2018-02-13 20:10:28 | [diff] [blame] | 52 | EXPECT_EQ(ax::mojom::Gesture::kClick, client.last_a11y_gesture()); |
Qiang Xu | 9e12fa76 | 2017-12-19 03:27:49 | [diff] [blame] | 53 | |
| 54 | touch_exploration_manager.HandleAccessibilityGesture( |
Dominic Mazzoni | dcef1b73 | 2018-01-26 17:57:04 | [diff] [blame] | 55 | ax::mojom::Gesture::kSwipeLeft1); |
Qiang Xu | 9e12fa76 | 2017-12-19 03:27:49 | [diff] [blame] | 56 | a11y_controller->FlushMojoForTest(); |
Qiang Xu | c4b0575 | 2018-02-13 20:10:28 | [diff] [blame] | 57 | EXPECT_EQ(ax::mojom::Gesture::kSwipeLeft1, client.last_a11y_gesture()); |
Qiang Xu | 9e12fa76 | 2017-12-19 03:27:49 | [diff] [blame] | 58 | } |
| 59 | |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 60 | } // namespace ash |