Keun young Park | 5eba08f | 2012-03-26 18:31:29 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | class MixerTest : public testing::Test { |
| 25 | public: |
| 26 | |
| 27 | virtual void SetUp() { |
| 28 | |
| 29 | } |
| 30 | |
| 31 | virtual void TearDown() { |
| 32 | |
| 33 | } |
| 34 | }; |
| 35 | |
| 36 | |
| 37 | TEST_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); |
keunyoung | 4fc16d1 | 2013-04-08 09:44:01 -0700 | [diff] [blame] | 43 | LOGI("Number of mixel control %d", num_ctls); |
Keun young Park | 5eba08f | 2012-03-26 18:31:29 -0700 | [diff] [blame] | 44 | 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 | } |
keunyoung | 4fc16d1 | 2013-04-08 09:44:01 -0700 | [diff] [blame] | 51 | // no mixer control for MobilePre. If this assumption fails, |
| 52 | // mixer control should be added. |
| 53 | ASSERT_TRUE(num_ctls == 0); |
Keun young Park | 5eba08f | 2012-03-26 18:31:29 -0700 | [diff] [blame] | 54 | mixer_close(mixerp); |
| 55 | } |
| 56 | |