Don't preload rarely seen large images
[chromium-blink-merge.git] / chromeos / audio / audio_devices_pref_handler_impl_unittest.cc
blobba871325debb5cd4c47a626a676e7023f11d4130
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
3 // found in the LICENSE file.
5 #include "chromeos/audio/audio_devices_pref_handler_impl.h"
7 #include "base/memory/ref_counted.h"
8 #include "base/prefs/testing_pref_service.h"
9 #include "chromeos/audio/audio_device.h"
10 #include "chromeos/audio/audio_devices_pref_handler.h"
11 #include "chromeos/chromeos_pref_names.h"
12 #include "chromeos/dbus/audio_node.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace chromeos {
17 const uint64 kInternalMicId = 10003;
18 const uint64 kHeadphoneId = 10002;
19 const uint64 kHDMIOutputId = 10006;
20 const uint64 kOtherTypeOutputId = 90001;
21 const uint64 kOtherTypeInputId = 90002;
23 const AudioDevice kInternalMic(AudioNode(true,
24 kInternalMicId,
25 "Fake Mic",
26 "INTERNAL_MIC",
27 "Internal Mic",
28 false,
29 0));
31 const AudioDevice kHeadphone(AudioNode(false,
32 kHeadphoneId,
33 "Fake Headphone",
34 "HEADPHONE",
35 "Headphone",
36 false,
37 0));
39 const AudioDevice kHDMIOutput(AudioNode(false,
40 kHDMIOutputId,
41 "HDMI output",
42 "HDMI",
43 "HDMI output",
44 false,
45 0));
47 const AudioDevice kInputDeviceWithSpecialCharacters(
48 AudioNode(true,
49 kOtherTypeInputId,
50 "Fake ~!@#$%^&*()_+`-=<>?,./{}|[]\\\\Mic",
51 "SOME_OTHER_TYPE",
52 "Other Type Input Device",
53 true,
54 0));
56 const AudioDevice kOutputDeviceWithSpecialCharacters(
57 AudioNode(false,
58 kOtherTypeOutputId,
59 "Fake ~!@#$%^&*()_+`-=<>?,./{}|[]\\\\Headphone",
60 "SOME_OTHER_TYPE",
61 "Other Type Output Device",
62 false,
63 0));
65 class AudioDevicesPrefHandlerTest : public testing::Test {
66 public:
67 AudioDevicesPrefHandlerTest() {}
68 ~AudioDevicesPrefHandlerTest() override {}
70 void SetUp() override {
71 pref_service_.reset(new TestingPrefServiceSimple());
72 AudioDevicesPrefHandlerImpl::RegisterPrefs(pref_service_->registry());
73 audio_pref_handler_ = new AudioDevicesPrefHandlerImpl(pref_service_.get());
76 void TearDown() override { audio_pref_handler_ = NULL; }
78 protected:
79 scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_;
80 scoped_ptr<TestingPrefServiceSimple> pref_service_;
82 private:
83 DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerTest);
86 TEST_F(AudioDevicesPrefHandlerTest, TestDefaultValues) {
87 // TODO(rkc): Once the bug with default preferences is fixed, fix this test
88 // also. http://crbug.com/442489
89 EXPECT_EQ(75.0, audio_pref_handler_->GetInputGainValue(&kInternalMic));
90 EXPECT_EQ(75.0, audio_pref_handler_->GetOutputVolumeValue(&kHeadphone));
91 EXPECT_EQ(75.0, audio_pref_handler_->GetOutputVolumeValue(&kHDMIOutput));
94 TEST_F(AudioDevicesPrefHandlerTest, PrefsRegistered) {
95 // The standard audio prefs are registered.
96 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesVolumePercent));
97 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioDevicesMute));
98 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioOutputAllowed));
99 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioVolumePercent));
100 EXPECT_TRUE(pref_service_->FindPreference(prefs::kAudioMute));
103 TEST_F(AudioDevicesPrefHandlerTest, TestBasicInputOutputDevices) {
104 audio_pref_handler_->SetVolumeGainValue(kInternalMic, 13.37);
105 EXPECT_EQ(13.37, audio_pref_handler_->GetInputGainValue(&kInternalMic));
106 audio_pref_handler_->SetVolumeGainValue(kHeadphone, 47.28);
107 EXPECT_EQ(47.28, audio_pref_handler_->GetOutputVolumeValue(&kHeadphone));
110 TEST_F(AudioDevicesPrefHandlerTest, TestSpecialCharactersInDeviceNames) {
111 audio_pref_handler_->SetVolumeGainValue(kInputDeviceWithSpecialCharacters,
112 73.31);
113 audio_pref_handler_->SetVolumeGainValue(kOutputDeviceWithSpecialCharacters,
114 85.92);
116 EXPECT_EQ(73.31, audio_pref_handler_->GetInputGainValue(
117 &kInputDeviceWithSpecialCharacters));
118 EXPECT_EQ(85.92, audio_pref_handler_->GetOutputVolumeValue(
119 &kOutputDeviceWithSpecialCharacters));
122 } // namespace chromeos