From af301e4b57d5cb0ae447bb03c8e3e904eca859ba Mon Sep 17 00:00:00 2001 From: du-zhihai Date: Sat, 29 Oct 2022 09:29:15 +0800 Subject: [PATCH] =?UTF-8?q?continuationManager=E6=96=B0=E5=A2=9E=E6=9D=83?= =?UTF-8?q?=E9=99=90xts=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: du-zhihai Change-Id: I958076c19b0acedc75c7b39e186f84855df9f0b5 --- .../continuationmanagertest/src/main/config.json | 9 +++++++-- .../src/main/js/MainAbility/app.js | 14 ++++++++++++++ .../main/js/test/ContinuationManagerJsunit.test.js | 10 +++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ability/dmsfwk/continuationmanagertest/src/main/config.json b/ability/dmsfwk/continuationmanagertest/src/main/config.json index 50a2247f9..8e5de0cae 100644 --- a/ability/dmsfwk/continuationmanagertest/src/main/config.json +++ b/ability/dmsfwk/continuationmanagertest/src/main/config.json @@ -17,7 +17,7 @@ "name": ".entry", "mainAbility": ".MainAbility", "deviceType": [ - "tablet", + "tablet", "default" ], "distro": { @@ -86,10 +86,15 @@ } } ], + "reqPermissions": [ + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ], "testRunner": { "name": "OpenHarmonyTestRunner", "srcPath": "TestRunner" }, "srcPath": "" } -} +} diff --git a/ability/dmsfwk/continuationmanagertest/src/main/js/MainAbility/app.js b/ability/dmsfwk/continuationmanagertest/src/main/js/MainAbility/app.js index 3a41e590e..f9098cabb 100644 --- a/ability/dmsfwk/continuationmanagertest/src/main/js/MainAbility/app.js +++ b/ability/dmsfwk/continuationmanagertest/src/main/js/MainAbility/app.js @@ -12,9 +12,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import featureAbility from '@ohos.ability.featureAbility'; + +async function requestPermission() { + try { + let context = featureAbility.getContext(); + await context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, (data) => { + console.info('TestApplication requestPermission data: ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('TestApplication permission' + JSON.stringify(err)); + } +} + export default { onCreate() { console.info('TestApplication onCreate'); + requestPermission(); }, onDestroy() { console.info('TestApplication onDestroy'); diff --git a/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js b/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js index 6a76b1fbb..c50748002 100644 --- a/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js +++ b/ability/dmsfwk/continuationmanagertest/src/main/js/test/ContinuationManagerJsunit.test.js @@ -1466,7 +1466,7 @@ describe('continuationManagerTest', function() { done(); } catch (e) { console.info("testUpdateContinuationState001 " + e); - expect(null).assertFail(); + expect(e.code == 401).assertTrue(); done(); } }) @@ -1506,7 +1506,7 @@ describe('continuationManagerTest', function() { done(); } catch (e) { console.info("testUpdateContinuationState003 " + e); - expect(null).assertFail(); + expect(e.code == 401).assertTrue(); done(); } }) @@ -1528,7 +1528,7 @@ describe('continuationManagerTest', function() { done(); } catch (e) { console.info("testUpdateContinuationState004 " + e); - expect(null).assertFail(); + expect(e.code == 401).assertTrue(); done(); } }) @@ -1550,7 +1550,7 @@ describe('continuationManagerTest', function() { done(); } catch (e) { console.info("testUpdateContinuationState005 " + e); - expect(null).assertFail(); + expect(e.code == 401).assertTrue(); done(); } }) @@ -1571,7 +1571,7 @@ describe('continuationManagerTest', function() { done(); } catch (e) { console.info("testUpdateContinuationState006 " + e); - expect(null).assertFail(); + expect(e.code == 401).assertTrue(); done(); } }) -- GitLab