mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-18 20:44:48 -04:00
@@ -345,9 +345,9 @@ export function mockRequireNapiFun() {
|
||||
return mockFileManager();
|
||||
case "environment":
|
||||
return mockEnvironment();
|
||||
case "storagestatistics":
|
||||
case "storageStatistics":
|
||||
return mockStorageStatistics();
|
||||
case "volumemanager":
|
||||
case "volumemManager":
|
||||
return mockVolumeManager();
|
||||
case "settings":
|
||||
return mockSettings();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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,24 +16,29 @@
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockFileManager() {
|
||||
const fileInfoMock = {
|
||||
const FileInfo = {
|
||||
name: '[PC preview] unknow name',
|
||||
path: '[PC preview] unknow path',
|
||||
type: '[PC preview] unknow type',
|
||||
size: '[PC preview] unknow size',
|
||||
addedTime: '[PC preview] unknow addedTime',
|
||||
modifiedTime: '[PC preview] unknow modifiedTime',
|
||||
modifiedTime: '[PC preview] unknow modifiedTime'
|
||||
};
|
||||
const DevInfo = {
|
||||
name: '[PC preview] unknow name'
|
||||
};
|
||||
const filemanager = {
|
||||
FileInfo: FileInfo,
|
||||
DevInfo: DevInfo,
|
||||
getRoot: function (...args) {
|
||||
console.warn("filemanager.getRoot 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(fileInfoMock))
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo))
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Array(fileInfoMock));
|
||||
resolve(Array(FileInfo));
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -42,10 +47,10 @@ export function mockFileManager() {
|
||||
" 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(fileInfoMock))
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, Array(FileInfo))
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Array(fileInfoMock));
|
||||
resolve(Array(FileInfo));
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -60,7 +65,7 @@ export function mockFileManager() {
|
||||
resolve(paramMock.paramStringMock);
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
return filemanager;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,22 @@
|
||||
import { paramMock } from '../utils';
|
||||
|
||||
export function mockStorageStatistics() {
|
||||
const BundleStatsMock = {
|
||||
const BundleStats = {
|
||||
appSize: '[PC preview] unknow appSize',
|
||||
cacheSize: '[PC preview] unknow cacheSize',
|
||||
dataSize: '[PC preview] unknow dataSize'
|
||||
};
|
||||
const StorageStats= {
|
||||
total: '[PC preview] unknow total',
|
||||
audio: '[PC preview] unknow audio',
|
||||
video: '[PC preview] unknow video',
|
||||
image: '[PC preview] unknow image',
|
||||
file: '[PC preview] unknow file',
|
||||
app: '[PC preview] unknow app'
|
||||
}
|
||||
const storageStatistics = {
|
||||
BundleStats: BundleStatsMock,
|
||||
BundleStats: BundleStats,
|
||||
StorageStats: StorageStats,
|
||||
getTotalSizeOfVolume: function(...args) {
|
||||
console.warn('storageStatistics.getTotalSizeOfVolume interface mocked in the Previewer. How this interface works on the' +
|
||||
' Previewer may be different from that on a real device.');
|
||||
@@ -58,6 +67,66 @@ export function mockStorageStatistics() {
|
||||
resolve(BundleStatsMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getCurrentBundleStats: function(...args) {
|
||||
console.warn('storageStatistics.getCurrentBundleStats 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, BundleStats);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(BundleStats);
|
||||
});
|
||||
}
|
||||
},
|
||||
getSystemSize: function(...args) {
|
||||
console.warn('storageStatistics.getSystemSize 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getUserStorageStats: function(...args) {
|
||||
console.warn('storageStatistics.getUserStorageStats 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, StorageStats);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(StorageStats);
|
||||
});
|
||||
}
|
||||
},
|
||||
getTotalSize: function(...args) {
|
||||
console.warn('storageStatistics.getTotalSize 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
},
|
||||
getFreeSize: function(...args) {
|
||||
console.warn('storageStatistics.getFreeSize 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, paramMock.paramNumberMock);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(paramMock.paramNumberMock);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return storageStatistics;
|
||||
|
||||
@@ -14,19 +14,27 @@
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
import {VolumeMock} from './volume/volumeInfo'
|
||||
|
||||
export function mockVolumeManager() {
|
||||
const Volume = {
|
||||
id: '[PC preview] unknow id',
|
||||
uuid: '[PC preview] unknow uuid',
|
||||
description: '[PC preview] unknow description',
|
||||
removeAble: '[PC preview] unknow removeAble',
|
||||
path: '[PC preview] unknow path',
|
||||
state: '[PC preview] unknow state'
|
||||
};
|
||||
const volumeManager = {
|
||||
Volume: Volume,
|
||||
getAllVolumes: function (...args) {
|
||||
console.warn("volumeManager.getAllVolumes 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(VolumeMock));
|
||||
args[len - 1].call(this, paramMock.businessErrorMock, Array(Volume));
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Array(VolumeMock));
|
||||
resolve(Array(Volume));
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -54,6 +62,66 @@ export function mockVolumeManager() {
|
||||
})
|
||||
}
|
||||
},
|
||||
getVolumeByUuid: function (...args) {
|
||||
console.warn("volumeManager.getVolumeByUuid 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, Volume);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Volume);
|
||||
})
|
||||
}
|
||||
},
|
||||
getVolumeById: function (...args) {
|
||||
console.warn("volumeManager.getVolumeById 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, Volume);
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(Volume);
|
||||
})
|
||||
}
|
||||
},
|
||||
setVolumeDescription: function (...args) {
|
||||
console.warn("volumeManager.setVolumeDescription 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
format: function (...args) {
|
||||
console.warn("volumeManager.format 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();
|
||||
})
|
||||
}
|
||||
},
|
||||
partition: function (...args) {
|
||||
console.warn("volumeManager.partition 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();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return volumeManager;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user