1 /* 2 * Copyright (c) 2021 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 <gtest/gtest.h> 16 #include <memory> 17 #define private public 18 #include "mock_data_obs_manager_onchange_callback.h" 19 #include "data_ability_observer_proxy.h" 20 21 using namespace testing::ext; 22 using namespace testing; 23 namespace OHOS { 24 namespace AAFwk { 25 class DataAbilityObserverProxyTest : public testing::Test { 26 public: 27 static void SetUpTestCase(void); 28 static void TearDownTestCase(void); 29 void SetUp(); 30 void TearDown(); 31 std::shared_ptr<DataAbilityObserverProxy> proxy_ = nullptr; 32 }; 33 SetUpTestCase(void)34void DataAbilityObserverProxyTest::SetUpTestCase(void) 35 {} TearDownTestCase(void)36void DataAbilityObserverProxyTest::TearDownTestCase(void) 37 {} SetUp()38void DataAbilityObserverProxyTest::SetUp() 39 {} TearDown()40void DataAbilityObserverProxyTest::TearDown() 41 {} 42 43 /* 44 * Feature: DataAbilityObserverProxy. 45 * Function: DataObsManagerProxy::OnChange is called. 46 * SubFunction: NA. 47 * FunctionPoints: NA. 48 * EnvConditions: NA. 49 * CaseDescription: NA. 50 */ 51 HWTEST_F(DataAbilityObserverProxyTest, DataAbilityObserverProxy_OnChangeInner_001, TestSize.Level1) 52 { 53 // 1.stub define 54 sptr<MockDataObsManagerOnChangeCallBack> mockDataAbilityObserverStub(new MockDataObsManagerOnChangeCallBack()); 55 56 // 2.obsver1 define 57 sptr<DataAbilityObserverProxy> proxy(new DataAbilityObserverProxy(mockDataAbilityObserverStub)); 58 59 EXPECT_CALL(*mockDataAbilityObserverStub, OnChange()).Times(1); 60 61 if (proxy != nullptr) { 62 proxy->OnChange(); 63 } 64 } 65 } // namespace AAFwk 66 } // namespace OHOS 67