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 "base/macros.h" | 7 #include "base/macros.h" |
8 #include "chromeos/audio/audio_device.h" | 8 #include "chromeos/audio/audio_device.h" |
9 #include "chromeos/audio/cras_audio_handler.h" | 9 #include "chromeos/audio/cras_audio_handler.h" |
10 #include "chromeos/dbus/audio_node.h" | 10 #include "chromeos/dbus/audio_node.h" |
11 #include "chromeos/dbus/cras_audio_client_stub_impl.h" | |
12 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
| 12 #include "chromeos/dbus/fake_cras_audio_client.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using chromeos::AudioDevice; | 15 using chromeos::AudioDevice; |
16 using chromeos::AudioNode; | 16 using chromeos::AudioNode; |
17 using chromeos::AudioNodeList; | 17 using chromeos::AudioNodeList; |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 class ShellAudioControllerTest : public testing::Test { | 21 class ShellAudioControllerTest : public testing::Test { |
22 public: | 22 public: |
23 ShellAudioControllerTest() : next_node_id_(1) { | 23 ShellAudioControllerTest() : next_node_id_(1) { |
24 // This also initializes DBusThreadManager. | 24 // This also initializes DBusThreadManager. |
25 scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = | 25 scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter = |
26 chromeos::DBusThreadManager::GetSetterForTesting(); | 26 chromeos::DBusThreadManager::GetSetterForTesting(); |
27 | 27 |
28 audio_client_ = new chromeos::CrasAudioClientStubImpl(); | 28 audio_client_ = new chromeos::FakeCrasAudioClient(); |
29 audio_client_->SetAudioNodesForTesting(AudioNodeList()); | 29 audio_client_->SetAudioNodesForTesting(AudioNodeList()); |
30 dbus_setter->SetCrasAudioClient(make_scoped_ptr(audio_client_)); | 30 dbus_setter->SetCrasAudioClient(make_scoped_ptr(audio_client_)); |
31 | 31 |
32 chromeos::CrasAudioHandler::Initialize( | 32 chromeos::CrasAudioHandler::Initialize( |
33 new ShellAudioController::PrefHandler()); | 33 new ShellAudioController::PrefHandler()); |
34 audio_handler_ = chromeos::CrasAudioHandler::Get(); | 34 audio_handler_ = chromeos::CrasAudioHandler::Get(); |
35 | 35 |
36 controller_.reset(new ShellAudioController()); | 36 controller_.reset(new ShellAudioController()); |
37 } | 37 } |
38 | 38 |
(...skipping 21 matching lines...) Expand all Loading... |
60 for (AudioNodeList::iterator it = nodes->begin(); | 60 for (AudioNodeList::iterator it = nodes->begin(); |
61 it != nodes->end(); ++it) { | 61 it != nodes->end(); ++it) { |
62 if (it->id == id) { | 62 if (it->id == id) { |
63 it->active = active; | 63 it->active = active; |
64 return; | 64 return; |
65 } | 65 } |
66 } | 66 } |
67 ASSERT_TRUE(false) << "Didn't find ID " << id; | 67 ASSERT_TRUE(false) << "Didn't find ID " << id; |
68 } | 68 } |
69 | 69 |
70 chromeos::CrasAudioClientStubImpl* audio_client_; // Not owned. | 70 chromeos::FakeCrasAudioClient* audio_client_; // Not owned. |
71 chromeos::CrasAudioHandler* audio_handler_; // Not owned. | 71 chromeos::CrasAudioHandler* audio_handler_; // Not owned. |
72 scoped_ptr<ShellAudioController> controller_; | 72 scoped_ptr<ShellAudioController> controller_; |
73 | 73 |
74 // Next audio node ID to be returned by CreateNode(). | 74 // Next audio node ID to be returned by CreateNode(). |
75 uint64 next_node_id_; | 75 uint64 next_node_id_; |
76 | 76 |
77 private: | 77 private: |
78 DISALLOW_COPY_AND_ASSIGN(ShellAudioControllerTest); | 78 DISALLOW_COPY_AND_ASSIGN(ShellAudioControllerTest); |
79 }; | 79 }; |
80 | 80 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 nodes.push_back(CreateNode(chromeos::AUDIO_TYPE_INTERNAL_MIC)); | 124 nodes.push_back(CreateNode(chromeos::AUDIO_TYPE_INTERNAL_MIC)); |
125 audio_client_->SetAudioNodesAndNotifyObserversForTesting(nodes); | 125 audio_client_->SetAudioNodesAndNotifyObserversForTesting(nodes); |
126 | 126 |
127 EXPECT_FALSE(audio_handler_->IsOutputMuted()); | 127 EXPECT_FALSE(audio_handler_->IsOutputMuted()); |
128 EXPECT_FALSE(audio_handler_->IsInputMuted()); | 128 EXPECT_FALSE(audio_handler_->IsInputMuted()); |
129 EXPECT_EQ(100, audio_handler_->GetOutputVolumePercent()); | 129 EXPECT_EQ(100, audio_handler_->GetOutputVolumePercent()); |
130 EXPECT_EQ(100, audio_handler_->GetInputGainPercent()); | 130 EXPECT_EQ(100, audio_handler_->GetInputGainPercent()); |
131 } | 131 } |
132 | 132 |
133 } // namespace extensions | 133 } // namespace extensions |
OLD | NEW |