Signed-off-by: xuzheheng <xuzheheng1@huawei.com>
Change-Id: I580a1b601f9c19165b231417d0bc2421ea751ee3
This commit is contained in:
xuzheheng
2022-07-18 13:04:58 +08:00
parent bdf2f266e8
commit 94e57fbcce
36 changed files with 1126 additions and 19 deletions
@@ -0,0 +1,289 @@
/*
* 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"
const DataAbilityResult = {
uri: "[PC Preview] unknow uri",
count: "[PC Preview] unknow count"
}
const ResultSet = {
columnNames: [paramMock.paramStringMock],
columnCount: "[PC Preview] unknow columnCount",
rowCount: "[PC Preview] unknow rowCount",
rowIndex: "[PC Preview] unknow rowIndex",
isAtFirstRow: "[PC Preview] unknow isAtFirstRow",
isAtLastRow: "[PC Preview] unknow isAtLastRow",
isEnded: "[PC Preview] unknow isEnded",
isStarted: "[PC Preview] unknow isStarted",
isClose: "[PC Preview] unknow isClose",
getColumnIndex: function (...args) {
console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getColumnName: function (...args) {
console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
goTo: function (...args) {
console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToRow: function (...args) {
console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToLastRow: function (...args) {
console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToFirstRow: function (...args) {
console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToNextRow: function (...args) {
console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
goToPreviousRow: function (...args) {
console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
getBlob: function (...args) {
console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramArrayMock;
},
getString: function (...args) {
console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramStringMock;
},
getLong: function (...args) {
console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
getDouble: function (...args) {
console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramNumberMock;
},
isColumnNull: function (...args) {
console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
return paramMock.paramBooleanMock;
},
close: function () {
console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
}
}
export const PacMap = {key:{}}
export const dataAbilityHelper = {
openFile: function (...args) {
console.warn("dataAbilityHelper.openFile 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) => {
resolve(paramMock.paramNumberMock);
})
}
},
on: function (...args) {
console.warn("dataAbilityHelper.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') {
args[len - 1].call(this, paramMock.businessErrorMock)
}
},
off: function (...args) {
console.warn("dataAbilityHelper.off 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)
}
},
call: function (...args) {
console.warn("dataAbilityHelper.call 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, PacMap)
} else {
return new Promise((resolve) => {
resolve(PacMap);
})
}
},
getType: function (...args) {
console.warn("dataAbilityHelper.getType 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.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
getFileTypes: function (...args) {
console.warn("dataAbilityHelper.getFileTypes 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.paramStringMock])
} else {
return new Promise((resolve) => {
resolve([paramMock.paramStringMock]);
})
}
},
normalizeUri: function (...args) {
console.warn("dataAbilityHelper.normalizeUri 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.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
denormalizeUri: function (...args) {
console.warn("dataAbilityHelper.denormalizeUri 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.paramStringMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramStringMock);
})
}
},
notifyChange: function (...args) {
console.warn("dataAbilityHelper.notifyChange 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();
})
}
},
insert: function (...args) {
console.warn("dataAbilityHelper.insert 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) => {
resolve(paramMock.paramNumberMock);
})
}
},
batchInsert: function (...args) {
console.warn("dataAbilityHelper.batchInsert 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) => {
resolve(paramMock.paramNumberMock);
})
}
},
delete: function (...args) {
console.warn("dataAbilityHelper.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, paramMock.paramNumberMock)
} else {
return new Promise((resolve) => {
resolve(paramMock.paramNumberMock);
})
}
},
update: function (...args) {
console.warn("dataAbilityHelper.update 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) => {
resolve(paramMock.paramNumberMock);
})
}
},
query: function (...args) {
console.warn("dataAbilityHelper.query 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, ResultSet)
} else {
return new Promise((resolve) => {
resolve(ResultSet);
})
}
},
call: function (...args) {
console.warn("dataAbilityHelper.call 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, PacMap)
} else {
return new Promise((resolve) => {
resolve(PacMap);
})
}
},
executeBatch: function (...args) {
console.warn("dataAbilityHelper.executeBatch 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, [DataAbilityResult])
} else {
return new Promise((resolve) => {
resolve([DataAbilityResult]);
})
}
}
}
@@ -0,0 +1,33 @@
/*
* 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"
import { mockDataAbility } from "../ohos_data_dataAbility"
export const DataAbilityOperation = {
uri: "[PC Preview] unknow uri",
type: {
TYPE_INSERT: 1,
TYPE_UPDATE: 2,
TYPE_DELETE: 3,
TYPE_ASSERT: 4
},
valuesBucket: {key:{}},
valueBackReferences: {key:{}},
predicates: mockDataAbility().DataAbilityPredicates,
predicatesBackReferences: new Map([[paramMock.paramNumberMock, paramMock.paramNumberMock]]),
interrupted: "[PC Preview] unknow interrupted",
expectedCount: "[PC Preview] unknow expectedCount"
}
@@ -0,0 +1,19 @@
/*
* 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.
*/
export const DataAbilityResult = {
uri: "[PC Preview] unknow uri",
count: "[PC Preview] unknow count",
}
@@ -0,0 +1,39 @@
/*
* 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.
*/
const ElementName = {
deviceId: '[PC preview] unknow deviceId',
bundleName: '[PC preview] unknow bundleName',
abilityName: '[PC preview] unknow abilityName',
uri: '[PC preview] unknow uri',
shortName: '[PC preview] unknow shortName',
moduleName: '[PC preview] unknow moduleName'
}
const AbilityState = {
INITIAL: 0,
FOREGROUND: 9,
BACKGROUND: 10,
FOREGROUNDING: 11,
BACKGROUNDING: 12
}
export const AbilityRunningInfo = {
ability: ElementName,
pid: '[PC preview] unknow pid',
uid: '[PC preview] unknow uid',
processName: '[PC preview] unknow processName',
startTime: '[PC preview] unknow startTime',
abilityState: AbilityState
}
@@ -0,0 +1,28 @@
/*
* 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 { ContextClass } from "./Context"
import { HapModuleInfo } from "../bundle/HapModuleInfo"
import { Configuration } from "../ohos.application.Configuration"
export const AbilityStageContextClass = class AbilityStageContext extends ContextClass {
constructor() {
super();
console.warn("AbilityStageContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.currentHapModuleInfo = HapModuleInfo;
this.config = Configuration;
}
};
@@ -0,0 +1,28 @@
/*
* 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.
*/
export const AbilityStateDataClass = class AbilityStateData {
constructor() {
console.warn("AbilityStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.moduleName = "[PC Preview] unknow moduleName",
this.bundleName = "[PC Preview] unknow bundleName",
this.abilityName = "[PC Preview] unknow abilityName",
this.pid = "[PC Preview] unknow pid",
this.uid = "[PC Preview] unknow uid",
this.state = "[PC Preview] unknow state",
this.abilityType = "[PC Preview] unknow abilityType"
}
};
@@ -0,0 +1,24 @@
/*
* 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.
*/
export const AppStateDataClass = class AppStateData {
constructor() {
console.warn("AppStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.bundleName = "[PC Preview] unknow bundleName",
this.uid = "[PC Preview] unknow uid",
this.state = "[PC Preview] unknow state",
}
};
@@ -0,0 +1,59 @@
/*
* 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"
import { ContextClass } from "./Context"
export const ApplicationContextClass = class ApplicationContext extends ContextClass {
constructor() {
super();
console.warn('ApplicationContext.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.registerAbilityLifecycleCallback = function (...args) {
console.warn("ApplicationContext.registerAbilityLifecycleCallback interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.unregisterAbilityLifecycleCallback = function (...args) {
console.warn("ApplicationContext.unregisterAbilityLifecycleCallback 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();
})
}
};
this.registerEnvironmentCallback = function (...args) {
console.warn("ApplicationContext.registerEnvironmentCallback interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.unregisterEnvironmentCallback = function (...args) {
console.warn("ApplicationContext.unregisterEnvironmentCallback 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();
})
}
};
}
}
@@ -0,0 +1,37 @@
/*
* 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.
*/
export const ApplicationStateObserverClass = class ApplicationStateObserver {
constructor() {
console.warn('ApplicationStateObserver.constructor interface mocked in the Previewer. How this interface works on' +
' the Previewer may be different from that on a real device.');
this.onForegroundApplicationChanged = function (...args) {
console.warn("ApplicationStateObserver.onForegroundApplicationChanged interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
this.onAbilityStateChanged = function (...args) {
console.warn("ApplicationStateObserver.onAbilityStateChanged interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
this.onProcessCreated = function (...args) {
console.warn("ApplicationStateObserver.onProcessCreated interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
this.onProcessDied = function (...args) {
console.warn("ApplicationStateObserver.onProcessDied interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
};
}
}
@@ -280,10 +280,12 @@ export const ContextClass = class Context extends BaseContext {
this.tempDir = "[PC Preview] unknow tempDir";
this.filesDir = "[PC Preview] unknow filesDir";
this.databaseDir = "[PC Preview] unknow databaseDir";
this.preferencesDir = "[PC Preview] unknow preferencesDir";
this.storageDir = "[PC Preview] unknow storageDir";
this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir";
this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir";
this.eventHub = new EventHubClass();
this.area = AreaMode;
this.createBundleContext = function (...args) {
console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
@@ -0,0 +1,25 @@
/*
* 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.
*/
export const ErrorObserverClass = class ErrorObserver {
constructor() {
console.warn("ErrorObserver.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.onUnhandledException = function (...args) {
console.warn("ErrorObserver.onUnhandledException interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
};
@@ -0,0 +1,33 @@
/*
* 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.
*/
export const EventHubClass = class EventHub {
constructor() {
console.warn("EventHub.constructor 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("EventHub.on 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("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
this.emit = function (...args) {
console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
};
}
};
@@ -0,0 +1,30 @@
/*
* 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 { HapModuleInfo } from "../bundle/HapModuleInfo";
import { Configuration } from "../ohos.application.Configuration"
import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo"
import { ContextClass } from "./Context"
export const ExtensionContextClass = class ExtensionContext extends ContextClass {
constructor() {
super();
console.warn("ExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.currentHapModuleInfo = HapModuleInfo;
this.config = Configuration;
this.extensionAbilityInfo = ExtensionAbilityInfo;
}
};
@@ -0,0 +1,50 @@
/*
* 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"
const ElementName = {
deviceId: '[PC preview] unknow deviceId',
bundleName: '[PC preview] unknow bundleName',
abilityName: '[PC preview] unknow abilityName',
uri: '[PC preview] unknow uri',
shortName: '[PC preview] unknow shortName',
moduleName: '[PC preview] unknow moduleName'
}
const ExtensionAbilityType = {
FORM: 0,
WORK_SCHEDULER: 1,
INPUT_METHOD: 2,
SERVICE: 3,
ACCESSIBILITY: 4,
DATA_SHARE: 5,
FILE_SHARE: 6,
STATIC_SUBSCRIBER: 7,
WALLPAPER: 8,
BACKUP: 9,
WINDOW: 10,
ENTERPRISE_ADMIN: 11,
UNSPECIFIED: 20
}
export const ExtensionRunningInfo = {
extension: ElementName,
pid: '[PC preview] unknow pid',
uid: '[PC preview] unknow uid',
processName: '[PC preview] unknow processName',
startTime: '[PC preview] unknow startTime',
clientPackage: [paramMock.paramStringMock],
abilityState: ExtensionAbilityType
}
@@ -0,0 +1,27 @@
/*
* 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 { WantClass } from "../ohos.application.Want"
export const MissionInfo = {
missionId: '[PC preview] unknow missionId',
runningState: '[PC preview] unknow runningState',
lockedState: '[PC preview] unknow lockedState',
timestamp: '[PC preview] unknow timestamp',
want: new WantClass(),
label: '[PC preview] unknow label',
iconPath: '[PC preview] unknow iconPath',
continuable: '[PC preview] unknow continuable'
}
@@ -0,0 +1,37 @@
/*
* 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.
*/
export const MissionListener = {
onMissionCreated: function(...args) {
console.warn("MissionListener.onMissionCreated interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionDestroyed: function(...args) {
console.warn("MissionListener.onMissionDestroyed interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionSnapshotChanged: function(...args) {
console.warn("MissionListener.onMissionSnapshotChanged interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionMovedToFront: function(...args) {
console.warn("MissionListener.onMissionMovedToFront interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
},
onMissionIconUpdated: function(...args) {
console.warn("MissionListener.onMissionIconUpdated interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
}
}
@@ -0,0 +1,30 @@
/*
* 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 { PixelMapMock } from "../../multimedia"
const ElementName = {
deviceId: '[PC preview] unknown deviceId',
bundleName: '[PC preview] unknown bundleName',
abilityName: '[PC preview] unknown abilityName',
uri: '[PC preview] unknown uri',
shortName: '[PC preview] unknown shortName',
moduleName: '[PC preview] unknown moduleName'
}
export const MissionSnapshot = {
abality: ElementName,
snapshot: PixelMapMock
}
@@ -0,0 +1,25 @@
/*
* 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 const PermissionRequestResultClass = class PermissionRequestResult {
constructor() {
console.warn("PermissionRequestResult.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.permissions = [paramMock.paramStringMock]
this.authResults = [paramMock.paramNumberMock]
}
};
@@ -0,0 +1,26 @@
/*
* 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 const ProcessDataClass = class ProcessData {
constructor() {
console.warn("ProcessData.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.bundleName = "[PC Preview] unknow bundleName"
this.pid = "[PC Preview] unknow pid"
this.uid = "[PC Preview] unknow uid"
}
};
@@ -0,0 +1,23 @@
/*
* 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 const ProcessRunningInfo = {
pid: "[PC Preview] unknow pid",
uid: "[PC Preview] unknow uid",
processName: "[PC Preview] unknow processName",
bundleNames: [paramMock.paramStringMock]
}
@@ -0,0 +1,131 @@
/*
* 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"
import { ExtensionContextClass } from "./ExtensionContext"
export const ServiceExtensionContextClass = class ServiceExtensionContext extends ExtensionContextClass {
constructor() {
super();
console.warn("ServiceExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
" may be different from that on a real device.")
this.startAbility = function (...args) {
console.warn("ServiceExtensionContext.startAbility 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();
})
}
};
this.startAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.startAbilityWithAccount 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();
})
}
};
this.startServiceExtensionAbility = function (...args) {
console.warn("ServiceExtensionContext.startServiceExtensionAbility 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();
})
}
};
this.startServiceExtensionAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.startServiceExtensionAbilityWithAccount 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();
})
}
};
this.stopServiceExtensionAbility = function (...args) {
console.warn("ServiceExtensionContext.stopServiceExtensionAbility 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();
})
}
};
this.stopServiceExtensionAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.stopServiceExtensionAbilityWithAccount 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();
})
}
};
this.terminateSelf = function (...args) {
console.warn("ServiceExtensionContext.terminateSelf 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();
})
}
};
this.connectAbility = function (...args) {
console.warn("ServiceExtensionContext.connectAbility interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.connectAbilityWithAccount = function (...args) {
console.warn("ServiceExtensionContext.connectAbilityWithAccount interface mocked in the Previewer." +
" How this interface works on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock
};
this.disconnectAbility = function (...args) {
console.warn("ServiceExtensionContext.disconnectAbility 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();
})
}
};
}
};
@@ -18,5 +18,5 @@ export const CommonEventData = {
bundleName: '[PC preview] unknow bundleName',
code: '[PC preview] unknow code',
data: '[PC preview] unknow data',
parameters: {}
}
parameters: {"key": "unknown any"},
}
@@ -21,5 +21,5 @@ export const CommonEventPublishData = {
subscriberPermissions: [paramMock.paramStringMock],
isOrdered: '[PC preview] unknow isOrdered',
isSticky: '[PC preview] unknow isSticky',
parameters: {}
}
parameters: {"key": "unknown any"},
}
@@ -23,5 +23,5 @@ export const ContinuationExtraParams = {
description: "[PC Preview] unknow description",
filter: "[PC Preview] unknow filter",
continuationMode: ContinuationMode,
authInfo: {}
}
authInfo: {"key":"unknow any"}
}
+3
View File
@@ -28,6 +28,7 @@ import { mockServiceExtensionAbility } from './ohos_application_ServiceExtension
import { mockAbilityStage } from './ohos_application_AbilityStage'
import { mockFormBindingData } from './ohos_application_formBindingData'
import { mockAbilityManager } from './ohos_application_abilityManager'
import { mockParticleAbility } from './ohos_ability_particleAbility'
import { mockAppManager } from './ohos_application_appManager'
import { mockDataShareExtensionAbility } from './ohos_application_DataShareExtensionAbility'
import { mockMissionManager } from "./ohos_application_missionManager"
@@ -276,6 +277,8 @@ export function mockRequireNapiFun() {
return mockSystemParameter();
case "ability.dataUriUtils":
return mockDataUriUtils();
case "ability.particleAbility":
return mockParticleAbility();
case "ability.featureAbility":
return mockFeatureAbility();
case "application.Ability":
@@ -17,6 +17,6 @@ import { NotificationUserInput } from "./notificationUserInput"
export const NotificationActionButton = {
title: '[PC preview] unknow title',
wantAgent: '[PC preview] unknow wantAgent',
extras: {},
extras: {"key": "unknown any"},
userInput: NotificationUserInput,
}
}
@@ -30,7 +30,7 @@ export const NotificationRequest = {
tapDismissed: '[PC preview] unknow tapDismissed',
autoDeletedTime: '[PC preview] unknow autoDeletedTime',
wantAgent: '[PC preview] unknow wantAgent',
extraInfo: {},
extraInfo: {"key": "unknown any"},
color: '[PC preview] unknow color',
colorEnabled: '[PC preview] unknow colorEnabled',
isAlertOnce: '[PC preview] unknow isAlertOnce',
@@ -64,4 +64,4 @@ export const DistributedOptions = {
supportDisplayDevices: [paramMock.paramStringMock],
supportOperateDevices: [paramMock.paramStringMock],
remindType: '[PC preview] unknow remindType',
}
}
@@ -15,6 +15,6 @@
import { paramMock } from "../../utils"
export const NotificationSortingMap = {
sortings: {},
sortings: {"key": "unknown any"},
sortedHashCode: [paramMock.paramStringMock],
};
};
@@ -14,5 +14,5 @@
*/
export const NotificationTemplate = {
name: '[PC preview] unknow name',
data: {},
}
data: {"key": "unknown any"},
}
@@ -0,0 +1,96 @@
/*
* 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"
import { dataAbilityHelper } from "./ability/dataAbilityHelper"
export function mockParticleAbility() {
const particleAbility = {
startAbility: function (...args) {
console.warn("ability.particleAbility.startAbility 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()
})
}
},
terminateSelf: function (...args) {
console.warn("ability.particleAbility.terminateSelf 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()
})
}
},
acquireDataAbilityHelper: function (...args) {
console.warn("ability.particleAbility.acquireDataAbilityHelper interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return dataAbilityHelper;
},
connectAbility: function (...args) {
console.warn("ability.particleAbility.connectAbility interface mocked in the Previewer. How this interface works" +
" on the Previewer may be different from that on a real device.")
return paramMock.paramNumberMock;
},
disconnectAbility: function (...args) {
console.warn("ability.particleAbility.disconnectAbility 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()
})
}
},
startBackgroundRunning: function (...args) {
console.warn("ability.particleAbility.startBackgroundRunning 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()
})
}
},
cancelBackgroundRunning: function (...args) {
console.warn("ability.particleAbility.cancelBackgroundRunning 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()
})
}
},
ErrorCode : {
INVALID_PARAMETER: -1,
}
}
return particleAbility;
}
@@ -19,4 +19,5 @@ export const Configuration = {
direction: Direction,
screenDensity: ScreenDensity,
displayId: '[PC preview] unknow displayId',
hasPointerDevice: '[PC preview] unknow hasPointerDevice',
}
@@ -23,7 +23,7 @@ export const WantClass = class Want {
this.abilityName = "[PC Preview] unknow abilityName";
this.uri = "[PC Preview] unknow uri";
this.type = "[PC Preview] unknow type";
this.flag = "[PC Preview] unknow flag";
this.flags = "[PC Preview] unknow flags";
this.action = "[PC Preview] unknow action";
this.parameters = {};
this.entities = [paramMock.paramStringMock];
View File
@@ -92,6 +92,18 @@ export function mockMissionManager() {
});
}
},
getLowResolutionMissionSnapShot: function (...args) {
console.warn('missionManager.getLowResolutionMissionSnapShot 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, MissionSnapshotMock);
} else {
return new Promise((resolve) => {
resolve(MissionSnapshotMock);
});
}
},
lockMission: function (...args) {
console.warn('missionManager.lockMission interface mocked in the Previewer. How this interface works on the' +
' Previewer may be different from that on a real device.');
@@ -17,5 +17,5 @@ export const TriggerInfo = {
code: '[PC preview] unknow code',
want: new WantClass(),
permission: '[PC preview] unknow permission',
extraInfo: {},
};
extraInfo: {"key": "unknown any"},
};
@@ -20,5 +20,5 @@ export const WantAgentInfo = {
operationType: OperationType,
requestCode: '[PC preview] unknow requestCode',
wantAgentFlags: [WantAgentFlags],
extraInfo: {},
};
extraInfo: {"key": "unknown any"},
};