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 16 import router from '@system.router'; 17 import {describe, beforeAll,afterAll, it, expect} from '@ohos/hypium'; 18 19 20 export default function pickerViewPropsJsTest32() { describe('pickerViewPropsJsTest32', function () { 21 22 async function sleep(time) { 23 return new Promise((resolve, reject) => { 24 setTimeout(() => { 25 resolve() 26 }, time) 27 }).then(() => { 28 console.info(`sleep ${time} over...`) 29 }) 30 } 31 32 async function backToIndex() { 33 let backToIndexPromise = new Promise((resolve, reject) => { 34 setTimeout(() => { 35 router.back({ 36 uri: 'pages/index/index' 37 }); 38 resolve(); 39 }, 500); 40 }) 41 let clearPromise = new Promise((resolve, reject) => { 42 setTimeout(() => { 43 router.clear(); 44 resolve(); 45 }, 500); 46 }) 47 await backToIndexPromise.then(() => { 48 return clearPromise; 49 }) 50 } 51 52 /** 53 * run before testcase 54 */ 55 beforeAll(async function (done) { 56 console.info('[pickerViewPropsJsTest] before each called') 57 58 let result; 59 let options = { 60 uri: 'pages/pickerView/prop32/index' 61 } 62 try { 63 result = router.push(options) 64 console.info("push pickerViewProps page success " + JSON.stringify(result)); 65 } catch (err) { 66 console.error("push pickerViewProps page error " + JSON.stringify(result)); 67 } 68 await sleep(4000) 69 done() 70 }) 71 72 /** 73 * run after testcase 74 */ 75 afterAll(async function () { 76 console.info('[pickerViewPropsJsTest] after each called') 77 await backToIndex() 78 await sleep(1000) 79 }) 80 81 /** 82 * @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100 83 * @tc.name testPickerViewDataProp 84 * @tc.desc ACE 85 */ 86 it('testPickerViewDataProp', 0, async function (done) { 87 console.info('testPickerViewDataProp START'); 88 console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value)); 89 90 let obj = JSON.parse(globalThis.value.dataProp); 91 console.info("[pickerViewProps] get inspector value is: " + JSON.stringify(obj)); 92 console.info("[pickerViewProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs)); 93 94 expect(obj.$type).assertEqual('picker-view') 95 expect(obj.$attrs.id).assertEqual('dataProp') 96 expect(obj.$attrs.datapickerView).assertEqual(undefined); 97 console.info("[pickerViewProps] get datapickerView value is: " + JSON.stringify(obj.$attrs.datapickerView)); 98 done(); 99 }); 100 101 /** 102 * @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100 103 * @tc.name testPickerViewDataPropNone 104 * @tc.desc ACE 105 */ 106 it('testPickerViewDataPropNone', 0, async function (done) { 107 console.info('testPickerViewDataPropNone START'); 108 console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value)); 109 110 let obj = JSON.parse(globalThis.value.dataPropNone); 111 console.info("[pickerViewProps] get inspector value is: " + JSON.stringify(obj)); 112 console.info("[pickerViewProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs)); 113 114 expect(obj.$type).assertEqual('picker-view') 115 expect(obj.$attrs.id).assertEqual('dataPropNone') 116 expect(obj.$attrs.datapickerView).assertEqual(undefined) 117 console.info("[pickerViewProps] get datapickerView value is: " + JSON.stringify(obj.$attrs.datapickerView)); 118 done(); 119 }); 120 121 /** 122 * @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100 123 * @tc.name testPickerViewClickEffectPropSmall 124 * @tc.desc ACE 125 */ 126 it('testPickerViewClickEffectPropSmall', 0, async function (done) { 127 console.info('testPickerViewClickEffectPropSmall START'); 128 console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value)); 129 130 let obj = JSON.parse(globalThis.value.clickEffectPropSmall); 131 console.info("[pickerViewProps] get inspector value is: " + JSON.stringify(obj)); 132 console.info("[pickerViewProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs)); 133 134 expect(obj.$type).assertEqual('picker-view') 135 expect(obj.$attrs.id).assertEqual('clickEffectPropSmall') 136 expect(obj.$attrs.clickEffect).assertEqual('spring-small') 137 done(); 138 }); 139 140 /** 141 * @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100 142 * @tc.name testPickerViewClickEffectPropMedium 143 * @tc.desc ACE 144 */ 145 it('testPickerViewClickEffectPropMedium', 0, async function (done) { 146 console.info('testPickerViewClickEffectPropMedium START'); 147 console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value)); 148 149 let obj = JSON.parse(globalThis.value.clickEffectPropMedium); 150 console.info("[pickerViewProps] get inspector value is: " + JSON.stringify(obj)); 151 console.info("[pickerViewProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs)); 152 153 expect(obj.$type).assertEqual('picker-view') 154 expect(obj.$attrs.id).assertEqual('clickEffectPropMedium') 155 expect(obj.$attrs.clickEffect).assertEqual('spring-medium') 156 done(); 157 }); 158 159 /** 160 * @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100 161 * @tc.name testPickerViewClickEffectPropLarge 162 * @tc.desc ACE 163 */ 164 it('testPickerViewClickEffectPropLarge', 0, async function (done) { 165 console.info('testPickerViewClickEffectPropLarge START'); 166 console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value)); 167 168 let obj = JSON.parse(globalThis.value.clickEffectPropLarge); 169 console.info("[pickerViewProps] get inspector value is: " + JSON.stringify(obj)); 170 console.info("[pickerViewProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs)); 171 172 expect(obj.$type).assertEqual('picker-view') 173 expect(obj.$attrs.id).assertEqual('clickEffectPropLarge') 174 expect(obj.$attrs.clickEffect).assertEqual('spring-large') 175 done(); 176 }); 177 178 /** 179 * @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0100 180 * @tc.name testPickerViewClickEffectPropNone 181 * @tc.desc ACE 182 */ 183 it('testPickerViewClickEffectPropNone', 0, async function (done) { 184 console.info('testPickerViewClickEffectPropNone START'); 185 console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value)); 186 187 let obj = JSON.parse(globalThis.value.clickEffectPropNone); 188 console.info("[pickerViewProps] get inspector value is: " + JSON.stringify(obj)); 189 console.info("[pickerViewProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs)); 190 191 expect(obj.$type).assertEqual('picker-view') 192 expect(obj.$attrs.id).assertEqual('clickEffectPropNone') 193 expect(obj.$attrs.clickEffect).assertEqual(undefined) 194 console.info("[pickerViewProps] get clickEffect value is: " + JSON.stringify(obj.$attrs.clickEffect)); 195 done(); 196 }); 197 198 }); 199} 200