• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <gtest/gtest.h>
16 #include "dhcp_logger.h"
17 #include "dhcp_result_store_manager.h"
18 
19 DEFINE_DHCPLOG_DHCP_LABEL("DhcpResultStoreManagerTest");
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 constexpr int ZERO = 0;
25 class DhcpResultStoreManagerTest : public testing::Test {
26 public:
SetUpTestCase()27     static void SetUpTestCase()
28     {}
TearDownTestCase()29     static void TearDownTestCase()
30     {}
SetUp()31     virtual void SetUp()
32     {}
TearDown()33     virtual void TearDown()
34     {}
35 };
36 /**
37  * @tc.name: SaveIpInfoInLocalFile_SUCCESS
38  * @tc.desc: SaveIpInfoInLocalFile
39  * @tc.type: FUNC
40  * @tc.require: issue
41 */
42 HWTEST_F(DhcpResultStoreManagerTest, SaveIpInfoInLocalFile_SUCCESS, TestSize.Level1)
43 {
44     DHCP_LOGE("enter SaveIpInfoInLocalFile_SUCCESS");
45     IpInfoCached ipInfoCached;
46     ipInfoCached.bssid = "12:34:56:48:78:56";
47     ipInfoCached.absoluteLeasetime = 1;
48     DHCP::DhcpResultStoreManager::GetInstance().SaveIpInfoInLocalFile(ipInfoCached);
49     EXPECT_EQ(DHCP_OPT_SUCCESS, ZERO);
50 }
51 /**
52  * @tc.name: GetCachedDhcpResult_SUCCESS
53  * @tc.desc: GetCachedDhcpResult
54  * @tc.type: FUNC
55  * @tc.require: issue
56 */
57 HWTEST_F(DhcpResultStoreManagerTest, GetCachedDhcpResult_SUCCESS, TestSize.Level1)
58 {
59     DHCP_LOGE("enter GetCachedDhcpResult_SUCCESS");
60     std::string targetBssid = "12:34:56:48:78:56";
61     IpInfoCached ipInfo;
62     DHCP::DhcpResultStoreManager::GetInstance().GetCachedIp(targetBssid, ipInfo);
63     EXPECT_EQ(DHCP_OPT_SUCCESS, ZERO);
64 }
65 }  // namespace OHOS