• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "dm_rs_surface_node.h"
18 
19 using namespace testing::ext;
20 
21 namespace OHOS::Rosen {
22 /**
23  * @tc.name: Marshalling
24  * @tc.desc: Marshalling test with an empty surfaceNode
25  * @tc.type: FUNC
26  */
27 HWTEST(DmRsSurfaceNodeTest, Marshalling, TestSize.Level1)
28 {
29     DmRsSurfaceNode DmRsSurfaceNode;
30     Parcel parcel;
31     bool ret = DmRsSurfaceNode.Marshalling(parcel);
32     ASSERT_FALSE(ret);
33 }
34 
35 /**
36  * @tc.name: MarshallingUnmarshalling_CustomValues
37  * @tc.desc: Marshalling and unmarshalling test with custom values
38  * @tc.type: FUNC
39  */
40 HWTEST(DmRsSurfaceNodeTest, MarshallingUnmarshalling_CustomValues, TestSize.Level1)
41 {
42     RSSurfaceNodeConfig rsSurfaceNodeConfig;
43     std::shared_ptr<RSSurfaceNode> surfaceNode = std::make_shared<RSSurfaceNode>(rsSurfaceNodeConfig, true, 10);
44     DmRsSurfaceNode dmRsSurfaceNode(surfaceNode);
45 
46     Parcel parcel;
47     bool ret = dmRsSurfaceNode.Marshalling(parcel);
48     ASSERT_TRUE(ret);
49 
50     sptr<DmRsSurfaceNode> node = DmRsSurfaceNode::Unmarshalling(parcel);
51     ASSERT_NE(node, nullptr);
52     EXPECT_TRUE(node->GetSurfaceNode()->isRenderServiceNode_);
53     EXPECT_EQ(node->GetSurfaceNode()->id_, 10);
54     EXPECT_EQ(node->GetSurfaceNode()->isTextureExportNode_, rsSurfaceNodeConfig.isTextureExportNode);
55     EXPECT_EQ(node->GetSurfaceNode()->name_, rsSurfaceNodeConfig.SurfaceNodeName);
56     EXPECT_NE(node->surfaceNode_, nullptr);
57 }
58 } // namespace OHOS::Rosen
59