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 <gtest/gtest.h>
17 #include <hilog/log.h>
18 #include <memory>
19 #include <unistd.h>
20
21 #include "pipeline/rs_base_render_node.h"
22 #include "pipeline/rs_context.h"
23
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS::Rosen {
28 static const int nodeId1 = 1;
29
30 class RSTunnelHandleTest : public testing::Test {
31 public:
32 static constexpr HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, 0, "RSTunnelHandleTest" };
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp() override;
36 void TearDown() override;
37
38 static inline std::shared_ptr<RSContext> context = nullptr;
39 static inline std::shared_ptr<RSBaseRenderNode> node1 = nullptr;
40 };
41
SetUpTestCase()42 void RSTunnelHandleTest::SetUpTestCase()
43 {
44 context = std::make_shared<RSContext>();
45 node1 = std::make_shared<RSBaseRenderNode>(nodeId1, context->weak_from_this());
46 }
47
TearDownTestCase()48 void RSTunnelHandleTest::TearDownTestCase()
49 {
50 node1 = nullptr;
51 context = nullptr;
52 }
53
SetUp()54 void RSTunnelHandleTest::SetUp() {}
TearDown()55 void RSTunnelHandleTest::TearDown() {}
56
57 /**
58 * @tc.name: GetDefaultTunnelHandleChange
59 * @tc.desc: Verify the main function of RSTunnelHandle
60 * @tc.type: FUNC
61 * @tc.require: issueI5HSJS
62 */
63 HWTEST_F(RSTunnelHandleTest, GetDefaultTunnelHandleChange, Function | SmallTest | Level2)
64 {
65 // check TunnelHandleChange
66 EXPECT_EQ(node1->GetTunnelHandleChange(), false);
67 }
68
69 /**
70 * @tc.name: SetTunnelHandleChange
71 * @tc.desc: Verify the main function of RSTunnelHandle
72 * @tc.type: FUNC
73 * @tc.require: issueI5HSJS
74 */
75 HWTEST_F(RSTunnelHandleTest, SetTunnelHandleChange, Function | SmallTest | Level2)
76 {
77 // call SetTunnelHandleChange
78 node1->SetTunnelHandleChange(true);
79 // check TunnelHandleChange
80 EXPECT_EQ(node1->GetTunnelHandleChange(), true);
81 }
82 } // namespace OHOS::Rosen
83