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> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/ptr_util.h" |
11 #include "chromeos/audio/audio_device.h" | 13 #include "chromeos/audio/audio_device.h" |
12 #include "chromeos/audio/audio_devices_pref_handler.h" | 14 #include "chromeos/audio/audio_devices_pref_handler.h" |
13 #include "chromeos/audio/cras_audio_handler.h" | 15 #include "chromeos/audio/cras_audio_handler.h" |
14 #include "chromeos/dbus/audio_node.h" | 16 #include "chromeos/dbus/audio_node.h" |
15 #include "chromeos/dbus/dbus_thread_manager.h" | 17 #include "chromeos/dbus/dbus_thread_manager.h" |
16 #include "chromeos/dbus/fake_cras_audio_client.h" | 18 #include "chromeos/dbus/fake_cras_audio_client.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 | 20 |
19 using chromeos::AudioDevice; | 21 using chromeos::AudioDevice; |
20 using chromeos::AudioNode; | 22 using chromeos::AudioNode; |
21 using chromeos::AudioNodeList; | 23 using chromeos::AudioNodeList; |
22 | 24 |
23 namespace extensions { | 25 namespace extensions { |
24 | 26 |
25 class ShellAudioControllerTest : public testing::Test { | 27 class ShellAudioControllerTest : public testing::Test { |
26 public: | 28 public: |
27 ShellAudioControllerTest() : next_node_id_(1) { | 29 ShellAudioControllerTest() : next_node_id_(1) { |
28 // This also initializes DBusThreadManager. | 30 // This also initializes DBusThreadManager. |
29 scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = | 31 std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = |
30 chromeos::DBusThreadManager::GetSetterForTesting(); | 32 chromeos::DBusThreadManager::GetSetterForTesting(); |
31 | 33 |
32 audio_client_ = new chromeos::FakeCrasAudioClient(); | 34 audio_client_ = new chromeos::FakeCrasAudioClient(); |
33 audio_client_->SetAudioNodesForTesting(AudioNodeList()); | 35 audio_client_->SetAudioNodesForTesting(AudioNodeList()); |
34 dbus_setter->SetCrasAudioClient(make_scoped_ptr(audio_client_)); | 36 dbus_setter->SetCrasAudioClient(base::WrapUnique(audio_client_)); |
35 | 37 |
36 chromeos::CrasAudioHandler::InitializeForTesting(); | 38 chromeos::CrasAudioHandler::InitializeForTesting(); |
37 audio_handler_ = chromeos::CrasAudioHandler::Get(); | 39 audio_handler_ = chromeos::CrasAudioHandler::Get(); |
38 | 40 |
39 controller_.reset(new ShellAudioController()); | 41 controller_.reset(new ShellAudioController()); |
40 } | 42 } |
41 | 43 |
42 ~ShellAudioControllerTest() override { | 44 ~ShellAudioControllerTest() override { |
43 controller_.reset(); | 45 controller_.reset(); |
44 chromeos::CrasAudioHandler::Shutdown(); | 46 chromeos::CrasAudioHandler::Shutdown(); |
(...skipping 20 matching lines...) Expand all Loading... |
65 if (it->id == id) { | 67 if (it->id == id) { |
66 it->active = active; | 68 it->active = active; |
67 return; | 69 return; |
68 } | 70 } |
69 } | 71 } |
70 ASSERT_TRUE(false) << "Didn't find ID " << id; | 72 ASSERT_TRUE(false) << "Didn't find ID " << id; |
71 } | 73 } |
72 | 74 |
73 chromeos::FakeCrasAudioClient* audio_client_; // Not owned. | 75 chromeos::FakeCrasAudioClient* audio_client_; // Not owned. |
74 chromeos::CrasAudioHandler* audio_handler_; // Not owned. | 76 chromeos::CrasAudioHandler* audio_handler_; // Not owned. |
75 scoped_ptr<ShellAudioController> controller_; | 77 std::unique_ptr<ShellAudioController> controller_; |
76 | 78 |
77 // Next audio node ID to be returned by CreateNode(). | 79 // Next audio node ID to be returned by CreateNode(). |
78 uint64_t next_node_id_; | 80 uint64_t next_node_id_; |
79 | 81 |
80 private: | 82 private: |
81 DISALLOW_COPY_AND_ASSIGN(ShellAudioControllerTest); | 83 DISALLOW_COPY_AND_ASSIGN(ShellAudioControllerTest); |
82 }; | 84 }; |
83 | 85 |
84 // Tests that higher-priority devices are activated as soon as they're | 86 // Tests that higher-priority devices are activated as soon as they're |
85 // connected. | 87 // connected. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 EXPECT_FALSE(audio_handler_->IsInputMuted()); | 133 EXPECT_FALSE(audio_handler_->IsInputMuted()); |
132 EXPECT_EQ(static_cast<double>( | 134 EXPECT_EQ(static_cast<double>( |
133 chromeos::AudioDevicesPrefHandler::kDefaultOutputVolumePercent), | 135 chromeos::AudioDevicesPrefHandler::kDefaultOutputVolumePercent), |
134 audio_handler_->GetOutputVolumePercent()); | 136 audio_handler_->GetOutputVolumePercent()); |
135 | 137 |
136 // TODO(rkc): The default value for gain is wrong. http://crbug.com/442489 | 138 // TODO(rkc): The default value for gain is wrong. http://crbug.com/442489 |
137 EXPECT_EQ(75.0, audio_handler_->GetInputGainPercent()); | 139 EXPECT_EQ(75.0, audio_handler_->GetInputGainPercent()); |
138 } | 140 } |
139 | 141 |
140 } // namespace extensions | 142 } // namespace extensions |
OLD | NEW |