From 6dc07818bc27d9391b76f89970383082bda3b543 Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Wed, 12 Apr 2017 10:18:32 -0700 Subject: [PATCH] Add VTS tests for Bonjour and Upnp service This covers the following APIs by adding tests to ISupplicantP2pIface: ISupplicantP2pIface::addBonjourService(), ISupplicantP2pIface::removeBonjourService(), ISupplicantP2pIface::addUpnpService(), ISupplicantP2pIface::removeUpnpService() Bug: 33457575 Test: VTS tests pass Change-Id: I9fb9a9243a40c2309e549775acabbf90ac9b31da --- .../functional/supplicant_p2p_iface_hidl_test.cpp | 67 +++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp index 6ef32273..0b77a006 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_p2p_iface_hidl_test.cpp @@ -40,6 +40,10 @@ namespace { constexpr uint8_t kTestSsidPostfix[] = {'t', 'e', 's', 't'}; constexpr uint8_t kTestMacAddr[] = {0x56, 0x67, 0x67, 0xf4, 0x56, 0x92}; constexpr uint8_t kTestPeerMacAddr[] = {0x56, 0x67, 0x55, 0xf4, 0x56, 0x92}; +constexpr uint8_t kTestBonjourServiceQuery[] = {'t', 'e', 's', 't', 'q', + 'u', 'e', 'r', 'y'}; +constexpr uint8_t kTestBonjourServiceResponse[] = { + 't', 'e', 's', 't', 'r', 'e', 's', 'p', 'o', 'n', 's', 'e'}; constexpr char kTestConnectPin[] = "34556665"; constexpr char kTestGroupIfName[] = "TestGroup"; constexpr char kTestWpsDeviceName[] = "TestWpsDeviceName"; @@ -47,17 +51,18 @@ constexpr char kTestWpsManufacturer[] = "TestManufacturer"; constexpr char kTestWpsModelName[] = "TestModelName"; constexpr char kTestWpsModelNumber[] = "TestModelNumber"; constexpr char kTestWpsSerialNumber[] = "TestSerialNumber"; +constexpr char kTestUpnpServiceName[] = "TestServiceName"; constexpr uint8_t kTestWpsDeviceType[] = {[0 ... 7] = 0x01}; constexpr uint16_t kTestWpsConfigMethods = 0xffff; constexpr uint32_t kTestConnectGoIntent = 6; constexpr uint32_t kTestFindTimeout = 5; constexpr uint32_t kTestSetGroupIdleTimeout = 6; -constexpr SupplicantNetworkId kTestNetworkId = 5; constexpr uint32_t kTestChannel = 1; constexpr uint32_t kTestOperatingClass = 81; constexpr uint32_t kTestFreqRange[] = {2412, 2432}; constexpr uint32_t kTestExtListenPeriod = 400; constexpr uint32_t kTestExtListenInterval = 400; +constexpr SupplicantNetworkId kTestNetworkId = 5; } // namespace class SupplicantP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase { @@ -534,3 +539,63 @@ TEST_F(SupplicantP2pIfaceHidlTest, SetWpsConfigMethods) { HIDL_INVOKE(p2p_iface_, setWpsConfigMethods, kTestWpsConfigMethods) .code); } + +/* + * AddAndRemoveBonjourService + * This tests that we are able to add a bonjour service, and we can remove it + * by using the same query data. + * This also tests that removeBonjourSerive() returns error when there is no + * existing bonjour service with the same query data. + */ +TEST_F(SupplicantP2pIfaceHidlTest, AddAndRemoveBonjourService) { + EXPECT_EQ(SupplicantStatusCode::SUCCESS, + HIDL_INVOKE( + p2p_iface_, addBonjourService, + std::vector(kTestBonjourServiceQuery, + kTestBonjourServiceQuery + + sizeof(kTestBonjourServiceQuery)), + std::vector(kTestBonjourServiceResponse, + kTestBonjourServiceResponse + + sizeof(kTestBonjourServiceResponse))) + .code); + EXPECT_EQ( + SupplicantStatusCode::SUCCESS, + HIDL_INVOKE(p2p_iface_, removeBonjourService, + std::vector(kTestBonjourServiceQuery, + kTestBonjourServiceQuery + + sizeof(kTestBonjourServiceQuery))) + .code); + // This will fail because boujour service with kTestBonjourServiceQuery was + // already removed. + EXPECT_NE( + SupplicantStatusCode::SUCCESS, + HIDL_INVOKE(p2p_iface_, removeBonjourService, + std::vector(kTestBonjourServiceQuery, + kTestBonjourServiceQuery + + sizeof(kTestBonjourServiceQuery))) + .code); +} + +/* + * AddAndRemoveUpnpService + * This tests that we are able to add a upnp service, and we can remove it + * by using the same service name. + * This also tests that removeUpnpService() returns error when there is no + * exsiting upnp service with the same service name. + */ +TEST_F(SupplicantP2pIfaceHidlTest, AddAndRemoveUpnpService) { + EXPECT_EQ(SupplicantStatusCode::SUCCESS, + HIDL_INVOKE(p2p_iface_, addUpnpService, 0 /* version */, + kTestUpnpServiceName) + .code); + EXPECT_EQ(SupplicantStatusCode::SUCCESS, + HIDL_INVOKE(p2p_iface_, removeUpnpService, 0 /* version */, + kTestUpnpServiceName) + .code); + // This will fail because Upnp service with kTestUpnpServiceName was + // already removed. + EXPECT_NE(SupplicantStatusCode::SUCCESS, + HIDL_INVOKE(p2p_iface_, removeUpnpService, 0 /* version */, + kTestUpnpServiceName) + .code); +} -- 2.11.0