未验证 提交 4a77460d 编写于 作者: O openharmony_ci 提交者: Gitee

!7105 【杂散】【时间模块】新增dateTimeTest测试用例

Merge pull request !7105 from 张育帅/master
...@@ -14,5 +14,8 @@ ...@@ -14,5 +14,8 @@
import("//build/ohos_var.gni") import("//build/ohos_var.gni")
group("time") { group("time") {
testonly = true testonly = true
deps = [ "timeTest:ActsTimeAPITest" ] deps = [
"dateTimeTest:ActsDateTimeAPITest",
"timeTest:ActsTimeAPITest",
]
} }
{
"app": {
"bundleName": "com.acts.dateTime.test",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":9,
"targetAPIVersion":9
}
}
{
"string": [
{
"name": "app_name",
"value": "ActsDateTimeAPITest"
}
]
}
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsDateTimeAPITest") {
deps = [
":time_assets",
":time_resources",
]
ets2abc = true
js_build_mode = "debug"
subsystem_name = "time"
part_name = "time_service"
hap_name = "ActsDateTimeAPITest"
hap_profile = "entry/src/main/module.json"
certificate_profile = "signature/ActsDateTimeAPITest.p7b"
}
ohos_app_scope("time_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("time_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("time_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":time_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.dateTime.test",
"module-name": "entry_test",
"shell-timeout": "180000",
"testcase-timeout": 600000
},
"kits": [{
"test-file-name": [
"ActsDateTimeAPITest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}]
}
import hilog from '@ohos.hilog';
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'AbilityStage onCreate');
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import Window from '@ohos.window';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import Ability from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
var abilityDelegator: any;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var abilityDelegatorArguments: any;
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
if (abilityDelegator != undefined && abilityDelegatorArguments != undefined) {
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
} else {
hilog.info(0x0000, 'testTag', '%{public}s', 'abilityDelegator or abilityDelegatorArguments is undefined!!!');
}
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
}
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
var abilityDelegator = undefined;
var abilityDelegatorArguments = undefined;
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`;
}
}
return targetParams.trim();
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
var cmd = 'aa start -d 0 -a MainAbility ' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters['-D'];
if (debug == 'true')
{
cmd += ' -D';
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
});
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
// @ts-nocheck
/**
* 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 hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'TIME ETS TEST'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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 systemDateTimeJsunit from './systemDateTimeJsunit.test';
export default function testsuite() {
systemDateTimeJsunit();
}
\ No newline at end of file
/*
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import systemDateTime from "@ohos.systemDateTime";
export default function systemDateTimeJsunit() {
describe('systemDateTimeTest', function () {
console.info('====>---------------systemDateTimeTest start-----------------------');
/**
* @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0001
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getCurrentTime_JS_API_0001", 0, async function (done) {
console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0001 start----------------");
systemDateTime.getCurrentTime(true, (error, data) => {
try {
if (error) {
console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0001 fail: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>systemDateTime.getCurrentTime success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
} catch (error) {
console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0001 catch error: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0001 end-----------------");
});
});
/**
* @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0002
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getCurrentTime_JS_API_0002", 0, async function (done) {
console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0002 start----------------");
await systemDateTime.getCurrentTime(false).then((data) => {
console.info('====>SUB_systemDateTime_getCurrentTime_JS_API_0002 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
}).catch(err => {
console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0002 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0002 end------------");
});
/**
* @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0003
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getCurrentTime_JS_API_0003", 0, async function (done) {
console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0003 start----------------");
await systemDateTime.getCurrentTime().then((data) => {
console.info('====>SUB_systemDateTime_getCurrentTime_JS_API_0003 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
}).catch(err => {
console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0003 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info("====>-----SUB_systemDateTime_getCurrentTime_JS_API_0003 end------------");
});
/**
* @tc.number SUB_systemDateTime_getCurrentTime_JS_API_0004
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds that have elapsed since the Unix epoch.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getCurrentTime_JS_API_0004", 0, async function (done) {
console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0004 start----------------");
systemDateTime.getCurrentTime((error, data) => {
try {
if (error) {
console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0004 fail: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>systemDateTime.getCurrentTime success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
} catch (error) {
console.error('====>SUB_systemDateTime_getCurrentTime_JS_API_0004 catch error: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemDateTime_getCurrentTime_JS_API_0004 end-----------------");
});
});
/**
* @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0001
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealActiveTime_JS_API_0001", 0, async function (done) {
console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0001 start----------------");
systemDateTime.getRealActiveTime(true, (error, data) => {
try {
if (error) {
console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0001 fail: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>SUB_systemDateTime_getRealActiveTime_JS_API_0001 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
} catch (error) {
console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0001 catch err: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0001 end-----------------");
});
});
/**
* @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0002
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealActiveTime_JS_API_0002", 0, async function (done) {
console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0002 start----------------");
await systemDateTime.getRealActiveTime(false).then((data) => {
console.log('SUB_systemDateTime_getRealActiveTime_JS_API_0002 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
}).catch(err => {
console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0002 err: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0002 end------------");
});
/**
* @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0003
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealActiveTime_JS_API_0003", 0, async function (done) {
console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0003 start----------------");
await systemDateTime.getRealActiveTime().then((data) => {
console.log('SUB_systemDateTime_getRealActiveTime_JS_API_0003 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
}).catch(err => {
console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0003 err: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info("====>-----SUB_systemDateTime_getRealActiveTime_JS_API_0003 end------------");
});
/**
* @tc.number SUB_systemDateTime_getRealActiveTime_JS_API_0004
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealActiveTime_JS_API_0004", 0, async function (done) {
console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0004 start----------------");
systemDateTime.getRealActiveTime((error, data) => {
try {
if (error) {
console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0004 fail: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>SUB_systemDateTime_getRealActiveTime_JS_API_0004 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
} catch (error) {
console.error('====>SUB_systemDateTime_getRealActiveTime_JS_API_0004 catch err: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemDateTime_getRealActiveTime_JS_API_0004 end-----------------");
});
});
/**
* @tc.number SUB_systemDateTime_getRealTime_JS_API_0001
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealTime_JS_API_0001", 0, async function (done) {
console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0001 start----------------");
systemDateTime.getRealTime(true, (error, data) => {
try {
if (error) {
console.error('SUB_systemDateTime_getRealTime_JS_API_0001 fail: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>SUB_systemDateTime_getRealTime_JS_API_0001 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
} catch (error) {
console.error('====>SUB_systemDateTime_getRealTime_JS_API_0001 catch err: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0001 end-----------------");
});
});
/**
* @tc.number SUB_systemDateTime_getRealTime_JS_API_0002
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealTime_JS_API_0002", 0, async function (done) {
console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0002 start----------------");
await systemDateTime.getRealTime(false).then((data) => {
console.info('====>SUB_systemDateTime_getRealTime_JS_API_0002 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
}).catch(error => {
console.error('====>SUB_systemDateTime_getRealTime_JS_API_0002 err: ' + JSON.stringify(error));
expect().assertFail();
done();
});
console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0002 end------------");
});
/**
* @tc.number SUB_systemDateTime_getRealTime_JS_API_0003
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, not including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealTime_JS_API_0003", 0, async function (done) {
console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0003 start----------------");
await systemDateTime.getRealTime().then((data) => {
console.info('====>SUB_systemDateTime_getRealTime_JS_API_0003 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
}).catch(error => {
console.error('====>SUB_systemDateTime_getRealTime_JS_API_0003 err: ' + JSON.stringify(error));
expect().assertFail();
done();
});
console.info("====>-----SUB_systemDateTime_getRealTime_JS_API_0003 end------------");
});
/**
* @tc.number SUB_systemDateTime_getRealTime_JS_API_0004
* @tc.name Test systemTimeDate.getCurrentTime
* @tc.desc Obtains the number of milliseconds elapsed since the system was booted, including deep sleep time.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 1
*/
it("SUB_systemDateTime_getRealTime_JS_API_0004", 0, async function (done) {
console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0004 start----------------");
systemDateTime.getRealTime((error, data) => {
try {
if (error) {
console.error('SUB_systemDateTime_getRealTime_JS_API_0004 fail: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info('====>SUB_systemDateTime_getRealTime_JS_API_0004 success data : ' + JSON.stringify(data));
expect(data != null).assertEqual(true);
done();
} catch (error) {
console.error('====>SUB_systemDateTime_getRealTime_JS_API_0004 catch err: ' + JSON.stringify(error));
done();
}
console.info("====>----------SUB_systemDateTime_getRealTime_JS_API_0004 end-----------------");
});
});
/**
* @tc.number SUB_systemDateTime_getDate_JS_API_0100
* @tc.name Test systemTimeDate.setDate true value
* @tc.desc Test systemTimeDate_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemDateTime_getDate_JS_API_0100', 0, async function (done) {
console.info("====>SUB_systemDateTime_getDate_JS_API_0100 start");
await systemDateTime.getDate().then((data) => {
console.info("====>SUB_systemDateTime_getDate_JS_API_0100 getDate: " + data);
expect(data != null).assertTrue();
done();
}).catch(error => {
console.info("====>SUB_systemDateTime_getDate_JS_API_0100 getDate fail: " + error);
expect().assertFail();
done();
})
console.info("====>SUB_systemDateTime_getDate_JS_API_0100 end");
});
/**
* @tc.number SUB_systemDateTime_getDate_JS_API_0200
* @tc.name Test systemTimeDate.setDate true value
* @tc.desc Test systemTimeDate_setDate API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemDateTime_getDate_JS_API_0200', 0, async function (done) {
console.info("====>SUB_systemDateTime_getDate_JS_API_0200 start");
systemDateTime.getDate((err, data) => {
try{
if(err){
console.info("====>SUB_systemDateTime_getDate_JS_API_0200 getTimezone fail: " + err);
expect().assertFail();
done();
}
console.info("====>SUB_systemDateTime_getDate_JS_API_0200 getTimezone success: " + data);
expect(data != null).assertTrue();
done();
}catch(error){
console.info("====>SUB_systemDateTime_getDate_JS_API_0200 catch error " + error);
done();
}
})
console.info("====>SUB_systemDateTime_getDate_JS_API_0200 end");
});
/**
* @tc.number SUB_systemDateTime_getTimezone_JS_API_0100
* @tc.name Test systemTime.SUB_systemDateTime_getTimezone_JS_API_0100 true value
* @tc.desc Test systemTimeDate_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemDateTime_getTimezone_JS_API_0100', 0, async function (done) {
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 start");
await systemDateTime.getTimezone().then( data => {
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 getTimezone success: " + data);
expect(data != null).assertTrue();
done();
}).catch(error => {
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 getTimezone fail: " + error);
expect().assertFail();
done();
});
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0100 end");
});
/**
* @tc.number SUB_systemDateTime_getTimezone_JS_API_0200
* @tc.name Test systemTimeDate.setTimezone true value
* @tc.desc Test systemTimeDate_setTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_systemDateTime_getTimezone_JS_API_0200', 0, async function (done) {
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 start");
systemDateTime.getTimezone((err, data) => {
try{
if(err){
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 getTimezone fail: " + err);
expect().assertFail();
done();
}
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 getTimezone success: " + data);
expect(data != null).assertTrue();
done();
}catch(error){
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 catch error " + error);
done();
}
})
console.info("====>SUB_systemDateTime_getTimezone_JS_API_0200 end");
});
});
};
{
"module": {
"name": "entry_test",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "ActsDateTimeAPITest"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册