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" 17export function mockXml() { 18 const XmlSerializerClass = class XmlSerializer { 19 constructor(...args) { 20 console.warn("XmlSerializer.constructor interface mocked in the Previewer. How this interface works on the Previewer" + 21 " may be different from that on a real device."); 22 this.setAttributes = function (...args) { 23 console.warn("XmlSerializer.setAttributes interface mocked in the Previewer. How this interface works on the Previewer" + 24 " may be different from that on a real device."); 25 }; 26 this.addEmptyElement = function (...args) { 27 console.warn("XmlSerializer.addEmptyElement 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.setDeclaration = function (...args) { 31 console.warn("XmlSerializer.setDeclaration 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.startElement = function (...args) { 35 console.warn("XmlSerializer.startElement 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.endElement = function (...args) { 39 console.warn("XmlSerializer.endElement interface mocked in the Previewer. How this interface works on the Previewer" + 40 " may be different from that on a real device."); 41 }; 42 this.setNamespace = function (...args) { 43 console.warn("XmlSerializer.setNamespace interface mocked in the Previewer. How this interface works on the Previewer" + 44 " may be different from that on a real device."); 45 }; 46 this.setComment = function (...args) { 47 console.warn("XmlSerializer.setCommnet interface mocked in the Previewer. How this interface works on the Previewer" + 48 " may be different from that on a real device."); 49 }; 50 this.setCData = function (...args) { 51 console.warn("XmlSerializer.setCData interface mocked in the Previewer. How this interface works on the Previewer" + 52 " may be different from that on a real device."); 53 }; 54 this.setText = function (...args) { 55 console.warn("XmlSerializer.setText interface mocked in the Previewer. How this interface works on the Previewer" + 56 " may be different from that on a real device."); 57 }; 58 this.setDocType = function (...args) { 59 console.warn("XmlSerializer.setDocType interface mocked in the Previewer. How this interface works on the Previewer" + 60 " may be different from that on a real device."); 61 } 62 } 63 }; 64 65 const XmlPullParserClass = class XmlPullParser { 66 constructor(...args) { 67 console.warn("XmlPullParser.constructor interface mocked in the Previewer. How this interface works on the Previewer" + 68 " may be different from that on a real device."); 69 this.parse = function (...args) { 70 console.warn("XmlPullParser.parse interface mocked in the Previewer. How this interface works on the Previewer" + 71 " may be different from that on a real device."); 72 } 73 } 74 }; 75 76 const xmlMock = { 77 XmlSerializer : XmlSerializerClass, 78 XmlPullParser : XmlPullParserClass, 79 80 EventType : { 81 START_DOCUMENT: 0, 82 END_DOCUMENT: 1, 83 START_TAG: 2, 84 END_TAG: 3, 85 TEXT: 4, 86 CDSECT: 5, 87 COMMENT: 6, 88 DOCDECL: 7, 89 INSTRUCTION: 8, 90 ENTITY_REFERENCE: 9, 91 WHITESPACE: 10 92 } 93 }; 94 95 const ParseInfoMock = { 96 getColumnNumber: function () { 97 console.warn("ParseInfo.getColumnNumber interface mocked in the Previewer. How this interface works on the Previewer" + 98 " may be different from that on a real device.") 99 return paramMock.paramNumberMock; 100 }, 101 getDepth: function () { 102 console.warn("ParseInfo.getDepth interface mocked in the Previewer. How this interface works on the Previewer" + 103 " may be different from that on a real device.") 104 return paramMock.paramNumberMock; 105 }, 106 getLineNumber: function () { 107 console.warn("ParseInfo.getLineNumber interface mocked in the Previewer. How this interface works on the Previewer" + 108 " may be different from that on a real device.") 109 return paramMock.paramNumberMock; 110 }, 111 getName: function () { 112 console.warn("ParseInfo.getName interface mocked in the Previewer. How this interface works on the Previewer" + 113 " may be different from that on a real device.") 114 return paramMock.paramStringMock; 115 }, 116 getNamespace: function () { 117 console.warn("ParseInfo.getNamespace interface mocked in the Previewer. How this interface works on the Previewer" + 118 " may be different from that on a real device.") 119 return paramMock.paramStringMock; 120 }, 121 getPrefix: function () { 122 console.warn("ParseInfo.getPrefix interface mocked in the Previewer. How this interface works on the Previewer" + 123 " may be different from that on a real device.") 124 return paramMock.paramStringMock; 125 }, 126 getText: function () { 127 console.warn("ParseInfo.getText interface mocked in the Previewer. How this interface works on the Previewer" + 128 " may be different from that on a real device.") 129 return paramMock.paramStringMock; 130 }, 131 isEmptyElementTag: function () { 132 console.warn("ParseInfo.isEmptyElementTag interface mocked in the Previewer. How this interface works on the Previewer" + 133 " may be different from that on a real device.") 134 return paramMock.paramBooleanMock; 135 }, 136 isWhitespace: function () { 137 console.warn("ParseInfo.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" + 138 " may be different from that on a real device.") 139 return paramMock.paramBooleanMock; 140 }, 141 getAttributeCount: function () { 142 console.warn("ParseInfo.getAttributeCount interface mocked in the Previewer. How this interface works on the Previewer" + 143 " may be different from that on a real device.") 144 return paramMock.paramNumberMock; 145 } 146 }; 147 148 const ParseOptionsMock = { 149 supportDoctype: '[PC preview] unknow supportDoctype', 150 ignoreNameSpace: '[PC preview] unknow ignoreNameSpace', 151 tagValueCallbackFunction: function(...args) { 152 console.warn("ParseOptions.tagValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + 153 " may be different from that on a real device.") 154 return paramMock.paramNumberMock; 155 }, 156 attributeValueCallbackFunction: function(...args) { 157 console.warn("ParseOptions.attributeValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + 158 " may be different from that on a real device.") 159 return paramMock.paramNumberMock; 160 }, 161 tokenValueCallbackFunction: function(...args) { 162 console.warn("ParseOptions.tokenValueCallbackFunction interface mocked in the Previewer. How this interface works on the Previewer" + 163 " may be different from that on a real device.") 164 return paramMock.paramNumberMock; 165 } 166 }; 167 return xmlMock; 168} 169