From b25946a42e831dfea41a7cf0d2cfc817685cde22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=B5=B7?= Date: Thu, 29 Dec 2022 14:47:29 +0000 Subject: [PATCH] [xts-acts][access_token][master]requestPermissionsFromUser new use case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 金海 --- .../src/main/js/test/AccessToken.test.js | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js b/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js index 25dd9f2e0..4fcd8e979 100644 --- a/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js +++ b/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js @@ -312,5 +312,96 @@ describe('AccessTokenTest', function () { done(); }) + + /** + * @tc.number Test_requestPermissionsFromUser_0100 + * @tc.name Test_requestPermissionsFromUser_001. + * @tc.desc RequestPermissionsFromUser normal scenario(Promise). + */ + it('Test_requestPermissionsFromUser_001', 0, async function(done){ + console.info("Test_requestPermissionsFromUser_001 start"); + var atManager = abilityAccessCtrl.createAtManager(); + try { + atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"]).then((data) => { + console.info("data:" + JSON.stringify(data)); + console.info("data permissions:" + data.permissions); + console.info("data authResults:" + data.authResults); + expect(data.authResults).assertEqual(0); + }).catch((err) => { + console.info("data:" + JSON.stringify(err)); + }) + } catch(err) { + console.log(`Test_requestPermissionsFromUser_001 catch err->${JSON.stringify(err)}`); + } + done(); + }) + + + /** + * @tc.number Test_requestPermissionsFromUser_0200 + * @tc.name Test_requestPermissionsFromUser_002. + * @tc.desc Exception scenario use case(Promise). + */ + it('Test_requestPermissionsFromUser_002', 0, async function(done){ + console.info("Test_requestPermissionsFromUser_002 start"); + var atManager = abilityAccessCtrl.createAtManager(); + console.info("Test_requestPermissionsFromUser_002 start"); + try { + var result = atManager.requestPermissionsFromUser(this.context, ["abc"]).then((data) => { + console.info("data:" + JSON.stringify(data)); + console.info("data permissions:" + data.permissions); + console.info("data authResults:" + data.authResults); + }).catch((err) => { + console.info("data:" + JSON.stringify(err)); + }) + } catch(err) { + console.log("Test_requestPermissionsFromUser_002 catch err" + err.code + "message" + err.message); + expect(result).assertEqual(undefined); + } + done(); + }) + + /** + * @tc.number Test_requestPermissionsFromUser_0300 + * @tc.name Test_requestPermissionsFromUser_003. + * @tc.desc RequestPermissionsFromUser normal scenario(callback). + */ + it('Test_requestPermissionsFromUser_003', 0, async function(done){ + console.info("Test_requestPermissionsFromUser_003 start"); + var atManager = abilityAccessCtrl.createAtManager(); + try { + atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"], (err, data)=>{ + console.info("data:" + JSON.stringify(data)); + console.info("data permissions:" + data.permissions); + console.info("data authResults:" + data.authResults); + expect(data.authResults).assertEqual(0); + }); + } catch(err) { + console.log(`Test_requestPermissionsFromUser_003 catch err->${JSON.stringify(err)}`); + } + done(); + }) + + /** + * @tc.number Test_requestPermissionsFromUser_0400 + * @tc.name Test_requestPermissionsFromUser_004. + * @tc.desc Exception scenario use case(callback). + */ + it('Test_requestPermissionsFromUser_004', 0, async function(done){ + console.info("Test_requestPermissionsFromUser_004 start "); + var atManager = abilityAccessCtrl.createAtManager(); + try { + var result = atManager.requestPermissionsFromUser(this.context, ["a"], (err, data)=>{ + console.info("data:" + JSON.stringify(data)); + console.info("data permissions:" + data.permissions); + console.info("data authResults:" + data.authResults); + }); + } catch(err) { + console.log(`Test_requestPermissionsFromUser_004 catch err->${JSON.stringify(err)}`); + expect(result).assertEqual(undefined); + } + done(); + }) + }) } -- GitLab