From d0d76c990bd25dc0f6e6564378d871f88e93bb90 Mon Sep 17 00:00:00 2001 From: huangke11 Date: Thu, 10 Feb 2022 20:45:35 +0800 Subject: [PATCH] add cust js api test Signed-off-by: huangke11 --- .../src/main/js/default/test/Cust.test.js | 149 ------------------ .../js/default/test/GetCfgDirList.test.js | 47 ++++++ .../main/js/default/test/GetCfgFiles.test.js | 71 +++++++++ .../js/default/test/GetOneCfgFile.test.js | 71 +++++++++ .../src/main/js/default/test/List.test.js | 4 +- 5 files changed, 192 insertions(+), 150 deletions(-) delete mode 100755 global/cust/custjs/src/main/js/default/test/Cust.test.js create mode 100755 global/cust/custjs/src/main/js/default/test/GetCfgDirList.test.js create mode 100755 global/cust/custjs/src/main/js/default/test/GetCfgFiles.test.js create mode 100755 global/cust/custjs/src/main/js/default/test/GetOneCfgFile.test.js diff --git a/global/cust/custjs/src/main/js/default/test/Cust.test.js b/global/cust/custjs/src/main/js/default/test/Cust.test.js deleted file mode 100755 index 26a726ca5..000000000 --- a/global/cust/custjs/src/main/js/default/test/Cust.test.js +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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 'deccjsunit/index' -import cust from '@ohos.cust' - -describe('CustTest', function () { - console.log('CustTest**************************start'); - - /* * - * @tc.number SUB_CUST_JS_0100 - * @tc.name test getOneCfgFile method in callback mode - * @tc.desc get getOneCfgFile in callback mode - */ - it('getOneCfgFile_test_001', 0, async function (done) { - cust.getOneCfgFile('custxml/none.xml', (error, value) => { - expect(value.length == 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_001, none.xml:' + value); - }); - cust.getOneCfgFile('custxml/system.xml', (error, value) => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_001, system.xml:' + value); - }); - cust.getOneCfgFile('custxml/both.xml', (error, value) => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_001, both.xml:' + value); - }); - cust.getOneCfgFile('custxml/user.xml', (error, value) => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_001, user.xml:' + value); - }); - done(); - }) - - /* * - * @tc.number SUB_CUST_JS_0200 - * @tc.name test getOneCfgFile method in promise mode - * @tc.desc get getOneCfgFile in promise mode - */ - it('getOneCfgFile_test_002', 0, async function (done) { - cust.getOneCfgFile('custxml/none.xml').then(value => { - expect(value.length == 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_002, none.xml:' + value); - }); - cust.getOneCfgFile('custxml/system.xml').then(value => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_002, system.xml:' + value); - }); - cust.getOneCfgFile('custxml/both.xml').then(value => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_002, both.xml:' + value); - }); - cust.getOneCfgFile('custxml/user.xml').then(value => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getOneCfgFile_test_002, user.xml:' + value); - }); - done(); - }) - - /* * - * @tc.number SUB_CUST_JS_0300 - * @tc.name test getCfgFiles method in callback mode - * @tc.desc get getCfgFiles in callback mode - */ - it('getCfgFiles_test_003', 0, async function (done) { - cust.getCfgFiles('custxml/none.xml', (error, value) => { - expect(value.length == 0).assertTrue(); - console.log('CustTest getCfgFiles_test_003, none.xml:' + value); - }); - cust.getCfgFiles('custxml/system.xml', (error, value) => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgFiles_test_003, system.xml:' + value); - }); - cust.getCfgFiles('custxml/both.xml', (error, value) => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgFiles_test_003, both.xml:' + value); - }); - cust.getCfgFiles('custxml/user.xml', (error, value) => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgFiles_test_003, user.xml:' + value); - }); - done(); - }) - - /* * - * @tc.number SUB_CUST_JS_0400 - * @tc.name test getCfgFiles method in promise mode - * @tc.desc get getCfgFiles in promise mode - */ - it('getCfgFiles_test_004', 0, async function (done) { - cust.getCfgFiles('custxml/none.xml').then(value => { - expect(value.length == 0).assertTrue(); - console.log('CustTest getCfgFiles_test_004, none.xml:' + value); - }); - cust.getCfgFiles('custxml/system.xml').then(value => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgFiles_test_004, system.xml:' + value); - }); - cust.getCfgFiles('custxml/both.xml').then(value => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgFiles_test_004, both.xml:' + value); - }); - cust.getCfgFiles('custxml/user.xml').then(value => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgFiles_test_004, user.xml:' + value); - }); - done(); - }) - - /* * - * @tc.number SUB_CUST_JS_0500 - * @tc.name test getCfgDirList method in callback mode - * @tc.desc get getCfgDirList in callback mode - */ - it('getCfgDirList_test_005', 0, async function (done) { - cust.getCfgDirList((error, value) => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgDirList_test_005:' + value); - }); - done(); - }) - - /* * - * @tc.number SUB_CUST_JS_060 - * @tc.name test getCfgDirList method in promise mode - * @tc.desc get getCfgDirList in promise mode - */ - it('getCfgDirList_test_006', 0, async function (done) { - cust.getCfgDirList().then(value => { - expect(value.length != 0).assertTrue(); - console.log('CustTest getCfgDirList_test_006:' + value); - }); - done(); - }) - - console.log('CustTest**************************end'); -}) diff --git a/global/cust/custjs/src/main/js/default/test/GetCfgDirList.test.js b/global/cust/custjs/src/main/js/default/test/GetCfgDirList.test.js new file mode 100755 index 000000000..b2d1daa58 --- /dev/null +++ b/global/cust/custjs/src/main/js/default/test/GetCfgDirList.test.js @@ -0,0 +1,47 @@ +/* + * 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 'deccjsunit/index' + +import cust from '@ohos.cust' + +describe('GetCfgDirListTest', function () { + + /* * + * @tc.number SUB_CUST_JS_005 + * @tc.name test getCfgDirList method in callback mode + * @tc.desc get getCfgDirList in callback mode + */ + it('getCfgDirList_test_005', 0, async function (done) { + cust.getCfgDirList((error, value) => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgDirList_test_005:' + value); + }); + done(); + }) + + /* * + * @tc.number SUB_CUST_JS_006 + * @tc.name test getCfgDirList method in promise mode + * @tc.desc get getCfgDirList in promise mode + */ + it('getCfgDirList_test_006', 0, async function (done) { + cust.getCfgDirList().then(value => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgDirList_test_006:' + value); + }); + done(); + }) +}) diff --git a/global/cust/custjs/src/main/js/default/test/GetCfgFiles.test.js b/global/cust/custjs/src/main/js/default/test/GetCfgFiles.test.js new file mode 100755 index 000000000..955e841e7 --- /dev/null +++ b/global/cust/custjs/src/main/js/default/test/GetCfgFiles.test.js @@ -0,0 +1,71 @@ +/* + * 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 'deccjsunit/index' + +import cust from '@ohos.cust' + +describe('GetCfgFilesTest', function () { + + /* * + * @tc.number SUB_CUST_JS_003 + * @tc.name test getCfgFiles method in callback mode + * @tc.desc get getCfgFiles in callback mode + */ + it('getCfgFiles_test_003', 0, async function (done) { + cust.getCfgFiles('custxml/none.xml', (error, value) => { + expect(value.length == 0).assertTrue(); + console.log('CustTest getCfgFiles_test_003, none.xml:' + value); + }); + cust.getCfgFiles('custxml/system.xml', (error, value) => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgFiles_test_003, system.xml:' + value); + }); + cust.getCfgFiles('custxml/both.xml', (error, value) => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgFiles_test_003, both.xml:' + value); + }); + cust.getCfgFiles('custxml/user.xml', (error, value) => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgFiles_test_003, user.xml:' + value); + }); + done(); + }) + + /* * + * @tc.number SUB_CUST_JS_004 + * @tc.name test getCfgFiles method in promise mode + * @tc.desc get getCfgFiles in promise mode + */ + it('getCfgFiles_test_004', 0, async function (done) { + cust.getCfgFiles('custxml/none.xml').then(value => { + expect(value.length == 0).assertTrue(); + console.log('CustTest getCfgFiles_test_004, none.xml:' + value); + }); + cust.getCfgFiles('custxml/system.xml').then(value => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgFiles_test_004, system.xml:' + value); + }); + cust.getCfgFiles('custxml/both.xml').then(value => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgFiles_test_004, both.xml:' + value); + }); + cust.getCfgFiles('custxml/user.xml').then(value => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getCfgFiles_test_004, user.xml:' + value); + }); + done(); + }) +}) diff --git a/global/cust/custjs/src/main/js/default/test/GetOneCfgFile.test.js b/global/cust/custjs/src/main/js/default/test/GetOneCfgFile.test.js new file mode 100755 index 000000000..c560e9675 --- /dev/null +++ b/global/cust/custjs/src/main/js/default/test/GetOneCfgFile.test.js @@ -0,0 +1,71 @@ +/* + * 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 'deccjsunit/index' + +import cust from '@ohos.cust' + +describe('GetOneCfgFileTest', function () { + + /* * + * @tc.number SUB_CUST_JS_001 + * @tc.name test getOneCfgFile method in callback mode + * @tc.desc get getOneCfgFile in callback mode + */ + it('getOneCfgFile_test_001', 0, async function (done) { + cust.getOneCfgFile('custxml/none.xml', (error, value) => { + expect(value.length == 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_001, none.xml:' + value); + }); + cust.getOneCfgFile('custxml/system.xml', (error, value) => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_001, system.xml:' + value); + }); + cust.getOneCfgFile('custxml/both.xml', (error, value) => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_001, both.xml:' + value); + }); + cust.getOneCfgFile('custxml/user.xml', (error, value) => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_001, user.xml:' + value); + }); + done(); + }) + + /* * + * @tc.number SUB_CUST_JS_002 + * @tc.name test getOneCfgFile method in promise mode + * @tc.desc get getOneCfgFile in promise mode + */ + it('getOneCfgFile_test_002', 0, async function (done) { + cust.getOneCfgFile('custxml/none.xml').then(value => { + expect(value.length == 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_002, none.xml:' + value); + }); + cust.getOneCfgFile('custxml/system.xml').then(value => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_002, system.xml:' + value); + }); + cust.getOneCfgFile('custxml/both.xml').then(value => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_002, both.xml:' + value); + }); + cust.getOneCfgFile('custxml/user.xml').then(value => { + expect(value.length != 0).assertTrue(); + console.log('CustTest getOneCfgFile_test_002, user.xml:' + value); + }); + done(); + }) +}) diff --git a/global/cust/custjs/src/main/js/default/test/List.test.js b/global/cust/custjs/src/main/js/default/test/List.test.js index d7db3c7fd..1e1e1aac5 100755 --- a/global/cust/custjs/src/main/js/default/test/List.test.js +++ b/global/cust/custjs/src/main/js/default/test/List.test.js @@ -13,4 +13,6 @@ * limitations under the License. */ -require('./Cust.test.js') \ No newline at end of file +require('./GetOneCfgFile.test.js') +require('./GetCfgFiles.test.js') +require('./GetCfgDirList.test.js') \ No newline at end of file -- GitLab