• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 */
15import { describe, it, expect } from '@ohos/hypium';
16import { Scan } from '../../../main/ets/scan/scan'
17import { ScanLog } from '../../../main/ets/scan/log'
18import { ScannerDevice } from '../../../main/ets/scan/scan'
19import { ScanOptionValue } from '../../../main/ets/scan/scan'
20export function scanTest() {
21  describe('ScanAbilityTest', () => {
22    it('ScanTest_000', 0, ()=>{
23      Scan.initScan().then((data:number)=>{
24        ScanLog.info('init scan successful')
25      }).catch(() => {
26        ScanLog.warn('init scan error')
27      })
28    });
29    it('ScanTest_001', 0, ()=>{
30      Scan.exitScan().then(()=>{
31        ScanLog.info('exitScan scan successful')
32      }).catch(() => {
33        ScanLog.warn('exitScan scan error')
34      })
35    });
36    it('ScanTest_002', 0, ()=>{
37      let scannerId : string = "";
38      Scan.openScanner(scannerId).then(()=>{
39        ScanLog.info('openScanner scan successful')
40      }).catch(() => {
41        ScanLog.warn('openScanner scan error')
42      })
43    });
44    it('ScanTest_003', 0, ()=>{
45      let scannerId : string = "";
46      Scan.closeScanner(scannerId).then(()=>{
47        ScanLog.info('closeScanner scan successful')
48      }).catch(() => {
49        ScanLog.warn('closeScanner scan error')
50      })
51    });
52    it('ScanTest_004', 0, ()=>{
53      let scannerId : string = ""
54      Scan.startScan(scannerId, false).then(()=>{
55        ScanLog.info('startScan scan successful')
56      }).catch(() => {
57        ScanLog.warn('startScan scan error')
58      })
59    });
60    it('ScanTest_005', 0, ()=>{
61      let scannerId : string = "";
62      Scan.cancelScan(scannerId).then(()=>{
63        ScanLog.info('cancelScan scan successful')
64      }).catch(() => {
65        ScanLog.warn('cancelScan scan error')
66      })
67    });
68    it('ScanTest_006', 0, ()=>{
69      let scannerId : string = "";
70      Scan.getProgress(scannerId).then(()=>{
71        ScanLog.info('getProgress scan successful')
72      }).catch(() => {
73        ScanLog.warn('getProgress scan error')
74      })
75    });
76    it('ScanTest_007', 0, ()=>{
77      let scannerId : string = "";
78      let value : ScanOptionValue = {
79        valueType : 3,
80        valueSize : 0,
81        strValue : 'Automatic Document Feeder',
82      };
83      Scan.setScanOption(scannerId, 6, value).then(()=>{
84        ScanLog.info('getProgress scan successful')
85      }).catch(() => {
86        ScanLog.warn('getProgress scan error')
87      })
88    });
89    it('ScanTest_008', 0, ()=>{
90      let scannerId : string = "";
91      Scan.getScanOption(scannerId, 0 ,1, 4).then(() => {
92      }).catch(() => {
93        ScanLog.warn('scan getScanOption error');
94      })
95    });
96    it('ScanTest_009', 0, ()=>{
97      Scan.on('scanDeviceFound', (device: ScannerDevice | string) => {
98        ScanLog.info('scanner info : ' + JSON.stringify(device));
99      })
100      Scan.getScannerList().then(() => {
101        ScanLog.info('scan getScannerList successful');
102      }).catch(() => {
103        ScanLog.warn('scan getScannerList error')
104      })
105    });
106    it('ScanTest_010', 0, ()=>{
107      let scannerId : string = "";
108      Scan.getScanOptionDesc(scannerId, 0).then(() => {
109        ScanLog.info('scan getScanOptionDesc successful');
110      }).catch(() => {
111        ScanLog.warn('scan getScanOptionDesc error')
112      })
113    });
114  })
115}