• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
18const DataAbilityResult = {
19  uri: "[PC Preview] unknow uri",
20  count: "[PC Preview] unknow count"
21}
22const ResultSet = {
23  columnNames: [paramMock.paramStringMock],
24  columnCount: "[PC Preview] unknow columnCount",
25  rowCount: "[PC Preview] unknow rowCount",
26  rowIndex: "[PC Preview] unknow rowIndex",
27  isAtFirstRow: "[PC Preview] unknow isAtFirstRow",
28  isAtLastRow: "[PC Preview] unknow isAtLastRow",
29  isEnded: "[PC Preview] unknow isEnded",
30  isStarted: "[PC Preview] unknow isStarted",
31  isClose: "[PC Preview] unknow isClose",
32  getColumnIndex: function (...args) {
33    console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" +
34      " may be different from that on a real device.")
35    return paramMock.paramNumberMock;
36  },
37  getColumnName: function (...args) {
38    console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" +
39      " may be different from that on a real device.")
40    return paramMock.paramStringMock;
41  },
42  goTo: function (...args) {
43    console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" +
44      " may be different from that on a real device.")
45    return paramMock.paramBooleanMock;
46  },
47  goToRow: function (...args) {
48    console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" +
49      " may be different from that on a real device.")
50    return paramMock.paramBooleanMock;
51  },
52  goToLastRow: function (...args) {
53    console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" +
54      " may be different from that on a real device.")
55    return paramMock.paramBooleanMock;
56  },
57  goToFirstRow: function (...args) {
58    console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" +
59      " may be different from that on a real device.")
60    return paramMock.paramBooleanMock;
61  },
62  goToNextRow: function (...args) {
63    console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" +
64      " may be different from that on a real device.")
65    return paramMock.paramBooleanMock;
66  },
67  goToPreviousRow: function (...args) {
68    console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" +
69      " may be different from that on a real device.")
70    return paramMock.paramBooleanMock;
71  },
72  getBlob: function (...args) {
73    console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" +
74      " may be different from that on a real device.")
75    return paramMock.paramArrayMock;
76  },
77  getString: function (...args) {
78    console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" +
79      " may be different from that on a real device.")
80    return paramMock.paramStringMock;
81  },
82  getLong: function (...args) {
83    console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" +
84      " may be different from that on a real device.")
85    return paramMock.paramNumberMock;
86  },
87  getDouble: function (...args) {
88    console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" +
89      " may be different from that on a real device.")
90    return paramMock.paramNumberMock;
91  },
92  isColumnNull: function (...args) {
93    console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
94      " may be different from that on a real device.")
95    return paramMock.paramBooleanMock;
96  },
97  close: function () {
98    console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the Previewer" +
99      " may be different from that on a real device.")
100  }
101}
102
103export const PacMap = {key:{}}
104export const DataAbilityHelper = {
105  openFile: function (...args) {
106    console.warn("dataAbilityHelper.openFile interface mocked in the Previewer. How this interface works on the Previewer" +
107      " may be different from that on a real device.")
108    const len = args.length
109    if (typeof args[len - 1] === 'function') {
110      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
111    } else {
112      return new Promise((resolve) => {
113        resolve(paramMock.paramNumberMock);
114      })
115    }
116  },
117  on: function (...args) {
118    console.warn("dataAbilityHelper.on interface mocked in the Previewer. How this interface works on the Previewer" +
119      " may be different from that on a real device.")
120    const len = args.length
121    if (typeof args[len - 1] === 'function') {
122      args[len - 1].call(this, paramMock.businessErrorMock)
123    }
124  },
125  off: function (...args) {
126    console.warn("dataAbilityHelper.off interface mocked in the Previewer. How this interface works on the Previewer" +
127      " may be different from that on a real device.")
128    const len = args.length
129    if (typeof args[len - 1] === 'function') {
130      args[len - 1].call(this, paramMock.businessErrorMock)
131    }
132  },
133  call: function (...args) {
134    console.warn("dataAbilityHelper.call interface mocked in the Previewer. How this interface works on the Previewer" +
135      " may be different from that on a real device.")
136    const len = args.length
137    if (typeof args[len - 1] === 'function') {
138      args[len - 1].call(this, paramMock.businessErrorMock, PacMap)
139    } else {
140      return new Promise((resolve) => {
141        resolve(PacMap);
142      })
143    }
144  },
145  getType: function (...args) {
146    console.warn("dataAbilityHelper.getType interface mocked in the Previewer. How this interface works on the Previewer" +
147      " may be different from that on a real device.")
148    const len = args.length
149    if (typeof args[len - 1] === 'function') {
150      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
151    } else {
152      return new Promise((resolve) => {
153        resolve(paramMock.paramStringMock);
154      })
155    }
156  },
157  getFileTypes: function (...args) {
158    console.warn("dataAbilityHelper.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" +
159      " may be different from that on a real device.")
160    const len = args.length
161    if (typeof args[len - 1] === 'function') {
162      args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock])
163    } else {
164      return new Promise((resolve) => {
165        resolve([paramMock.paramStringMock]);
166      })
167    }
168  },
169  normalizeUri: function (...args) {
170    console.warn("dataAbilityHelper.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
171      " may be different from that on a real device.")
172    const len = args.length
173    if (typeof args[len - 1] === 'function') {
174      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
175    } else {
176      return new Promise((resolve) => {
177        resolve(paramMock.paramStringMock);
178      })
179    }
180  },
181  denormalizeUri: function (...args) {
182    console.warn("dataAbilityHelper.denormalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
183      " may be different from that on a real device.")
184    const len = args.length
185    if (typeof args[len - 1] === 'function') {
186      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
187    } else {
188      return new Promise((resolve) => {
189        resolve(paramMock.paramStringMock);
190      })
191    }
192  },
193  notifyChange: function (...args) {
194    console.warn("dataAbilityHelper.notifyChange interface mocked in the Previewer. How this interface works on the Previewer" +
195      " may be different from that on a real device.")
196    const len = args.length
197    if (typeof args[len - 1] === 'function') {
198      args[len - 1].call(this, paramMock.businessErrorMock)
199    } else {
200      return new Promise((resolve) => {
201        resolve();
202      })
203    }
204  },
205  insert: function (...args) {
206    console.warn("dataAbilityHelper.insert interface mocked in the Previewer. How this interface works on the Previewer" +
207      " may be different from that on a real device.")
208    const len = args.length
209    if (typeof args[len - 1] === 'function') {
210      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
211    } else {
212      return new Promise((resolve) => {
213        resolve(paramMock.paramNumberMock);
214      })
215    }
216  },
217  batchInsert: function (...args) {
218    console.warn("dataAbilityHelper.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" +
219      " may be different from that on a real device.")
220    const len = args.length
221    if (typeof args[len - 1] === 'function') {
222      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
223    } else {
224      return new Promise((resolve) => {
225        resolve(paramMock.paramNumberMock);
226      })
227    }
228  },
229  delete: function (...args) {
230    console.warn("dataAbilityHelper.delete interface mocked in the Previewer. How this interface works on the Previewer" +
231      " may be different from that on a real device.")
232    const len = args.length
233    if (typeof args[len - 1] === 'function') {
234      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
235    } else {
236      return new Promise((resolve) => {
237        resolve(paramMock.paramNumberMock);
238      })
239    }
240  },
241  update: function (...args) {
242    console.warn("dataAbilityHelper.update interface mocked in the Previewer. How this interface works on the Previewer" +
243      " may be different from that on a real device.")
244    const len = args.length
245    if (typeof args[len - 1] === 'function') {
246      args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
247    } else {
248      return new Promise((resolve) => {
249        resolve(paramMock.paramNumberMock);
250      })
251    }
252  },
253  query: function (...args) {
254    console.warn("dataAbilityHelper.query interface mocked in the Previewer. How this interface works on the Previewer" +
255      " may be different from that on a real device.")
256    const len = args.length
257    if (typeof args[len - 1] === 'function') {
258      args[len - 1].call(this, paramMock.businessErrorMock, ResultSet)
259    } else {
260      return new Promise((resolve) => {
261        resolve(ResultSet);
262      })
263    }
264  },
265  call: function (...args)  {
266    console.warn("dataAbilityHelper.call interface mocked in the Previewer. How this interface works on the Previewer" +
267      " may be different from that on a real device.")
268    const len = args.length
269    if (typeof args[len - 1] === 'function') {
270      args[len - 1].call(this, paramMock.businessErrorMock, PacMap)
271    } else {
272      return new Promise((resolve) => {
273        resolve(PacMap);
274      })
275    }
276  },
277  executeBatch: function (...args) {
278    console.warn("dataAbilityHelper.executeBatch interface mocked in the Previewer. How this interface works on the Previewer" +
279      " may be different from that on a real device.")
280    const len = args.length
281    if (typeof args[len - 1] === 'function') {
282      args[len - 1].call(this, paramMock.businessErrorMock, [DataAbilityResult])
283    } else {
284      return new Promise((resolve) => {
285        resolve([DataAbilityResult]);
286      })
287    }
288  }
289}
290