1 /*
2  * Copyright (c) 2023 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 
16 #include <gtest/gtest.h>
17 
18 #include "drv_bundle_state_callback.h"
19 namespace OHOS {
20 namespace ExternalDeviceManager {
21 using namespace std;
22 using namespace testing::ext;
23 using namespace OHOS::ExternalDeviceManager;
24 
25 class DrvBundleStateCallbackTest : public testing::Test {
26 public:
27     DrvBundleStateCallback drvbundleInstance;
SetUp()28     void SetUp() override
29     {
30         cout << "DrvBundleStateCallbackTest SetUp" << endl;
31     }
TearDown()32     void TearDown() override
33     {
34         cout << "DrvBundleStateCallbackTest TearDown" << endl;
35     }
36 };
37 
38 HWTEST_F(DrvBundleStateCallbackTest, DrvBundleCallback_GetAllInfos_Test, TestSize.Level1)
39 {
40     bool ret = drvbundleInstance.GetAllDriverInfos();
41     EXPECT_EQ(true, ret);
42     cout << "Ptr DrvBundleCallback_GetAllInfos_Test" << endl;
43 }
44 
45 HWTEST_F(DrvBundleStateCallbackTest, DrvBundleCallback_GetStiching_Test, TestSize.Level1)
46 {
47     string stiching = drvbundleInstance.GetStiching();
48     EXPECT_NE(true, stiching.empty());
49     cout << "Ptr DrvBundleCallback_GetStiching_Test" << endl;
50 }
51 
52 class DrvBundleStateCallbackPtrTest : public testing::Test {
53 public:
54     DrvBundleStateCallback *drvbundleInstance = nullptr;
SetUp()55     void SetUp() override
56     {
57         drvbundleInstance = new DrvBundleStateCallback();
58         cout << "DrvBundleStateCallbackPtrTest SetUp" << endl;
59     }
TearDown()60     void TearDown() override
61     {
62         if (drvbundleInstance != nullptr) {
63             delete drvbundleInstance;
64             drvbundleInstance = nullptr;
65         }
66         cout << "DrvBundleStateCallbackPtrTest TearDown" << endl;
67     }
68 };
69 
70 HWTEST_F(DrvBundleStateCallbackPtrTest, DrvBundleCallback_New_Test, TestSize.Level1)
71 {
72     EXPECT_NE(nullptr, drvbundleInstance);
73     cout << "DrvBundleCallback_New_Test" << endl;
74 }
75 
76 HWTEST_F(DrvBundleStateCallbackPtrTest, DrvBundleCallback_Delete_Test, TestSize.Level1)
77 {
78     if (drvbundleInstance != nullptr) {
79         delete drvbundleInstance;
80         drvbundleInstance = nullptr;
81         EXPECT_EQ(nullptr, drvbundleInstance);
82     }
83     cout << "DrvBundleCallback_Delete_Test" << endl;
84 }
85 }
86 }