mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "p2p: add vts for addGroup_1_2"
This commit is contained in:
2
wifi/supplicant/1.2/vts/OWNERS
Normal file
2
wifi/supplicant/1.2/vts/OWNERS
Normal file
@@ -0,0 +1,2 @@
|
||||
rpius@google.com
|
||||
etancohen@google.com
|
||||
60
wifi/supplicant/1.2/vts/functional/Android.bp
Normal file
60
wifi/supplicant/1.2/vts/functional/Android.bp
Normal file
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// Copyright (C) 2019 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
cc_library_static {
|
||||
name: "VtsHalWifiSupplicantV1_2TargetTestUtil",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["supplicant_hidl_test_utils_1_2.cpp"],
|
||||
export_include_dirs: [
|
||||
"."
|
||||
],
|
||||
static_libs: [
|
||||
"VtsHalWifiV1_0TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_0TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_1TargetTestUtil",
|
||||
"android.hardware.wifi.supplicant@1.0",
|
||||
"android.hardware.wifi.supplicant@1.1",
|
||||
"android.hardware.wifi.supplicant@1.2",
|
||||
"android.hardware.wifi@1.0",
|
||||
"libcrypto",
|
||||
"libgmock",
|
||||
"libwifi-system",
|
||||
"libwifi-system-iface",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalWifiSupplicantP2pV1_2TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: [
|
||||
"VtsHalWifiSupplicantV1_2TargetTest.cpp",
|
||||
"supplicant_p2p_iface_hidl_test.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"VtsHalWifiV1_0TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_0TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_1TargetTestUtil",
|
||||
"VtsHalWifiSupplicantV1_2TargetTestUtil",
|
||||
"android.hardware.wifi.supplicant@1.0",
|
||||
"android.hardware.wifi.supplicant@1.1",
|
||||
"android.hardware.wifi.supplicant@1.2",
|
||||
"android.hardware.wifi@1.0",
|
||||
"libcrypto",
|
||||
"libgmock",
|
||||
"libwifi-system",
|
||||
"libwifi-system-iface",
|
||||
],
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <android/hardware/wifi/supplicant/1.1/ISupplicant.h>
|
||||
#include <android/hardware/wifi/supplicant/1.2/ISupplicant.h>
|
||||
|
||||
#include "supplicant_hidl_test_utils.h"
|
||||
#include "wifi_hidl_test_utils.h"
|
||||
|
||||
class WifiSupplicantHidlEnvironment_1_2 : public WifiSupplicantHidlEnvironment {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static WifiSupplicantHidlEnvironment_1_2* Instance() {
|
||||
static WifiSupplicantHidlEnvironment_1_2* instance =
|
||||
new WifiSupplicantHidlEnvironment_1_2;
|
||||
return instance;
|
||||
}
|
||||
virtual void registerTestServices() override {
|
||||
registerTestService<::android::hardware::wifi::V1_0::IWifi>();
|
||||
registerTestService<
|
||||
::android::hardware::wifi::supplicant::V1_0::ISupplicant>();
|
||||
registerTestService<
|
||||
::android::hardware::wifi::supplicant::V1_1::ISupplicant>();
|
||||
registerTestService<
|
||||
::android::hardware::wifi::supplicant::V1_2::ISupplicant>();
|
||||
}
|
||||
|
||||
private:
|
||||
WifiSupplicantHidlEnvironment_1_2() {}
|
||||
};
|
||||
|
||||
WifiSupplicantHidlEnvironment* gEnv =
|
||||
WifiSupplicantHidlEnvironment_1_2::Instance();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(gEnv);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
gEnv->init(&argc, argv);
|
||||
int status = gEnv->initFromOptions(argc, argv);
|
||||
if (status == 0) {
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "supplicant_hidl_test_utils.h"
|
||||
#include "supplicant_hidl_test_utils_1_2.h"
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantP2pIface;
|
||||
|
||||
sp<ISupplicantP2pIface> getSupplicantP2pIface_1_2() {
|
||||
return ISupplicantP2pIface::castFrom(getSupplicantP2pIface());
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SUPPLICANT_HIDL_TEST_UTILS_1_2_H
|
||||
#define SUPPLICANT_HIDL_TEST_UTILS_1_2_H
|
||||
|
||||
#include <android/hardware/wifi/supplicant/1.2/ISupplicantP2pIface.h>
|
||||
|
||||
android::sp<android::hardware::wifi::supplicant::V1_2::ISupplicantP2pIface>
|
||||
getSupplicantP2pIface_1_2();
|
||||
|
||||
#endif /* SUPPLICANT_HIDL_TEST_UTILS_1_2_H */
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
|
||||
#include <android/hardware/wifi/supplicant/1.2/ISupplicantP2pIface.h>
|
||||
|
||||
#include "supplicant_hidl_test_utils.h"
|
||||
#include "supplicant_hidl_test_utils_1_2.h"
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus;
|
||||
using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode;
|
||||
using ::android::hardware::wifi::supplicant::V1_2::ISupplicantP2pIface;
|
||||
|
||||
namespace {
|
||||
constexpr uint8_t kTestSsid[] = {'D', 'I', 'R', 'E', 'C', 'T', '-', 'x',
|
||||
'y', '-', 'H', 'E', 'L', 'L', 'O'};
|
||||
constexpr char kTestPassphrase[] = "P2pWorld1234";
|
||||
constexpr uint8_t kTestZeroMacAddr[] = {[0 ... 5] = 0x0};
|
||||
} // namespace
|
||||
|
||||
class SupplicantP2pIfaceHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
startSupplicantAndWaitForHidlService();
|
||||
EXPECT_TRUE(turnOnExcessiveLogging());
|
||||
p2p_iface_ = getSupplicantP2pIface_1_2();
|
||||
ASSERT_NE(p2p_iface_.get(), nullptr);
|
||||
}
|
||||
|
||||
virtual void TearDown() override { stopSupplicant(); }
|
||||
|
||||
protected:
|
||||
// ISupplicantP2pIface object used for all tests in this fixture.
|
||||
sp<ISupplicantP2pIface> p2p_iface_;
|
||||
};
|
||||
|
||||
/*
|
||||
* Verify that AddGroup_1_2 could create a group successfully.
|
||||
*/
|
||||
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_Success) {
|
||||
std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
|
||||
std::string passphrase = kTestPassphrase;
|
||||
int freq = 5;
|
||||
std::array<uint8_t, 6> zero_mac_addr;
|
||||
memcpy(zero_mac_addr.data(), kTestZeroMacAddr, zero_mac_addr.size());
|
||||
bool persistent = false;
|
||||
int is_join = false;
|
||||
|
||||
p2p_iface_->addGroup_1_2(ssid, passphrase, persistent, freq, zero_mac_addr,
|
||||
is_join, [](const SupplicantStatus& status) {
|
||||
EXPECT_EQ(SupplicantStatusCode::SUCCESS,
|
||||
status.code);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that AddGroup_1_2 fails due to invalid SSID.
|
||||
*/
|
||||
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidSsid) {
|
||||
std::vector<uint8_t> ssid;
|
||||
std::string passphrase = kTestPassphrase;
|
||||
int freq = 5;
|
||||
std::array<uint8_t, 6> zero_mac_addr;
|
||||
memcpy(zero_mac_addr.data(), kTestZeroMacAddr, zero_mac_addr.size());
|
||||
bool persistent = false;
|
||||
int is_join = false;
|
||||
|
||||
p2p_iface_->addGroup_1_2(
|
||||
ssid, passphrase, persistent, freq, zero_mac_addr, is_join,
|
||||
[](const SupplicantStatus& status) {
|
||||
EXPECT_EQ(SupplicantStatusCode::FAILURE_ARGS_INVALID, status.code);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that AddGroup_1_2 fails due to invalid passphrase.
|
||||
*/
|
||||
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidPassphrase) {
|
||||
std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
|
||||
std::string passphrase = "1234";
|
||||
int freq = 5;
|
||||
std::array<uint8_t, 6> zero_mac_addr;
|
||||
memcpy(zero_mac_addr.data(), kTestZeroMacAddr, zero_mac_addr.size());
|
||||
bool persistent = false;
|
||||
int is_join = false;
|
||||
|
||||
p2p_iface_->addGroup_1_2(
|
||||
ssid, passphrase, persistent, freq, zero_mac_addr, is_join,
|
||||
[](const SupplicantStatus& status) {
|
||||
EXPECT_EQ(SupplicantStatusCode::FAILURE_ARGS_INVALID, status.code);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that AddGroup_1_2 fails due to invalid frequency.
|
||||
*/
|
||||
TEST_F(SupplicantP2pIfaceHidlTest, AddGroup_1_2_FailureInvalidFrequency) {
|
||||
std::vector<uint8_t> ssid(kTestSsid, kTestSsid + sizeof(kTestSsid));
|
||||
std::string passphrase = kTestPassphrase;
|
||||
int freq = 9999;
|
||||
std::array<uint8_t, 6> zero_mac_addr;
|
||||
memcpy(zero_mac_addr.data(), kTestZeroMacAddr, zero_mac_addr.size());
|
||||
bool persistent = false;
|
||||
int is_join = false;
|
||||
|
||||
p2p_iface_->addGroup_1_2(
|
||||
ssid, passphrase, persistent, freq, zero_mac_addr, is_join,
|
||||
[](const SupplicantStatus& status) {
|
||||
EXPECT_EQ(SupplicantStatusCode::FAILURE_UNKNOWN, status.code);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user