• 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 <utility>
18 
19 #include "avsession_sysevent.h"
20 
21 using namespace OHOS;
22 using namespace OHOS::AVSession;
23 
24 class AVsessionSyseventTest : public testing::Test {
25 public:
26     static void SetUpTestCase(void);
27     static void TearDownTestCase(void);
28     void SetUp();
29     void TearDown();
30 };
31 
SetUpTestCase()32 void AVsessionSyseventTest::SetUpTestCase()
33 {}
34 
TearDownTestCase()35 void AVsessionSyseventTest::TearDownTestCase()
36 {}
37 
SetUp()38 void AVsessionSyseventTest::SetUp()
39 {}
40 
TearDown()41 void AVsessionSyseventTest::TearDown()
42 {}
43 
44 #ifdef ENABLE_AVSESSION_SYSEVENT_CONTROL
45 /**
46 * @tc.name: Regiter001
47 * @tc.desc: test Regiter
48 * @tc.type: FUNC
49 * @tc.require:
50 */
51 static HWTEST_F(AVsessionSyseventTest, Regiter001, testing::ext::TestSize.Level0)
52 {
53     AVSessionSysEvent::GetInstance().Unregister();
54     EXPECT_EQ(AVSessionSysEvent::GetInstance().timer_, nullptr);
55     AVSessionSysEvent::GetInstance().Regiter();
56     AVSessionSysEvent::GetInstance().Regiter();
57     AVSessionSysEvent::GetInstance().Unregister();
58 }
59 
60 /**
61 * @tc.name: AddLowQualityInfo001
62 * @tc.desc: test AddLowQualityInfo
63 * @tc.type: FUNC
64 * @tc.require:
65 */
66 static HWTEST_F(AVsessionSyseventTest, AddLowQualityInfo001, testing::ext::TestSize.Level0)
67 {
68     AVSessionSysEvent::BackControlReportInfo reportInfo;
69     AVSessionSysEvent::GetInstance().lowQualityInfos_.insert(std::make_pair("default", reportInfo));
70     AVSessionSysEvent::GetInstance().AddLowQualityInfo(reportInfo);
71 }
72 
73 /**
74 * @tc.name: AddLowQualityInfo002
75 * @tc.desc: test AddLowQualityInfo
76 * @tc.type: FUNC
77 * @tc.require:
78 */
79 static HWTEST_F(AVsessionSyseventTest, AddLowQualityInfo002, testing::ext::TestSize.Level0)
80 {
81     AVSessionSysEvent::BackControlReportInfo reportInfo;
82     reportInfo.bundleName_ = "default";
83     AVSessionSysEvent::GetInstance().lowQualityInfos_.insert(std::make_pair("default", reportInfo));
84     AVSessionSysEvent::GetInstance().AddLowQualityInfo(reportInfo);
85 }
86 #endif
87