1 /*
2  * Copyright 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 
17 #ifndef ANDROID_AUTOMOTIVE_COMPUTEPIPE_TESTS
18 #define ANDROID_AUTOMOTIVE_COMPUTEPIPE_TESTS
19 
20 #include <aidl/android/automotive/computepipe/runner/BnPipeRunner.h>
21 #include <aidl/android/automotive/computepipe/runner/IPipeRunner.h>
22 
23 #include <memory>
24 
25 namespace android {
26 namespace automotive {
27 namespace computepipe {
28 namespace tests {
29 
30 // TODO: Wrap under version flag
31 
32 // This is a fake runner class whose various methods can be mocked in order
33 // to test the Runner logic.
34 
35 class FakeRunner : public aidl::android::automotive::computepipe::runner::BnPipeRunner {
36   public:
37     ::ndk::ScopedAStatus init(
38         const std::shared_ptr<::aidl::android::automotive::computepipe::runner::IPipeStateCallback>&
39             in_statecb) override;
40     ::ndk::ScopedAStatus getPipeDescriptor(
41         ::aidl::android::automotive::computepipe::runner::PipeDescriptor* _aidl_return) override;
42     ::ndk::ScopedAStatus setPipeInputSource(int32_t in_configId) override;
43     ::ndk::ScopedAStatus setPipeOffloadOptions(int32_t in_configId) override;
44     ::ndk::ScopedAStatus setPipeTermination(int32_t in_configId) override;
45     ::ndk::ScopedAStatus setPipeOutputConfig(
46         int32_t in_configId, int32_t in_maxInFlightCount,
47         const std::shared_ptr<::aidl::android::automotive::computepipe::runner::IPipeStream>&
48             in_handler) override;
49     ::ndk::ScopedAStatus applyPipeConfigs() override;
50     ::ndk::ScopedAStatus resetPipeConfigs() override;
51     ::ndk::ScopedAStatus startPipe() override;
52     ::ndk::ScopedAStatus stopPipe() override;
53     ::ndk::ScopedAStatus doneWithPacket(int32_t in_bufferId, int32_t in_streamId) override;
54     ::ndk::ScopedAStatus getPipeDebugger(
55         std::shared_ptr<::aidl::android::automotive::computepipe::runner::IPipeDebugger>*
56             _aidl_return) override;
57     ::ndk::ScopedAStatus releaseRunner() override;
~FakeRunner()58     ~FakeRunner() {
59         mOutputCallbacks.clear();
60     }
61 
62   private:
63     aidl::android::automotive::computepipe::runner::PipeDescriptor mDesc;
64     std::vector<std::shared_ptr<aidl::android::automotive::computepipe::runner::IPipeStream>>
65         mOutputCallbacks;
66     std::shared_ptr<aidl::android::automotive::computepipe::runner::IPipeStateCallback> mStateCallback;
67 };
68 
69 }  // namespace tests
70 }  // namespace computepipe
71 }  // namespace automotive
72 }  // namespace android
73 #endif
74