Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 const uint64_t kJabraSpeaker2StableDeviceId = 80002; | 33 const uint64_t kJabraSpeaker2StableDeviceId = 80002; |
| 34 const uint64_t kHDMIOutputId = 30003; | 34 const uint64_t kHDMIOutputId = 30003; |
| 35 const uint64_t kHDMIOutputStabeDevicelId = 80003; | 35 const uint64_t kHDMIOutputStabeDevicelId = 80003; |
| 36 const uint64_t kJabraMic1Id = 40001; | 36 const uint64_t kJabraMic1Id = 40001; |
| 37 const uint64_t kJabraMic1StableDeviceId = 90001; | 37 const uint64_t kJabraMic1StableDeviceId = 90001; |
| 38 const uint64_t kJabraMic2Id = 40002; | 38 const uint64_t kJabraMic2Id = 40002; |
| 39 const uint64_t kJabraMic2StableDeviceId = 90002; | 39 const uint64_t kJabraMic2StableDeviceId = 90002; |
| 40 const uint64_t kWebcamMicId = 40003; | 40 const uint64_t kWebcamMicId = 40003; |
| 41 const uint64_t kWebcamMicStableDeviceId = 90003; | 41 const uint64_t kWebcamMicStableDeviceId = 90003; |
| 42 | 42 |
| 43 const AudioNode kJabraSpeaker1(false, | 43 struct AudioNodeInfo { |
| 44 kJabraSpeaker1Id, | 44 bool is_input; |
| 45 kJabraSpeaker1StableDeviceId, | 45 uint64_t id; |
| 46 "Jabra Speaker", | 46 uint64_t stable_id; |
| 47 "USB", | 47 const char* const device_name; |
| 48 "Jabra Speaker 1", | 48 const char* const type; |
| 49 false, | 49 const char* const name; |
| 50 0); | 50 }; |
| 51 | 51 |
| 52 const AudioNode kJabraSpeaker2(false, | 52 const AudioNodeInfo kJabraSpeaker1 = { |
| 53 kJabraSpeaker2Id, | 53 false, kJabraSpeaker1Id, kJabraSpeaker1StableDeviceId, "Jabra Speaker", |
| 54 kJabraSpeaker2StableDeviceId, | 54 "USB", "Jabra Speaker 1"}; |
| 55 "Jabra Speaker", | |
| 56 "USB", | |
| 57 "Jabra Speaker 2", | |
| 58 false, | |
| 59 0); | |
| 60 | 55 |
| 61 const AudioNode kHDMIOutput(false, | 56 const AudioNodeInfo kJabraSpeaker2 = { |
| 62 kHDMIOutputId, | 57 false, kJabraSpeaker2Id, kJabraSpeaker2StableDeviceId, "Jabra Speaker", |
| 63 kHDMIOutputStabeDevicelId, | 58 "USB", "Jabra Speaker 2"}; |
| 64 "HDMI output", | |
| 65 "HDMI", | |
| 66 "HDA Intel MID", | |
| 67 false, | |
| 68 0); | |
| 69 | 59 |
| 70 const AudioNode kJabraMic1(true, | 60 const AudioNodeInfo kHDMIOutput = { |
| 71 kJabraMic1Id, | 61 false, kHDMIOutputId, kHDMIOutputStabeDevicelId, |
| 72 kJabraMic1StableDeviceId, | 62 "HDMI output", "HDMI", "HDA Intel MID"}; |
|
jennyz
2016/12/09 23:52:18
Remove the extra white space in between.
| |
| 73 "Jabra Mic", | |
| 74 "USB", | |
| 75 "Jabra Mic 1", | |
| 76 false, | |
| 77 0); | |
| 78 | 63 |
| 79 const AudioNode kJabraMic2(true, | 64 const AudioNodeInfo kJabraMic1 = { |
| 80 kJabraMic2Id, | 65 true, kJabraMic1Id, kJabraMic1StableDeviceId, |
| 81 kJabraMic2StableDeviceId, | 66 "Jabra Mic", "USB", "Jabra Mic 1"}; |
|
jennyz
2016/12/09 23:52:18
ditto
| |
| 82 "Jabra Mic", | |
| 83 "USB", | |
| 84 "Jabra Mic 2", | |
| 85 false, | |
| 86 0); | |
| 87 | 67 |
| 88 const AudioNode kUSBCameraMic(true, | 68 const AudioNodeInfo kJabraMic2 = { |
| 89 kWebcamMicId, | 69 true, kJabraMic2Id, kJabraMic2StableDeviceId, |
| 90 kWebcamMicStableDeviceId, | 70 "Jabra Mic", "USB", "Jabra Mic 2"}; |
|
jennyz
2016/12/09 23:52:18
ditto
| |
| 91 "Webcam Mic", | 71 |
| 92 "USB", | 72 const AudioNodeInfo kUSBCameraMic = { |
| 93 "Logitech Webcam", | 73 true, kWebcamMicId, kWebcamMicStableDeviceId, |
| 94 false, | 74 "Webcam Mic", "USB", "Logitech Webcam"}; |
|
jennyz
2016/12/09 23:52:19
ditto
| |
| 95 0); | 75 |
| 76 AudioNode CreateAudioNode(const AudioNodeInfo& info, int version) { | |
| 77 return AudioNode(info.is_input, info.id, version == 2, | |
| 78 // stable_device_id: | |
| 79 info.stable_id ^ (version == 1 ? 0 : 0xFFFF), | |
| 80 // stable_device_id_old: | |
| 81 version == 1 ? 0 : info.stable_id, info.device_name, | |
| 82 info.type, info.name, false, 0); | |
| 83 } | |
| 96 | 84 |
| 97 class AudioApiTest : public ShellApiTest { | 85 class AudioApiTest : public ShellApiTest { |
| 98 public: | 86 public: |
| 99 AudioApiTest() : cras_audio_handler_(NULL), fake_cras_audio_client_(NULL) {} | 87 AudioApiTest() : cras_audio_handler_(NULL), fake_cras_audio_client_(NULL) {} |
| 100 ~AudioApiTest() override {} | 88 ~AudioApiTest() override {} |
| 101 | 89 |
| 102 void SetUpCrasAudioHandlerWithTestingNodes(const AudioNodeList& audio_nodes) { | 90 void SetUpCrasAudioHandlerWithTestingNodes(const AudioNodeList& audio_nodes) { |
| 103 chromeos::DBusThreadManager* dbus_manager = | 91 chromeos::DBusThreadManager* dbus_manager = |
| 104 chromeos::DBusThreadManager::Get(); | 92 chromeos::DBusThreadManager::Get(); |
| 105 DCHECK(dbus_manager); | 93 DCHECK(dbus_manager); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 118 audio_nodes); | 106 audio_nodes); |
| 119 base::RunLoop().RunUntilIdle(); | 107 base::RunLoop().RunUntilIdle(); |
| 120 } | 108 } |
| 121 | 109 |
| 122 protected: | 110 protected: |
| 123 base::MessageLoopForUI message_loop_; | 111 base::MessageLoopForUI message_loop_; |
| 124 chromeos::CrasAudioHandler* cras_audio_handler_; // Not owned. | 112 chromeos::CrasAudioHandler* cras_audio_handler_; // Not owned. |
| 125 chromeos::FakeCrasAudioClient* fake_cras_audio_client_; // Not owned. | 113 chromeos::FakeCrasAudioClient* fake_cras_audio_client_; // Not owned. |
| 126 }; | 114 }; |
| 127 | 115 |
| 128 IN_PROC_BROWSER_TEST_F(AudioApiTest, Audio) { | 116 IN_PROC_BROWSER_TEST_F(AudioApiTest, AudioV1StableId) { |
| 129 // Set up the audio nodes for testing. | 117 // Set up the audio nodes for testing. |
| 130 AudioNodeList audio_nodes; | 118 AudioNodeList audio_nodes = { |
| 131 audio_nodes.push_back(kJabraSpeaker1); | 119 CreateAudioNode(kJabraSpeaker1, 1), CreateAudioNode(kJabraSpeaker2, 1), |
| 132 audio_nodes.push_back(kJabraSpeaker2); | 120 CreateAudioNode(kHDMIOutput, 1), CreateAudioNode(kJabraMic1, 1), |
| 133 audio_nodes.push_back(kHDMIOutput); | 121 CreateAudioNode(kJabraMic2, 1), CreateAudioNode(kUSBCameraMic, 1)}; |
|
jennyz
2016/12/09 23:52:19
Is git cl format ok with the extra spaces in betwe
tbarzic
2016/12/10 02:35:08
actually, that's what git cl format came up with (
| |
| 134 audio_nodes.push_back(kJabraMic1); | 122 |
| 135 audio_nodes.push_back(kJabraMic2); | 123 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 136 audio_nodes.push_back(kUSBCameraMic); | 124 |
| 125 EXPECT_TRUE(RunAppTest("api_test/audio")) << message_; | |
| 126 } | |
| 127 | |
| 128 IN_PROC_BROWSER_TEST_F(AudioApiTest, AudioV2StableId) { | |
| 129 // Set up the audio nodes for testing. | |
| 130 AudioNodeList audio_nodes = { | |
| 131 CreateAudioNode(kJabraSpeaker1, 2), CreateAudioNode(kJabraSpeaker2, 2), | |
| 132 CreateAudioNode(kHDMIOutput, 2), CreateAudioNode(kJabraMic1, 2), | |
| 133 CreateAudioNode(kJabraMic2, 2), CreateAudioNode(kUSBCameraMic, 2)}; | |
|
jennyz
2016/12/09 23:52:19
ditto
| |
| 134 | |
| 137 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); | 135 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 138 | 136 |
| 139 EXPECT_TRUE(RunAppTest("api_test/audio")) << message_; | 137 EXPECT_TRUE(RunAppTest("api_test/audio")) << message_; |
| 140 } | 138 } |
| 141 | 139 |
| 142 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnLevelChangedOutputDevice) { | 140 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnLevelChangedOutputDevice) { |
| 143 AudioNodeList audio_nodes; | 141 AudioNodeList audio_nodes = {CreateAudioNode(kJabraSpeaker1, 1), |
| 144 audio_nodes.push_back(kJabraSpeaker1); | 142 CreateAudioNode(kHDMIOutput, 1)}; |
| 145 audio_nodes.push_back(kHDMIOutput); | |
| 146 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); | 143 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 147 | 144 |
| 148 // Verify the jabra speaker is the active output device. | 145 // Verify the jabra speaker is the active output device. |
| 149 AudioDevice device; | 146 AudioDevice device; |
| 150 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); | 147 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); |
| 151 EXPECT_EQ(device.id, kJabraSpeaker1.id); | 148 EXPECT_EQ(device.id, kJabraSpeaker1.id); |
| 152 | 149 |
| 153 // Loads background app. | 150 // Loads background app. |
| 154 ResultCatcher result_catcher; | 151 ResultCatcher result_catcher; |
| 155 ExtensionTestMessageListener load_listener("loaded", false); | 152 ExtensionTestMessageListener load_listener("loaded", false); |
| 156 ASSERT_TRUE(LoadApp("api_test/audio/volume_change")); | 153 ASSERT_TRUE(LoadApp("api_test/audio/volume_change")); |
| 157 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); | 154 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); |
| 158 | 155 |
| 159 // Change output device volume. | 156 // Change output device volume. |
| 160 const int kVolume = 60; | 157 const int kVolume = 60; |
| 161 cras_audio_handler_->SetOutputVolumePercent(kVolume); | 158 cras_audio_handler_->SetOutputVolumePercent(kVolume); |
| 162 | 159 |
| 163 // Verify the output volume is changed to the designated value. | 160 // Verify the output volume is changed to the designated value. |
| 164 EXPECT_EQ(kVolume, cras_audio_handler_->GetOutputVolumePercent()); | 161 EXPECT_EQ(kVolume, cras_audio_handler_->GetOutputVolumePercent()); |
| 165 EXPECT_EQ(kVolume, | 162 EXPECT_EQ(kVolume, |
| 166 cras_audio_handler_->GetOutputVolumePercentForDevice(device.id)); | 163 cras_audio_handler_->GetOutputVolumePercentForDevice(device.id)); |
| 167 | 164 |
| 168 // Verify the background app got the OnOutputNodeVolumeChanged event | 165 // Verify the background app got the OnOutputNodeVolumeChanged event |
| 169 // with the expected node id and volume value. | 166 // with the expected node id and volume value. |
| 170 ASSERT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); | 167 ASSERT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); |
| 171 } | 168 } |
| 172 | 169 |
| 173 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnOutputMuteChanged) { | 170 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnOutputMuteChanged) { |
| 174 AudioNodeList audio_nodes; | 171 AudioNodeList audio_nodes = {CreateAudioNode(kJabraSpeaker1, 1), |
| 175 audio_nodes.push_back(kJabraSpeaker1); | 172 CreateAudioNode(kHDMIOutput, 1)}; |
| 176 audio_nodes.push_back(kHDMIOutput); | |
| 177 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); | 173 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 178 | 174 |
| 179 // Verify the jabra speaker is the active output device. | 175 // Verify the jabra speaker is the active output device. |
| 180 AudioDevice device; | 176 AudioDevice device; |
| 181 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); | 177 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); |
| 182 EXPECT_EQ(device.id, kJabraSpeaker1.id); | 178 EXPECT_EQ(device.id, kJabraSpeaker1.id); |
| 183 | 179 |
| 184 // Mute the output. | 180 // Mute the output. |
| 185 cras_audio_handler_->SetOutputMute(true); | 181 cras_audio_handler_->SetOutputMute(true); |
| 186 EXPECT_TRUE(cras_audio_handler_->IsOutputMuted()); | 182 EXPECT_TRUE(cras_audio_handler_->IsOutputMuted()); |
| 187 | 183 |
| 188 // Loads background app. | 184 // Loads background app. |
| 189 ResultCatcher result_catcher; | 185 ResultCatcher result_catcher; |
| 190 ExtensionTestMessageListener load_listener("loaded", false); | 186 ExtensionTestMessageListener load_listener("loaded", false); |
| 191 ASSERT_TRUE(LoadApp("api_test/audio/output_mute_change")); | 187 ASSERT_TRUE(LoadApp("api_test/audio/output_mute_change")); |
| 192 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); | 188 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); |
| 193 | 189 |
| 194 // Un-mute the output. | 190 // Un-mute the output. |
| 195 cras_audio_handler_->SetOutputMute(false); | 191 cras_audio_handler_->SetOutputMute(false); |
| 196 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); | 192 EXPECT_FALSE(cras_audio_handler_->IsOutputMuted()); |
| 197 | 193 |
| 198 // Verify the background app got the OnMuteChanged event | 194 // Verify the background app got the OnMuteChanged event |
| 199 // with the expected output un-muted state. | 195 // with the expected output un-muted state. |
| 200 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); | 196 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); |
| 201 } | 197 } |
| 202 | 198 |
| 203 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnInputMuteChanged) { | 199 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnInputMuteChanged) { |
| 204 AudioNodeList audio_nodes; | 200 AudioNodeList audio_nodes = {CreateAudioNode(kJabraMic1, 1), |
| 205 audio_nodes.push_back(kJabraMic1); | 201 CreateAudioNode(kUSBCameraMic, 1)}; |
| 206 audio_nodes.push_back(kUSBCameraMic); | |
| 207 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); | 202 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 208 | 203 |
| 209 // Set the jabra mic to be the active input device. | 204 // Set the jabra mic to be the active input device. |
| 210 AudioDevice jabra_mic(kJabraMic1); | 205 AudioDevice jabra_mic(CreateAudioNode(kJabraMic1, 1)); |
| 211 cras_audio_handler_->SwitchToDevice( | 206 cras_audio_handler_->SwitchToDevice( |
| 212 jabra_mic, true, chromeos::CrasAudioHandler::ACTIVATE_BY_USER); | 207 jabra_mic, true, chromeos::CrasAudioHandler::ACTIVATE_BY_USER); |
| 213 EXPECT_EQ(kJabraMic1.id, cras_audio_handler_->GetPrimaryActiveInputNode()); | 208 EXPECT_EQ(kJabraMic1.id, cras_audio_handler_->GetPrimaryActiveInputNode()); |
| 214 | 209 |
| 215 // Un-mute the input. | 210 // Un-mute the input. |
| 216 cras_audio_handler_->SetInputMute(false); | 211 cras_audio_handler_->SetInputMute(false); |
| 217 EXPECT_FALSE(cras_audio_handler_->IsInputMuted()); | 212 EXPECT_FALSE(cras_audio_handler_->IsInputMuted()); |
| 218 | 213 |
| 219 // Loads background app. | 214 // Loads background app. |
| 220 ResultCatcher result_catcher; | 215 ResultCatcher result_catcher; |
| 221 ExtensionTestMessageListener load_listener("loaded", false); | 216 ExtensionTestMessageListener load_listener("loaded", false); |
| 222 ASSERT_TRUE(LoadApp("api_test/audio/input_mute_change")); | 217 ASSERT_TRUE(LoadApp("api_test/audio/input_mute_change")); |
| 223 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); | 218 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); |
| 224 | 219 |
| 225 // Mute the input. | 220 // Mute the input. |
| 226 cras_audio_handler_->SetInputMute(true); | 221 cras_audio_handler_->SetInputMute(true); |
| 227 EXPECT_TRUE(cras_audio_handler_->IsInputMuted()); | 222 EXPECT_TRUE(cras_audio_handler_->IsInputMuted()); |
| 228 | 223 |
| 229 // Verify the background app got the OnMuteChanged event | 224 // Verify the background app got the OnMuteChanged event |
| 230 // with the expected input muted state. | 225 // with the expected input muted state. |
| 231 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); | 226 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); |
| 232 } | 227 } |
| 233 | 228 |
| 234 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnNodesChangedAddNodes) { | 229 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnNodesChangedAddNodes) { |
| 235 AudioNodeList audio_nodes; | 230 AudioNodeList audio_nodes = {CreateAudioNode(kJabraSpeaker1, 1), |
| 236 audio_nodes.push_back(kJabraSpeaker1); | 231 CreateAudioNode(kJabraSpeaker2, 1)}; |
| 237 audio_nodes.push_back(kJabraSpeaker2); | |
| 238 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); | 232 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 239 const size_t init_device_size = audio_nodes.size(); | 233 const size_t init_device_size = audio_nodes.size(); |
| 240 | 234 |
| 241 AudioDeviceList audio_devices; | 235 AudioDeviceList audio_devices; |
| 242 cras_audio_handler_->GetAudioDevices(&audio_devices); | 236 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 243 EXPECT_EQ(init_device_size, audio_devices.size()); | 237 EXPECT_EQ(init_device_size, audio_devices.size()); |
| 244 | 238 |
| 245 // Load background app. | 239 // Load background app. |
| 246 ResultCatcher result_catcher; | 240 ResultCatcher result_catcher; |
| 247 ExtensionTestMessageListener load_listener("loaded", false); | 241 ExtensionTestMessageListener load_listener("loaded", false); |
| 248 ASSERT_TRUE(LoadApp("api_test/audio/add_nodes")); | 242 ASSERT_TRUE(LoadApp("api_test/audio/add_nodes")); |
| 249 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); | 243 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); |
| 250 | 244 |
| 251 // Plug in HDMI output. | 245 // Plug in HDMI output. |
| 252 audio_nodes.push_back(kHDMIOutput); | 246 audio_nodes.push_back(CreateAudioNode(kHDMIOutput, 1)); |
| 253 ChangeAudioNodes(audio_nodes); | 247 ChangeAudioNodes(audio_nodes); |
| 254 cras_audio_handler_->GetAudioDevices(&audio_devices); | 248 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 255 EXPECT_EQ(init_device_size + 1, audio_devices.size()); | 249 EXPECT_EQ(init_device_size + 1, audio_devices.size()); |
| 256 | 250 |
| 257 // Verify the background app got the OnNodesChanged event | 251 // Verify the background app got the OnNodesChanged event |
| 258 // with the new node added. | 252 // with the new node added. |
| 259 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); | 253 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); |
| 260 } | 254 } |
| 261 | 255 |
| 262 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnNodesChangedRemoveNodes) { | 256 IN_PROC_BROWSER_TEST_F(AudioApiTest, OnNodesChangedRemoveNodes) { |
| 263 AudioNodeList audio_nodes; | 257 AudioNodeList audio_nodes = {CreateAudioNode(kJabraMic1, 1), |
| 264 audio_nodes.push_back(kJabraMic1); | 258 CreateAudioNode(kJabraMic2, 1), |
| 265 audio_nodes.push_back(kJabraMic2); | 259 CreateAudioNode(kUSBCameraMic, 1)}; |
| 266 audio_nodes.push_back(kUSBCameraMic); | |
| 267 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); | 260 SetUpCrasAudioHandlerWithTestingNodes(audio_nodes); |
| 268 const size_t init_device_size = audio_nodes.size(); | 261 const size_t init_device_size = audio_nodes.size(); |
| 269 | 262 |
| 270 AudioDeviceList audio_devices; | 263 AudioDeviceList audio_devices; |
| 271 cras_audio_handler_->GetAudioDevices(&audio_devices); | 264 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 272 EXPECT_EQ(init_device_size, audio_devices.size()); | 265 EXPECT_EQ(init_device_size, audio_devices.size()); |
| 273 | 266 |
| 274 // Load background app. | 267 // Load background app. |
| 275 ResultCatcher result_catcher; | 268 ResultCatcher result_catcher; |
| 276 ExtensionTestMessageListener load_listener("loaded", false); | 269 ExtensionTestMessageListener load_listener("loaded", false); |
| 277 ASSERT_TRUE(LoadApp("api_test/audio/remove_nodes")); | 270 ASSERT_TRUE(LoadApp("api_test/audio/remove_nodes")); |
| 278 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); | 271 ASSERT_TRUE(load_listener.WaitUntilSatisfied()); |
| 279 | 272 |
| 280 // Remove camera mic. | 273 // Remove camera mic. |
| 281 audio_nodes.erase(audio_nodes.begin() + init_device_size - 1); | 274 audio_nodes.erase(audio_nodes.begin() + init_device_size - 1); |
| 282 ChangeAudioNodes(audio_nodes); | 275 ChangeAudioNodes(audio_nodes); |
| 283 cras_audio_handler_->GetAudioDevices(&audio_devices); | 276 cras_audio_handler_->GetAudioDevices(&audio_devices); |
| 284 EXPECT_EQ(init_device_size - 1, audio_devices.size()); | 277 EXPECT_EQ(init_device_size - 1, audio_devices.size()); |
| 285 | 278 |
| 286 // Verify the background app got the onNodesChanged event | 279 // Verify the background app got the onNodesChanged event |
| 287 // with the last node removed. | 280 // with the last node removed. |
| 288 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); | 281 EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message(); |
| 289 } | 282 } |
| 290 | 283 |
| 291 #endif // OS_CHROMEOS | 284 #endif // OS_CHROMEOS |
| 292 | 285 |
| 293 } // namespace extensions | 286 } // namespace extensions |
| OLD | NEW |