Phil Burk | d2a8a53 | 2020-07-01 18:16:28 -0700 | [diff] [blame^] | 1 | #include <oboe/Oboe.h>/* |
| 2 | * Copyright 2018 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 | |
| 17 | #include <gtest/gtest.h> |
| 18 | #include <oboe/Oboe.h> |
| 19 | #include "../src/aaudio/AAudioLoader.h" |
| 20 | |
| 21 | using namespace oboe; |
| 22 | |
| 23 | class AAudioDirect : public ::testing::Test { |
| 24 | public: |
| 25 | void createBuilder() { |
| 26 | mAAudioLoader = AAudioLoader::getInstance(); |
| 27 | ASSERT_NE(mAAudioLoader, nullptr); |
| 28 | ASSERT_EQ(0, mAAudioLoader->open()); |
| 29 | ASSERT_NE(mAAudioLoader->createStreamBuilder, nullptr); |
| 30 | aaudio_result_t result = mAAudioLoader->createStreamBuilder(&mBuilder); |
| 31 | ASSERT_NE(mBuilder, nullptr); |
| 32 | ASSERT_EQ(result, 0); |
| 33 | } |
| 34 | |
| 35 | void openCloseStream() { |
| 36 | AAudioStream *stream = nullptr; |
| 37 | aaudio_result_t result = mAAudioLoader->builder_openStream(mBuilder, &stream); |
| 38 | ASSERT_EQ(result, 0); |
| 39 | ASSERT_NE(stream, nullptr); |
| 40 | |
| 41 | result = mAAudioLoader->stream_close(stream); |
| 42 | ASSERT_EQ(result, 0); |
| 43 | } |
| 44 | |
| 45 | AAudioStreamBuilder *mBuilder = nullptr; |
| 46 | AAudioLoader *mAAudioLoader = nullptr; |
| 47 | }; |
| 48 | |
| 49 | TEST_F(AAudioDirect, InstantiateAAudioLoader){ |
| 50 | AAudioLoader *aaudioLoader = AAudioLoader::getInstance(); |
| 51 | ASSERT_NE(aaudioLoader, nullptr); |
| 52 | } |
| 53 | |
| 54 | TEST_F(AAudioDirect, OpenCloseHighLatencyStream){ |
| 55 | createBuilder(); |
| 56 | mAAudioLoader->builder_setPerformanceMode(mBuilder, AAUDIO_PERFORMANCE_MODE_NONE); |
| 57 | openCloseStream(); |
| 58 | } |
| 59 | |
| 60 | TEST_F(AAudioDirect, OpenCloseLowLatencyStream){ |
| 61 | createBuilder(); |
| 62 | mAAudioLoader->builder_setPerformanceMode(mBuilder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY); |
| 63 | openCloseStream(); |
| 64 | } |