1/* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' 17import ability_featureAbility from '@ohos.ability.featureAbility' 18import dataShare from '@ohos.data.dataShare' 19var context = ability_featureAbility.getContext() 20 21const TAG = "[DATA_SHARE_JSKITS_TEST]" 22let uri = ("datashare://com.acts.datasharetest/entry/DB00/TBL00?Proxy=true"); 23 24describe('dataShareTest', function () { 25 beforeAll(async function () { 26 console.info(TAG + 'beforeAll') 27 }) 28 29 beforeEach(function () { 30 console.info(TAG + 'beforeEach') 31 }) 32 33 afterEach(async function () { 34 console.info(TAG + 'afterEach') 35 }) 36 37 afterAll(async function () { 38 console.info(TAG + 'afterAll') 39 }) 40 41 console.log(TAG + "*************Unit Test Begin*************"); 42 43 /** 44 * @tc.number testSilentAccess0001 45 * @tc.name Normal test case of enableSilentProxy, test enable silent proxy; 46 * @tc.desc Execute enableSilentProxy 47 * @tc.size MediumTest 48 * @tc.type Function 49 * @tc.level Level 2 50 */ 51 it('testSilentAccess0001', 0, async function () { 52 console.log(TAG + "************* testSilentAccess0001 start *************"); 53 try { 54 await dataShare.enableSilentProxy(context, uri); 55 console.log(TAG + "enableSilentProxy done"); 56 } catch (e) { 57 expect().assertFail(); 58 } 59 console.log(TAG + "************* testSilentAccess0001 end *************"); 60 }) 61 62 /** 63 * @tc.number testSilentAccess0002 64 * @tc.name Normal test case of enableSilentProxy, test enable silent proxy, uri is null; 65 * @tc.desc Execute enableSilentProxy 66 * @tc.size MediumTest 67 * @tc.type Function 68 * @tc.level Level 2 69 */ 70 it('testSilentAccess0002', 0, async function () { 71 console.log(TAG + "************* testSilentAccess0002 start *************"); 72 try { 73 await dataShare.enableSilentProxy(context, ""); 74 console.log(TAG + "enableSilentProxy done"); 75 } catch (e) { 76 expect().assertFail(); 77 } 78 console.log(TAG + "************* testSilentAccess0002 end *************"); 79 }) 80 81 /** 82 * @tc.number testSilentAccess0003 83 * @tc.name Normal test case of disableSilentProxy, test disable silent proxy; 84 * @tc.desc Execute disableSilentProxy 85 * @tc.size MediumTest 86 * @tc.type Function 87 * @tc.level Level 2 88 */ 89 it('testSilentAccess0003', 0, async function () { 90 console.log(TAG + "************* testSilentAccess0003 start *************"); 91 try { 92 await dataShare.disableSilentProxy(context, uri); 93 console.log(TAG + "disableSilentProxy done"); 94 } catch (e) { 95 expect().assertFail(); 96 } 97 console.log(TAG + "************* testSilentAccess0003 end *************"); 98 }) 99 100 /** 101 * @tc.number testSilentAccess0004 102 * @tc.name Normal test case of disableSilentProxy, test disable silent proxy, uri is null; 103 * @tc.desc Execute disableSilentProxy 104 * @tc.size MediumTest 105 * @tc.type Function 106 * @tc.level Level 2 107 */ 108 it('testSilentAccess0004', 0, async function () { 109 console.log(TAG + "************* testSilentAccess0004 start *************"); 110 try { 111 await dataShare.disableSilentProxy(context, ""); 112 console.log(TAG + "disableSilentProxy done"); 113 } catch (e) { 114 expect().assertFail(); 115 } 116 console.log(TAG + "************* testSilentAccess0004 end *************"); 117 }) 118 119 console.log(TAG + "*************Unit Test End*************"); 120})