• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 pickerViewPropsJsTest2111() {  describe('pickerViewPropsJsTest2111', 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/prop2111/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(2000)
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      testPickerViewIdProp
84      * @tc.desc      ACE
85      */
86     it('testPickerViewIdProp', 0, async function (done) {
87         console.info('testPickerViewIdProp START');
88         console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
89
90         let obj = JSON.parse(globalThis.value.idProp);
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('idProp')
96         done();
97     });
98
99 });
100}
101