1 /*
2 * Copyright (C) 2021 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 #define LOG_TAG "VtsHalUsbV1_3TargetTest"
18 #include <android-base/logging.h>
19
20 #include <android/hardware/usb/1.3/IUsb.h>
21
22 #include <gtest/gtest.h>
23 #include <hidl/GtestPrinter.h>
24 #include <hidl/ServiceManagement.h>
25
26 #include <log/log.h>
27 #include <stdlib.h>
28 #include <condition_variable>
29
30 using ::android::sp;
31 using ::android::hardware::hidl_array;
32 using ::android::hardware::hidl_memory;
33 using ::android::hardware::hidl_string;
34 using ::android::hardware::hidl_vec;
35 using ::android::hardware::Return;
36 using ::android::hardware::Void;
37 using ::android::hardware::usb::V1_0::Status;
38 using ::android::hardware::usb::V1_3::IUsb;
39 using ::android::hidl::base::V1_0::IBase;
40
41 // The main test class for the USB hidl HAL
42 class UsbHidlTest : public ::testing::TestWithParam<std::string> {
43 public:
SetUp()44 virtual void SetUp() override {
45 ALOGI(__FUNCTION__);
46 usb = IUsb::getService(GetParam());
47 ASSERT_NE(usb, nullptr);
48 }
49
TearDown()50 virtual void TearDown() override { ALOGI("Teardown"); }
51
52 // USB hidl hal Proxy
53 sp<IUsb> usb;
54 };
55
56 /*
57 * Check to see if enable usb data signal succeeds.
58 * HAL service should call enableUsbDataSignal.
59 */
TEST_P(UsbHidlTest,enableUsbDataSignal)60 TEST_P(UsbHidlTest, enableUsbDataSignal) {
61 Return<bool> ret = usb->enableUsbDataSignal(true);
62 ASSERT_TRUE(ret.isOk());
63 }
64
65 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(UsbHidlTest);
66 INSTANTIATE_TEST_SUITE_P(
67 PerInstance, UsbHidlTest,
68 testing::ValuesIn(android::hardware::getAllHalInstanceNames(IUsb::descriptor)),
69 android::hardware::PrintInstanceNameToString);
70