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 "application_state_observer.h" 19 #include "edm_app_manager_impl.h" 20 21 using namespace testing::ext; 22 23 namespace OHOS { 24 namespace EDM { 25 namespace TEST { 26 class EdmAppManagerImplTest : public testing::Test {}; 27 28 29 /** 30 * @tc.name: TestRegisterApplicationStateObserver 31 * @tc.desc: Test RegisterApplicationStateObserver function. 32 * @tc.type: FUNC 33 */ 34 HWTEST_F(EdmAppManagerImplTest, TestRegisterApplicationStateObserver, TestSize.Level1) 35 { 36 EdmAppManagerImpl edmAppManagerImpl; 37 int ret = edmAppManagerImpl.RegisterApplicationStateObserver(nullptr); 38 ASSERT_TRUE(ret == ERR_APPLICATION_SERVICE_ABNORMALLY); 39 } 40 41 /** 42 * @tc.name: TestUnregisterApplicationStateObserver 43 * @tc.desc: Test UnregisterApplicationStateObserver function. 44 * @tc.type: FUNC 45 */ 46 HWTEST_F(EdmAppManagerImplTest, TestUnregisterApplicationStateObserver, TestSize.Level1) 47 { 48 EdmAppManagerImpl edmAppManagerImpl; 49 int ret = edmAppManagerImpl.UnregisterApplicationStateObserver(nullptr); 50 ASSERT_TRUE(ret == ERR_APPLICATION_SERVICE_ABNORMALLY); 51 } 52 53 /** 54 * @tc.name: TestRegisterApplicationStateObserver02 55 * @tc.desc: Test UnregisterApplicationStateObserver function. 56 * @tc.type: FUNC 57 */ 58 HWTEST_F(EdmAppManagerImplTest, TestRegisterApplicationStateObserver02, TestSize.Level1) 59 { 60 EdmAppManagerImpl edmAppManagerImpl; 61 sptr<AppExecFwk::IApplicationStateObserver> appStateObserver; 62 int ret = edmAppManagerImpl.RegisterApplicationStateObserver(appStateObserver); 63 ASSERT_TRUE(ret == ERR_APPLICATION_SERVICE_ABNORMALLY); 64 65 ret = edmAppManagerImpl.UnregisterApplicationStateObserver(appStateObserver); 66 ASSERT_TRUE(ret == ERR_APPLICATION_SERVICE_ABNORMALLY); 67 } 68 } // namespace TEST 69 } // namespace EDM 70 } // namespace OHOS 71