• 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"
17
18export function mockAI() {
19  const TTSCallBackMock = {
20    key: "[PC preview] unknow key"
21  };
22  global.systemplugin.ai = {};
23  global.systemplugin.ai.TTS = {
24    getTTSClient: function () {
25      console.warn("ai.TTS.getTTSClient interface mocked in the Previewer. How this interface works on the" +
26        " Previewer may be different from that on a real device.")
27      return TTSClient
28    },
29  };
30  const TTSClient = {
31    init: function (...args) {
32      console.warn("TTSClient.init interface mocked in the Previewer. How this interface works on the Previewer may" +
33        " be different from that on a real device.")
34      return paramMock.paramBooleanMock
35    },
36    isSpeaking: function () {
37      console.warn("TTSClient.isSpeaking interface mocked in the Previewer. How this interface works on the Previewer may" +
38        " be different from that on a real device.")
39      return paramMock.paramBooleanMock
40    },
41    setAudioType: function (...args) {
42      console.warn("TTSClient.setAudioType interface mocked in the Previewer. How this interface works on the Previewer may" +
43        " be different from that on a real device.")
44      return paramMock.paramBooleanMock
45    },
46    setParams: function (...args) {
47      console.warn("TTSClient.setParams interface mocked in the Previewer. How this interface works on the Previewer may" +
48        " be different from that on a real device.")
49      return paramMock.paramBooleanMock
50    },
51    connectService: function () {
52      console.warn("TTSClient.connectService interface mocked in the Previewer. How this interface works on the Previewer may" +
53        " be different from that on a real device.")
54    },
55    setIsSaveTtsData: function (...args) {
56      console.warn("TTSClient.setIsSaveTtsData interface mocked in the Previewer. How this interface works on the Previewer may" +
57        " be different from that on a real device.")
58      args[0].success()
59      hasComplete(args[0].complete)
60    },
61    release: function () {
62      console.warn("TTSClient.release interface mocked in the Previewer. How this interface works on the Previewer may" +
63        " be different from that on a real device.")
64    },
65    speakLongText: function (...args) {
66      console.warn("TTSClient.speakLongText interface mocked in the Previewer. How this interface works on the Previewer may" +
67        " be different from that on a real device.")
68      args[0].success()
69      hasComplete(args[0].complete)
70    },
71    speakText: function (...args) {
72      console.warn("TTSClient.speakText interface mocked in the Previewer. How this interface works on the Previewer may" +
73        " be different from that on a real device.")
74      args[0].success()
75      hasComplete(args[0].complete)
76    },
77    stopSpeak: function () {
78      console.warn("TTSClient.stopSpeak interface mocked in the Previewer. How this interface works on the Previewer may" +
79        " be different from that on a real device.")
80    },
81    destroy: function () {
82      console.warn("TTSClient.destroy interface mocked in the Previewer. How this interface works on the Previewer may" +
83        " be different from that on a real device.")
84    },
85    on: function (...args) {
86      console.warn("TTSClient.on interface mocked in the Previewer. How this interface works on the Previewer may be" +
87        " different from that on a real device.")
88      const len = args.length
89      args[len - 1].call(this, TTSCallBackMock)
90    },
91    getSupportMaxLength: function () {
92      console.warn("TTSClient.getSupportMaxLength interface mocked in the Previewer. How this interface works on the Previewer may" +
93        " be different from that on a real device.")
94      return paramMock.paramNumberMock
95    },
96    getVersion: function () {
97      console.warn("TTSClient.getVersion interface mocked in the Previewer. How this interface works on the Previewer may" +
98        " be different from that on a real device.")
99      return paramMock.paramStringMock
100    },
101  };
102}