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 16import { paramMock } from "../utils" 17 18export function mockData() { 19 const data = { 20 getDefaultCellularDataSlotId: function (...args) { 21 console.warn("telephony.data.getDefaultCellularDataSlotId interface mocked in the Previewer. How this interface works on the Previewer may" + 22 " be different from that on a real device.") 23 const len = args.length 24 if (typeof args[len - 1] === 'function') { 25 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 26 } else { 27 return new Promise((resolve, reject) => { 28 resolve(paramMock.paramNumberMock); 29 }) 30 } 31 }, 32 setDefaultCellularDataSlotId: function (...args) { 33 console.warn("telephony.data.setDefaultCellularDataSlotId interface mocked in the Previewer. How this interface works on the Previewer may" + 34 " be different from that on a real device.") 35 const len = args.length 36 if (typeof args[len - 1] === 'function') { 37 args[len - 1].call(this, paramMock.businessErrorMock); 38 } else { 39 return new Promise((resolve, reject) => { 40 resolve(); 41 }) 42 } 43 }, 44 getCellularDataFlowType: function (...args) { 45 console.warn("telephony.data.getCellularDataFlowType interface mocked in the Previewer. How this interface works on the Previewer may" + 46 " be different from that on a real device.") 47 const len = args.length 48 if (typeof args[len - 1] === 'function') { 49 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 50 } else { 51 return new Promise((resolve, reject) => { 52 resolve(paramMock.paramNumberMock); 53 }) 54 } 55 }, 56 getCellularDataState: function (...args) { 57 console.warn("telephony.data.getCellularDataState interface mocked in the Previewer. How this interface works on the Previewer may" + 58 " be different from that on a real device.") 59 const len = args.length 60 if (typeof args[len - 1] === 'function') { 61 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); 62 } else { 63 return new Promise((resolve, reject) => { 64 resolve(paramMock.paramNumberMock); 65 }) 66 } 67 }, 68 isCellularDataEnabled: function (...args) { 69 console.warn("telephony.data.isCellularDataEnabled interface mocked in the Previewer. How this interface works on the Previewer may" + 70 " be different from that on a real device.") 71 const len = args.length 72 if (typeof args[len - 1] === 'function') { 73 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 74 } else { 75 return new Promise((resolve, reject) => { 76 resolve(paramMock.paramBooleanMock); 77 }) 78 } 79 }, 80 enableCellularData: function (...args) { 81 console.warn("telephony.data.enableCellularData interface mocked in the Previewer. How this interface works on the Previewer may" + 82 " be different from that on a real device.") 83 const len = args.length 84 if (typeof args[len - 1] === 'function') { 85 args[len - 1].call(this, paramMock.businessErrorMock); 86 } else { 87 return new Promise((resolve, reject) => { 88 resolve(); 89 }) 90 } 91 }, 92 disableCellularData: function (...args) { 93 console.warn("telephony.data.disableCellularData interface mocked in the Previewer. How this interface works on the Previewer may" + 94 " be different from that on a real device.") 95 const len = args.length 96 if (typeof args[len - 1] === 'function') { 97 args[len - 1].call(this, paramMock.businessErrorMock); 98 } else { 99 return new Promise((resolve, reject) => { 100 resolve(); 101 }) 102 } 103 }, 104 isCellularDataRoamingEnabled: function (...args) { 105 console.warn("telephony.data.isCellularDataRoamingEnabled interface mocked in the Previewer. How this interface works on the Previewer may" + 106 " be different from that on a real device.") 107 const len = args.length 108 if (typeof args[len - 1] === 'function') { 109 args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); 110 } else { 111 return new Promise((resolve, reject) => { 112 resolve(paramMock.paramBooleanMock); 113 }) 114 } 115 }, 116 enableCellularDataRoaming: function (...args) { 117 console.warn("telephony.data.enableCellularDataRoaming interface mocked in the Previewer. How this interface works on the Previewer may" + 118 " be different from that on a real device.") 119 const len = args.length 120 if (typeof args[len - 1] === 'function') { 121 args[len - 1].call(this, paramMock.businessErrorMock); 122 } else { 123 return new Promise((resolve, reject) => { 124 resolve(); 125 }) 126 } 127 }, 128 disableCellularDataRoaming: function (...args) { 129 console.warn("telephony.data.disableCellularDataRoaming interface mocked in the Previewer. How this interface works on the Previewer may" + 130 " be different from that on a real device.") 131 const len = args.length 132 if (typeof args[len - 1] === 'function') { 133 args[len - 1].call(this, paramMock.businessErrorMock); 134 } else { 135 return new Promise((resolve, reject) => { 136 resolve(); 137 }) 138 } 139 } 140 } 141 return data 142}