blob: 96c23ed9f64632daa5265b4ff3c1d5284be4ca99 [file] [log] [blame]
Keun young Park5eba08f2012-03-26 18:31:29 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16#include <stdint.h>
17#include <gtest/gtest.h>
18
19#include <UniquePtr.h>
20#include <tinyalsa/asoundlib.h>
21#include <Log.h>
22#include <audio/AudioHardware.h>
23
24class MixerTest : public testing::Test {
25public:
26
27 virtual void SetUp() {
28
29 }
30
31 virtual void TearDown() {
32
33 }
34};
35
36
37TEST_F(MixerTest, tryTinyAlsaTest) {
38 int hwId = AudioHardware::detectAudioHw();
39 ASSERT_TRUE(hwId >= 0);
40 struct mixer* mixerp = mixer_open(hwId);
41 ASSERT_TRUE(mixerp != NULL);
42 int num_ctls = mixer_get_num_ctls(mixerp);
keunyoung4fc16d12013-04-08 09:44:01 -070043 LOGI("Number of mixel control %d", num_ctls);
Keun young Park5eba08f2012-03-26 18:31:29 -070044 for (int i = 0; i < num_ctls; i++) {
45 struct mixer_ctl* control = mixer_get_ctl(mixerp, i);
46 ASSERT_TRUE(control != NULL);
47 LOGI("Mixer control %s type %s value %d", mixer_ctl_get_name(control),
48 mixer_ctl_get_type_string(control), mixer_ctl_get_num_values(control));
49 free(control);
50 }
keunyoung4fc16d12013-04-08 09:44:01 -070051 // no mixer control for MobilePre. If this assumption fails,
52 // mixer control should be added.
53 ASSERT_TRUE(num_ctls == 0);
Keun young Park5eba08f2012-03-26 18:31:29 -070054 mixer_close(mixerp);
55}
56