Home | History | Annotate | Download | only in vintf
      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:
     40   virtual ~VtsTrebleVintfTestBase() {}
     41   virtual void SetUp() override;
     42 
     43   // Applies given function to each HAL instance in VINTF.
     44   static void ForEachHalInstance(const HalManifestPtr &, HalVerifyFn);
     45   // Retrieves an existing HAL service.
     46   static sp<IBase> GetHalService(const string &fq_name,
     47                                  const string &instance_name, Transport,
     48                                  bool log = true);
     49   static sp<IBase> GetHalService(const FQName &fq_name,
     50                                  const string &instance_name, Transport,
     51                                  bool log = true);
     52 
     53   static vector<string> GetInstanceNames(const sp<IServiceManager> &manager,
     54                                          const FQName &fq_name);
     55 
     56   static vector<string> GetInterfaceChain(const sp<IBase> &service);
     57 
     58   static set<string> GetPassthroughHals(HalManifestPtr manifest);
     59   static set<string> GetHwbinderHals(HalManifestPtr manifest);
     60   Partition GetPartition(sp<IBase> hal_service);
     61 
     62   // Default service manager.
     63   sp<IServiceManager> default_manager_;
     64 };
     65 
     66 }  // namespace testing
     67 }  // namespace vintf
     68 }  // namespace android
     69 
     70 #endif  // VTS_TREBLE_VINTF_TEST_BASE_H_
     71