mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-18 12:35:31 -04:00
修改枚举类,删掉无用函数
Signed-off-by: jiawen <jiawen.zhang@thundersoft.com> Change-Id: I06f01af58d7312eeb6294bb199cc995a68ae3ade
This commit is contained in:
@@ -15,70 +15,80 @@
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export const NetCap = {
|
||||
NET_CAPABILITY_MMS: '[PC preview] unknow NET_CAPABILITY_MMS',
|
||||
NET_CAPABILITY_NOT_METERED: '[PC preview] unknow NET_CAPABILITY_NOT_METERED',
|
||||
NET_CAPABILITY_INTERNET: '[PC preview] unknow NET_CAPABILITY_INTERNET',
|
||||
NET_CAPABILITY_NOT_VPN: '[PC preview] unknow NET_CAPABILITY_NOT_VPN',
|
||||
NET_CAPABILITY_VALIDATED: '[PC preview] unknow NET_CAPABILITY_VALIDATED'
|
||||
}
|
||||
|
||||
export const NetBearType = {
|
||||
BEARER_CELLULAR: '[PC preview] unknow BEARER_CELLULAR',
|
||||
BEARER_WIFI: '[PC preview] unknow BEARER_WIFI',
|
||||
BEARER_ETHERNET: '[PC preview] unknow BEARER_ETHERNET'
|
||||
}
|
||||
|
||||
export function mockConnection() {
|
||||
const NetSpecifierMock = {
|
||||
netCapabilities: NetCapabilitiesMock,
|
||||
const NetSpecifier = {
|
||||
netCapabilities: NetCapabilities,
|
||||
bearerPrivateIdentifier: '[PC preview] unknow bearerPrivateIdentifier'
|
||||
}
|
||||
|
||||
const NetCapabilitiesMock = {
|
||||
const NetCapabilities = {
|
||||
linkUpBandwidthKbps: '[PC preview] unknow linkUpBandwidthKbps',
|
||||
linkDownBandwidthKbps: '[PC preview] unknow linkDownBandwidthKbps',
|
||||
networkCap:[netCapMock],
|
||||
bearerTypes:[netBearTypeMock]
|
||||
networkCap:[NetCap],
|
||||
bearerTypes:[NetBearType]
|
||||
}
|
||||
|
||||
const netCapMock = '[PC preview] unknow NetCap'
|
||||
|
||||
const netBearTypeMock = '[PC preview] unknow NetBearType'
|
||||
|
||||
const ConnectionPropertiesMock = {
|
||||
const ConnectionProperties = {
|
||||
interfaceName: '[PC preview] unknow interfaceName',
|
||||
domains: '[PC preview] unknow domains',
|
||||
linkAddresses: [LinkAddressMock],
|
||||
dnses: [NetAddressMock],
|
||||
routes: [RouteInfoMock],
|
||||
linkAddresses: [LinkAddress],
|
||||
dnses: [NetAddress],
|
||||
routes: [RouteInfo],
|
||||
mtu: '[PC preview] unknow mtu'
|
||||
}
|
||||
|
||||
const LinkAddressMock = {
|
||||
address: NetAddressMock,
|
||||
const LinkAddress = {
|
||||
address: NetAddress,
|
||||
prefixLength: '[PC preview] unknow prefixLength'
|
||||
}
|
||||
|
||||
const NetAddressMock = {
|
||||
const NetAddress = {
|
||||
address: '[PC preview] unknow address',
|
||||
family: '[PC preview] unknow family',
|
||||
port: '[PC preview] unknow port'
|
||||
}
|
||||
|
||||
const RouteInfoMock = {
|
||||
const RouteInfo = {
|
||||
interface: '[PC preview] unknow interface',
|
||||
destination: LinkAddressMock,
|
||||
gateway: NetAddressMock,
|
||||
destination: LinkAddress,
|
||||
gateway: NetAddress,
|
||||
hasGateway: '[PC preview] unknow hasGateway',
|
||||
isDefaultRoute: '[PC preview] unknow isDefaultRoute'
|
||||
}
|
||||
|
||||
const netConnection = {
|
||||
const NetConnection = {
|
||||
on: function (...args) {
|
||||
console.warn("netConnection.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("NetConnection.on interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'netAvailable') {
|
||||
args[len - 1].call(this, netHandle);
|
||||
args[len - 1].call(this, NetHandle);
|
||||
} else if (args[0] === 'netBlockStatusChange') {
|
||||
var array = new Array(netHandle, paramMock.paramBooleanMock);
|
||||
var array = new Array(NetHandle, paramMock.paramBooleanMock);
|
||||
args[len - 1].call(this, array);
|
||||
} else if (args[0] === 'netCapabilitiesChange') {
|
||||
var array = new Array(netHandle, NetCapabilitiesMock);
|
||||
var array = new Array(NetHandle, NetCapabilities);
|
||||
args[len - 1].call(this, array);
|
||||
} else if (args[0] === 'netConnectionPropertiesChange') {
|
||||
var array = new Array(netHandle, ConnectionPropertiesMock);
|
||||
var array = new Array(NetHandle, ConnectionProperties);
|
||||
args[len - 1].call(this, array);
|
||||
} else if (args[0] === 'netLost') {
|
||||
args[len - 1].call(this, netHandle);
|
||||
args[len - 1].call(this, NetHandle);
|
||||
} else if (args[0] === 'netUnavailable') {
|
||||
args[len - 1].call(this);
|
||||
}
|
||||
@@ -86,80 +96,61 @@ export function mockConnection() {
|
||||
},
|
||||
|
||||
register: function (...args) {
|
||||
console.warn("netConnection.register interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("NetConnection.register interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
unregister: function (...args) {
|
||||
console.warn("netConnection.unregister interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("NetConnection.unregister interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const netHandle = {
|
||||
const NetHandle = {
|
||||
netId: '[PC preview] unknow netId',
|
||||
|
||||
bindSocket: function (...args) {
|
||||
console.warn("netHandle.bindSocket interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getAddressesByName: function (...args) {
|
||||
console.warn("netHandle.getAddressesByName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("NetHandle.getAddressesByName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NetAddressMock])
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NetAddress])
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([NetAddressMock])
|
||||
resolve([NetAddress])
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getAddressByName: function (...args) {
|
||||
console.warn("netHandle.getAddressByName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("NetHandle.getAddressByName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (len > 0 && typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, NetAddressMock)
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, NetAddress)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(NetAddressMock)
|
||||
resolve(NetAddress)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const connection = {
|
||||
NetCap,
|
||||
NetBearType,
|
||||
createNetConnection: function () {
|
||||
console.warn("connection.createNetConnection interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return netConnection;
|
||||
return NetConnection;
|
||||
},
|
||||
|
||||
getDefaultNet: function (...args) {
|
||||
@@ -167,10 +158,10 @@ export function mockConnection() {
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, netHandle)
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, NetHandle)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(netHandle)
|
||||
resolve(NetHandle)
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -180,10 +171,10 @@ export function mockConnection() {
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [netHandle])
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NetHandle])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([netHandle])
|
||||
resolve([NetHandle])
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -193,10 +184,10 @@ export function mockConnection() {
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ConnectionPropertiesMock)
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, ConnectionProperties)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(ConnectionPropertiesMock)
|
||||
resolve(ConnectionProperties)
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -206,10 +197,10 @@ export function mockConnection() {
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, NetCapabilitiesMock)
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, NetCapabilities)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(NetCapabilitiesMock)
|
||||
resolve(NetCapabilities)
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -284,106 +275,13 @@ export function mockConnection() {
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NetAddressMock])
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, [NetAddress])
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve([NetAddressMock])
|
||||
resolve([NetAddress])
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getAddressByName: function (...args) {
|
||||
console.warn("connection.getAddressByName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, NetAddressMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(NetAddressMock)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getAppNet: function (...args) {
|
||||
console.warn("connection.getAppNet interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, netHandle)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(netHandle)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
setAppNet: function (...args) {
|
||||
console.warn("connection.setAppNet interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
registerReportNetConnectCallback: function (...args) {
|
||||
console.warn("connection.registerReportNetConnectCallback interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
unregisterReportNetConnectCallback: function (...args) {
|
||||
console.warn("connection.unregisterReportNetConnectCallback interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getSpecificNet: function (...args) {
|
||||
console.warn("connection.getSpecificNet interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, Array(paramMock.paramNumberMock))
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve(Array(paramMock.paramNumberMock))
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
restoreFactoryData: function (...args) {
|
||||
console.warn("connection.restoreFactoryData interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock)
|
||||
} else {
|
||||
return new Promise((resolve) => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
return connection;
|
||||
|
||||
@@ -15,66 +15,72 @@
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export const RequestMethod = {
|
||||
OPTIONS: "[PC Preview] unknow OPTIONS",
|
||||
GET: "[PC Preview] unknow GET",
|
||||
HEAD: "[PC Preview] unknow HEAD",
|
||||
POST: "[PC Preview] unknow POST",
|
||||
PUT: "[PC Preview] unknow PUT",
|
||||
DELETE: "[PC Preview] unknow DELETE",
|
||||
TRACE: "[PC Preview] unknow TRACE",
|
||||
CONNECT: "[PC Preview] unknow CONNECT"
|
||||
}
|
||||
|
||||
export const ResponseCode = {
|
||||
OK: "[PC Preview] unknow OK",
|
||||
CREATED: "[PC Preview] unknow CREATED",
|
||||
ACCEPTED: "[PC Preview] unknow ACCEPTED",
|
||||
NOT_AUTHORITATIVE: "[PC Preview] unknow NOT_AUTHORITATIVE",
|
||||
NO_CONTENT: "[PC Preview] unknow NO_CONTENT",
|
||||
RESET: "[PC Preview] unknow RESET",
|
||||
PARTIAL: "[PC Preview] unknow PARTIAL",
|
||||
MULT_CHOICE: "[PC Preview] unknow MULT_CHOICE",
|
||||
MOVED_PERM: "[PC Preview] unknow MOVED_PERM",
|
||||
MOVED_TEMP: "[PC Preview] unknow MOVED_TEMP",
|
||||
SEE_OTHER: "[PC Preview] unknow SEE_OTHER",
|
||||
NOT_MODIFIED: "[PC Preview] unknow NOT_MODIFIED",
|
||||
USE_PROXY: "[PC Preview] unknow USE_PROXY",
|
||||
BAD_REQUEST: "[PC Preview] unknow BAD_REQUEST",
|
||||
UNAUTHORIZED: "[PC Preview] unknow UNAUTHORIZED",
|
||||
PAYMENT_REQUIRED: "[PC Preview] unknow PAYMENT_REQUIRED",
|
||||
FORBIDDEN: "[PC Preview] unknow FORBIDDEN",
|
||||
NOT_FOUND: "[PC Preview] unknow NOT_FOUND",
|
||||
BAD_METHOD: "[PC Preview] unknow BAD_METHOD",
|
||||
NOT_ACCEPTABLE: "[PC Preview] unknow NOT_ACCEPTABLE",
|
||||
PROXY_AUTH: "[PC Preview] unknow PROXY_AUTH",
|
||||
CLIENT_TIMEOUT: "[PC Preview] unknow CLIENT_TIMEOUT",
|
||||
CONFLICT: "[PC Preview] unknow CONFLICT",
|
||||
GONE: "[PC Preview] unknow GONE",
|
||||
LENGTH_REQUIRED: "[PC Preview] unknow LENGTH_REQUIRED",
|
||||
PRECON_FAILED: "[PC Preview] unknow PRECON_FAILED",
|
||||
ENTITY_TOO_LARGE: "[PC Preview] unknow ENTITY_TOO_LARGE",
|
||||
REQ_TOO_LONG: "[PC Preview] unknow REQ_TOO_LONG",
|
||||
UNSUPPORTED_TYPE: "[PC Preview] unknow UNSUPPORTED_TYPE",
|
||||
INTERNAL_ERROR: "[PC Preview] unknow INTERNAL_ERROR",
|
||||
NOT_IMPLEMENTED: "[PC Preview] unknow NOT_IMPLEMENTED",
|
||||
BAD_GATEWAY: "[PC Preview] unknow BAD_GATEWAY",
|
||||
UNAVAILABLE: "[PC Preview] unknow UNAVAILABLE",
|
||||
GATEWAY_TIMEOUT: "[PC Preview] unknow GATEWAY_TIMEOUT",
|
||||
VERSION: "[PC Preview] unknow VERSION"
|
||||
}
|
||||
|
||||
export function mockHttp() {
|
||||
const HttpResponseCacheOptions = {
|
||||
filePath: "[PC Preview] unknow filePath",
|
||||
fileChildPath: "[PC Preview] unknow fileChildPath",
|
||||
cacheSize: "[PC Preview] unknow cacheSize"
|
||||
}
|
||||
const HttpResponseCache = {
|
||||
close: function (...args) {
|
||||
console.warn("net.HttpResponseCache.close interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
delete: function (...args) {
|
||||
console.warn("net.HttpResponseCache.delete interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
},
|
||||
flush: function (...args) {
|
||||
console.warn("net.HttpResponseCache.flush interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
const HttpResponseMock = {
|
||||
const HttpResponse = {
|
||||
result: "[PC Preview] unknow result",
|
||||
responseCode: responseCodeMock,
|
||||
responseCode: ResponseCode,
|
||||
header: "[PC Preview] unknow header",
|
||||
cookies: "[PC Preview] unknow cookies"
|
||||
}
|
||||
const httpRequest = {
|
||||
const HttpRequest = {
|
||||
request: function (...args) {
|
||||
console.warn("HttpRequest.request interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseMock);
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponse);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(HttpResponseMock);
|
||||
resolve(HttpResponse);
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -115,48 +121,24 @@ export function mockHttp() {
|
||||
}
|
||||
}
|
||||
}
|
||||
const requestMethodMock = "[PC Preview] unknow RequestMethod"
|
||||
|
||||
const HttpRequestOptionsMock = {
|
||||
method: requestMethodMock,
|
||||
const HttpRequestOptions = {
|
||||
method: RequestMethod,
|
||||
extraData: "[PC Preview] unknow extraData",
|
||||
header: "[PC Preview] unknow header",
|
||||
readTimeout: "[PC Preview] unknow readTimeout",
|
||||
connectTimeout: "[PC Preview] unknow connectTimeout"
|
||||
}
|
||||
|
||||
const responseCodeMock = "[PC Preview] unknow ResponseCode"
|
||||
|
||||
const http = {
|
||||
RequestMethod,
|
||||
ResponseCode,
|
||||
createHttp: function () {
|
||||
console.warn("net.http.createHttp interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return httpRequest;
|
||||
return HttpRequest;
|
||||
},
|
||||
getInstalledHttpResponseCache: function (...args) {
|
||||
console.warn("net.http.getInstalledHttpResponseCache interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseCache);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(HttpResponseCache);
|
||||
})
|
||||
}
|
||||
},
|
||||
createHttpResponseCache: function (...args) {
|
||||
console.warn("net.http.createHttpResponseCache interface mocked in the Previewer. How this interface works on the Previewer may" +
|
||||
" be different from that on a real device.")
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, HttpResponseCacheOptions);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(HttpResponseCache);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return http
|
||||
|
||||
return http;
|
||||
}
|
||||
@@ -102,14 +102,11 @@ export function mockSocket() {
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
|
||||
} else if (args[0] === 'listening') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'close') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
@@ -121,14 +118,11 @@ export function mockSocket() {
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
|
||||
} else if (args[0] === 'listening') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'close') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
@@ -227,14 +221,11 @@ export function mockSocket() {
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
|
||||
} else if (args[0] === 'connect') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'close') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
@@ -246,14 +237,11 @@ export function mockSocket() {
|
||||
const len = args.length
|
||||
if (typeof args[len - 1] === 'function') {
|
||||
if (args[0] === 'message') {
|
||||
args[len - 1].call(this, {
|
||||
message: "[PC Preview] unknow message",
|
||||
remoteInfo: SocketRemoteInfo
|
||||
});
|
||||
args[len - 1].call(this, {ArrayBuffer, SocketRemoteInfo});
|
||||
} else if (args[0] === 'connect') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'close') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
args[len - 1].call(this);
|
||||
} else if (args[0] === 'error') {
|
||||
args[len - 1].call(this, paramMock.businessErrorMock);
|
||||
}
|
||||
@@ -261,39 +249,41 @@ export function mockSocket() {
|
||||
}
|
||||
}
|
||||
|
||||
const UDPSendOptionsMock = {
|
||||
const UDPSendOptions = {
|
||||
data: "[PC Preview] unknow data",
|
||||
address: NetAddress,
|
||||
address: NetAddress
|
||||
}
|
||||
|
||||
const ExtraOptionsBaseMock = {
|
||||
const ExtraOptionsBase = {
|
||||
receiveBufferSize: "[PC Preview] unknow receiveBufferSize",
|
||||
sendBufferSize: "[PC Preview] unknow sendBufferSize",
|
||||
reuseAddress: "[PC Preview] unknow reuseAddress",
|
||||
socketTimeout: "[PC Preview] unknow socketTimeout",
|
||||
socketTimeout: "[PC Preview] unknow socketTimeout"
|
||||
}
|
||||
|
||||
const UDPExtraOptionsMock = {
|
||||
broadcast: "[PC Preview] unknow broadcast",
|
||||
const UDPExtraOptions = {
|
||||
broadcast: "[PC Preview] unknow broadcast"
|
||||
}
|
||||
|
||||
const TCPConnectionOptionsMock = {
|
||||
const TCPConnectOptions = {
|
||||
address: NetAddress,
|
||||
timeout: "[PC Preivew] unknow timeout",
|
||||
}
|
||||
|
||||
const TCPSendOptionsMock = {
|
||||
const TCPSendOptions = {
|
||||
data: "[PC Preview] unknow data",
|
||||
encoding: "[PC Preview] unknow encoding",
|
||||
}
|
||||
|
||||
const TCPExtraOptionsMock = {
|
||||
const TCPExtraOptions = {
|
||||
keepAlive: "[PC Preview] unknow keepAlive",
|
||||
OOBInline: "[PC Preview] unknow OOBInline",
|
||||
TCPNoDelay: "[PC Preview] unknow TCPNoDelay",
|
||||
socketLinger: "[PC Preview] unknow socketLinger",
|
||||
socketLinger: {
|
||||
on: "[PC Preview] unknow on",
|
||||
linger: "[PC Preview] unknow linger"
|
||||
}
|
||||
}
|
||||
|
||||
const socket = {
|
||||
constructUDPSocketInstance: function () {
|
||||
console.warn("net.socket.constructUDPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
@@ -304,12 +294,8 @@ export function mockSocket() {
|
||||
console.warn("net.socket.constructTCPSocketInstance interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return TCPSocket;
|
||||
},
|
||||
NetAddress: function() {
|
||||
console.warn("net.socket.NetAddress interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.");
|
||||
return NetAddress;
|
||||
}
|
||||
}
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user