1
1
package fr.free.nrw.commons.upload
2
2
3
+ import android.content.ContentResolver
4
+ import android.content.Context
3
5
import android.net.Uri
6
+ import androidx.compose.material3.InputChip
4
7
import fr.free.nrw.commons.location.LatLng
5
8
import fr.free.nrw.commons.media.MediaClient
6
9
import fr.free.nrw.commons.nearby.Place
@@ -18,6 +21,7 @@ import org.mockito.Mockito.mock
18
21
import org.mockito.Mockito.`when`
19
22
import org.mockito.MockitoAnnotations
20
23
import java.io.FileInputStream
24
+ import java.io.InputStream
21
25
22
26
class ImageProcessingServiceTest {
23
27
@Mock
@@ -38,6 +42,9 @@ class ImageProcessingServiceTest {
38
42
@Mock
39
43
internal var location: LatLng ? = null
40
44
45
+ @Mock
46
+ internal lateinit var appContext: Context
47
+
41
48
@InjectMocks
42
49
var imageProcessingService: ImageProcessingService ? = null
43
50
@@ -49,8 +56,10 @@ class ImageProcessingServiceTest {
49
56
fun setUp () {
50
57
MockitoAnnotations .openMocks(this )
51
58
val mediaUri = mock(Uri ::class .java)
59
+ val contentUri = mock(Uri ::class .java)
52
60
val mockPlace = mock(Place ::class .java)
53
61
val mockTitle = mock(List ::class .java)
62
+ val contentResolver = mock(ContentResolver ::class .java)
54
63
55
64
`when `(mockPlace.wikiDataEntityId).thenReturn(" Q1" )
56
65
`when `(mockPlace.getLocation()).thenReturn(mock(LatLng ::class .java))
@@ -59,6 +68,8 @@ class ImageProcessingServiceTest {
59
68
`when`(mockTitle.isSet).thenReturn(true)*/
60
69
61
70
`when `(uploadItem.mediaUri).thenReturn(mediaUri)
71
+ `when `(uploadItem.contentUri).thenReturn(contentUri)
72
+ `when `(appContext.contentResolver).thenReturn(contentResolver)
62
73
`when `(uploadItem.imageQuality).thenReturn(ImageUtils .IMAGE_WAIT )
63
74
64
75
`when `(uploadItem.uploadMediaDetails).thenReturn(mockTitle as MutableList <UploadMediaDetail >? )
@@ -68,7 +79,9 @@ class ImageProcessingServiceTest {
68
79
69
80
`when `(fileUtilsWrapper!! .getFileInputStream(ArgumentMatchers .anyString()))
70
81
.thenReturn(mock(FileInputStream ::class .java))
71
- `when `(fileUtilsWrapper!! .getSHA1(any(FileInputStream ::class .java)))
82
+ `when `(appContext.contentResolver.openInputStream(ArgumentMatchers .any()))
83
+ .thenReturn(mock(InputStream ::class .java))
84
+ `when `(fileUtilsWrapper!! .getSHA1(any(InputStream ::class .java)))
72
85
.thenReturn(" fileSha" )
73
86
74
87
`when `(fileUtilsWrapper!! .getGeolocationOfFile(ArgumentMatchers .anyString(), any(LatLng ::class .java)))
0 commit comments