1 /* 2 * Copyright (c) 2021-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 16 #ifndef MOCK_OHOS_ABILITY_RUNTIME_DEMO_ABILITY_TEST_H 17 #define MOCK_OHOS_ABILITY_RUNTIME_DEMO_ABILITY_TEST_H 18 #include "ability.h" 19 #include "ability_loader.h" 20 #include "want.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 class DemoAbility : public Ability { 25 protected: 26 void OnStart(const Want& want, sptr<AAFwk::SessionInfo> sessionInfo = nullptr) override; 27 void OnStop() override; 28 void OnActive() override; 29 void OnInactive() override; 30 void OnBackground() override; 31 void OnForeground(const Want& want) override; 32 void OnNewWant(const Want& want) override; 33 sptr<IRemoteObject> OnConnect(const Want& want) override; 34 void OnDisconnect(const Want& want) override; 35 void OnCommand(const AAFwk::Want& want, bool restart, int startId) override; 36 37 void OnRestoreAbilityState(const PacMap& inState); 38 void OnSaveAbilityState(PacMap& outState); 39 void OnAbilityResult(int requestCode, int resultCode, const Want& resultData); 40 41 std::vector<std::string> GetFileTypes(const Uri& uri, const std::string& mimeTypeFilter); 42 int OpenFile(const Uri& uri, const std::string& mode); 43 int Delete(const Uri& uri, const NativeRdb::DataAbilityPredicates& predicates); 44 int Insert(const Uri& uri, const NativeRdb::ValuesBucket& value); 45 int Update( 46 const Uri& uri, const NativeRdb::ValuesBucket& value, const NativeRdb::DataAbilityPredicates& predicates); 47 int OpenRawFile(const Uri& uri, const std::string& mode); 48 bool Reload(const Uri& uri, const PacMap& extras); 49 int BatchInsert(const Uri& uri, const std::vector<NativeRdb::ValuesBucket>& values); 50 std::string GetType(const Uri& uri); 51 std::shared_ptr<NativeRdb::AbsSharedResultSet> Query( 52 const Uri& uri, const std::vector<std::string>& columns, const NativeRdb::DataAbilityPredicates& predicates); 53 }; 54 } // namespace AppExecFwk 55 } // namespace OHOS 56 #endif // MOCK_OHOS_ABILITY_RUNTIME_DEMO_ABILITY_TEST_H 57