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
18 #include "acquire_fence_manager.h"
19 #include "sync_fence.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 class AcquireFenceTrackerTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 };
30
SetUpTestCase()31 void AcquireFenceTrackerTest::SetUpTestCase()
32 {
33 }
34
TearDownTestCase()35 void AcquireFenceTrackerTest::TearDownTestCase()
36 {
37 }
38
39 /*
40 * Function: TrackFence
41 * Type: Function
42 * Rank: Important(2)
43 * EnvConditions: N/A
44 * CaseDescription: 1. call TrackFence
45 * 2. check ret
46 */
47 HWTEST_F(AcquireFenceTrackerTest, TrackFence001, Function | MediumTest | Level2)
48 {
49 int32_t fd = -1;
50 sptr<SyncFence> syncFence = new SyncFence(fd);
51 bool traceTag = true;
52 AcquireFenceTracker::TrackFence((const sptr<SyncFence>&)syncFence, traceTag);
53 }
54
55 /*
56 * Function: SetBlurSize
57 * Type: Function
58 * Rank: Important(2)
59 * EnvConditions: N/A
60 * CaseDescription: 1. call SetBlurSize
61 * 2. check ret
62 */
63 HWTEST_F(AcquireFenceTrackerTest, blurSize001, Function | MediumTest | Level2)
64 {
65 int32_t blurSize = 10;
66 AcquireFenceTracker::SetBlurSize(blurSize);
67 }
68
69 /*
70 * Function: SetContainerNodeNum
71 * Type: Function
72 * Rank: Important(2)
73 * EnvConditions: N/A
74 * CaseDescription: 1. call SetContainerNodeNum
75 * 2. check ret
76 */
77 HWTEST_F(AcquireFenceTrackerTest, SetContainerNodeNum001, Function | MediumTest | Level2)
78 {
79 int containerNodeNum = 1000;
80 AcquireFenceTracker::SetContainerNodeNum(containerNodeNum);
81 }
82
83 /*
84 * Function: AcquireFenceTracker
85 * Type: Function
86 * Rank: Important(2)
87 * EnvConditions: N/A
88 * CaseDescription: 1. call AcquireFenceTracker
89 * 2. check ret
90 */
91 HWTEST_F(AcquireFenceTrackerTest, AcquireFenceTracker001, Function | MediumTest | Level2)
92 {
93 sptr<SyncFence> syncFence = new SyncFence(0);
94 AcquireFenceTracker::tracker_ = nullptr;
95 AcquireFenceTracker::TrackFence(syncFence, true);
96 int32_t blurSize = 10;
97 AcquireFenceTracker::SetBlurSize(blurSize);
98 int containerNodeNum = 1000;
99 AcquireFenceTracker::SetContainerNodeNum(containerNodeNum);
100 }
101
102 /*
103 * Function: GetStatus
104 * Type: Function
105 * Rank: Important(2)
106 * EnvConditions: N/A
107 * CaseDescription: 1. call GetStatus with invaild fd
108 * 2. check ret is ERROR
109 */
110 HWTEST_F(AcquireFenceTrackerTest, GetStatus001, Function | MediumTest | Level2)
111 {
112 sptr<SyncFence> syncFence = new SyncFence(-1);
113 EXPECT_EQ(syncFence->GetStatus(), ERROR);
114 }
115 }