1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __WIFI_HAL_MOCK_H__ 18 #define __WIFI_HAL_MOCK_H__ 19 20 #include "wifi_hal.h" 21 22 #include <rapidjson/document.h> 23 #include <rapidjson/stringbuffer.h> 24 #include <rapidjson/writer.h> 25 26 namespace android { 27 28 class HalMockJsonWriter { 29 public: 30 HalMockJsonWriter(); 31 32 void put_int(const char* name, int x); 33 34 void put_byte_array(const char* name, u8* byte_array, int array_length); 35 36 std::string to_string(); 37 38 private: 39 rapidjson::Document doc; 40 rapidjson::Document::AllocatorType& allocator; 41 }; 42 43 class HalMockJsonReader { 44 public: 45 HalMockJsonReader(const char* str); 46 47 int get_int(const char* key, bool* error); 48 49 void get_byte_array(const char* key, bool* error, u8* array, 50 unsigned int max_array_size); 51 private: 52 rapidjson::Document doc; 53 }; 54 55 /* declare all HAL mock APIs here*/ 56 wifi_error wifi_nan_enable_request_mock(transaction_id id, 57 wifi_interface_handle iface, 58 NanEnableRequest* msg); 59 wifi_error wifi_nan_disable_request_mock(transaction_id id, 60 wifi_interface_handle iface); 61 wifi_error wifi_nan_publish_request_mock(transaction_id id, 62 wifi_interface_handle iface, 63 NanPublishRequest* msg); 64 wifi_error wifi_nan_publish_cancel_request_mock(transaction_id id, 65 wifi_interface_handle iface, 66 NanPublishCancelRequest* msg); 67 wifi_error wifi_nan_subscribe_request_mock(transaction_id id, 68 wifi_interface_handle iface, 69 NanSubscribeRequest* msg); 70 wifi_error wifi_nan_subscribe_cancel_request_mock( 71 transaction_id id, wifi_interface_handle iface, 72 NanSubscribeCancelRequest* msg); 73 wifi_error wifi_nan_transmit_followup_request_mock( 74 transaction_id id, wifi_interface_handle iface, 75 NanTransmitFollowupRequest* msg); 76 wifi_error wifi_nan_stats_request_mock(transaction_id id, 77 wifi_interface_handle iface, 78 NanStatsRequest* msg); 79 wifi_error wifi_nan_config_request_mock(transaction_id id, 80 wifi_interface_handle iface, 81 NanConfigRequest* msg); 82 wifi_error wifi_nan_tca_request_mock(transaction_id id, 83 wifi_interface_handle iface, 84 NanTCARequest* msg); 85 wifi_error wifi_nan_beacon_sdf_payload_request_mock( 86 transaction_id id, wifi_interface_handle iface, 87 NanBeaconSdfPayloadRequest* msg); 88 wifi_error wifi_nan_register_handler_mock(wifi_interface_handle iface, 89 NanCallbackHandler handlers); 90 wifi_error wifi_nan_get_version_mock(wifi_handle handle, NanVersion* version); 91 wifi_error wifi_nan_get_capabilities_mock(transaction_id id, 92 wifi_interface_handle iface); 93 94 } // namespace android 95 96 #endif //__WIFI_HAL_MOCK_H__ 97