1 /*
2  * Copyright 2020 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 <android-base/logging.h>
18 #include <android/hardware/tv/tuner/1.0/IDemux.h>
19 #include <android/hardware/tv/tuner/1.0/ITuner.h>
20 #include <android/hardware/tv/tuner/1.0/types.h>
21 #include <binder/MemoryDealer.h>
22 #include <gtest/gtest.h>
23 #include <hidl/ServiceManagement.h>
24 #include <hidl/Status.h>
25 #include <hidlmemory/FrameworkUtils.h>
26 #include <utils/Condition.h>
27 #include <utils/Mutex.h>
28 #include <map>
29 
30 using android::sp;
31 using android::hardware::Return;
32 using android::hardware::Void;
33 using android::hardware::tv::tuner::V1_0::DemuxCapabilities;
34 using android::hardware::tv::tuner::V1_0::IDemux;
35 using android::hardware::tv::tuner::V1_0::IFilter;
36 using android::hardware::tv::tuner::V1_0::ITuner;
37 using android::hardware::tv::tuner::V1_0::Result;
38 
39 using ::testing::AssertionResult;
40 
41 class DemuxTests {
42   public:
setService(sp<ITuner> tuner)43     void setService(sp<ITuner> tuner) { mService = tuner; }
44 
45     AssertionResult openDemux(sp<IDemux>& demux, uint32_t& demuxId);
46     AssertionResult setDemuxFrontendDataSource(uint32_t frontendId);
47     AssertionResult getAvSyncId(sp<IFilter> filter, uint32_t& avSyncHwId);
48     AssertionResult getAvSyncTime(uint32_t avSyncId);
49     AssertionResult getDemuxCaps(DemuxCapabilities& demuxCaps);
50     AssertionResult closeDemux();
51 
52   protected:
failure()53     static AssertionResult failure() { return ::testing::AssertionFailure(); }
54 
success()55     static AssertionResult success() { return ::testing::AssertionSuccess(); }
56 
57     sp<ITuner> mService;
58     sp<IDemux> mDemux;
59 };
60