| 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" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 private: | 90 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerTest); | 91 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerTest); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 TEST_F(AudioDevicesPrefHandlerTest, TestDefaultValues) { | 94 TEST_F(AudioDevicesPrefHandlerTest, TestDefaultValues) { |
| 95 // TODO(rkc): Once the bug with default preferences is fixed, fix this test | 95 // TODO(rkc): Once the bug with default preferences is fixed, fix this test |
| 96 // also. http://crbug.com/442489 | 96 // also. http://crbug.com/442489 |
| 97 EXPECT_EQ(75.0, audio_pref_handler_->GetInputGainValue(&kInternalMic)); | 97 EXPECT_EQ(75.0, audio_pref_handler_->GetInputGainValue(&kInternalMic)); |
| 98 EXPECT_EQ(75.0, audio_pref_handler_->GetOutputVolumeValue(&kHeadphone)); | 98 EXPECT_EQ(75.0, audio_pref_handler_->GetOutputVolumeValue(&kHeadphone)); |
| 99 EXPECT_EQ(75.0, audio_pref_handler_->GetOutputVolumeValue(&kHDMIOutput)); | 99 EXPECT_EQ(75.0, audio_pref_handler_->GetOutputVolumeValue(&kHDMIOutput)); |
| 100 EXPECT_EQ(AUDIO_STATE_NOT_AVAILABLE, | 100 bool active, activate_by_user; |
| 101 audio_pref_handler_->GetDeviceState(kInternalMic)); | 101 EXPECT_FALSE(audio_pref_handler_->GetDeviceActive(kInternalMic, &active, |
| 102 EXPECT_EQ(AUDIO_STATE_NOT_AVAILABLE, | 102 &activate_by_user)); |
| 103 audio_pref_handler_->GetDeviceState(kHeadphone)); | 103 EXPECT_FALSE(audio_pref_handler_->GetDeviceActive(kHeadphone, &active, |
| 104 EXPECT_EQ(AUDIO_STATE_NOT_AVAILABLE, | 104 &activate_by_user)); |
| 105 audio_pref_handler_->GetDeviceState(kHDMIOutput)); | 105 EXPECT_FALSE(audio_pref_handler_->GetDeviceActive(kHDMIOutput, &active, |
| 106 &activate_by_user)); |
| 106 } | 107 } |
| 107 | 108 |
| 108 TEST_F(AudioDevicesPrefHandlerTest, PrefsRegistered) { | 109 TEST_F(AudioDevicesPrefHandlerTest, PrefsRegistered) { |
| 109 // The standard audio prefs are registered. | 110 // The standard audio prefs are registered. |
| 110 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesVolumePercent)); | 111 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesVolumePercent)); |
| 111 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesMute)); | 112 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesMute)); |
| 112 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioOutputAllowed)); | 113 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioOutputAllowed)); |
| 113 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioVolumePercent)); | 114 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioVolumePercent)); |
| 114 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioMute)); | 115 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioMute)); |
| 115 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesState)); | 116 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesState)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 128 audio_pref_handler_->SetVolumeGainValue(kOutputDeviceWithSpecialCharacters, | 129 audio_pref_handler_->SetVolumeGainValue(kOutputDeviceWithSpecialCharacters, |
| 129 85.92); | 130 85.92); |
| 130 | 131 |
| 131 EXPECT_EQ(73.31, audio_pref_handler_->GetInputGainValue( | 132 EXPECT_EQ(73.31, audio_pref_handler_->GetInputGainValue( |
| 132 &kInputDeviceWithSpecialCharacters)); | 133 &kInputDeviceWithSpecialCharacters)); |
| 133 EXPECT_EQ(85.92, audio_pref_handler_->GetOutputVolumeValue( | 134 EXPECT_EQ(85.92, audio_pref_handler_->GetOutputVolumeValue( |
| 134 &kOutputDeviceWithSpecialCharacters)); | 135 &kOutputDeviceWithSpecialCharacters)); |
| 135 } | 136 } |
| 136 | 137 |
| 137 TEST_F(AudioDevicesPrefHandlerTest, TestDeviceStates) { | 138 TEST_F(AudioDevicesPrefHandlerTest, TestDeviceStates) { |
| 138 audio_pref_handler_->SetDeviceState(kInternalMic, AUDIO_STATE_NOT_AVAILABLE); | 139 audio_pref_handler_->SetDeviceActive(kInternalMic, true, true); |
| 139 EXPECT_EQ(AUDIO_STATE_NOT_AVAILABLE, | 140 bool active = false; |
| 140 audio_pref_handler_->GetDeviceState(kInternalMic)); | 141 bool activate_by_user = false; |
| 141 audio_pref_handler_->SetDeviceState(kHeadphone, AUDIO_STATE_ACTIVE); | 142 EXPECT_TRUE(audio_pref_handler_->GetDeviceActive(kInternalMic, &active, |
| 142 EXPECT_EQ(AUDIO_STATE_ACTIVE, | 143 &activate_by_user)); |
| 143 audio_pref_handler_->GetDeviceState(kHeadphone)); | 144 EXPECT_TRUE(active); |
| 144 audio_pref_handler_->SetDeviceState(kHDMIOutput, AUDIO_STATE_INACTIVE); | 145 EXPECT_TRUE(activate_by_user); |
| 145 EXPECT_EQ(AUDIO_STATE_INACTIVE, | 146 |
| 146 audio_pref_handler_->GetDeviceState(kHDMIOutput)); | 147 audio_pref_handler_->SetDeviceActive(kHeadphone, true, false); |
| 148 EXPECT_TRUE(audio_pref_handler_->GetDeviceActive(kHeadphone, &active, |
| 149 &activate_by_user)); |
| 150 EXPECT_TRUE(active); |
| 151 EXPECT_FALSE(activate_by_user); |
| 152 |
| 153 audio_pref_handler_->SetDeviceActive(kHDMIOutput, false, false); |
| 154 EXPECT_TRUE(audio_pref_handler_->GetDeviceActive(kHDMIOutput, &active, |
| 155 &activate_by_user)); |
| 156 EXPECT_FALSE(active); |
| 147 } | 157 } |
| 148 | 158 |
| 149 } // namespace chromeos | 159 } // namespace chromeos |
| OLD | NEW |