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 18 #include "user_switch_reporter.h" 19 20 using namespace testing; 21 using namespace testing::ext; 22 23 namespace OHOS { 24 namespace Rosen { 25 class UserSwitchReporterTest : public Test { 26 protected: SetUp()27 void SetUp() override {} TearDown()28 void TearDown() override {} 29 }; 30 31 /** 32 * @tc.name: ConstructorInitializesStartTime 33 * @tc.desc: Verify that the constructor correctly records the switch start time. 34 * @tc.type: FUNC 35 */ 36 HWTEST_F(UserSwitchReporterTest, ConstructorInitializesStartTime, Function | SmallTest | Level1) 37 { 38 UserSwitchReporter reporter(true); 39 EXPECT_GT(reporter.startTime_, 0); 40 } 41 42 /** 43 * @tc.name: ReportSwitchDurationCorrectly 44 * @tc.desc: Verify that ReportSwitchDuration correctly reports the switch duration. 45 * @tc.type: FUNC 46 */ 47 HWTEST_F(UserSwitchReporterTest, ReportSwitchDurationCorrectly, Function | SmallTest | Level1) 48 { 49 UserSwitchReporter reporter(true); 50 EXPECT_TRUE(reporter.ReportSwitchDuration()); 51 } 52 } // namespace Rosen 53 } // namespace OHOS