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