• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #ifndef VTS_TREBLE_VINTF_TEST_BASE_H_
18 #define VTS_TREBLE_VINTF_TEST_BASE_H_
19 
20 #include <string>
21 #include <vector>
22 
23 #include <android/hidl/manager/1.0/IServiceManager.h>
24 #include <gtest/gtest.h>
25 #include <vintf/VintfObject.h>
26 
27 #include "utils.h"
28 
29 namespace android {
30 namespace vintf {
31 namespace testing {
32 
33 using android::sp;
34 using android::hidl::base::V1_0::IBase;
35 using android::hidl::manager::V1_0::IServiceManager;
36 
37 // Base class for many test suites. Provides some utility functions.
38 class VtsTrebleVintfTestBase : public ::testing::Test {
39  public:
~VtsTrebleVintfTestBase()40   virtual ~VtsTrebleVintfTestBase() {}
41   virtual void SetUp() override;
42 
43   // Applies given function to each HAL instance in VINTF.
44   static void ForEachAidlHalInstance(const HalManifestPtr &, AidlVerifyFn);
45   static void ForEachHidlHalInstance(const HalManifestPtr &, HidlVerifyFn);
46 
47   // Retrieves an existing HAL service.
48   static sp<IBase> GetHalService(const string &fq_name,
49                                  const string &instance_name, Transport,
50                                  bool log = true);
51   static sp<IBase> GetHalService(const FQName &fq_name,
52                                  const string &instance_name, Transport,
53                                  bool log = true);
54 
55   static vector<string> GetInstanceNames(const sp<IServiceManager> &manager,
56                                          const FQName &fq_name);
57 
58   static vector<string> GetInterfaceChain(const sp<IBase> &service);
59 
60   static set<string> GetPassthroughHals(HalManifestPtr manifest);
61   static set<string> GetHwbinderHals(HalManifestPtr manifest);
62   Partition GetPartition(sp<IBase> hal_service);
63 
64   // Default service manager.
65   sp<IServiceManager> default_manager_;
66 };
67 
68 }  // namespace testing
69 }  // namespace vintf
70 }  // namespace android
71 
72 #endif  // VTS_TREBLE_VINTF_TEST_BASE_H_
73