• 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 
16 #include <gtest/gtest.h>
17 #include "event_bean.h"
18 
19 using namespace std;
20 using namespace testing::ext;
21 using namespace OHOS::Media;
22 
23 namespace OHOS {
24 namespace Media {
25 namespace EventBeanUT {
26 class EventBeanInnerUnitTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29 
30     static void TearDownTestCase(void);
31 
32     void SetUp(void);
33 
34     void TearDown(void);
35 
36     std::shared_ptr<MediaMonitor::EventBean> eventBean_;
37     const std::string strKey = "invalidKey";
38     std::string strValue = "invalidValue";
39 };
40 
SetUpTestCase(void)41 void EventBeanInnerUnitTest::SetUpTestCase(void) {}
42 
TearDownTestCase(void)43 void EventBeanInnerUnitTest::TearDownTestCase(void) {}
44 
SetUp(void)45 void EventBeanInnerUnitTest::SetUp(void)
46 {
47     eventBean_ = std::make_shared<MediaMonitor::EventBean>();
48 }
49 
TearDown(void)50 void EventBeanInnerUnitTest::TearDown(void)
51 {
52     eventBean_ = nullptr;
53 }
54 
55 /**
56  * @tc.name: GetIntValue_001
57  * @tc.desc: Test GetIntValue interface
58  * @tc.type: FUNC
59  */
60 HWTEST_F(EventBeanInnerUnitTest, GetIntValue_001, TestSize.Level1)
61 {
62     EXPECT_EQ(-1, eventBean_->GetIntValue(strKey));
63 }
64 
65 /**
66  * @tc.name: GetStringValue_001
67  * @tc.desc: Test GetStringValue interface
68  * @tc.type: FUNC
69  */
70 HWTEST_F(EventBeanInnerUnitTest, GetStringValue_001, TestSize.Level1)
71 {
72     EXPECT_EQ("UNKNOWN", eventBean_->GetStringValue(strKey));
73 }
74 
75 /**
76  * @tc.name: GetUint64Value_001
77  * @tc.desc: Test GetUint64Value interface
78  * @tc.type: FUNC
79  */
80 HWTEST_F(EventBeanInnerUnitTest, GetUint64Value_001, TestSize.Level1)
81 {
82     EXPECT_EQ(0, eventBean_->GetUint64Value(strKey));
83 }
84 
85 /**
86  * @tc.name: GetFloatValue_001
87  * @tc.desc: Test GetFloatValue interface
88  * @tc.type: FUNC
89  */
90 HWTEST_F(EventBeanInnerUnitTest, GetFloatValue_001, TestSize.Level1)
91 {
92     EXPECT_EQ(0, eventBean_->GetFloatValue(strKey));
93 }
94 
95 /**
96  * @tc.name: UpdateIntMap_001
97  * @tc.desc: Test UpdateIntMap interface
98  * @tc.type: FUNC
99  */
100 HWTEST_F(EventBeanInnerUnitTest, UpdateIntMap_001, TestSize.Level1)
101 {
102     eventBean_->UpdateIntMap(strKey, 0);
103     EXPECT_EQ(-1, eventBean_->GetIntValue(strKey));
104 }
105 
106 /**
107  * @tc.name: UpdateStringMap_001
108  * @tc.desc: Test UpdateStringMap interface
109  * @tc.type: FUNC
110  */
111 HWTEST_F(EventBeanInnerUnitTest, UpdateStringMap_001, TestSize.Level1)
112 {
113     eventBean_->UpdateStringMap(strKey, strValue);
114     EXPECT_EQ("UNKNOWN", eventBean_->GetStringValue(strKey));
115 }
116 
117 /**
118  * @tc.name: UpdateUint64Map_001
119  * @tc.desc: Test UpdateUint64Map interface
120  * @tc.type: FUNC
121  */
122 HWTEST_F(EventBeanInnerUnitTest, UpdateUint64Map_001, TestSize.Level1)
123 {
124     eventBean_->UpdateUint64Map(strKey, 1);
125     EXPECT_EQ(0, eventBean_->GetUint64Value(strKey));
126 }
127 
128 /**
129  * @tc.name: UpdateFloatMap_001
130  * @tc.desc: Test UpdateFloatMap interface
131  * @tc.type: FUNC
132  */
133 HWTEST_F(EventBeanInnerUnitTest, UpdateFloatMap_001, TestSize.Level1)
134 {
135     eventBean_->UpdateFloatMap(strKey, 1);
136     EXPECT_EQ(0, eventBean_->GetFloatValue(strKey));
137 }
138 } // namespace EventBeanUT
139 } // namespace Media
140 } // namespace OHOS
141