| 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 "chromeos/audio/audio_devices_pref_handler_impl.h" | 5 #include "chromeos/audio/audio_devices_pref_handler_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "chromeos/audio/audio_device.h" | 11 #include "chromeos/audio/audio_device.h" |
| 12 #include "chromeos/audio/audio_devices_pref_handler.h" | 12 #include "chromeos/audio/audio_devices_pref_handler.h" |
| 13 #include "chromeos/chromeos_pref_names.h" | 13 #include "chromeos/chromeos_pref_names.h" |
| 14 #include "chromeos/dbus/audio_node.h" | 14 #include "chromeos/dbus/audio_node.h" |
| 15 #include "components/prefs/testing_pref_service.h" | 15 #include "components/prefs/testing_pref_service.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 const uint64_t kInternalMicId = 10003; | 20 const uint64_t kInternalMicId = 10003; |
| 21 const uint64_t kHeadphoneId = 10002; | 21 const uint64_t kHeadphoneId = 10002; |
| 22 const uint64_t kHDMIOutputId = 10006; | 22 const uint64_t kHDMIOutputId = 10006; |
| 23 const uint64_t kUSBMicId = 10004; |
| 23 const uint64_t kOtherTypeOutputId = 90001; | 24 const uint64_t kOtherTypeOutputId = 90001; |
| 24 const uint64_t kOtherTypeInputId = 90002; | 25 const uint64_t kOtherTypeInputId = 90002; |
| 25 | 26 |
| 26 const AudioDevice kInternalMic(AudioNode(true, | 27 const AudioDevice kInternalMic(AudioNode(true, |
| 27 kInternalMicId, | 28 kInternalMicId, |
| 28 kInternalMicId, | 29 kInternalMicId, |
| 29 "Fake Mic", | 30 "Fake Mic", |
| 30 "INTERNAL_MIC", | 31 "INTERNAL_MIC", |
| 31 "Internal Mic", | 32 "Internal Mic", |
| 32 false, | 33 false, |
| 33 0)); | 34 0)); |
| 35 const AudioDevice kUSBMic(AudioNode(true, |
| 36 kUSBMicId, |
| 37 kUSBMicId, |
| 38 "Fake USB Mic", |
| 39 "USB", |
| 40 "USB Microphone", |
| 41 false, |
| 42 0)); |
| 34 | 43 |
| 35 const AudioDevice kHeadphone(AudioNode(false, | 44 const AudioDevice kHeadphone(AudioNode(false, |
| 36 kHeadphoneId, | 45 kHeadphoneId, |
| 37 kHeadphoneId, | 46 kHeadphoneId, |
| 38 "Fake Headphone", | 47 "Fake Headphone", |
| 39 "HEADPHONE", | 48 "HEADPHONE", |
| 40 "Headphone", | 49 "Headphone", |
| 41 false, | 50 false, |
| 42 0)); | 51 0)); |
| 43 | 52 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 audio_pref_handler_->SetDeviceActive(kHeadphone, true, false); | 156 audio_pref_handler_->SetDeviceActive(kHeadphone, true, false); |
| 148 EXPECT_TRUE(audio_pref_handler_->GetDeviceActive(kHeadphone, &active, | 157 EXPECT_TRUE(audio_pref_handler_->GetDeviceActive(kHeadphone, &active, |
| 149 &activate_by_user)); | 158 &activate_by_user)); |
| 150 EXPECT_TRUE(active); | 159 EXPECT_TRUE(active); |
| 151 EXPECT_FALSE(activate_by_user); | 160 EXPECT_FALSE(activate_by_user); |
| 152 | 161 |
| 153 audio_pref_handler_->SetDeviceActive(kHDMIOutput, false, false); | 162 audio_pref_handler_->SetDeviceActive(kHDMIOutput, false, false); |
| 154 EXPECT_TRUE(audio_pref_handler_->GetDeviceActive(kHDMIOutput, &active, | 163 EXPECT_TRUE(audio_pref_handler_->GetDeviceActive(kHDMIOutput, &active, |
| 155 &activate_by_user)); | 164 &activate_by_user)); |
| 156 EXPECT_FALSE(active); | 165 EXPECT_FALSE(active); |
| 166 |
| 167 // Device not exist in device state prefs. |
| 168 EXPECT_FALSE(audio_pref_handler_->GetDeviceActive(kUSBMic, &active, |
| 169 &activate_by_user)); |
| 157 } | 170 } |
| 158 | 171 |
| 159 } // namespace chromeos | 172 } // namespace chromeos |
| OLD | NEW |