@@ -54,10 +54,11 @@ class NearbyParentFragmentUnitTest {
54
54
@Throws(Exception ::class )
55
55
fun `Start map without gps test when last location known` () {
56
56
val method: Method = NearbyParentFragment ::class .java.getDeclaredMethod(
57
- " startMapWithoutGPS"
57
+ " startMapWithCondition" ,
58
+ String ::class .java
58
59
)
59
60
method.isAccessible = true
60
- method.invoke(fragment)
61
+ method.invoke(fragment, " Without GPS " )
61
62
verify(mapView, times(1 )).onStart()
62
63
verify(applicationKvStore, times(1 )).getString(" LastLocation" )
63
64
verify(presenter, times(1 )).onMapReady()
@@ -77,10 +78,11 @@ class NearbyParentFragmentUnitTest {
77
78
fun `Start map without gps test when last location unknown` () {
78
79
`when `(applicationKvStore.getString(" LastLocation" )).thenReturn(" 23.76,56.876" )
79
80
val method: Method = NearbyParentFragment ::class .java.getDeclaredMethod(
80
- " startMapWithoutGPS"
81
+ " startMapWithCondition" ,
82
+ String ::class .java
81
83
)
82
84
method.isAccessible = true
83
- method.invoke(fragment)
85
+ method.invoke(fragment, " Without GPS " )
84
86
verify(mapView, times(1 )).onStart()
85
87
verify(applicationKvStore, times(2 )).getString(" LastLocation" )
86
88
verify(presenter, times(1 )).onMapReady()
@@ -94,4 +96,55 @@ class NearbyParentFragmentUnitTest {
94
96
verify(mapBox, times(1 ))
95
97
.moveCamera(CameraUpdateFactory .newCameraPosition(position))
96
98
}
99
+
100
+ @Test
101
+ @Throws(Exception ::class )
102
+ fun `Start map without location permission test when last location known` () {
103
+ val method: Method = NearbyParentFragment ::class .java.getDeclaredMethod(
104
+ " startMapWithCondition" ,
105
+ String ::class .java
106
+ )
107
+ method.isAccessible = true
108
+ method.invoke(fragment, " Without Permission" )
109
+ verify(mapView, times(1 )).onStart()
110
+ verify(applicationKvStore, times(1 )).getString(" LastLocation" )
111
+ verify(applicationKvStore, times(1 ))
112
+ .putBoolean(" doNotAskForLocationPermission" , true )
113
+ verify(presenter, times(1 )).onMapReady()
114
+ val position = CameraPosition .Builder ()
115
+ .target(LatLng (
116
+ 51.50550 ,
117
+ - 0.07520 , 0.0
118
+ ))
119
+ .zoom(0.0 )
120
+ .build()
121
+ verify(mapBox, times(1 ))
122
+ .moveCamera(CameraUpdateFactory .newCameraPosition(position))
123
+ }
124
+
125
+ @Test
126
+ @Throws(Exception ::class )
127
+ fun `Start map without location permission test when last location unknown` () {
128
+ `when `(applicationKvStore.getString(" LastLocation" )).thenReturn(" 23.76,56.876" )
129
+ val method: Method = NearbyParentFragment ::class .java.getDeclaredMethod(
130
+ " startMapWithCondition" ,
131
+ String ::class .java
132
+ )
133
+ method.isAccessible = true
134
+ method.invoke(fragment, " Without Permission" )
135
+ verify(mapView, times(1 )).onStart()
136
+ verify(applicationKvStore, times(2 )).getString(" LastLocation" )
137
+ verify(applicationKvStore, times(1 ))
138
+ .putBoolean(" doNotAskForLocationPermission" , true )
139
+ verify(presenter, times(1 )).onMapReady()
140
+ val position = CameraPosition .Builder ()
141
+ .target(LatLng (
142
+ 23.76 ,
143
+ 56.876 , 0.0
144
+ ))
145
+ .zoom(14.0 )
146
+ .build()
147
+ verify(mapBox, times(1 ))
148
+ .moveCamera(CameraUpdateFactory .newCameraPosition(position))
149
+ }
97
150
}
0 commit comments