1 /* 2 * Copyright (C) 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 #pragma once 18 19 #include <OffloadControlTestBase.h> 20 21 class OffloadControlTestV1_0_HalNotStarted : public OffloadControlTestBase { 22 public: SetUp()23 virtual void SetUp() override { 24 setupConfigHal(); 25 // Create tether offload control object without calling its initOffload. 26 prepareControlHal(); 27 } 28 createControl(const std::string & serviceName)29 virtual sp<android::hardware::tetheroffload::control::V1_0::IOffloadControl> createControl( 30 const std::string& serviceName) override { 31 return android::hardware::tetheroffload::control::V1_0::IOffloadControl::getService( 32 serviceName); 33 } 34 prepareControlHal()35 virtual void prepareControlHal() override { 36 control = createControl(std::get<1>(GetParam())); 37 ASSERT_NE(nullptr, control.get()) << "Could not get HIDL instance"; 38 39 control_cb = new TetheringOffloadCallback(); 40 ASSERT_NE(nullptr, control_cb.get()) << "Could not get get offload callback"; 41 } 42 initOffload(const bool expected_result)43 virtual void initOffload(const bool expected_result) override { 44 auto init_cb = [&](bool success, std::string errMsg) { 45 std::string msg = StringPrintf("Unexpectedly %s to init offload: %s", 46 success ? "succeeded" : "failed", errMsg.c_str()); 47 ASSERT_EQ(expected_result, success) << msg; 48 }; 49 const Return<void> ret = control->initOffload(control_cb, init_cb); 50 ASSERT_TRUE(ret.isOk()); 51 } 52 }; 53 54 class OffloadControlTestV1_0_HalStarted : public OffloadControlTestV1_0_HalNotStarted { 55 public: SetUp()56 virtual void SetUp() override { 57 setupConfigHal(); 58 setupControlHal(); 59 } 60 }; 61