• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "window_frame_trace.h"
17 #include <gtest/gtest.h>
18 #include <unistd.h>
19 
20 using namespace testing;
21 using namespace testing::ext;
22 namespace FRAME_TRACE {
23 class WindowFrameTraceImplTest : public testing::Test {
24   public:
WindowFrameTraceImplTest()25     WindowFrameTraceImplTest() {}
~WindowFrameTraceImplTest()26     ~WindowFrameTraceImplTest() {}
27 };
28 
29 namespace {
30 #ifdef FRAME_TRACE_ENABLE
31 /**
32  * @tc.name: AccessFrameTrace01
33  * @tc.desc: normal function
34  * @tc.type: FUNC
35  */
36 HWTEST_F(WindowFrameTraceImplTest, AccessFrameTrace01, Function | SmallTest | Level2)
37 {
38     GTEST_LOG_(INFO) << "WindowFrameTraceImplTest: AccessFrameTrace01 start";
39     WindowFrameTraceImpl trace;
40     bool res = trace.AccessFrameTrace();
41     ASSERT_EQ(res, true);
42     bool res1 = trace.AccessFrameTrace();
43     ASSERT_EQ(res1, true);
44     WindowFrameTraceImpl *trace_ = WindowFrameTraceImpl::GetInstance();
45     bool res2 = trace_->AccessFrameTrace();
46     ASSERT_EQ(res2, true);
47     GTEST_LOG_(INFO) << "WindowFrameTraceImplTest: AccessFrameTrace01 end";
48 }
49 
50 /**
51  * @tc.name: VsyncStartFrameTrace01
52  * @tc.desc: normal function
53  * @tc.type: FUNC
54  */
55 HWTEST_F(WindowFrameTraceImplTest, VsyncStartFrameTrace01, Function | SmallTest | Level2)
56 {
57     GTEST_LOG_(INFO) << "WindowFrameTraceImplTest: VsyncStartFrameTrace01 start";
58     WindowFrameTraceImpl trace;
59     int32_t res = 0;
60     trace.VsyncStartFrameTrace();
61     ASSERT_EQ(res, 0);
62     WindowFrameTraceImpl *trace_ = WindowFrameTraceImpl::GetInstance();
63     bool res2 = trace_->AccessFrameTrace();
64     trace_->VsyncStartFrameTrace();
65     ASSERT_EQ(res2, true);
66     GTEST_LOG_(INFO) << "WindowFrameTraceImplTest: VsyncStartFrameTrace01 end";
67 }
68 
69 /**
70  * @tc.name: VsyncStopFrameTrace01
71  * @tc.desc: normal function
72  * @tc.type: FUNC
73  */
74 HWTEST_F(WindowFrameTraceImplTest, VsyncStopFrameTrace01, Function | SmallTest | Level2)
75 {
76     GTEST_LOG_(INFO) << "WindowFrameTraceImplTest: VsyncStopFrameTrace01 start";
77     WindowFrameTraceImpl trace;
78     int32_t res = 0;
79     trace.VsyncStopFrameTrace();
80     ASSERT_EQ(res, 0);
81     WindowFrameTraceImpl *trace_ = WindowFrameTraceImpl::GetInstance();
82     bool res2 = trace_->AccessFrameTrace();
83     trace_->VsyncStartFrameTrace();
84     trace_->VsyncStopFrameTrace();
85     ASSERT_EQ(res2, true);
86     GTEST_LOG_(INFO) << "WindowFrameTraceImplTest: VsyncStopFrameTrace01 end";
87 }
88 #endif
89 } // namespace
90 } // namespace FRAME_TRACE
91