OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "extensions/shell/browser/shell_audio_controller_chromeos.h" | 5 #include "extensions/shell/browser/shell_audio_controller_chromeos.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "chromeos/audio/audio_device.h" | 10 #include "chromeos/audio/audio_device.h" |
9 #include "chromeos/audio/audio_devices_pref_handler.h" | 11 #include "chromeos/audio/audio_devices_pref_handler.h" |
10 #include "chromeos/audio/cras_audio_handler.h" | 12 #include "chromeos/audio/cras_audio_handler.h" |
11 #include "chromeos/dbus/audio_node.h" | 13 #include "chromeos/dbus/audio_node.h" |
12 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
13 #include "chromeos/dbus/fake_cras_audio_client.h" | 15 #include "chromeos/dbus/fake_cras_audio_client.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
15 | 17 |
16 using chromeos::AudioDevice; | 18 using chromeos::AudioDevice; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 node.is_input = | 51 node.is_input = |
50 type == chromeos::AUDIO_TYPE_MIC || | 52 type == chromeos::AUDIO_TYPE_MIC || |
51 type == chromeos::AUDIO_TYPE_INTERNAL_MIC || | 53 type == chromeos::AUDIO_TYPE_INTERNAL_MIC || |
52 type == chromeos::AUDIO_TYPE_KEYBOARD_MIC; | 54 type == chromeos::AUDIO_TYPE_KEYBOARD_MIC; |
53 node.id = next_node_id_++; | 55 node.id = next_node_id_++; |
54 node.type = AudioDevice::GetTypeString(type); | 56 node.type = AudioDevice::GetTypeString(type); |
55 return node; | 57 return node; |
56 } | 58 } |
57 | 59 |
58 // Changes the active state of the node with |id| in |nodes|. | 60 // Changes the active state of the node with |id| in |nodes|. |
59 void SetNodeActive(AudioNodeList* nodes, uint64 id, bool active) { | 61 void SetNodeActive(AudioNodeList* nodes, uint64_t id, bool active) { |
60 for (AudioNodeList::iterator it = nodes->begin(); | 62 for (AudioNodeList::iterator it = nodes->begin(); |
61 it != nodes->end(); ++it) { | 63 it != nodes->end(); ++it) { |
62 if (it->id == id) { | 64 if (it->id == id) { |
63 it->active = active; | 65 it->active = active; |
64 return; | 66 return; |
65 } | 67 } |
66 } | 68 } |
67 ASSERT_TRUE(false) << "Didn't find ID " << id; | 69 ASSERT_TRUE(false) << "Didn't find ID " << id; |
68 } | 70 } |
69 | 71 |
70 chromeos::FakeCrasAudioClient* audio_client_; // Not owned. | 72 chromeos::FakeCrasAudioClient* audio_client_; // Not owned. |
71 chromeos::CrasAudioHandler* audio_handler_; // Not owned. | 73 chromeos::CrasAudioHandler* audio_handler_; // Not owned. |
72 scoped_ptr<ShellAudioController> controller_; | 74 scoped_ptr<ShellAudioController> controller_; |
73 | 75 |
74 // Next audio node ID to be returned by CreateNode(). | 76 // Next audio node ID to be returned by CreateNode(). |
75 uint64 next_node_id_; | 77 uint64_t next_node_id_; |
76 | 78 |
77 private: | 79 private: |
78 DISALLOW_COPY_AND_ASSIGN(ShellAudioControllerTest); | 80 DISALLOW_COPY_AND_ASSIGN(ShellAudioControllerTest); |
79 }; | 81 }; |
80 | 82 |
81 // Tests that higher-priority devices are activated as soon as they're | 83 // Tests that higher-priority devices are activated as soon as they're |
82 // connected. | 84 // connected. |
83 TEST_F(ShellAudioControllerTest, SelectBestDevices) { | 85 TEST_F(ShellAudioControllerTest, SelectBestDevices) { |
84 AudioNode internal_speaker = | 86 AudioNode internal_speaker = |
85 CreateNode(chromeos::AUDIO_TYPE_INTERNAL_SPEAKER); | 87 CreateNode(chromeos::AUDIO_TYPE_INTERNAL_SPEAKER); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 EXPECT_FALSE(audio_handler_->IsInputMuted()); | 130 EXPECT_FALSE(audio_handler_->IsInputMuted()); |
129 EXPECT_EQ(static_cast<double>( | 131 EXPECT_EQ(static_cast<double>( |
130 chromeos::AudioDevicesPrefHandler::kDefaultOutputVolumePercent), | 132 chromeos::AudioDevicesPrefHandler::kDefaultOutputVolumePercent), |
131 audio_handler_->GetOutputVolumePercent()); | 133 audio_handler_->GetOutputVolumePercent()); |
132 | 134 |
133 // TODO(rkc): The default value for gain is wrong. http://crbug.com/442489 | 135 // TODO(rkc): The default value for gain is wrong. http://crbug.com/442489 |
134 EXPECT_EQ(75.0, audio_handler_->GetInputGainPercent()); | 136 EXPECT_EQ(75.0, audio_handler_->GetInputGainPercent()); |
135 } | 137 } |
136 | 138 |
137 } // namespace extensions | 139 } // namespace extensions |
OLD | NEW |