• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CheckPermissio_Test, TestSize.Level1)
39 {
40     bool ret = drvbundleInstance.CheckBundleMgrProxyPermission();
41     EXPECT_EQ(true, ret);
42     cout << "DrvBundleCallback_CheckPermissio_Test" << endl;
43 }
44 
45 HWTEST_F(DrvBundleStateCallbackTest, DrvBundleCallback_GetAllInfos_Test, TestSize.Level1)
46 {
47     std::map<string, DriverInfo> drvInfos_;
48     bool ret = drvbundleInstance.GetAllDriverInfos(drvInfos_);
49     EXPECT_EQ(true, ret);
50     cout << "Ptr DrvBundleCallback_GetAllInfos_Test" << endl;
51 }
52 
53 HWTEST_F(DrvBundleStateCallbackTest, DrvBundleCallback_GetStiching_Test, TestSize.Level1)
54 {
55     string stiching = drvbundleInstance.GetStiching();
56     EXPECT_NE(true, stiching.empty());
57     cout << "Ptr DrvBundleCallback_GetStiching_Test" << endl;
58 }
59 
60 class DrvBundleStateCallbackPtrTest : public testing::Test {
61 public:
62     DrvBundleStateCallback *drvbundleInstance = nullptr;
SetUp()63     void SetUp() override
64     {
65         drvbundleInstance = new DrvBundleStateCallback();
66         cout << "DrvBundleStateCallbackPtrTest SetUp" << endl;
67     }
TearDown()68     void TearDown() override
69     {
70         if (drvbundleInstance != nullptr) {
71             delete drvbundleInstance;
72             drvbundleInstance = nullptr;
73         }
74         cout << "DrvBundleStateCallbackPtrTest TearDown" << endl;
75     }
76 };
77 
78 HWTEST_F(DrvBundleStateCallbackPtrTest, DrvBundleCallback_New_Test, TestSize.Level1)
79 {
80     EXPECT_NE(nullptr, drvbundleInstance);
81     cout << "DrvBundleCallback_New_Test" << endl;
82 }
83 
84 HWTEST_F(DrvBundleStateCallbackPtrTest, DrvBundleCallback_Delete_Test, TestSize.Level1)
85 {
86     if (drvbundleInstance != nullptr) {
87         delete drvbundleInstance;
88         drvbundleInstance = nullptr;
89         EXPECT_EQ(nullptr, drvbundleInstance);
90     }
91     cout << "DrvBundleCallback_Delete_Test" << endl;
92 }
93 }
94 }