• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 <cstdio>
17 #include <gtest/gtest.h>
18 
19 #include "volume/notification.h"
20 
21 namespace {
22 using namespace std;
23 using namespace OHOS;
24 using namespace StorageManager;
25 class NotificationTest : public testing::Test {
26 public:
SetUpTestCase(void)27     static void SetUpTestCase(void) {};
TearDownTestCase()28     static void TearDownTestCase() {};
SetUp()29     void SetUp() {};
TearDown()30     void TearDown() {};
31 };
32 
33 /**
34  * @tc.number: SUB_STORAGE_Notification_NotifyVolumeChange_0000
35  * @tc.name: Notification_NotifyVolumeChange_0000
36  * @tc.desc: Test function of NotifyVolumeChange interface for SUCCESS.
37  * @tc.size: MEDIUM
38  * @tc.type: FUNC
39  * @tc.level Level 1
40  * @tc.require: SR000GGUPF
41  */
42 
43 HWTEST_F(NotificationTest, Notification_NotifyVolumeChange_0000, testing::ext::TestSize.Level1)
44 {
45     GTEST_LOG_(INFO) << "NotificationTest-begin Notification_NotifyVolumeChange_0000";
46         int32_t notifyCode = VOLUME_REMOVED;
47         std::string id = "000";
48         std::string diskId = "000";
49         std::string fsUuid = "000";
50         std::string path  = "/";
51         std::shared_ptr<Notification> notification = DelayedSingleton<Notification>::GetInstance();
52         notification->NotifyVolumeChange(notifyCode, id, diskId, fsUuid, path);
53     GTEST_LOG_(INFO) << "NotificationTest-end Notification_NotifyVolumeChange_0000";
54 }
55 
56 /**
57  * @tc.number: SUB_STORAGE_Notification_NotifyVolumeChange_0001
58  * @tc.name: Notification_NotifyVolumeChange_0001
59  * @tc.desc: Test function of NotifyVolumeChange interface for SUCCESS.
60  * @tc.size: MEDIUM
61  * @tc.type: FUNC
62  * @tc.level Level 1
63  * @tc.require: SR000GGUPF
64  */
65 
66 HWTEST_F(NotificationTest, Notification_NotifyVolumeChange_0001, testing::ext::TestSize.Level1)
67 {
68     GTEST_LOG_(INFO) << "NotificationTestt-begin Notification_NotifyVolumeChange_0001";
69         int32_t notifyCode = VOLUME_UNMOUNTED;
70         std::string id = "111";
71         std::string diskId = "111";
72         std::string fsUuid = "111";
73         std::string path  = "/";
74         std::shared_ptr<Notification> notification = DelayedSingleton<Notification>::GetInstance();
75         notification->NotifyVolumeChange(notifyCode, id, diskId, fsUuid, path);
76     GTEST_LOG_(INFO) << "NotificationTest-end Notification_NotifyVolumeChange_0001";
77 }
78 
79 /**
80  * @tc.number: SUB_STORAGE_Notification_NotifyVolumeChange_0002
81  * @tc.name: Notification_NotifyVolumeChange_0002
82  * @tc.desc: Test function of NotifyVolumeChange interface for SUCCESS.
83  * @tc.size: MEDIUM
84  * @tc.type: FUNC
85  * @tc.level Level 1
86  * @tc.require: SR000GGUPF
87  */
88 
89 HWTEST_F(NotificationTest, Notification_NotifyVolumeChange_0002, testing::ext::TestSize.Level1)
90 {
91     GTEST_LOG_(INFO) << "NotificationTest-begin Notification_NotifyVolumeChange_0002";
92         int32_t notifyCode = VOLUME_MOUNTED;
93         std::string id = "222";
94         std::string diskId = "222";
95         std::string fsUuid = "222";
96         std::string path  = "/";
97         std::shared_ptr<Notification> notification = DelayedSingleton<Notification>::GetInstance();
98         notification->NotifyVolumeChange(notifyCode, id, diskId, fsUuid, path);
99     GTEST_LOG_(INFO) << "NotificationTest-end Notification_NotifyVolumeChange_0002";
100 }
101 
102 /**
103  * @tc.number: SUB_STORAGE_Notification_NotifyVolumeChange_0003
104  * @tc.name: Notification_NotifyVolumeChange_0003
105  * @tc.desc: Test function of NotifyVolumeChange interface for SUCCESS.
106  * @tc.size: MEDIUM
107  * @tc.type: FUNC
108  * @tc.level Level 1
109  * @tc.require: SR000GGUPF
110  */
111 
112 HWTEST_F(NotificationTest, Notification_NotifyVolumeChange_0003, testing::ext::TestSize.Level1)
113 {
114     GTEST_LOG_(INFO) << "NotificationTest-begin Notification_NotifyVolumeChange_0003";
115         int32_t notifyCode = VOLUME_BAD_REMOVAL;
116         std::string id = "333";
117         std::string diskId = "333";
118         std::string fsUuid = "333";
119         std::string path  = "/";
120         std::shared_ptr<Notification> notification = DelayedSingleton<Notification>::GetInstance();
121         notification->NotifyVolumeChange(notifyCode, id, diskId, fsUuid, path);
122     GTEST_LOG_(INFO) << "NotificationTest-end Notification_NotifyVolumeChange_0003";
123 }
124 
125 /**
126  * @tc.number: SUB_STORAGE_Notification_NotifyVolumeChange_0004
127  * @tc.name: Notification_NotifyVolumeChange_0004
128  * @tc.desc: Test function of NotifyVolumeChange interface for SUCCESS.
129  * @tc.size: MEDIUM
130  * @tc.type: FUNC
131  * @tc.level Level 1
132  * @tc.require: SR000GGUPF
133  */
134 
135 HWTEST_F(NotificationTest, Notification_NotifyVolumeChange_0004, testing::ext::TestSize.Level1)
136 {
137     GTEST_LOG_(INFO) << "NotificationTest-begin Notification_NotifyVolumeChange_0004";
138         int32_t notifyCode = VOLUME_EJECT;
139         std::string id = "444";
140         std::string diskId = "444";
141         std::string fsUuid = "444";
142         std::string path  = "/";
143         std::shared_ptr<Notification> notification = DelayedSingleton<Notification>::GetInstance();
144         notification->NotifyVolumeChange(notifyCode, id, diskId, fsUuid, path);
145     GTEST_LOG_(INFO) << "NotificationTest-end Notification_NotifyVolumeChange_0004";
146 }
147 
148 /**
149  * @tc.number: SUB_STORAGE_Notification_NotifyVolumeChange_0005
150  * @tc.name: Notification_NotifyVolumeChange_0005
151  * @tc.desc: Test function of NotifyVolumeChange interface for SUCCESS.
152  * @tc.size: MEDIUM
153  * @tc.type: FUNC
154  * @tc.level Level 1
155  * @tc.require: SR000GGUPF
156  */
157 
158 HWTEST_F(NotificationTest, Notification_NotifyVolumeChange_0005, testing::ext::TestSize.Level1)
159 {
160     GTEST_LOG_(INFO) << "NotificationTest-begin Notification_NotifyVolumeChange_0005";
161         int32_t notifyCode = 5;
162         std::string id = "555";
163         std::string diskId = "555";
164         std::string fsUuid = "555";
165         std::string path  = "/";
166         std::shared_ptr<Notification> notification = DelayedSingleton<Notification>::GetInstance();
167         notification->NotifyVolumeChange(notifyCode, id, diskId, fsUuid, path);
168     GTEST_LOG_(INFO) << "NotificationTest-end Notification_NotifyVolumeChange_0005";
169 }
170 }
171