• 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
16import { describe, it, expect } from 'deccjsunit/index'
17import {
18  photoKeys,
19  photoFetchOption,
20  getFileAsset,
21  getAssetId,
22  isNum,
23  photoType,
24} from '../../../../../../../common'
25
26export default function getTest () {
27  describe('getTest', function () {
28    async function get (done, testNum, fetchOps, key, value) {
29      try {
30        let asset = await getFileAsset(testNum, fetchOps);
31        console.info(`${testNum} key: ${key}, value: ${value}, asset.key: ${asset.get(key)}`);
32        if (key === 'uri') {
33          const id = getAssetId(asset.get(key));
34          const expectUri = value + id;
35          const uri = asset.get(key).toString();
36          const isIncludes = uri.includes(expectUri);
37          expect(isIncludes).assertTrue();
38        } else if (key === 'date_added' || key === 'date_modified' || key === 'date_taken') {
39          expect(isNum(asset.get(key))).assertTrue();
40        } else {
41          expect(asset.get(key)).assertEqual(value);
42        }
43        done();
44      } catch (error) {
45        console.info(`${testNum} failed; error: ${error}`);
46        expect(false).assertTrue();
47        done();
48      }
49    }
50
51    //callback
52    //image
53    /**
54     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0000
55     * @tc.name      : get_000
56     * @tc.desc      : image get photoKeys.URI
57     * @tc.size      : MEDIUM
58     * @tc.type      : Function
59     * @tc.level     : Level 2
60     */
61    it('get_000', 2, async function (done) {
62      const testNum = 'get_000';
63      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
64      const key = photoKeys.URI;
65      const value = 'file://media/Photo/';
66      await get(done, testNum, fetchOps, key, value);
67    });
68
69    /**
70     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0100
71     * @tc.name      : get_001
72     * @tc.desc      : image get photoKeys.PHOTO_TYPE
73     * @tc.size      : MEDIUM
74     * @tc.type      : Function
75     * @tc.level     : Level 2
76     */
77    it('get_001', 2, async function (done) {
78      const testNum = 'get_001';
79      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
80      const key = photoKeys.PHOTO_TYPE;
81      const value = photoType.IMAGE;
82      await get(done, testNum, fetchOps, key, value);
83    });
84
85    /**
86     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0200
87     * @tc.name      : get_002
88     * @tc.desc      : image get photoKeys.DISPLAY_NAME
89     * @tc.size      : MEDIUM
90     * @tc.type      : Function
91     * @tc.level     : Level 2
92     */
93    it('get_002', 2, async function (done) {
94      const testNum = 'get_002';
95      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
96      const key = photoKeys.DISPLAY_NAME;
97      const value = '01.jpg';
98      await get(done, testNum, fetchOps, key, value);
99    });
100
101    /**
102     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0300
103     * @tc.name      : get_003
104     * @tc.desc      : image get photoKeys.DATE_ADDED
105     * @tc.size      : MEDIUM
106     * @tc.type      : Function
107     * @tc.level     : Level 2
108     */
109    it('get_003', 2, async function (done) {
110      const testNum = 'get_003';
111      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
112      const key = photoKeys.DATE_ADDED;
113      const value = 1;
114      await get(done, testNum, fetchOps, key, value);
115    });
116
117    /**
118     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0400
119     * @tc.name      : get_004
120     * @tc.desc      : image get photoKeys.DATE_MODIFIED
121     * @tc.size      : MEDIUM
122     * @tc.type      : Function
123     * @tc.level     : Level 2
124     */
125    it('get_004', 2, async function (done) {
126      const testNum = 'get_004';
127      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
128      const key = photoKeys.DATE_MODIFIED;
129      const value = 1;
130      await get(done, testNum, fetchOps, key, value);
131    });
132
133    /**
134     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0500
135     * @tc.name      : get_005
136     * @tc.desc      : image get photoKeys.DURATION
137     * @tc.size      : MEDIUM
138     * @tc.type      : Function
139     * @tc.level     : Level 2
140     */
141    it('get_005', 2, async function (done) {
142      const testNum = 'get_005';
143      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
144      const key = photoKeys.DURATION;
145      const value = 0;
146      await get(done, testNum, fetchOps, key, value);
147    });
148
149    /**
150     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0600
151     * @tc.name      : get_006
152     * @tc.desc      : image get photoKeys.WIDTH
153     * @tc.size      : MEDIUM
154     * @tc.type      : Function
155     * @tc.level     : Level 2
156     */
157    it('get_006', 2, async function (done) {
158      const testNum = 'get_006';
159      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
160      const key = photoKeys.WIDTH;
161      const value = 1279;
162      await get(done, testNum, fetchOps, key, value);
163    });
164
165    /**
166     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0700
167     * @tc.name      : get_007
168     * @tc.desc      : image get photoKeys.HEIGHT
169     * @tc.size      : MEDIUM
170     * @tc.type      : Function
171     * @tc.level     : Level 2
172     */
173    it('get_007', 2, async function (done) {
174      const testNum = 'get_007';
175      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
176      const key = photoKeys.HEIGHT;
177      const value = 1706;
178      await get(done, testNum, fetchOps, key, value);
179    });
180
181    /**
182     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0800
183     * @tc.name      : get_008
184     * @tc.desc      : image get photoKeys.DATE_TAKEN
185     * @tc.size      : MEDIUM
186     * @tc.type      : Function
187     * @tc.level     : Level 2
188     */
189    it('get_008', 2, async function (done) {
190      const testNum = 'get_008';
191      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
192      const key = photoKeys.DATE_TAKEN;
193      const value = 1;
194      await get(done, testNum, fetchOps, key, value);
195    });
196
197    /**
198     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_0900
199     * @tc.name      : get_009
200     * @tc.desc      : image get photoKeys.ORIENTATION
201     * @tc.size      : MEDIUM
202     * @tc.type      : Function
203     * @tc.level     : Level 2
204     */
205    it('get_009', 2, async function (done) {
206      const testNum = 'get_009';
207      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
208      const key = photoKeys.ORIENTATION;
209      const value = 0;
210      await get(done, testNum, fetchOps, key, value);
211    });
212
213    /**
214     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_1000
215     * @tc.name      : get_010
216     * @tc.desc      : image get photoKeys.FAVORITE
217     * @tc.size      : MEDIUM
218     * @tc.type      : Function
219     * @tc.level     : Level 2
220     */
221    it('get_010', 2, async function (done) {
222      const testNum = 'get_010';
223      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
224      const key = photoKeys.FAVORITE;
225      const value = 0;
226      await get(done, testNum, fetchOps, key, value);
227    });
228
229    /**
230     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_1100
231     * @tc.name      : get_011
232     * @tc.desc      : image get photoKeys.SIZE
233     * @tc.size      : MEDIUM
234     * @tc.type      : Function
235     * @tc.level     : Level 2
236     */
237    it('get_011', 2, async function (done) {
238      const testNum = 'get_011';
239      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
240      const key = photoKeys.SIZE;
241      const value = 348113;
242      await get(done, testNum, fetchOps, key, value);
243    });
244
245    /**
246     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_1200
247     * @tc.name      : get_012
248     * @tc.desc      : image get photoKeys.TITLE
249     * @tc.size      : MEDIUM
250     * @tc.type      : Function
251     * @tc.level     : Level 2
252     */
253    it('get_012', 2, async function (done) {
254      const testNum = 'get_012';
255      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
256      const key = photoKeys.TITLE;
257      const value = '01';
258      await get(done, testNum, fetchOps, key, value);
259    });
260
261    /**
262     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_1300
263     * @tc.name      : get_013
264     * @tc.desc      : image get photoKeys.POSITION
265     * @tc.size      : MEDIUM
266     * @tc.type      : Function
267     * @tc.level     : Level 2
268     */
269    it('get_013', 2, async function (done) {
270      const testNum = 'get_013';
271      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
272      const key = photoKeys.POSITION;
273      const value = 1;
274      await get(done, testNum, fetchOps, key, value);
275    });
276
277    /**
278     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_1400
279     * @tc.name      : get_014
280     * @tc.desc      : image get photoKeys.DATE_TRASHED
281     * @tc.size      : MEDIUM
282     * @tc.type      : Function
283     * @tc.level     : Level 2
284     */
285    it('get_014', 2, async function (done) {
286      const testNum = 'get_014';
287      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
288      const key = photoKeys.DATE_TRASHED;
289      const value = 0;
290      await get(done, testNum, fetchOps, key, value);
291    });
292
293    /**
294     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_1500
295     * @tc.name      : get_015
296     * @tc.desc      : image get photoKeys.HIDDEN
297     * @tc.size      : MEDIUM
298     * @tc.type      : Function
299     * @tc.level     : Level 2
300     */
301    it('get_015', 2, async function (done) {
302      const testNum = 'get_015';
303      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.jpg');
304      const key = photoKeys.HIDDEN;
305      const value = 0;
306      await get(done, testNum, fetchOps, key, value);
307    });
308
309    //video
310    /**
311     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5000
312     * @tc.name      : get_050
313     * @tc.desc      : video get photoKeys.URI
314     * @tc.size      : MEDIUM
315     * @tc.type      : Function
316     * @tc.level     : Level 2
317     */
318    it('get_050', 2, async function (done) {
319      const testNum = 'get_050';
320      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
321      const key = photoKeys.URI;
322      const value = 'file://media/Photo/';
323      await get(done, testNum, fetchOps, key, value);
324    });
325
326    /**
327     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5100
328     * @tc.name      : get_051
329     * @tc.desc      : video get photoKeys.PHOTO_TYPE
330     * @tc.size      : MEDIUM
331     * @tc.type      : Function
332     * @tc.level     : Level 2
333     */
334    it('get_051', 2, async function (done) {
335      const testNum = 'get_051';
336      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
337      const key = photoKeys.PHOTO_TYPE;
338      const value = photoType.VIDEO;
339      await get(done, testNum, fetchOps, key, value);
340    });
341
342    /**
343     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5200
344     * @tc.name      : get_052
345     * @tc.desc      : video get photoKeys.DISPLAY_NAME
346     * @tc.size      : MEDIUM
347     * @tc.type      : Function
348     * @tc.level     : Level 2
349     */
350    it('get_052', 2, async function (done) {
351      const testNum = 'get_052';
352      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
353      const key = photoKeys.DISPLAY_NAME;
354      const value = '01.mp4';
355      await get(done, testNum, fetchOps, key, value);
356    });
357
358    /**
359     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5300
360     * @tc.name      : get_053
361     * @tc.desc      : video get photoKeys.DATE_ADDED
362     * @tc.size      : MEDIUM
363     * @tc.type      : Function
364     * @tc.level     : Level 2
365     */
366    it('get_053', 2, async function (done) {
367      const testNum = 'get_053';
368      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
369      const key = photoKeys.DATE_ADDED;
370      const value = 1;
371      await get(done, testNum, fetchOps, key, value);
372    });
373
374    /**
375     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5400
376     * @tc.name      : get_054
377     * @tc.desc      : video get photoKeys.DATE_MODIFIED
378     * @tc.size      : MEDIUM
379     * @tc.type      : Function
380     * @tc.level     : Level 2
381     */
382    it('get_054', 2, async function (done) {
383      const testNum = 'get_054';
384      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
385      const key = photoKeys.DATE_MODIFIED;
386      const value = 1;
387      await get(done, testNum, fetchOps, key, value);
388    });
389
390    /**
391     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5500
392     * @tc.name      : get_055
393     * @tc.desc      : video get photoKeys.DURATION
394     * @tc.size      : MEDIUM
395     * @tc.type      : Function
396     * @tc.level     : Level 2
397     */
398    it('get_055', 2, async function (done) {
399      const testNum = 'get_055';
400      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
401      const key = photoKeys.DURATION;
402      const value = 10100;
403      await get(done, testNum, fetchOps, key, value);
404    });
405
406    /**
407     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5600
408     * @tc.name      : get_056
409     * @tc.desc      : video get photoKeys.WIDTH
410     * @tc.size      : MEDIUM
411     * @tc.type      : Function
412     * @tc.level     : Level 2
413     */
414    it('get_056', 2, async function (done) {
415      const testNum = 'get_056';
416      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
417      const key = photoKeys.WIDTH;
418      const value = 1280;
419      await get(done, testNum, fetchOps, key, value);
420    });
421
422    /**
423     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5700
424     * @tc.name      : get_057
425     * @tc.desc      : video get photoKeys.HEIGHT
426     * @tc.size      : MEDIUM
427     * @tc.type      : Function
428     * @tc.level     : Level 2
429     */
430    it('get_057', 2, async function (done) {
431      const testNum = 'get_057';
432      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
433      const key = photoKeys.HEIGHT;
434      const value = 720;
435      await get(done, testNum, fetchOps, key, value);
436    });
437
438    /**
439     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5800
440     * @tc.name      : get_058
441     * @tc.desc      : video get photoKeys.DATE_TAKEN
442     * @tc.size      : MEDIUM
443     * @tc.type      : Function
444     * @tc.level     : Level 2
445     */
446    it('get_058', 2, async function (done) {
447      const testNum = 'get_058';
448      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
449      const key = photoKeys.DATE_TAKEN;
450      const value = 1;
451      await get(done, testNum, fetchOps, key, value);
452    });
453
454    /**
455     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_5900
456     * @tc.name      : get_059
457     * @tc.desc      : video get photoKeys.ORIENTATION
458     * @tc.size      : MEDIUM
459     * @tc.type      : Function
460     * @tc.level     : Level 2
461     */
462    it('get_059', 2, async function (done) {
463      const testNum = 'get_059';
464      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
465      const key = photoKeys.ORIENTATION;
466      const value = 0;
467      await get(done, testNum, fetchOps, key, value);
468    });
469
470    /**
471     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_6000
472     * @tc.name      : get_060
473     * @tc.desc      : video get photoKeys.FAVORITE
474     * @tc.size      : MEDIUM
475     * @tc.type      : Function
476     * @tc.level     : Level 2
477     */
478    it('get_060', 2, async function (done) {
479      const testNum = 'get_060';
480      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
481      const key = photoKeys.FAVORITE;
482      const value = 0;
483      await get(done, testNum, fetchOps, key, value);
484    });
485
486    /**
487     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_6100
488     * @tc.name      : get_061
489     * @tc.desc      : video get photoKeys.SIZE
490     * @tc.size      : MEDIUM
491     * @tc.type      : Function
492     * @tc.level     : Level 2
493     */
494    it('get_061', 2, async function (done) {
495      const testNum = 'get_061';
496      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
497      const key = photoKeys.SIZE;
498      const value = 4853005;
499      await get(done, testNum, fetchOps, key, value);
500    });
501
502    /**
503     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_6200
504     * @tc.name      : get_062
505     * @tc.desc      : video get photoKeys.TITLE
506     * @tc.size      : MEDIUM
507     * @tc.type      : Function
508     * @tc.level     : Level 2
509     */
510    it('get_062', 2, async function (done) {
511      const testNum = 'get_062';
512      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
513      const key = photoKeys.TITLE;
514      const value = '01';
515      await get(done, testNum, fetchOps, key, value);
516    });
517
518    /**
519     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_6300
520     * @tc.name      : get_063
521     * @tc.desc      : video get photoKeys.POSITION
522     * @tc.size      : MEDIUM
523     * @tc.type      : Function
524     * @tc.level     : Level 2
525     */
526    it('get_063', 2, async function (done) {
527      const testNum = 'get_063';
528      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
529      const key = photoKeys.POSITION;
530      const value = 1;
531      await get(done, testNum, fetchOps, key, value);
532    });
533
534    /**
535     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_6400
536     * @tc.name      : get_064
537     * @tc.desc      : video get photoKeys.DATE_TRASHED
538     * @tc.size      : MEDIUM
539     * @tc.type      : Function
540     * @tc.level     : Level 2
541     */
542    it('get_064', 2, async function (done) {
543      const testNum = 'get_064';
544      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
545      const key = photoKeys.DATE_TRASHED;
546      const value = 0;
547      await get(done, testNum, fetchOps, key, value);
548    });
549
550    /**
551     * @tc.number    : SUB_PHOTOACCESS_HELPER_GET_6500
552     * @tc.name      : get_065
553     * @tc.desc      : video get photoKeys.HIDDEN
554     * @tc.size      : MEDIUM
555     * @tc.type      : Function
556     * @tc.level     : Level 2
557     */
558    it('get_065', 2, async function (done) {
559      const testNum = 'get_065';
560      const fetchOps = photoFetchOption(testNum, photoKeys.DISPLAY_NAME, '01.mp4');
561      const key = photoKeys.HIDDEN;
562      const value = 0;
563      await get(done, testNum, fetchOps, key, value);
564    });
565  })
566}
567