!521 Correct the inconsistency between Mock and d.ts of language compilation subsystem

Merge pull request !521 from 李兴阳/master
This commit is contained in:
openharmony_ci
2022-07-22 01:36:22 +00:00
committed by Gitee
7 changed files with 960 additions and 717 deletions
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -16,19 +16,42 @@
import { paramMock } from "../utils"
export function mockConvertXml() {
const result = {
ConvertXML: function (...args) {
console.warn("convertXml.ConvertXML interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return ConvertXMLMock;
}
}
const ConvertXMLClass = class ConvertXML {
constructor(...args) {
console.warn("convertXml.ConvertXML.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
this.convert = function (...args) {
console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
return paramMock.paramObjectMock;
}
}
};
const ConvertXMLMock = {
convert: function (...args) {
console.warn("ConvertXML.convert interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramObjectMock;
}
}
return result;
ConvertXML : ConvertXMLClass
};
const ConvertOptionsMock = {
trim : '[PC preview] unknow trim',
ignoreDeclaration : '[PC preview] unknow ignoreDeclaration',
ignoreInstruction : '[PC preview] unknow ignoreInstruction',
ignoreAttributes : '[PC preview] unknow ignoreAttributes',
ignoreComment : '[PC preview] unknow ignoreComment',
ignoreCDATA : '[PC preview] unknow ignoreCDATA',
ignoreDoctype : '[PC preview] unknow ignoreDoctype',
ignoreText : '[PC preview] unknow ignoreText',
declarationKey : '[PC preview] unknow declarationKey',
instructionKey : '[PC preview] unknow instructionKey',
attributesKey : '[PC preview] unknow attributesKey',
textKey : '[PC preview] unknow textKey',
cdataKey : '[PC preview] unknow cdataKey',
doctypeKey : '[PC preview] unknow doctypeKey',
commentKey : '[PC preview] unknow commentKey',
parentKey : '[PC preview] unknow parentKey',
typeKey : '[PC preview] unknow typeKey',
nameKey : '[PC preview] unknow nameKey',
elementsKey : '[PC preview] unknow elementsKey'
};
return ConvertXMLMock;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockProcess() {
const result = {
const process = {
runCmd: function (...args) {
console.warn("process.runCmd interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -155,5 +155,5 @@ export function mockProcess() {
" may be different from that on a real device.")
}
}
return result;
return process;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -16,7 +16,7 @@
import { paramMock } from "../utils"
export function mockUri() {
const result = {
const uri = {
URI: function (...args) {
console.warn("uri.URI interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -24,6 +24,10 @@ export function mockUri() {
}
}
const URIMock = {
constructor(...args) {
console.warn("uri.URI.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
toString: function (...args) {
console.warn("URI.toString interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -45,7 +49,7 @@ export function mockUri() {
return paramMock.paramObjectMock;
},
scheme: '[PC preview] unknow scheme',
userinfo: '[PC preview] unknow userinfo',
userInfo: '[PC preview] unknow userInfo',
host: '[PC preview] unknow host',
port: '[PC preview] unknow port',
path: '[PC preview] unknow path',
@@ -54,5 +58,5 @@ export function mockUri() {
authority: '[PC preview] unknow authority',
ssp: '[PC preview] unknow ssp'
}
return result;
return uri;
}
@@ -143,9 +143,9 @@ export function mockUrl() {
this.username = '[PC preview] unknow username';
}
};
const result = {
const urlMock = {
URLSearchParams: URLSearchParamsClass,
URL: URLClass
};
return result;
return urlMock;
}
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -16,71 +16,159 @@
import { paramMock } from "../utils"
export function mockWorker() {
const result = {
Worker: function (params) {
console.warn("worker.Worker interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return WorkerMock;
const WorkerOptionsMock = {
type: '[PC preview] unknow type',
name: '[PC preview] unknow name',
shared: '[PC preview] unknow shared'
};
const EventMock = {
type: '[PC preview] unknow type',
timeStamp: '[PC preview] unknow timeStamp'
};
const ErrorEventMock = {
message: '[PC preview] unknow message',
filename: '[PC preview] unknow filename',
lineno: '[PC preview] unknow lineno',
colno: '[PC preview] unknow colno',
error: '[PC preview] unknow error'
};
const MessageEventMock = {
data: '[PC preview] unknow data'
};
const PostMessageOptionsMock = {
transfer:'[PC preview] unknow transfer'
};
const EventListenerMock = {
evt : function (...args) {
console.warn('EventListener.evt interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.') ;
}
}
const WorkerMock = {
postMessage: function (...args) {
console.warn("Worker.postMessage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
const EventTargetMock = {
addEventListener : function (...args) {
console.warn('PostMessageOptions.addEventListener interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
},
terminate: function (...args) {
console.warn("Worker.terminate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
dispatchEvent : function (...args) {
console.warn('PostMessageOptions.dispatchEvent interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
return paramMock.paramBooleanMock;
},
on: function (...args) {
console.warn("Worker.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
once: function (...args) {
console.warn("Worker.once interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
off: function (...args) {
console.warn("Worker.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
addEventListener: function (...args) {
console.warn("Worker.addEventListener interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
dispatchEvent: function (...args) {
console.warn("Worker.dispatchEvent interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
removeEventListener: function (...args) {
console.warn("Worker.removeEventListener interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
removeAllListener: function (...args) {
console.warn("Worker.removeAllListener interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
},
onmessage: function (...args) {
console.warn("Worker.onmessage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
onmessageerror: function (...agrs) {
console.warn("Worker.onmessageerror interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.")
removeEventListener : function (...args) {
console.warn("PostMessageOptions.removeEventListener interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
removeAllListener : function (...args) {
console.warn("PostMessageOptions.removeAllListener interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
}
};
const WorkerGlobalScopeMock = {
name: '[PC preview] unknow name',
onerror: function (...args) {
console.warn("Worker.onerror interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
console.warn("WorkerGlobalScope.onerror interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
onclose: function (...args) {
console.warn("Worker.onclose interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
self: '[PC preview] unknow self'
};
const DedicatedWorkerGlobalScopeMock = {
onmessage: function (...args) {
console.warn("DedicatedWorkerGlobalScope.onmessage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
onexit: function (...args) {
console.warn("Worker.onexit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
onmessageerror: function (...args) {
console.warn("DedicatedWorkerGlobalScope.onmessageerror interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
close : function (...args) {
console.warn("DedicatedWorkerGlobalScope.close interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
postMessage : function (...args) {
console.warn("DedicatedWorkerGlobalScope.postMessage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
postMessage : function (...args) {
console.warn("DedicatedWorkerGlobalScope.postMessage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
}
}
return result;
}
};
const WorkerClass = class Worker {
constructor(...args){
console.warn('Worker.constructor interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
this.postMessage = function (...args) {
console.warn("Worker.postMessage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.terminate = function (...args) {
console.warn("Worker.terminate interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.on = function (...args) {
console.warn("Worker.on interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.once = function (...args) {
console.warn("Worker.once interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.off = function (...args) {
console.warn("Worker.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.addEventListener = function (...args) {
console.warn("Worker.addEventListener interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
},
this.dispatchEvent = function (...args) {
console.warn("Worker.dispatchEvent interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
return paramMock.paramBooleanMock;
},
this.removeEventListener = function (...args) {
console.warn("Worker.removeEventListener interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
},
this.removeAllListener = function (...args) {
console.warn("Worker.removeAllListener interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
},
this.onmessage = function (...args) {
console.warn("Worker.onmessage interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.onmessageerror = function (...agrs) {
console.warn("Worker.onmessageerror interface mocked in the Previewer. How this interface works on the" +
" Previewer may be different from that on a real device.");
},
this.onerror = function (...args) {
console.warn("Worker.onerror interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.onclose = function (...args) {
console.warn("Worker.onclose interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
},
this.onexit = function (...args) {
console.warn("Worker.onexit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
}
}
};
const workerMock = {
Worker : WorkerClass
};
return workerMock;
}
+168 -80
View File
@@ -1,80 +1,168 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockXml() {
const result = {
XmlSerializer: function (...args) {
console.warn("xml.XmlSerializer interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return XmlSerializerMock;
},
XmlPullParser: function (...args) {
console.warn("xml.XmlPullParser interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return XmlPullParserMock;
}
}
const XmlSerializerMock = {
setAttributes: function (...args) {
console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
addEmptyElement: function (...args) {
console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
setDeclaration: function (...args) {
console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
startElement: function (...args) {
console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
endElement: function (...args) {
console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
setNamespace: function (...args) {
console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
setCommnet: function (...args) {
console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
setCData: function (...args) {
console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
setText: function (...args) {
console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
},
setDocType: function (...args) {
console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
const XmlPullParserMock = {
parse: function (...args) {
console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
return result;
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { paramMock } from "../utils"
export function mockXml() {
const XmlSerializerClass = class XmlSerializer {
constructor(...args) {
console.warn("XmlSerializer.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
this.setAttributes = function (...args) {
console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.addEmptyElement = function (...args) {
console.warn("XmlSerializer.addEmptyElement interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.setDeclaration = function (...args) {
console.warn("XmlSerializer.setDeclaration interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.startElement = function (...args) {
console.warn("XmlSerializer.startElement interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.endElement = function (...args) {
console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.setNamespace = function (...args) {
console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.setComment = function (...args) {
console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.setCData = function (...args) {
console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.setText = function (...args) {
console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
};
this.setDocType = function (...args) {
console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
}
}
};
const XmlPullParserClass = class XmlPullParser {
constructor(...args) {
console.warn("XmlPullParser.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
this.parse = function (...args) {
console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.");
}
}
};
const xmlMock = {
XmlSerializer : XmlSerializerClass,
XmlPullParser : XmlPullParserClass,
EventType : {
START_DOCUMENT: 0,
END_DOCUMENT: 1,
START_TAG: 2,
END_TAG: 3,
TEXT: 4,
CDSECT: 5,
COMMENT: 6,
DOCDECL: 7,
INSTRUCTION: 8,
ENTITY_REFERENCE: 9,
WHITESPACE: 10
}
};
const ParseInfoMock = {
getColumnNumber: function () {
console.warn("ParseInfo.getColumnNumber interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getDepth: function () {
console.warn("ParseInfo.getDepth interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getLineNumber: function () {
console.warn("ParseInfo.getLineNumber interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getName: function () {
console.warn("ParseInfo.getName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getNamespace: function () {
console.warn("ParseInfo.getNamespace interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getPrefix: function () {
console.warn("ParseInfo.getPrefix interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getText: function () {
console.warn("ParseInfo.getText interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
isEmptyElementTag: function () {
console.warn("ParseInfo.isEmptyElementTag interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
isWhitespace: function () {
console.warn("ParseInfo.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getAttributeCount: function () {
console.warn("ParseInfo.getAttributeCount interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
}
};
const ParseOptionsMock = {
supportDoctype: '[PC preview] unknow supportDoctype',
ignoreNameSpace: '[PC preview] unknow ignoreNameSpace',
tagValueCallbackFunction: function(...args) {
console.warn("ParseOptions.tagValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
attributeValueCallbackFunction: function(...args) {
console.warn("ParseOptions.attributeValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
tokenValueCallbackFunction: function(...args) {
console.warn("ParseOptions.tokenValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
}
};
return xmlMock;
}