• 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 pickerViewPropsJsTest4121() {  describe('pickerViewPropsJsTest4121', 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/prop4121/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(35000)
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      /**
83       * @tc.number    SUB_ACE_BASIC_COMPONENT_JS_API_0100
84       * @tc.name      testPickerViewPickerViewTime
85       * @tc.desc      ACE
86       */
87      it('testPickerViewPickerViewTime', 0, async function (done) {
88          console.info('testPickerViewPickerViewTime START');
89          console.info("[pickerViewProps] get globalThis.value is: " + JSON.stringify(globalThis.value));
90 
91          let obj = JSON.parse(globalThis.value.pickerViewTime);
92          console.info("[pickerViewProps] get inspector value is: " + JSON.stringify(obj));
93          console.info("[pickerViewProps] get inspector attrs value is: " + JSON.stringify(obj.$attrs));
94 
95          expect(obj.$type).assertEqual('picker-view')
96          expect(obj.$attrs.id).assertEqual('pickerViewTime')
97          expect(obj.$attrs.type).assertEqual('time')
98          console.info("[pickerViewProps] get type value is: " + JSON.stringify(obj.$attrs.type));
99          done();
100      });
101 
102  });
103 }
104