Compare commits

..

10 Commits

Author SHA1 Message Date
Mariya
d82ecf624e device registering issue resolved 2024-01-27 12:55:42 +05:30
Mariya
d2d965d524 Uncomment the code for firebase 2024-01-25 11:51:17 +05:30
Mariya
5e0d333fca changes added when testing in dEVICE UPDATION 2024-01-24 12:35:34 +05:30
Mariya
126aeaed5d Merge remote-tracking branch 'origin/dev' into dev 2024-01-23 18:12:57 +05:30
Mariya
bce12a4fca changes added when testing in device provision- and removed unwanted codes 2024-01-23 18:12:05 +05:30
Pritimay Sarkar
2c21a29d22 lower limit of buffer adc 2024-01-23 18:00:13 +05:30
Pritimay Sarkar
012efd9904 add default device and handle incompatiblity 2024-01-23 17:01:04 +05:30
Pritimay Sarkar
f83823a15f refactoring hemocube fragment and add tests 2024-01-23 13:42:27 +05:30
Mariya
a0fc7f7be4 Added baud rate 2024-01-22 14:51:24 +05:30
Pritimay Sarkar
b139289765 refactoring 2024-01-20 10:56:04 +05:30
20 changed files with 589 additions and 463 deletions

View File

@@ -16,11 +16,11 @@ android {
// prod - production, preprod - preproduction, quality - qc, dev - development
defaultConfig {
applicationId "in.sminnovations.hpostesting.dev"
applicationId "in.sminnovations.hpostesting"
minSdk 21
targetSdk 34
versionCode 91
versionName "2.1.91"
versionCode 93
versionName "2.1.93"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -108,6 +108,8 @@ dependencies {
testImplementation 'org.mockito:mockito-core:3.12.4'
androidTestImplementation 'org.mockito:mockito-android:3.12.4'
androidTestImplementation 'org.mockito:mockito-inline:3.12.4'
androidTestImplementation 'org.mockito:mockito-android:3.12.4'
testImplementation "androidx.arch.core:core-testing:2.2.0"
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1'

View File

@@ -34,6 +34,35 @@
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:650071678820:android:7865bef608cdee6f6c6471",
"android_client_info": {
"package_name": "com.smi.counselling"
}
},
"oauth_client": [
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:650071678820:android:2925e9ce3417d2386c6471",

View File

@@ -177,7 +177,7 @@ object Constants {
const val DEVICE_ID = "DEVICE_ID"
const val BUFFER_LED_LOWER_BOUND = 21000
const val BUFFER_LED_UPPER_BOUND = 24500
const val BUFFER_LED_UPPER_BOUND = 23500
const val TEST_STATUS_CODE_TEST_STARTED = 1.0
const val TEST_STATUS_CODE_CONFIG_STARTED = 2.0
@@ -1175,64 +1175,64 @@ object Constants {
val BUFFER_INTENSITY_THRESHOLDS: Map<String, List<List<Int>>> = mapOf<String, List<List<Int>>>(
"HCV-000-3001" to listOf(
listOf(20000, 25074),
listOf(20000, 24596),
listOf(20000, 26065),
listOf(20000, 27093),
listOf(23000, 25074),
listOf(23000, 24596),
listOf(23000, 26065),
listOf(23000, 27093),
),
"HCV-000-3002" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3003" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3004" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3005" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3006" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3007" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3008" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3009" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3010" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3011" to listOf(
listOf(20000, 25074),
@@ -1241,58 +1241,58 @@ object Constants {
listOf(20000, 27093),
),
"HCV-000-3012" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-1015" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3014" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3015" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3016" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3017" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3018" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3019" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3020" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3021" to listOf(
listOf(20000, 25074),
@@ -1301,58 +1301,58 @@ object Constants {
listOf(20000, 27093),
),
"HCV-000-3022" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3023" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3024" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3025" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3026" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3027" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3028" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3029" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HCV-000-3030" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0001" to listOf(
listOf(20000, 25074),
@@ -1361,58 +1361,58 @@ object Constants {
listOf(20000, 27093),
),
"HPP1-0124-0002" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0003" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0004" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0005" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0006" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0007" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0008" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0009" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0010" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0011" to listOf(
listOf(20000, 25074),
@@ -1421,118 +1421,118 @@ object Constants {
listOf(20000, 27093),
),
"HPP1-0124-0012" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0013" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0014" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0015" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0016" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0017" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0018" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0019" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0020" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0021" to listOf(
listOf(20000, 25074),
listOf(20000, 24596),
listOf(20000, 26065),
listOf(20000, 27093),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0022" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0023" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0024" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0025" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0026" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0027" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0028" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0029" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0030" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0031" to listOf(
listOf(20000, 25074),
@@ -1541,118 +1541,118 @@ object Constants {
listOf(20000, 27093),
),
"HPP1-0124-0032" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0033" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0034" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0035" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0036" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0037" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0038" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0039" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0040" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0041" to listOf(
listOf(20000, 25074),
listOf(20000, 24596),
listOf(20000, 26065),
listOf(20000, 27093),
"HPP1-0124-0040" to listOf(
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0042" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0043" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0044" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0045" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0046" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0047" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0048" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0049" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
),
"HPP1-0124-0050" to listOf(
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(24500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
listOf(23500, 26250),
)
)

View File

@@ -243,8 +243,6 @@ class UserListAdapter(
}
}
private fun isBetween15And30Minutes(createdAt: String): Long {
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
val createdAtDate: Date = formatter.parse(createdAt)!!

View File

@@ -1,5 +1,6 @@
package com.example.hpostesting.presentation.dashboard
import android.annotation.SuppressLint
import android.app.DownloadManager
import android.content.BroadcastReceiver
import android.content.Context
@@ -24,9 +25,6 @@ import com.example.hpostesting.data.constant.LanguageManager
import com.example.hpostesting.presentation.NatsManager
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
import com.google.android.material.navigation.NavigationView
import com.google.android.material.progressindicator.LinearProgressIndicator
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.firebase.appdistribution.FirebaseAppDistribution
import com.google.firebase.appdistribution.FirebaseAppDistributionException
@@ -50,6 +48,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
var responses: String = ""
lateinit var nats: NatsManager
private var downloadId: Long = 0
private var isReceiverRegistered = false
// TODO: Remove hemocube viewmodel
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
@@ -72,11 +71,10 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
hemocubeViewModel.deviceUpdate.observe(this) { result ->
when (result) {
is Result.Success -> {
// Handle success
val apkUrl = result.data
// val apkUrl = "https://dl.dropboxusercontent.com/s/fi/1c3nn7t0co431hicl3hrt/app-debug.apk?rlkey=e4uf13ty1dpcked614vy1aaqp&dl=0"
initiateUpdate(apkUrl.toString())
Log.d("ApI", "APK URL: $apkUrl")
Log.d("ApI", "APK URL For App Update: $apkUrl")
Toast.makeText(
this,
"APK UPLOAD ${result.data}",
@@ -129,17 +127,13 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
@SuppressLint("UnspecifiedRegisterReceiverFlag")
private fun initiateUpdate(responseBody: String) {
// Extract the URL from the ResponseBody
val apkUrl = responseBody
// Check if the extracted APK URL is valid
if (!isValidHttpUrl(apkUrl)) {
// Handle the case where the URL is not valid
if (!isValidHttpUrl(responseBody)) {
return
}
val request = DownloadManager.Request(Uri.parse(apkUrl))
val request = DownloadManager.Request(Uri.parse(responseBody))
request.setTitle("App Update")
request.setDescription("Downloading update...")
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
@@ -147,20 +141,16 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
downloadId = downloadManager.enqueue(request)
// Register a BroadcastReceiver to receive the download complete event
val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
if (!isReceiverRegistered) {
val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
registerReceiver(downloadReceiver, filter)
isReceiverRegistered = true
}
}
// Function to check if a URL has a valid HTTP/HTTPS scheme
// Function to extract the APK URL from the ResponseBody
private fun extractApkUrl(responseBody: ResponseBody): String {
// Assuming your ResponseBody contains the APK URL as a string
return responseBody.string()
}
// Function to check if a URL has a valid HTTP/HTTPS scheme
private fun isValidHttpUrl(url: String): Boolean {
return url.startsWith("http://") || url.startsWith("https://")
}
@@ -168,7 +158,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
override fun onReceive(context: Context?, intent: Intent?) {
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
if (id == downloadId) {
// Install the downloaded APK
installApk()
}
}
@@ -201,11 +190,11 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
override fun onDestroy() {
super.onDestroy()
if (isReceiverRegistered) {
unregisterReceiver(downloadReceiver)
isReceiverRegistered = false
}
}
override fun onResume() {
super.onResume()

View File

@@ -200,7 +200,9 @@ class HomeFragment : Fragment() {
hemoCubeViewModel.login(createLoginRequestData(userID, password))
} else {
isTokenAvailable = true
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
// hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
hemoCubeViewModel.deviceUpdate(createDeviceRequestData())
hemoCubeViewModel.uploadLogs()
hemoCubeViewModel.startPeriodicCheckUpdate()
}
@@ -237,34 +239,6 @@ class HomeFragment : Fragment() {
}
}
hemoCubeViewModel.deviceUpdate.observe(viewLifecycleOwner) { response ->
when (response) {
is Result.Success -> {
Toast.makeText(
requireContext(), response.data.toString(), Toast.LENGTH_SHORT
).show()
}
is Result.Error -> {
response.exception.let { message ->
Toast.makeText(
activity,
"An error occurred check update: $message",
Toast.LENGTH_LONG
)
.show()
}
}
is Result.Loading -> {
}
else -> {}
}
}
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
when (response) {
is Result.Success -> {
@@ -363,9 +337,10 @@ class HomeFragment : Fragment() {
)
}
private fun createDeviceUpdateRequestData(): DeviceUpdateRequest {
private fun createDeviceRequestData(): DeviceUpdateRequest {
return DeviceUpdateRequest(
serial_no = sharedPreference.getString(Constants.DEVICE_ID, "")
serial_no = Constants.DEVICE_ID
)
}

View File

@@ -34,6 +34,8 @@ import dagger.hilt.android.AndroidEntryPoint
import `in`.sminnovations.hpostesting.R
import `in`.sminnovations.hpostesting.databinding.ActivityCalibrationBinding
import `in`.sminnovations.hpostesting.databinding.ActivityDeviceBinding
@Suppress("MemberVisibilityCanBePrivate")
@AndroidEntryPoint
class DeviceActivity : AppCompatActivity() {
private lateinit var binding: ActivityDeviceBinding
@@ -110,6 +112,7 @@ class DeviceActivity : AppCompatActivity() {
}
}
}
open fun connectUsb(permissionGranted: Boolean) {
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
@@ -125,12 +128,9 @@ class DeviceActivity : AppCompatActivity() {
} else {
setupService()
}
}
}
fun onErrorReported(msg: String) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
if (!isFinishing) onBackPressed()
@@ -142,6 +142,7 @@ class DeviceActivity : AppCompatActivity() {
supportFragmentManager.beginTransaction().replace(binding.fgDevice.id, DeviceFragment())
.commit()
}
@SuppressLint("MutableImplicitPendingIntent")
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
val mPendingIntent: PendingIntent
@@ -163,7 +164,6 @@ class DeviceActivity : AppCompatActivity() {
manager.requestPermission(device, mPendingIntent)
}
fun setupService() {
val intent = Intent(this, UsbService::class.java)
bindService(intent, connection, Context.BIND_AUTO_CREATE)

View File

@@ -1,20 +1,14 @@
package com.example.hpostesting.presentation.deviceinfo
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.hpostesting.data.NetworkStatusLiveData
import com.example.hpostesting.data.dao.HemoCubeDao
import com.example.hpostesting.data.model.Response
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
import com.example.hpostesting.data.model.patient.DeviceData
import com.example.hpostesting.data.repository.Repository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
class DeviceViewModel @Inject constructor(

View File

@@ -62,7 +62,6 @@ class DeviceProvisionActivity : AppCompatActivity() {
}
}
private val connection = object : ServiceConnection {
override fun onServiceConnected(className: ComponentName, service: IBinder) {
val binder = service as UsbService.UsbServiceBinder

View File

@@ -1,5 +1,6 @@
package com.example.hpostesting.presentation.diagnostics
import android.annotation.SuppressLint
import android.app.PendingIntent
import android.content.BroadcastReceiver
import android.content.ComponentName
@@ -31,6 +32,7 @@ import dagger.hilt.android.AndroidEntryPoint
import `in`.sminnovations.hpostesting.R
import `in`.sminnovations.hpostesting.databinding.ActivityDiagnosticsBinding
@Suppress("MemberVisibilityCanBePrivate")
@AndroidEntryPoint
class DiagnosticsActivity : AppCompatActivity() {
private lateinit var binding: ActivityDiagnosticsBinding
@@ -141,6 +143,7 @@ class DiagnosticsActivity : AppCompatActivity() {
.commit()
}
@SuppressLint("MutableImplicitPendingIntent")
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
val mPendingIntent: PendingIntent
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {

View File

@@ -25,12 +25,10 @@ import com.example.hpostesting.presentation.utils.MyDialogListener
import com.example.hpostesting.presentation.utils.UIUtils
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.google.firebase.perf.ktx.performance
import `in`.sminnovations.hpostesting.R
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
import kotlin.math.abs
import kotlin.math.log10
import kotlin.math.round
@Suppress("MemberVisibilityCanBePrivate")
class HemoCubeFragment : Fragment() {
@@ -44,7 +42,6 @@ class HemoCubeFragment : Fragment() {
private var resultData: String = ""
private var currentResultData: String = ""
private var isUsingExistingBuffer = false
private var loginId: String = ""
private var isTestOngoing = false
private var startListening = MutableLiveData<Boolean>(false)
private var led1BufferForDevice = 0.0
@@ -59,7 +56,7 @@ class HemoCubeFragment : Fragment() {
private var fittedAbs2 = 0.0
private var fittedAbs3 = 0.0
private var fittedAbs4 = 0.0
private var _predictedDenovixRatio = 0.0
private var calculatedPredictedDenovixRatio = 0.0
private var validationError = false
private var deviceHardwareId = ""
private var allErrorMessages = ""
@@ -211,9 +208,9 @@ class HemoCubeFragment : Fragment() {
apply {
DataHolder.hemoCubeTestData?.let {
currentDeviceData?.coefficients?.let { coefficients ->
val coefficient1 = coefficients[0]
val coefficient2 = coefficients[1]
val result = coefficient1 * coefficient2
// val coefficient1 = coefficients[0]
// val coefficient2 = coefficients[1]
// val result = coefficient1 * coefficient2
}
}
isOnline = isNetworkAvailable
@@ -377,7 +374,7 @@ class HemoCubeFragment : Fragment() {
hemoCubeViewModel.deviceMessages.postValue(currentResultData)
when {
resultData.contains("SNE") && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
(resultData.contains("SNE") || resultData.contains("SN"))&& this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
processHardwareId(resultData)
}
@@ -394,7 +391,7 @@ class HemoCubeFragment : Fragment() {
}
}
resultData.contains("#SS1") && this.testStatusCode < TestStatus.SAMPLE_STARTED.code -> {
(resultData.contains("#SS") || resultData.contains("#SS1")) && this.testStatusCode < TestStatus.SAMPLE_STARTED.code -> {
this.testStatusCode = TestStatus.SAMPLE_STARTED.code
activity?.runOnUiThread {
binding.tvSubtitle4.text = getString(R.string.sample_started)
@@ -402,7 +399,7 @@ class HemoCubeFragment : Fragment() {
}
}
resultData.contains("#SC1") && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
hemoCubeViewModel.messages.postValue(
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data))
@@ -582,17 +579,26 @@ class HemoCubeFragment : Fragment() {
binding.btnPlacebuffer.visibility = View.VISIBLE
}
hemoCubeViewModel.messages.postValue(getString(R.string.start))
} else {
hemoCubeViewModel.messages.postValue("Config error")
}
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
deviceHardwareId = "HCV-000-3001"
assignDefaultDevice()
allErrorMessages += "Calibration configuration for this device id is not found\n"
}
if (!Constants.BUFFER_INTENSITY_THRESHOLDS.containsKey(deviceHardwareId)) {
allErrorMessages += "ADC thresholds for this device id are not found\n"
}
} else {
hemoCubeViewModel.messages.postValue("Config error")
}
fun assignDefaultDevice() {
deviceHardwareId = "HCV-000-3001"
testStatusCode = TestStatus.CONFIG_COMPLETED.code
activity?.runOnUiThread {
binding.btnPlacebuffer.visibility = View.VISIBLE
}
hemoCubeViewModel.messages.postValue(getString(R.string.start))
}
fun extractMiddleString(input: String): String? {
@@ -696,25 +702,25 @@ class HemoCubeFragment : Fragment() {
val slope1 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(1)?.get(0)
val intercept1 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(1)?.get(1)
val _hb1 = (led3Average - intercept1!!) / slope1!!
val calculatedHb1 = (led1Average - intercept1!!) / slope1!!
val slope2 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(0)
val intercept = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(1)
val _hb2 = (led4Average - intercept!!) / slope2!!
val calculatedHb2 = (led2Average - intercept!!) / slope2!!
val slope3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(0)
val intercept3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(1)
val _hb3 = (led3Average - intercept3!!) / slope3!!
val calculatedHb3 = (led3Average - intercept3!!) / slope3!!
val slope4 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(0)
val intercept4 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(1)
val _hb4 = (led4Average - intercept4!!) / slope4!!
val calculatedHb4 = (led4Average - intercept4!!) / slope4!!
_predictedDenovixRatio = fittedAbs3.div(fittedAbs1)
calculatedPredictedDenovixRatio = fittedAbs3.div(fittedAbs1)
val slope = (led1Average - led2Average) / (435 - 415)
val _slopeRatio = abs(led3Average / slope)
val slopeClass = slopeRatioClassification(_slopeRatio)
val calculatedSlopeRatio = abs(led3Average / slope)
val slopeClass = slopeRatioClassification(calculatedSlopeRatio)
if (fittedAbs1 <= fittedAbs2) {
validationError = true
@@ -733,7 +739,7 @@ class HemoCubeFragment : Fragment() {
}
}
if ((led1Average < 0.7 || led2Average < 0.7 || led3Average < 0.7 || led4Average < 0.7) && _slopeRatio > 35.0) {
if ((led1Average < 0.7 || led2Average < 0.7 || led3Average < 0.7 || led4Average < 0.7) && calculatedSlopeRatio > 35.0) {
validationError = true
activity?.runOnUiThread {
binding.errorMessage.text = "Severely Low Hb. Repeat test with 12 ul in 2 ml Buffer"
@@ -769,12 +775,12 @@ class HemoCubeFragment : Fragment() {
this.abs2 = fittedAbs2
this.abs3 = fittedAbs3
this.abs4 = fittedAbs4
this.hb3 = _hb3
this.hb4 = _hb4
this.hb3 = calculatedHb3
this.hb4 = calculatedHb4
this.deviceRatio = deviceRatio
this.calculatedRatio = calculateRatio(deviceRatio)
this.predictedDenovixRatio = _predictedDenovixRatio
this.slopeRatio = _slopeRatio
this.predictedDenovixRatio = calculatedPredictedDenovixRatio
this.slopeRatio = calculatedSlopeRatio
this.coefficients = currentDeviceData?.coefficients?.get(0)
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
@@ -783,7 +789,7 @@ class HemoCubeFragment : Fragment() {
this.classificationResult = deviceRatioClass //findResult(calculatedRatio)
hemoCubeViewModel.messages.postValue("${this.deviceRatioClass} ${if (led4Average < 0.17) " - Low Hb" else ""}\n")
if (DataHolder.hemoCubeTestData?.testType == "HB")
hemoCubeViewModel.messages.postValue("HB: $_hb4")
hemoCubeViewModel.messages.postValue("HB: $calculatedHb4")
this.errorMessages = allErrorMessages
this.resultData = deviceLog
this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString()

View File

@@ -3,7 +3,6 @@ package com.example.hpostesting.presentation.hemocube
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import android.os.BatteryManager
import android.util.Log
import androidx.lifecycle.LiveData
@@ -35,7 +34,6 @@ import com.example.hpostesting.data.model.patient.toHemoCubeTestData
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
import com.example.hpostesting.data.repository.DatabaseRepository
import com.example.hpostesting.data.repository.Repository
import com.example.hpostesting.domain.CheckUpdateWorker
import com.example.hpostesting.domain.LogFileManager
@@ -47,7 +45,6 @@ import okhttp3.RequestBody.Companion.asRequestBody
import okhttp3.ResponseBody
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
import java.util.Locale
import java.util.concurrent.TimeUnit
import javax.inject.Inject

View File

@@ -2,7 +2,6 @@ package com.example.hpostesting.presentation.testRight
import android.content.Context
import android.net.Uri
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
@@ -26,7 +25,6 @@ import com.example.hpostesting.domain.TestRightResultCalculation
import com.example.hpostesting.util.MyUtils
import com.google.firebase.storage.FirebaseStorage
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.scopes.ViewModelScoped
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import java.io.File

View File

@@ -34,7 +34,7 @@ class UsbService : Service() {
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
mPort = driver.ports[0] // Most devices have just one port (port 0)
mPort.open(connection)
mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
isUsbConnected = true
Log.d(TAG, "My Usb Connected ${mPort.driver}")

View File

@@ -83,7 +83,7 @@
android:id="@+id/btn_deviceProvision"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:visibility="visible"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="24dp"
android:clickable="false"
@@ -92,7 +92,7 @@
app:cornerRadius="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_calibration" />
app:layout_constraintTop_toBottomOf="@id/btn_deviceInfo" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_deviceInfo"

View File

@@ -214,7 +214,7 @@
android:layout_width="414dp"
android:layout_height="201dp"
android:gravity="center"
android:text="#SS1\n#SC1"
android:text="no device message"
android:textColor="@color/black"
android:textSize="11sp"
app:layout_constraintEnd_toEndOf="parent"

View File

@@ -1,27 +1,20 @@
package com.example.hpostesting
import android.content.Context
import android.os.Build
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.lifecycle.Observer
import androidx.work.Configuration
import androidx.work.testing.SynchronousExecutor
import androidx.work.testing.WorkManagerTestInitHelper
import com.example.hpostesting.data.Result
import com.example.hpostesting.data.model.login.LoginResponse
import com.example.hpostesting.data.repository.Repository
import com.example.hpostesting.domain.LogFileManager
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
import com.example.hpostesting.util.TestCoroutineRule
import io.mockk.MockKAnnotations
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import io.mockk.verify
import junit.framework.TestCase
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import org.junit.After
import org.junit.Before
import org.junit.Rule
@@ -29,35 +22,34 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import java.io.File
//@RunWith(RobolectricTestRunner::class)
//@Config(manifest = Config.NONE)
//@ExperimentalCoroutinesApi
//class HemocubeViewModelTest {
//
// @get:Rule
// val instantTaskExecutorRule = InstantTaskExecutorRule()
//
// @get:Rule
// val coroutineRule = TestCoroutineRule()
//
// @MockK(relaxed = true)
// lateinit var repository: Repository
//
// @MockK(relaxed = true)
// lateinit var logFileManager: LogFileManager
//
// @MockK(relaxed = true)
// lateinit var context: Context
//
// @MockK(relaxed = true)
// lateinit var observer: Observer<Result<LoginResponse>>
//
// private lateinit var viewModel: HemoCubeViewModel
//
// @Before
// fun setup() {
@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE)
@ExperimentalCoroutinesApi
class HemocubeViewModelTest {
@get:Rule
val instantTaskExecutorRule = InstantTaskExecutorRule()
@get:Rule
val coroutineRule = TestCoroutineRule()
@MockK(relaxed = true)
lateinit var repository: Repository
@MockK(relaxed = true)
lateinit var logFileManager: LogFileManager
@MockK(relaxed = true)
lateinit var context: Context
@MockK(relaxed = true)
lateinit var observer: Observer<Result<LoginResponse>>
private lateinit var viewModel: HemoCubeViewModel
@Before
fun setup() {
// MockKAnnotations.init(this)
//
// val config = Configuration.Builder()
@@ -78,13 +70,34 @@ import java.io.File
// context
// )
// viewModel.loginResponse.observeForever(observer)
// }
//
// @After
// fun teardown() {
}
@After
fun teardown() {
// viewModel.loginResponse.removeObserver(observer)
// }
//
}
@Test
fun `testAddNumbers in HemocubeViewModelTest`() {
// Create a mock of the Calculator class using Mockito-Kotlin
val calculatorMock = mockk<Calculator>()
// Define the behavior of the add method on the mock
every { calculatorMock.add(2, 3) } returns 5
// Create an instance of MathApplication with the mock Calculator
val mathApplication = MathApplication(calculatorMock)
// Perform the test using the MathApplication
val result = mathApplication.addNumbers(2, 3)
// Verify that the add method of the mock was called with the correct parameters
verify { calculatorMock.add(2, 3) }
// Verify the result of the test
TestCase.assertEquals(5, result)
}
// @Test
// fun `login() should update LiveData with success`() = coroutineRule.runBlockingTest {
//
@@ -124,7 +137,7 @@ import java.io.File
// viewModel.uploadLogs()
//
// // Assert
// verify { observer.onChanged(response) }
// verify { observer.onChanged(response as Result<LoginResponse>) }
// }
//
// @Test
@@ -141,4 +154,4 @@ import java.io.File
// // Assert
// verify { observer.onChanged(response) }
// }
//}
}

View File

@@ -0,0 +1,15 @@
package com.example.hpostesting
class Calculator {
fun add(a: Int, b: Int): Int {
return a + b
}
}
class MathApplication(private val calculator: Calculator) {
fun addNumbers(a: Int, b: Int): Int {
return calculator.add(a, b)
}
}

View File

@@ -0,0 +1,31 @@
package com.example.hpostesting
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import junit.framework.TestCase.assertEquals
import org.junit.Test
class MathApplicationTest {
@Test
fun testAddNumbers() {
// Create a mock of the Calculator class using Mockito-Kotlin
val calculatorMock = mockk<Calculator>()
// Define the behavior of the add method on the mock
every { calculatorMock.add(2, 3) } returns 5
// Create an instance of MathApplication with the mock Calculator
val mathApplication = MathApplication(calculatorMock)
// Perform the test using the MathApplication
val result = mathApplication.addNumbers(2, 3)
// Verify that the add method of the mock was called with the correct parameters
verify { calculatorMock.add(2, 3) }
// Verify the result of the test
assertEquals(5, result)
}
}

View File

@@ -0,0 +1,77 @@
package com.example.hpostesting
import android.content.Context
import android.net.ConnectivityManager
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import junit.framework.TestCase
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
@RunWith(MockitoJUnitRunner::class)
class NetworkStatusLiveDataTest {
@get:Rule
val instantTaskExecutorRule = InstantTaskExecutorRule()
@Mock
private lateinit var mockContext: Context
@Mock
private lateinit var mockConnectivityManager: ConnectivityManager
@Before
fun setUp() {
// mockContext = ApplicationProvider.getApplicationContext<Context>()
// mockConnectivityManager = mockContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
}
@Test
fun testAddNumbers() {
// Create a mock of the Calculator class using Mockito-Kotlin
val calculatorMock = mockk<Calculator>()
// Define the behavior of the add method on the mock
every { calculatorMock.add(2, 3) } returns 5
// Create an instance of MathApplication with the mock Calculator
val mathApplication = MathApplication(calculatorMock)
// Perform the test using the MathApplication
val result = mathApplication.addNumbers(2, 3)
// Verify that the add method of the mock was called with the correct parameters
verify { calculatorMock.add(2, 3) }
// Verify the result of the test
TestCase.assertEquals(5, result)
}
// @Test
// fun testNetworkStatusLiveData() {
// // Assuming mockConnectivityManager is a mocked ConnectivityManager instance
// val mockNetwork = mock(Network::class.java)
// val mockNetworkCapabilities = mock(NetworkCapabilities::class.java)
//
// // Define desired capabilities
// `when`(mockNetworkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)).thenReturn(true)
// `when`(mockNetworkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)).thenReturn(true)
//
// // Set up network to return mocked capabilities
// `when`(mockConnectivityManager.activeNetwork).thenReturn(mockNetwork)
// `when`(mockConnectivityManager.getNetworkCapabilities(mockNetwork)).thenReturn(mockNetworkCapabilities)
//
// // Act
// val networkStatusLiveData = NetworkStatusLiveData(mockContext)
// val isConnected = networkStatusLiveData.value
//
// // Assert
// assertTrue("Network should be connected", isConnected!!)
// }
}