• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "media_service_helper_unit_test.h"
17 #include "media_errors.h"
18 
19 using namespace std;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Media {
24 constexpr int32_t CONSTRUCTED_PID = 999999;
25 
SetUpTestCase(void)26 void MediaServiceHelperUnitTest::SetUpTestCase(void)
27 {
28 }
29 
TearDownTestCase(void)30 void MediaServiceHelperUnitTest::TearDownTestCase(void)
31 {
32 }
33 
SetUp(void)34 void MediaServiceHelperUnitTest::SetUp(void)
35 {
36 }
37 
TearDown(void)38 void MediaServiceHelperUnitTest::TearDown(void)
39 {
40 }
41 
42 HWTEST_F(MediaServiceHelperUnitTest, ProxyForFreeze_001, TestSize.Level0)
43 {
44     std::set<int32_t> pidList;
45     pidList.insert(CONSTRUCTED_PID);
46     bool isProxy = true;
47     auto ret = MediaServiceHelper::ProxyForFreeze(pidList, isProxy);
48     EXPECT_FALSE(ret);
49 }
50 
51 HWTEST_F(MediaServiceHelperUnitTest, ResetAllProxy_001, TestSize.Level0)
52 {
53     auto ret = MediaServiceHelper::ResetAllProxy();
54     EXPECT_FALSE(ret);
55 }
56 
57 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_001, TestSize.Level0)
58 {
59     EXPECT_TRUE(MediaServiceHelper::CanKillMediaService());
60 }
61 
62 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_002, TestSize.Level0)
63 {
64     std::shared_ptr<Player> player = PlayerFactory::CreatePlayer();
65     EXPECT_TRUE(MediaServiceHelper::CanKillMediaService());
66 }
67 
68 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_003, TestSize.Level0)
69 {
70     std::shared_ptr<Player> player = PlayerFactory::CreatePlayer();
71     std::shared_ptr<Recorder> recoder = RecorderFactory::CreateRecorder();
72     EXPECT_FALSE(MediaServiceHelper::CanKillMediaService());
73 }
74 
75 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_004, TestSize.Level0)
76 {
77     std::shared_ptr<Player> player = PlayerFactory::CreatePlayer();
78     std::shared_ptr<IRecorderProfilesService> recorderProfilesService =
79         MediaServiceFactory::GetInstance().CreateRecorderProfilesService();
80     EXPECT_FALSE(MediaServiceHelper::CanKillMediaService());
81 }
82 
83 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_005, TestSize.Level0)
84 {
85     std::shared_ptr<Player> player = PlayerFactory::CreatePlayer();
86     std::shared_ptr<ScreenCapture> screenCapture = ScreenCaptureFactory::CreateScreenCapture();
87     EXPECT_FALSE(MediaServiceHelper::CanKillMediaService());
88 }
89 
90 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_006, TestSize.Level0)
91 {
92     std::shared_ptr<Player> player = PlayerFactory::CreatePlayer();
93     std::shared_ptr<ScreenCaptureController> controller =
94         ScreenCaptureControllerFactory::CreateScreenCaptureController();
95     std::shared_ptr<IScreenCaptureController> controllerClient =
96         MediaServiceFactory::GetInstance().CreateScreenCaptureControllerClient();
97     EXPECT_FALSE(MediaServiceHelper::CanKillMediaService());
98 }
99 
100 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_007, TestSize.Level0)
101 {
102     std::shared_ptr<Player> player = PlayerFactory::CreatePlayer();
103     std::shared_ptr<TransCoder> transCoder = TransCoderFactory::CreateTransCoder();
104     EXPECT_FALSE(MediaServiceHelper::CanKillMediaService());
105 }
106 
107 HWTEST_F(MediaServiceHelperUnitTest, CanKillMediaService_008, TestSize.Level0)
108 {
109     std::shared_ptr<Player> player = PlayerFactory::CreatePlayer();
110     std::shared_ptr<AVMetadataHelper> avMetadata = AVMetadataHelperFactory::CreateAVMetadataHelper();
111     EXPECT_FALSE(MediaServiceHelper::CanKillMediaService());
112 }
113 
114 } // namespace Media
115 } // namespace OHOS