diff --git a/miscservices/TimeTest_js/src/main/config.json b/miscservices/TimeTest_js/src/main/config.json index 22990b5228e19e44d81c318956038a284513e6e2..e8b1e6715ef5b88a81713724ff8225d32199447d 100755 --- a/miscservices/TimeTest_js/src/main/config.json +++ b/miscservices/TimeTest_js/src/main/config.json @@ -23,6 +23,16 @@ "moduleName": "entry", "moduleType": "entry" }, + "reqPermissions": [ + { + "name": "ohos.permission.SET_TIME", + "reason": "use.ohos.permission.SET_TIME" + }, + { + "name": "ohos.permission.SET_TIME_ZONE", + "reason": "use.ohos.permission.SET_TIME_ZONE" + } + ], "abilities": [ { "visible": true, diff --git a/miscservices/TimeTest_js/src/main/js/default/test/List.test.js b/miscservices/TimeTest_js/src/main/js/default/test/List.test.js index 73a1578832846d4352ea23240d3671e097ff9d76..62932bde1e4ba649d86c491ea3c932641f4b6382 100755 --- a/miscservices/TimeTest_js/src/main/js/default/test/List.test.js +++ b/miscservices/TimeTest_js/src/main/js/default/test/List.test.js @@ -13,4 +13,5 @@ * limitations under the License. */ -require('./SystemTimeJsunit.test.js') \ No newline at end of file +require('./SystemTimeJsunit.test.js') +require('./SystemTimeJsunit.Pertest.js') \ No newline at end of file diff --git a/miscservices/TimeTest_js/src/main/js/default/test/SystemTimeJsunit.Pertest.js b/miscservices/TimeTest_js/src/main/js/default/test/SystemTimeJsunit.Pertest.js new file mode 100644 index 0000000000000000000000000000000000000000..c935195d6b95063f62ef51faacd48feb064a9ce4 --- /dev/null +++ b/miscservices/TimeTest_js/src/main/js/default/test/SystemTimeJsunit.Pertest.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 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. + */ + +// @ts-nocheck +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import systemTime from '@ohos.systemtime' + +describe('TimeTest', function() { + console.log('start################################start'); + + /** + * @tc.number SUB_systemTime_setTime_JS_API_0100 + * @tc.name Test systemTime.setTime + * @tc.desc Test systemTime_setTime API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setTime_test1', 0, async function (done) { + console.log("SUB_systemTime_setTime_JS_API_0100 start"); + systemTime.setTime(152600, (err, data) => { // callback形式调用异步接口 + if (err) { + console.error('SetTime failed because ' + JSON.stringify(err)); + expect().assertFail(); + done(); + return; + } + console.info('SetTime success data : ' + JSON.stringify(data)); + }); + console.log('SUB_systemTime_setTime_JS_API_0100 end'); + }) + + /** + * @tc.number SUB_systemTime_setTimezone_JS_API_0100 + * @tc.name Test systemTime.setTimezone timezone = 'Anadyr, Russia' + * @tc.desc Test systemTime_setTimezone API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('systemTime_setTimezone_test1', 0, async function (done) { + console.log("SUB_systemTime_setTimezone_JS_API_0100 start"); + systemTime.setTimezone('Anadyr, Russia', (err, data) => { // callback形式调用异步接口 + if (err) { + console.error('setTimezone failed because ' + JSON.stringify(err)); + expect().assertFail(); + done(); + return; + } + console.info('setTimezone success data : ' + JSON.stringify(data)); + }); + console.log('SUB_systemTime_setTimezone_JS_API_0100 end'); + }) +})