• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 { ServiceExtensionContextClass } from "./application/ServiceExtensionContext"
18import { RemoteObjectClass } from "./ohos_rpc"
19
20export function mockServiceExtensionAbility() {
21  const ServiceExtensionAbilityClass = class ServiceExtensionAbility {
22    constructor() {
23      console.warn('application.ServiceExtensionAbility.constructor interface mocked in the Previewer. How this interface works on' +
24        ' the Previewer may be different from that on a real device.');
25      this.context = new ServiceExtensionContextClass();
26      this.onCreate = function (...args) {
27        console.warn("application.ServiceExtensionAbility.onCreate interface mocked in the Previewer. How this interface works on the Previewer" +
28          " may be different from that on a real device.")
29      };
30      this.onDestroy = function () {
31        console.warn("application.ServiceExtensionAbility.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" +
32          " may be different from that on a real device.")
33      };
34      this.onRequest = function (...args) {
35        console.warn("application.ServiceExtensionAbility.onRequest interface mocked in the Previewer. How this interface works on the Previewer" +
36          " may be different from that on a real device.")
37      };
38      this.onConnect = function (...args) {
39        console.warn("application.ServiceExtensionAbility.onConnect interface mocked in the Previewer. How this interface works on the Previewer" +
40          " may be different from that on a real device.")
41        return new RemoteObjectClass();
42      };
43      this.onDisconnect = function (...args) {
44        console.warn("application.ServiceExtensionAbility.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" +
45          " may be different from that on a real device.")
46      };
47      this.onReconnect = function (...args) {
48        console.warn("application.ServiceExtensionAbility.onReconnect interface mocked in the Previewer. How this interface works on the Previewer" +
49          " may be different from that on a real device.")
50      };
51      this.onConfigurationUpdated = function (...args) {
52        console.warn("application.ServiceExtensionAbility.onConfigurationUpdated interface mocked in the Previewer. How this interface works on the Previewer" +
53          " may be different from that on a real device.")
54      };
55      this.dump = function (...args) {
56        console.warn("application.ServiceExtensionAbility.dump interface mocked in the Previewer. How this interface works on the Previewer" +
57          " may be different from that on a real device.")
58        return [paramMock.paramStringMock];
59      };
60    }
61  }
62  return new ServiceExtensionAbilityClass();
63}