1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.providers.media.photopicker.data.model;
18 
19 import static android.provider.MediaStore.Files.FileColumns._SPECIAL_FORMAT_NONE;
20 
21 import android.provider.MediaStore;
22 
23 public class ModelTestUtils {
24     private static final String MIME_TYPE_JPEG = "image/jpeg";
25 
26     /**
27      * Generate the {@link Item}
28      * @param id the id
29      * @param mimeType the mime type
30      * @param dateTaken the time of date taken
31      * @param generationModified the generation number associated with the media
32      * @param duration the duration
33      * @return the Item
34      */
generateItem(String id, String mimeType, long dateTaken, long generationModified, long duration)35     public static Item generateItem(String id, String mimeType, long dateTaken,
36             long generationModified, long duration) {
37         return new Item(id, mimeType, dateTaken, generationModified, duration,
38                 MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL, Long.parseLong(id)),
39                 _SPECIAL_FORMAT_NONE);
40     }
41 
42     /**
43      * Generate the {@link Item}
44      * @param id the id
45      * @param mimeType the mime type
46      * @param dateTaken the time of date taken
47      * @param generationModified the generation number associated with the media
48      * @param duration the duration
49      * @param specialFormat the special format. See
50      * {@link MediaStore.Files.FileColumns#_SPECIAL_FORMAT}
51      * @return the Item
52      */
generateSpecialFormatItem(String id, String mimeType, long dateTaken, long generationModified, long duration, int specialFormat)53     public static Item generateSpecialFormatItem(String id, String mimeType, long dateTaken,
54             long generationModified, long duration, int specialFormat) {
55         return new Item(id, mimeType, dateTaken, generationModified, duration,
56                 MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL, Long.parseLong(id)),
57                 specialFormat);
58     }
59 
60     /** Generate the JPEG {@link Item} */
generateJpegItem(String id, long dateTaken, long generationModified)61     public static Item generateJpegItem(String id, long dateTaken, long generationModified) {
62         return generateItem(id, MIME_TYPE_JPEG, dateTaken, generationModified, /* duration */ 1000);
63     }
64 }
65