blob: 3263aa738e4c9bdf3776bd33b4610a71584568af [file] [log] [blame]
[email protected]7d487592014-07-24 03:54:501// 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 Cookd3332922018-03-09 15:54:135#include "ash/accessibility/touch_exploration_manager.h"
[email protected]7d487592014-07-24 03:54:506
Qiang Xu9e12fa762017-12-19 03:27:497#include "ash/accessibility/accessibility_controller.h"
8#include "ash/accessibility/test_accessibility_controller_client.h"
[email protected]7d487592014-07-24 03:54:509#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 Xuc4b05752018-02-13 20:10:2813#include "ui/accessibility/ax_enums.mojom.h"
[email protected]7d487592014-07-24 03:54:5014
15namespace ash {
16
James Cookd3332922018-03-09 15:54:1317using TouchExplorationManagerTest = AshTestBase;
[email protected]7d487592014-07-24 03:54:5018
James Cookd3332922018-03-09 15:54:1319TEST_F(TouchExplorationManagerTest, AdjustSound) {
[email protected]7d487592014-07-24 03:54:5020 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
James Cookd3332922018-03-09 15:54:1321 TouchExplorationManager touch_exploration_manager(controller);
jamescookb8dcef522016-06-25 14:42:5522 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get();
[email protected]7d487592014-07-24 03:54:5023
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 Cookd3332922018-03-09 15:54:1341TEST_F(TouchExplorationManagerTest, HandleAccessibilityGesture) {
Qiang Xu9e12fa762017-12-19 03:27:4942 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
James Cookd3332922018-03-09 15:54:1343 TouchExplorationManager touch_exploration_manager(controller);
Qiang Xu9e12fa762017-12-19 03:27:4944 AccessibilityController* a11y_controller =
45 Shell::Get()->accessibility_controller();
46 TestAccessibilityControllerClient client;
47 a11y_controller->SetClient(client.CreateInterfacePtrAndBind());
48
Dominic Mazzonidcef1b732018-01-26 17:57:0449 touch_exploration_manager.HandleAccessibilityGesture(
50 ax::mojom::Gesture::kClick);
Qiang Xu9e12fa762017-12-19 03:27:4951 a11y_controller->FlushMojoForTest();
Qiang Xuc4b05752018-02-13 20:10:2852 EXPECT_EQ(ax::mojom::Gesture::kClick, client.last_a11y_gesture());
Qiang Xu9e12fa762017-12-19 03:27:4953
54 touch_exploration_manager.HandleAccessibilityGesture(
Dominic Mazzonidcef1b732018-01-26 17:57:0455 ax::mojom::Gesture::kSwipeLeft1);
Qiang Xu9e12fa762017-12-19 03:27:4956 a11y_controller->FlushMojoForTest();
Qiang Xuc4b05752018-02-13 20:10:2857 EXPECT_EQ(ax::mojom::Gesture::kSwipeLeft1, client.last_a11y_gesture());
Qiang Xu9e12fa762017-12-19 03:27:4958}
59
jamescookb8dcef522016-06-25 14:42:5560} // namespace ash