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" 17 18export function mockUri() { 19 const URIClass = class URI { 20 constructor(...args) { 21 console.warn("uri.URI.constructor interface mocked in the Previewer. How this interface works on the Previewer" + 22 " may be different from that on a real device."); 23 this.toString = function (...args) { 24 console.warn("URI.toString interface mocked in the Previewer. How this interface works on the Previewer" + 25 " may be different from that on a real device."); 26 return paramMock.paramStringMock; 27 }; 28 this.equals = function (...args) { 29 console.warn("URI.equals interface mocked in the Previewer. How this interface works on the Previewer" + 30 " may be different from that on a real device."); 31 return paramMock.paramBooleanMock; 32 }; 33 this.checkIsAbsolute = function (...args) { 34 console.warn("URI.checkIsAbsolute interface mocked in the Previewer. How this interface works on the Previewer" + 35 " may be different from that on a real device."); 36 return paramMock.paramBooleanMock; 37 }; 38 this.normalize = function (...args) { 39 console.warn("URI.normalize 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 URIClass(); 42 }; 43 this.scheme = '[PC preview] unknow scheme'; 44 this.userInfo = '[PC preview] unknow userInfo'; 45 this.host = '[PC preview] unknow host'; 46 this.port = '[PC preview] unknow port'; 47 this.path = '[PC preview] unknow path'; 48 this.query = '[PC preview] unknow query'; 49 this.fragment = '[PC preview] unknow fragment'; 50 this.authority = '[PC preview] unknow authority'; 51 this.ssp = '[PC preview] unknow ssp'; 52 } 53 }; 54 const uriMock = { 55 URI : URIClass 56 }; 57 return uriMock; 58} 59