!1483 hml 1.0 补充TDD用例

Merge pull request !1483 from HW-cjd/master
This commit is contained in:
openharmony_ci 2023-11-24 13:50:50 +00:00 committed by Gitee
commit c3c87b5105
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 208 additions and 0 deletions

View File

@ -61,6 +61,7 @@ ohos_unittest("wifi_hal_unittest") {
"wifi_hal_ap_interface_test.cpp",
"wifi_hal_base_interface_test.cpp",
"wifi_hal_callback_test.cpp",
"wifi_hal_chba_interface_test.cpp",
"wifi_hal_chip_interface_test.cpp",
"wifi_hal_common_func_test.cpp",
"wifi_hal_crpc_p2p_test.cpp",
@ -69,6 +70,7 @@ ohos_unittest("wifi_hal_unittest") {
"wifi_hal_hostapd_test.cpp",
"wifi_hal_p2p_interface_test.cpp",
"wifi_hal_sta_interface_test.cpp",
"wifi_hal_wpa_common_test.cpp",
"wifi_hal_wpa_p2p_test.cpp",
"wifi_hal_wpa_sta_test.cpp",
"wifi_wpa_common_test.cpp",

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* 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 "wifi_hal_chba_interface_test.h"
#include "securec.h"
#include "wifi_log.h"
#include "wifi_hal_chba_interface.h"
#include "mock_wpa_ctrl.h"
#undef LOG_TAG
#define LOG_TAG "WifiHalChbaInterfaceTest"
using namespace testing::ext;
namespace OHOS {
namespace Wifi {
void WifiHalChbaInterfaceTest::SetUpTestCase()
{
MockInitGlobalCmd();
}
HWTEST_F(WifiHalChbaInterfaceTest, ChbaStartTest, TestSize.Level1)
{
LOGE("enter ChbaStartTest");
EXPECT_TRUE(ChbaStart() == WIFI_HAL_SUCCESS);
}
HWTEST_F(WifiHalChbaInterfaceTest, ChbaStopTest, TestSize.Level1)
{
LOGE("enter ChbaStopTest");
EXPECT_TRUE(ChbaStop() == WIFI_HAL_SUCCESS);
}
} // namespace Wifi
} // namespace OHOS

View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* 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 OHOS_WIFI_HAL_CHBA_INTERFACE_TEST_H
#define OHOS_WIFI_HAL_CHBA_INTERFACE_TEST_H
#include <gtest/gtest.h>
namespace OHOS {
namespace Wifi {
class WifiHalChbaInterfaceTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase()
{}
virtual void SetUp()
{}
virtual void TearDown()
{}
};
} // namespace Wifi
} // namespace OHOS
#endif

View File

@ -27,6 +27,9 @@
#include "mock_wpa_ctrl.h"
#include "wifi_hal_common_func.h"
#undef LOG_TAG
#define LOG_TAG "WifiHalCRpcServerTest"
using namespace testing::ext;
namespace OHOS {
@ -1462,5 +1465,34 @@ HWTEST_F(WifiHalCRpcServerTest, RpcSetSuspendModeTest, TestSize.Level1)
mContext->nSize = strlen(buff1);
EXPECT_TRUE(RpcSetSuspendMode(mServer, mContext) == 0);
}
HWTEST_F(WifiHalCRpcServerTest, RpcGetCommonCmdTest, TestSize.Level1)
{
LOGE("enter RpcGetCommonCmdTest");
EXPECT_TRUE(RpcGetCommonCmd(nullptr, nullptr) < 0);
EXPECT_TRUE(RpcGetCommonCmd(mServer, nullptr) < 0);
char buff[] = "N\tRpcGetCommonCmd\tchba0";
mContext->oneProcess = buff;
mContext->nPos = strlen("N\tRpcGetCommonCmd\t");
mContext->nSize = strlen(buff);
EXPECT_TRUE(RpcGetCommonCmd(mServer, mContext) == -1);
}
HWTEST_F(WifiHalCRpcServerTest, RpcChbaStartTest, TestSize.Level1)
{
LOGE("enter RpcChbaStartTest");
EXPECT_TRUE(RpcChbaStart(nullptr, nullptr) < 0);
EXPECT_TRUE(RpcChbaStart(mServer, nullptr) < 0);
EXPECT_TRUE(RpcChbaStart(mServer, mContext) == 0);
}
HWTEST_F(WifiHalCRpcServerTest, RpcChbaStopTest, TestSize.Level1)
{
LOGE("enter RpcChbaStopTest");
EXPECT_TRUE(RpcChbaStop(nullptr, nullptr) < 0);
EXPECT_TRUE(RpcChbaStop(mServer, nullptr) < 0);
EXPECT_TRUE(RpcChbaStop(mServer, mContext) == 0);
}
} // namespace Wifi
} // namespace OHOS

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* 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 "wifi_hal_wpa_common_test.h"
#include "securec.h"
#include "wifi_log.h"
#include "wifi_common_hal.h"
#include "mock_wpa_ctrl.h"
#undef LOG_TAG
#define LOG_TAG "WifiHalWpaCommonTest"
using namespace testing::ext;
namespace OHOS {
namespace Wifi {
void WifiHalWpaCommonTest::SetUpTestCase()
{
}
void WifiHalWpaCommonTest::TearDownTestCase()
{
}
HWTEST_F(WifiHalWpaCommonTest, SendComCmdTest, TestSize.Level1)
{
LOGE("enter SendComCmdTest");
const char* cmd = nullptr;
EXPECT_EQ(-1, SendComCmd(cmd));
const char* cmd1 = "nullptr";
EXPECT_EQ(-1, SendComCmd(cmd1));
}
HWTEST_F(WifiHalWpaCommonTest, HalCallbackNotifyTest, TestSize.Level1)
{
LOGE("enter HalCallbackNotifyTest");
const char* event = nullptr;
EXPECT_EQ(-1, HalCallbackNotify(event));
const char* event1 = "nullptr";
EXPECT_EQ(0, HalCallbackNotify(event1));
}
} // namespace Wifi
} // namespace OHOS

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* 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 OHOS_WIFI_HAL_WPA_COMMON_TEST_H
#define OHOS_WIFI_HAL_WPA_COMMON_TEST_H
#include <gtest/gtest.h>
#include "server.h"
#include "wifi_p2p_hal.h"
#include "wifi_wpa_hal.h"
#include "wifi_common_hal.h"
namespace OHOS {
namespace Wifi {
class WifiHalWpaCommonTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
virtual void SetUp()
{}
virtual void TearDown()
{}
};
} // namespace Wifi
} // namespace OHOS
#endif