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 "uc_state_observer_test.h" 17 18 #include "uc_app_state_observer.h" 19 #include "uc_render_state_observer.h" 20 21 using namespace testing::ext; 22 using namespace OHOS::AppExecFwk; 23 using namespace OHOS::HiviewDFX; 24 SetUpTestCase()25void UCStateObserverTest::SetUpTestCase() {} 26 TearDownTestCase()27void UCStateObserverTest::TearDownTestCase() {} 28 SetUp()29void UCStateObserverTest::SetUp() {} 30 TearDown()31void UCStateObserverTest::TearDown() {} 32 33 /** 34 * @tc.name: UCStateObserverTest001 35 * @tc.desc: test UcAppStateObserver callback 36 * @tc.type: FUNC 37 */ 38 HWTEST_F(UCStateObserverTest, UCStateObserverTest001, TestSize.Level3) 39 { 40 UcAppStateObserver appStateObserver; 41 AppStateData appStateData; 42 appStateData.pid = 100; // 100 : test pid 43 appStateData.state = static_cast<int32_t>(ApplicationState::APP_STATE_FOREGROUND); 44 appStateObserver.OnForegroundApplicationChanged(appStateData); 45 ASSERT_TRUE(true); 46 appStateData.state = static_cast<int32_t>(ApplicationState::APP_STATE_BACKGROUND); 47 appStateObserver.OnForegroundApplicationChanged(appStateData); 48 ASSERT_TRUE(true); 49 ProcessData processData; 50 processData.pid = 100; // 100 : test pid 51 appStateObserver.OnProcessCreated(processData); 52 ASSERT_TRUE(true); 53 } 54 55 /** 56 * @tc.name: UCStateObserverTest002 57 * @tc.desc: test UcRenderStateObserver callback 58 * @tc.type: FUNC 59 */ 60 HWTEST_F(UCStateObserverTest, UCStateObserverTest002, TestSize.Level3) 61 { 62 UcRenderStateObserver renderStateObserver; 63 RenderStateData renderStateData; 64 renderStateData.pid = 100; // 100 : test pid 65 renderStateObserver.OnRenderStateChanged(renderStateData); 66 ASSERT_TRUE(true); 67 } 68