1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of 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,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include <math.h>
17
18 // pull in all the <= 4.0 tests
19 #include "4.0/AudioPrimaryHidlHalTest.cpp"
20
TEST_P(InputStreamTest,SetMicrophoneDirection)21 TEST_P(InputStreamTest, SetMicrophoneDirection) {
22 doc::test("Make sure setMicrophoneDirection correctly handles valid & invalid arguments");
23
24 // MicrophoneDirection dir = MicrophoneDirection::FRONT;
25 for (MicrophoneDirection dir : android::hardware::hidl_enum_range<MicrophoneDirection>()) {
26 ASSERT_RESULT(okOrNotSupported, stream->setMicrophoneDirection(dir));
27 }
28
29 // Bogus values
30 for (auto dir : {42, -1, 4}) {
31 ASSERT_RESULT(invalidArgsOrNotSupported,
32 stream->setMicrophoneDirection(MicrophoneDirection(dir)));
33 }
34 }
35
TEST_P(InputStreamTest,SetMicrophoneFieldDimension)36 TEST_P(InputStreamTest, SetMicrophoneFieldDimension) {
37 doc::test("Make sure setMicrophoneFieldDimension correctly handles valid & invalid arguments");
38
39 // Valid zoom values -1.0 -> 1.0
40 float incr = 0.1f;
41 for (float val = -1.0f; val <= 1.0; val += incr) {
42 ASSERT_RESULT(okOrNotSupported, stream->setMicrophoneFieldDimension(val));
43 }
44
45 // Bogus values
46 for (float val = 1.0f + incr; val <= 10.0f; val += incr) {
47 ASSERT_RESULT(invalidArgsOrNotSupported, stream->setMicrophoneFieldDimension(val));
48 ASSERT_RESULT(invalidArgsOrNotSupported, stream->setMicrophoneFieldDimension(-val));
49 }
50 // Some extremes
51 ASSERT_RESULT(invalidArgsOrNotSupported, stream->setMicrophoneFieldDimension(NAN));
52 ASSERT_RESULT(invalidArgsOrNotSupported, stream->setMicrophoneFieldDimension(-NAN));
53 ASSERT_RESULT(invalidArgsOrNotSupported, stream->setMicrophoneFieldDimension(INFINITY));
54 ASSERT_RESULT(invalidArgsOrNotSupported, stream->setMicrophoneFieldDimension(-INFINITY));
55 }
56