• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #include "picture_in_picture_manager.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Rosen {
24 class PictureInPictureManagerTest : public testing::Test {
25 public:
26     static void SetUpTestCase();
27     static void TearDownTestCase();
28     void SetUp() override;
29     void TearDown() override;
30 };
31 
SetUpTestCase()32 void PictureInPictureManagerTest::SetUpTestCase()
33 {
34 }
35 
TearDownTestCase()36 void PictureInPictureManagerTest::TearDownTestCase()
37 {
38 }
39 
SetUp()40 void PictureInPictureManagerTest::SetUp()
41 {
42 }
43 
TearDown()44 void PictureInPictureManagerTest::TearDown()
45 {
46 }
47 
48 namespace {
49 
50 /**
51  * @tc.name: PipWindowState
52  * @tc.desc: PutPipControllerInfo/RemovePipControllerInfo
53  * @tc.type: FUNC
54  */
55 HWTEST_F(PictureInPictureManagerTest, PipControllerInfo, Function | SmallTest | Level2)
56 {
57     sptr<PipOption> option = new PipOption();
58     sptr<PictureInPictureController> pipController = new PictureInPictureController(option, nullptr, 100, nullptr);
59     PictureInPictureManager::PutPipControllerInfo(100, pipController);
60     ASSERT_EQ(1, static_cast<int>(PictureInPictureManager::windowToControllerMap_.size()));
61     PictureInPictureManager::RemovePipControllerInfo(100);
62     ASSERT_EQ(0, static_cast<int>(PictureInPictureManager::windowToControllerMap_.size()));
63 }
64 
65 /**
66  * @tc.name: PictureInPictureController
67  * @tc.desc: SetActiveController/IsActiveController/HasActiveController/RemoveActiveController
68  * @tc.type: FUNC
69  */
70 HWTEST_F(PictureInPictureManagerTest, PictureInPictureController, Function | SmallTest | Level2)
71 {
72     sptr<PipOption> option = new PipOption();
73     sptr<PictureInPictureController> pipController = new PictureInPictureController(option, nullptr, 100, nullptr);
74     PictureInPictureManager::SetActiveController(pipController);
75     ASSERT_TRUE(PictureInPictureManager::HasActiveController());
76     ASSERT_TRUE(PictureInPictureManager::IsActiveController(pipController));
77     ASSERT_TRUE(PictureInPictureManager::IsAttachedToSameWindow(100));
78     ASSERT_FALSE(PictureInPictureManager::IsAttachedToSameWindow(1));
79     PictureInPictureManager::RemoveActiveController(pipController);
80     ASSERT_FALSE(PictureInPictureManager::HasActiveController());
81     ASSERT_FALSE(PictureInPictureManager::IsActiveController(pipController));
82 }
83 }
84 }
85 }