1 /* 2 * Copyright (c) 2022 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 #ifndef LOCATOR_FUZZER_H 16 #define LOCATOR_FUZZER_H 17 18 #include "iremote_object.h" 19 #include "iremote_proxy.h" 20 21 #include "cached_locations_callback_host.h" 22 #include "country_code_callback_host.h" 23 #include "gnss_status_callback_host.h" 24 #include "i_locator.h" 25 #include "locator_proxy.h" 26 #include "location_switch_callback_host.h" 27 #include "locator_callback_host.h" 28 #include "nmea_message_callback_host.h" 29 30 namespace OHOS { 31 namespace Location { 32 #define FUZZ_PROJECT_NAME "locator_fuzzer" 33 class LocatorProxyTestFuzzer : public LocatorProxy { 34 public: LocatorProxyTestFuzzer(const sptr<IRemoteObject> & impl)35 explicit LocatorProxyTestFuzzer(const sptr<IRemoteObject> &impl) 36 : LocatorProxy(impl) 37 {} GetRemote()38 sptr<IRemoteObject> GetRemote() 39 { 40 return Remote(); 41 } 42 }; 43 44 void AddPermission(); 45 bool LocatorProxySendRequestTest(const uint8_t* data, size_t size); 46 bool LocatorImplFuzzerTest(const uint8_t* data, size_t size); 47 bool TestMockFunc(const uint8_t* data, size_t size); 48 bool TestCallbackRegister(const uint8_t* data, size_t size); 49 bool CachedLocationsCallbackHostFuzzerTest(const uint8_t* data, size_t size); 50 bool CountryCodeCallbackHostFuzzerTest(const uint8_t* data, size_t size); 51 bool GnssStatusCallbackHostFuzzerTest(const uint8_t* data, size_t size); 52 bool LocationSwitchCallbackHostFuzzerTest(const uint8_t* data, size_t size); 53 bool LocationCallbackHostFuzzerTest(const uint8_t* data, size_t size); 54 bool NmeaMessageCallbackHostFuzzerTest(const uint8_t* data, size_t size); 55 56 bool LocatorAbility001FuzzerTest(const uint8_t* data, size_t size); 57 bool LocatorAbility002FuzzerTest(const uint8_t* data, size_t size); 58 bool LocatorAbility003FuzzerTest(const uint8_t* data, size_t size); 59 } // namespace Location 60 } // namespace OHOS 61 #endif // LOCATOR_FUZZER_H 62