• 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"
17import { ExtensionContextClass } from "./application/ExtensionContext"
18
19export function mockDataShareExtensionAbility() {
20  const DataShareExtensionAbilityClass = class DataShareExtensionAbility {
21    constructor() {
22      console.warn('application.DataShareExtensionAbility interface mocked in the Previewer. How this interface works on' +
23        ' the Previewer may be different from that on a real device.');
24      this.context = new ExtensionContextClass();
25      this.onCreate = function (...args) {
26        console.warn("application.DataShareExtensionAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
27        " may be different from that on a real device.")
28        const len = args.length
29        if (typeof args[len - 1] === 'function') {
30          args[len - 1].call(this, paramMock.businessErrorMock)
31        }
32      },
33      this.getFileTypes = function (...args) {
34        console.warn("application.DataShareExtensionAbility.getFileTypes interface mocked in the Previewer. How this interface works on the Previewer" +
35        " may be different from that on a real device.")
36        const len = args.length
37        if (typeof args[len - 1] === 'function') {
38          args[len - 1].call(this, paramMock.businessErrorMock,[paramMock.paramStringMock])
39        }
40      },
41      this.openFile = function (...args) {
42        console.warn("application.DataShareExtensionAbility.openFile interface mocked in the Previewer. How this interface works on the Previewer" +
43        " may be different from that on a real device.")
44        const len = args.length
45        if (typeof args[len - 1] === 'function') {
46          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
47        }
48      },
49      this.insert = function (...args) {
50        console.warn("application.DataShareExtensionAbility.insert interface mocked in the Previewer. How this interface works on the Previewer" +
51        " may be different from that on a real device.")
52        const len = args.length
53        if (typeof args[len - 1] === 'function') {
54          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
55        }
56      },
57      this.update = function (...args) {
58        console.warn("application.DataShareExtensionAbility.update interface mocked in the Previewer. How this interface works on the Previewer" +
59        " may be different from that on a real device.")
60        const len = args.length
61        if (typeof args[len - 1] === 'function') {
62          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
63        }
64      },
65      this.delete = function (...args) {
66        console.warn("application.DataShareExtensionAbility.delete interface mocked in the Previewer. How this interface works on the Previewer" +
67        " may be different from that on a real device.")
68        const len = args.length
69        if (typeof args[len - 1] === 'function') {
70          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
71        }
72      },
73      this.query = function (...args) {
74        console.warn("application.DataShareExtensionAbility.query interface mocked in the Previewer. How this interface works on the Previewer" +
75        " may be different from that on a real device.")
76        const len = args.length
77        if (typeof args[len - 1] === 'function') {
78          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
79        }
80      },
81      this.getType = function (...args) {
82        console.warn("application.DataShareExtensionAbility.getType interface mocked in the Previewer. How this interface works on the Previewer" +
83        " may be different from that on a real device.")
84        const len = args.length
85        if (typeof args[len - 1] === 'function') {
86          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
87        }
88      },
89      this.batchInsert = function (...args) {
90        console.warn("application.DataShareExtensionAbility.batchInsert interface mocked in the Previewer. How this interface works on the Previewer" +
91        " may be different from that on a real device.")
92        const len = args.length
93        if (typeof args[len - 1] === 'function') {
94          args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
95        }
96      },
97      this.normalizeUri = function (...args) {
98        console.warn("application.DataShareExtensionAbility.normalizeUri interface mocked in the Previewer. How this interface works on the Previewer" +
99        " may be different from that on a real device.")
100        const len = args.length
101        if (typeof args[len - 1] === 'function') {
102          args[len - 1].call(this, paramMock.businessErrorMock)
103        }
104      },
105      this.denormalizeUri = function (...args) {
106        console.warn("application.DataShareExtensionAbility.denormalizeUri 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)
111        }
112      }
113    }
114  }
115  return DataShareExtensionAbilityClass;
116}
117