blob: ed35d4223ecfa15df86590a74ecdbd33dc8a2a95 [file] [log] [blame]
Albert Wang29233682020-11-17 13:23:40 +08001/*
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
30using ::android::sp;
31using ::android::hardware::hidl_array;
32using ::android::hardware::hidl_memory;
33using ::android::hardware::hidl_string;
34using ::android::hardware::hidl_vec;
35using ::android::hardware::Return;
36using ::android::hardware::Void;
37using ::android::hardware::usb::V1_0::Status;
38using ::android::hardware::usb::V1_3::IUsb;
39using ::android::hidl::base::V1_0::IBase;
40
41// The main test class for the USB hidl HAL
42class UsbHidlTest : public ::testing::TestWithParam<std::string> {
43 public:
44 virtual void SetUp() override {
45 ALOGI(__FUNCTION__);
46 usb = IUsb::getService(GetParam());
47 ASSERT_NE(usb, nullptr);
48 }
49
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 */
60TEST_P(UsbHidlTest, enableUsbDataSignal) {
61 Return<bool> ret = usb->enableUsbDataSignal(true);
62 ASSERT_TRUE(ret.isOk());
63}
64
65GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(UsbHidlTest);
66INSTANTIATE_TEST_SUITE_P(
67 PerInstance, UsbHidlTest,
68 testing::ValuesIn(android::hardware::getAllHalInstanceNames(IUsb::descriptor)),
69 android::hardware::PrintInstanceNameToString);