-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix for build pipeline
- Loading branch information
Showing
6 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
app/src/testShared/java/pl/marianjureczko/poszukiwacz/CustomScanIntentResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package pl.marianjureczko.poszukiwacz | ||
|
||
class CustomScanIntentResult { | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/testShared/java/pl/marianjureczko/poszukiwacz/QrScannerLauncherMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package pl.marianjureczko.poszukiwacz | ||
|
||
open class QrScannerLauncherMock //: ManagedActivityResultLauncher<ScanOptions, ScanIntentResult>(a,b) | ||
{ | ||
// override fun launch(input: ScanOptions) { | ||
// //no-op | ||
// } | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/testShared/java/pl/marianjureczko/poszukiwacz/TestCameraPort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package pl.marianjureczko.poszukiwacz | ||
|
||
import android.net.Uri | ||
import androidx.compose.runtime.Composable | ||
import org.mockito.Mockito.mock | ||
import pl.marianjureczko.poszukiwacz.shared.DoPhoto | ||
import pl.marianjureczko.poszukiwacz.shared.port.CameraPort | ||
|
||
class TestCameraPort : CameraPort(mock()) { | ||
var counter: Int = 0 | ||
|
||
@Composable | ||
override fun doPhoto( | ||
permissionGranted: Boolean, | ||
successMsg: Int, | ||
failureMsg: Int, | ||
getPhotoUri: () -> Uri, | ||
handleSuccess: () -> Unit, | ||
): DoPhoto { | ||
return { | ||
counter++ | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/testShared/java/pl/marianjureczko/poszukiwacz/TestLocationPort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package pl.marianjureczko.poszukiwacz | ||
|
||
import android.location.Location | ||
import kotlinx.coroutines.CoroutineScope | ||
import org.mockito.ArgumentMatchers.any | ||
import org.mockito.BDDMockito.given | ||
import org.mockito.Mockito.mock | ||
import pl.marianjureczko.poszukiwacz.activity.searching.n.UpdateLocationCallback | ||
import pl.marianjureczko.poszukiwacz.shared.port.LocationPort | ||
|
||
class TestLocationPort : LocationPort(mock(), mock(), mock(), mock()) { | ||
|
||
lateinit var callback: UpdateLocationCallback | ||
override fun startFetching(scope: CoroutineScope, callback: UpdateLocationCallback) { | ||
this.callback = callback | ||
} | ||
|
||
override fun stopFetching() {/*do nothing*/ | ||
} | ||
|
||
fun updateLocation(latitude: Double, longitude: Double, distanceToTreasure: Float = 0f) { | ||
val location = mock<Location>() | ||
given(location.latitude).willReturn(latitude) | ||
given(location.longitude).willReturn(longitude) | ||
given(location.distanceTo(any())).willReturn(distanceToTreasure) | ||
callback.invoke(location) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/testShared/java/pl/marianjureczko/poszukiwacz/TestQrScannerPort.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package pl.marianjureczko.poszukiwacz | ||
|
||
import androidx.activity.result.ActivityResultLauncher | ||
import androidx.compose.runtime.Composable | ||
import com.journeyapps.barcodescanner.ScanOptions | ||
import org.mockito.BDDMockito.given | ||
import org.mockito.Mockito.any | ||
import org.mockito.Mockito.mock | ||
import pl.marianjureczko.poszukiwacz.activity.searching.n.SearchingViewModel | ||
import pl.marianjureczko.poszukiwacz.screen.searching.QrScannerPort | ||
import pl.marianjureczko.poszukiwacz.shared.GoToResults | ||
|
||
class TestQrScannerPort : QrScannerPort() { | ||
var counter: Int = 0 | ||
|
||
@Volatile | ||
private var contents: String = "" | ||
|
||
@Composable | ||
override fun provideLauncher( | ||
viewModel: SearchingViewModel, | ||
goToResult: GoToResults, | ||
): ActivityResultLauncher<ScanOptions> { | ||
val result: ActivityResultLauncher<ScanOptions> = mock() | ||
given(result.launch(any())).will { | ||
counter++ | ||
viewModel.scannedTreasureCallback(goToResult)(contents) | ||
} | ||
return result | ||
} | ||
|
||
@Synchronized | ||
fun getContents(): String { | ||
return contents | ||
} | ||
|
||
@Synchronized | ||
fun setContents(value: String) { | ||
contents = value | ||
} | ||
} |