Compare commits
4 Commits
API-CALLS-
...
2.1.99
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5980a9cfe | ||
|
|
3e0523e163 | ||
|
|
173d4a2767 | ||
|
|
c166bab804 |
@@ -112,6 +112,8 @@ dependencies {
|
||||
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 'org.powermock:powermock-api-mockito2:2.0.9'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
|
||||
|
||||
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1'
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.example.hpostesting.data.constant
|
||||
|
||||
object Constants {
|
||||
const val ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION"
|
||||
const val HOMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||
const val HEMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||
|
||||
const val BASE_URL = "www.google.com"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.example.hpostesting.domain
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
@@ -32,7 +31,7 @@ class LogFileManagerImpl @Inject constructor(private val context: Context) : Log
|
||||
|
||||
file
|
||||
} catch (e: IOException) {
|
||||
Log.e("LogFileManager", "Error creating log file: ${e.message}")
|
||||
// Log.e("LogFileManager", "Error creating log file: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,51 +208,21 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
//Setting up the SDK handler
|
||||
|
||||
//Setting up the SDK handler
|
||||
sdkHandler = SDKHandler(this)
|
||||
|
||||
//Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications.
|
||||
|
||||
//Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications.
|
||||
sdkHandler!!.dcssdkSetDelegate(this)
|
||||
|
||||
//this command is telling the sdk that we're going to be connecting to the scanner via USB
|
||||
|
||||
//this command is telling the sdk that we're going to be connecting to the scanner via USB
|
||||
sdkHandler!!.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_SNAPI)
|
||||
|
||||
|
||||
//deciding what kind of notifications we want to receive. Explained more in the function
|
||||
//first we use bitmapping to set these values into the notifications_mask.
|
||||
|
||||
|
||||
//deciding what kind of notifications we want to receive. Explained more in the function
|
||||
//first we use bitmapping to set these values into the notifications_mask.
|
||||
var notifications_mask = 0
|
||||
// We would like to subscribe to all barcode events
|
||||
// We would like to subscribe to all barcode events
|
||||
notifications_mask =
|
||||
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
||||
// subscribe to events set in notification mask
|
||||
// subscribe to events set in notification mask
|
||||
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
||||
|
||||
|
||||
//so adding all the scanners to the mScannerInfoList, then connecting to the first scanner.
|
||||
//There's only one scanner so this step is unnecessary, I did it thinking about possible scalability.
|
||||
//here I just get the list of available scanners which also returns the USB scanner attached to the tinker board.
|
||||
|
||||
|
||||
//so adding all the scanners to the mScannerInfoList, then connecting to the first scanner.
|
||||
//There's only one scanner so this step is unnecessary, I did it thinking about possible scalability.
|
||||
//here I just get the list of available scanners which also returns the USB scanner attached to the tinker board.
|
||||
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
||||
|
||||
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
||||
|
||||
//I'm doing mScannerInfoList.get(0) because there's only one scanner which will be at position 0.
|
||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||
}
|
||||
|
||||
|
||||
@@ -145,18 +145,18 @@ class AutoDacActivity: AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -12,11 +12,15 @@ import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.presentation.UsbServiceListener
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import `in`.sminnovations.hpostesting.databinding.FragmentAutoDacBinding
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
class AutoDacFragment: Fragment() {
|
||||
|
||||
@@ -141,22 +145,19 @@ class AutoDacFragment: Fragment() {
|
||||
}
|
||||
|
||||
if (resultData.contains("#CC")) {
|
||||
autoDacViewModel.addAutoDacDataToDb(
|
||||
DiagnosticsData(
|
||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
||||
deviceData = resultData,
|
||||
runTime = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
)
|
||||
)
|
||||
activity?.runOnUiThread {
|
||||
binding.ivCheck.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
if (resultData.contains("END") || fullReadOutput.contains("END")) {
|
||||
// autoDacViewModel.addAutoDacDataToDb(
|
||||
// DiagnosticsData(
|
||||
// deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
||||
// deviceData = resultData,
|
||||
// runTime = SimpleDateFormat(
|
||||
// "yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
// ).format(Calendar.getInstance().time)
|
||||
// )
|
||||
// )
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUsbError(e: Exception?) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.example.hpostesting.presentation.buffercheck
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.PendingIntent
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.ComponentName
|
||||
@@ -124,21 +125,22 @@ open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
@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) {
|
||||
PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -144,18 +144,18 @@ class CalibrationActivity: AppCompatActivity() {
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -24,15 +24,11 @@ import androidx.core.view.get
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.calibration.CalibrationFragment
|
||||
import com.example.hpostesting.presentation.calibration.CalibrationViewModel
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.testRight.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityCalibrationBinding
|
||||
import `in`.sminnovations.hpostesting.databinding.ActivityDeviceBinding
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@@ -148,18 +144,18 @@ class DeviceActivity : AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
@@ -32,7 +32,7 @@ class DeviceFragment : Fragment() {
|
||||
): View {
|
||||
binding = FragmentDeviceBinding.inflate(inflater, container, false)
|
||||
sharedPreferences =
|
||||
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.example.hpostesting.presentation.deviceinfo
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
@@ -14,16 +11,15 @@ import javax.inject.Inject
|
||||
class DeviceViewModel @Inject constructor(
|
||||
private val hemoCubeDao: HemoCubeDao,
|
||||
private val repository: Repository,
|
||||
context: Context
|
||||
) : ViewModel() {
|
||||
var isServiceConnected = false
|
||||
val progressBar = MutableLiveData(false)
|
||||
val messages = MutableLiveData<String>()
|
||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
val allUserData = hemoCubeDao.getAll()
|
||||
// private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||
// val allUserData = hemoCubeDao.getAll()
|
||||
val deviceData = MutableLiveData<DeviceData?>()
|
||||
val networkStatusLiveData: LiveData<Boolean>
|
||||
get() = _networkStatusLiveData
|
||||
// val networkStatusLiveData: LiveData<Boolean>
|
||||
// get() = _networkStatusLiveData
|
||||
val fireBaseUpload = MutableLiveData<String>()
|
||||
|
||||
}
|
||||
@@ -144,18 +144,18 @@ class DeviceProvisionActivity : AppCompatActivity() {
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import androidx.core.view.get
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.LanguageManager
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||
import com.example.hpostesting.presentation.testRight.UsbService
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||
@@ -148,18 +146,18 @@ class DiagnosticsActivity : AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -130,18 +130,18 @@ open class HemocubeActivity : AppCompatActivity() {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -127,23 +127,23 @@ class TrueHemeActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("MutableImplicitPendingIntent")
|
||||
@SuppressLint("MutableImplicitPendingIntent", "UnspecifiedRegisterReceiverFlag")
|
||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||
val mPendingIntent: PendingIntent
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||
)
|
||||
} else {
|
||||
mPendingIntent = PendingIntent.getBroadcast(
|
||||
this,
|
||||
0,
|
||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||
registerReceiver(broadcastReceiver, filter)
|
||||
manager.requestPermission(device, mPendingIntent)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.example.hpostesting.presentation.trueheme
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
@@ -33,6 +34,7 @@ import kotlin.math.abs
|
||||
import kotlin.math.log10
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@SuppressLint("SetTextI18n")
|
||||
class TrueHemeFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentTruehemeSampleBinding
|
||||
@@ -1141,4 +1143,8 @@ class TrueHemeFragment : Fragment() {
|
||||
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 0.0
|
||||
return coefficient1 * ratio + coefficient2
|
||||
}
|
||||
|
||||
private fun reconnect() {
|
||||
(activity as HemocubeActivity).reconnectDevice()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
//
|
||||
//@PrepareForTest(Object::class)
|
||||
//class AuthInterceptorTest {
|
||||
//
|
||||
//// @Rule
|
||||
//// val rule = PowerMockRule()
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var sharedPreferences: SharedPreferences
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var chain: Interceptor.Chain
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var request: okhttp3.Request
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var response: Response
|
||||
//
|
||||
// @Captor
|
||||
// private lateinit var captor: ArgumentCaptor<okhttp3.Request>
|
||||
//
|
||||
// private lateinit var authInterceptor: AuthInterceptor
|
||||
//
|
||||
// @Before
|
||||
// fun setup() {
|
||||
// MockitoAnnotations.initMocks(this)
|
||||
// authInterceptor = AuthInterceptor(sharedPreferences)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun intercept_withToken_shouldAddAuthorizationHeader() {
|
||||
// // Arrange
|
||||
// val accessToken = "fakeAccessToken"
|
||||
// `when`(sharedPreferences.getString(Constants.ACCESS_TOKEN, null)).thenReturn(accessToken)
|
||||
// `when`(chain.request()).thenReturn(request)
|
||||
// `when`(chain.proceed(request)).thenReturn(response)
|
||||
//
|
||||
// // Act
|
||||
// val result = authInterceptor.intercept(chain)
|
||||
//
|
||||
// // Assert
|
||||
// verify(chain).proceed(captor.capture())
|
||||
// assertEquals("Bearer $accessToken", captor.value.header("Authorization"))
|
||||
// assertEquals(response, result)
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun intercept_withoutToken_shouldNotAddAuthorizationHeader() {
|
||||
// // Arrange
|
||||
// `when`(sharedPreferences.getString(Constants.ACCESS_TOKEN, null)).thenReturn(null)
|
||||
// `when`(chain.request()).thenReturn(request)
|
||||
// `when`(chain.proceed(request)).thenReturn(response)
|
||||
//
|
||||
// // Act
|
||||
// val result = authInterceptor.intercept(chain)
|
||||
//
|
||||
// // Assert
|
||||
// verify(chain).proceed(captor.capture())
|
||||
// assertEquals(null, captor.value.header("Authorization"))
|
||||
// assertEquals(response, result)
|
||||
// }
|
||||
//}
|
||||
67
app/src/test/java/com/example/hpostesting/CsvWriterTest.kt
Normal file
67
app/src/test/java/com/example/hpostesting/CsvWriterTest.kt
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.Context
|
||||
import com.example.hpostesting.data.CsvWriter
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(manifest = Config.NONE)
|
||||
class CsvWriterTest {
|
||||
|
||||
private lateinit var csvWriter: CsvWriter
|
||||
private lateinit var context: Context
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
context = androidx.test.core.app.ApplicationProvider.getApplicationContext()
|
||||
csvWriter = CsvWriter(context)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun writeCsv_Success() {
|
||||
// Arrange
|
||||
val fileName = "test.csv"
|
||||
val data = listOf(
|
||||
arrayOf("1", "A", "1990", "Positive", "2024-02-04", "image_url1", "John Doe"),
|
||||
arrayOf("2", "B", "1985", "Negative", "2024-02-05", "image_url2", "Jane Doe")
|
||||
)
|
||||
|
||||
// Act
|
||||
val result = csvWriter.writeCsv(fileName, data)
|
||||
|
||||
// Assert
|
||||
Assert.assertTrue(result)
|
||||
}
|
||||
|
||||
// @Test
|
||||
// fun writeCsv_Failure() {
|
||||
// // Arrange
|
||||
// val fileName = "test.csv"
|
||||
// val data = listOf(
|
||||
// arrayOf("1", "A", "1990", "Positive", "2024-02-04", "image_url1", "John Doe"),
|
||||
// arrayOf("2", "B", "1985", "Negative", "2024-02-05", "image_url2", "Jane Doe")
|
||||
// )
|
||||
//
|
||||
// // Mocking Environment.getExternalStorageDirectory()
|
||||
// val mockFile = Mockito.mock(File::class.java)
|
||||
// Mockito.`when`(Environment.getExternalStorageDirectory()).thenReturn(mockFile)
|
||||
// Mockito.`when`(mockFile.exists()).thenReturn(true)
|
||||
//
|
||||
// // Mocking FileWriter to simulate IOException
|
||||
// val mockWriter = Mockito.mock(FileWriter::class.java)
|
||||
// Mockito.`when`(mockWriter.write(Mockito.anyString())).thenThrow(IOException::class.java)
|
||||
// Mockito.`when`(mockFile.absolutePath).thenReturn("/fake/path/to/file.csv")
|
||||
// Mockito.`when`(FileWriter(mockFile)).thenReturn(mockWriter)
|
||||
//
|
||||
// // Act
|
||||
// val result = csvWriter.writeCsv(fileName, data)
|
||||
//
|
||||
// // Assert
|
||||
// Assert.assertFalse("Expected writeCsv to fail", result)
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.Context
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||
import com.example.hpostesting.data.repository.Repository
|
||||
import com.example.hpostesting.presentation.deviceinfo.DeviceViewModel
|
||||
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 DeviceViewModelTest {
|
||||
|
||||
@get:Rule
|
||||
val rule = InstantTaskExecutorRule()
|
||||
|
||||
@Mock
|
||||
private lateinit var hemoCubeDao: HemoCubeDao
|
||||
|
||||
@Mock
|
||||
private lateinit var repository: Repository
|
||||
|
||||
@Mock
|
||||
private lateinit var context: Context
|
||||
|
||||
private lateinit var viewModel: DeviceViewModel
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
viewModel = DeviceViewModel(hemoCubeDao, repository)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test initial state`() {
|
||||
assert(!viewModel.isServiceConnected)
|
||||
assert(!viewModel.progressBar.value!!)
|
||||
assert(viewModel.messages.value == null)
|
||||
// assert(viewModel.allUserData == hemoCubeDao.getAll())
|
||||
// assert(viewModel.deviceData.value == null)
|
||||
// assert(viewModel.networkStatusLiveData.value == false)
|
||||
assert(viewModel.fireBaseUpload.value == null)
|
||||
}
|
||||
|
||||
// Add more tests for other functions and interactions as needed
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
//
|
||||
//class LogFileManagerImplTest {
|
||||
//
|
||||
// @Mock
|
||||
// private lateinit var mockContext: Context
|
||||
//
|
||||
// private lateinit var logFileManager: LogFileManagerImpl
|
||||
//
|
||||
// @Before
|
||||
// fun setUp() {
|
||||
// mockContext = mock()
|
||||
// logFileManager = LogFileManagerImpl(mockContext)
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// fun testCreateLogFileSuccess() {
|
||||
// // Mock filesDir
|
||||
// whenever(mockContext.getString(R.string.app_name)).thenReturn("MockedAppName")
|
||||
// val mockFilesDir = mock<File>()
|
||||
// doReturn(true).whenever(mockContext).getFilesDir().exists()
|
||||
// doReturn(mockFilesDir).whenever(mockContext).getFilesDir()
|
||||
//
|
||||
// // Set expected file name
|
||||
// val expectedFileName = "hpos_1234567890.log"
|
||||
// val currentTime = System.currentTimeMillis() / 1000L
|
||||
// doReturn(true).whenever(mockFilesDir).createNewFile(expectedFileName)
|
||||
// doReturn(mockFilesDir.absolutePath + File.separator + expectedFileName).whenever(mockFilesDir).absolutePath
|
||||
//
|
||||
// // Mock FileOutputStream
|
||||
// val mockFileOutputStream = mock<FileOutputStream>()
|
||||
// doReturn(mockFileOutputStream).whenever(FileOutputStream(mockFilesDir.absolutePath + File.separator + expectedFileName))
|
||||
//
|
||||
// // Call createLogFile and verify result
|
||||
// val logFile = logFileManager.createLogFile()
|
||||
//
|
||||
// assertNotNull(logFile)
|
||||
// assertTrue(logFile.exists())
|
||||
// assertEquals(expectedFileName, logFile.name)
|
||||
//
|
||||
// // Verify FileOutputStream was called
|
||||
// verify(mockFileOutputStream).write(any())
|
||||
// verify(mockFileOutputStream).close()
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testCreateLogFileExistingFile() throws IOException {
|
||||
// // Mock filesDir with existing file
|
||||
// val mockFilesDir = mock<File>()
|
||||
// val existingFile = mock<File>()
|
||||
// doReturn(true).whenever(mockContext).getFilesDir().exists()
|
||||
// doReturn(mockFilesDir).whenever(mockContext).getFilesDir()
|
||||
// doReturn(true).whenever(mockFilesDir).exists()
|
||||
// doReturn(listOf(existingFile)).whenever(mockFilesDir).listFiles()
|
||||
//
|
||||
// // Call createLogFile and expect exception
|
||||
// try {
|
||||
// logFileManager.createLogFile()
|
||||
// fail("Expected IOException due to existing file")
|
||||
// } catch (e: IOException) {
|
||||
// // Expected behavior
|
||||
// }
|
||||
//
|
||||
// // Verify FileOutputStream was not called
|
||||
// verify(mockFilesDir, times(0)).createNewFile(anyString())
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// fun testCreateLogFileIOException() throws IOException {
|
||||
// // Mock filesDir and IOException
|
||||
// val mockFilesDir = mock<File>()
|
||||
// doReturn(true).whenever(mockContext).getFilesDir().exists()
|
||||
// doReturn(mockFilesDir).whenever(mockContext).getFilesDir()
|
||||
// doReturn(true).whenever(mockFilesDir).exists()
|
||||
// doThrow(IOException("Mock IOException")).whenever(mockFilesDir).createNewFile(anyString())
|
||||
//
|
||||
// // Call createLogFile and expect null result
|
||||
// val logFile = logFileManager.createLogFile()
|
||||
//
|
||||
// assertNull(logFile)
|
||||
//
|
||||
// // Verify FileOutputStream was not called
|
||||
// verify(mockFilesDir, times(0)).createNewFile(anyString())
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,350 @@
|
||||
package com.example.hpostesting
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.example.hpostesting.presentation.trueheme.TrueHemeFragment
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
class TrueHemeFragmentTest {
|
||||
|
||||
@Mock
|
||||
lateinit var mockContext: Context
|
||||
|
||||
@Mock
|
||||
private lateinit var mockSharedPreferences: SharedPreferences
|
||||
|
||||
private lateinit var fragment: TrueHemeFragment
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
fragment = TrueHemeFragment()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId to get device id`() {
|
||||
// Arrange
|
||||
Mockito.`when`(
|
||||
mockSharedPreferences.getString(
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString()
|
||||
)
|
||||
).thenReturn("dummy_value")
|
||||
|
||||
// Act
|
||||
val deviceId = fragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-9000", deviceId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `updateDeviceId in shared pref`() {
|
||||
// Arrange
|
||||
Mockito.`when`(
|
||||
mockSharedPreferences.getString(
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString()
|
||||
)
|
||||
).thenReturn("HPP1-0001")
|
||||
|
||||
// Act
|
||||
val deviceId = mockSharedPreferences.getString(
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyString()
|
||||
)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-0001", deviceId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `allReadingsComplete check`() {
|
||||
// Arrange
|
||||
val repeatReadingCount = 1
|
||||
val readingsPerSample = 1
|
||||
|
||||
// Act
|
||||
val result = fragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals(true, result)
|
||||
TestCase.assertEquals(fragment.allReadingsComplete(0, 1), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return hardware ID when input contains SN`() {
|
||||
// Arrange
|
||||
val input = "Some text SN ABC123 some more text"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("ABC123", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return null when input does not contain SN`() {
|
||||
// Arrange
|
||||
val input = "Some text without SN"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return null when input is empty`() {
|
||||
// Arrange
|
||||
val input = ""
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return null when input is null`() {
|
||||
// Arrange
|
||||
val input: String? = null
|
||||
|
||||
// Act
|
||||
val result = input?.let { fragment.extractV1HardwareId(it) }
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV1HardwareId should return hardware ID when input contains SN in a specific format`() {
|
||||
// Arrange
|
||||
val input = """
|
||||
SN HCV-000-3001
|
||||
#BS
|
||||
#BC
|
||||
#SS
|
||||
#SC
|
||||
RESULT
|
||||
LB1 20636.32
|
||||
LB2 15855.67
|
||||
LB3 21801.36
|
||||
LB4 18362.33
|
||||
LS1 17287
|
||||
LS2 14855.67
|
||||
LS3 15282.31
|
||||
LS4 9737.98
|
||||
REND
|
||||
""".trimIndent()
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV1HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HCV-000-3001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should return the correct hardware ID when it exists in the input`() {
|
||||
// Arrange
|
||||
val input = "SNS ABC123 SNE"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("ABC123", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should return null when no hardware ID is found in the input`() {
|
||||
// Arrange
|
||||
val input = "No hardware ID in this input"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle whitespace around the hardware ID`() {
|
||||
// Arrange
|
||||
val input = "SNS XYZ789 SNE"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("XYZ789", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HCV-000-3013`() {
|
||||
// Arrange
|
||||
val input = "SNS HCV-000-3013 SNE\n" +
|
||||
"#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT \n" +
|
||||
"LB1 23411.00\n" +
|
||||
"LB2 21417.00\n" +
|
||||
"LB3 23869.00\n" +
|
||||
"LB4 24967.00\n" +
|
||||
"LS1 3401.00\n" +
|
||||
"LS2 1107.00\n" +
|
||||
"LS3 14410.00\n" +
|
||||
"LS4 15047.00\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HCV-000-3013", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP1-4001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP1-4001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-4001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP1-000-4001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP1-000-4001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP1-000-4001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP-000-4001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP-000-4001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP-000-4001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `extractV2HardwareId should handle provided input string with HPP-000-5001`() {
|
||||
// Arrange
|
||||
val input = "SNS HPP-000-5001 SNE#SS1\n" +
|
||||
"#SC1\n" +
|
||||
"RESULT\n" +
|
||||
"LB1 23777\n" +
|
||||
"LB2 24130\n" +
|
||||
"LB3 23442\n" +
|
||||
"LB4 23945\n" +
|
||||
"LS1 2521\n" +
|
||||
"LS2 973\n" +
|
||||
"LS3 10252\n" +
|
||||
"LS4 11017\n" +
|
||||
"REND\n"
|
||||
|
||||
// Act
|
||||
val result = fragment.extractV2HardwareId(input)
|
||||
|
||||
// Assert
|
||||
TestCase.assertEquals("HPP-000-5001", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNormal() {
|
||||
val ratio = 0.25
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Normal", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationNegativeBorderline() {
|
||||
val ratio = 0.31
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Negative Borderline, Repeat Test", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellTrait() {
|
||||
val ratio = 0.34
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Sickle Cell Trait", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||
val ratio = 0.37
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationSickleCellDisease() {
|
||||
val ratio = 0.45
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Sickle Cell Disease", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeviceRatioClassificationInvalid() {
|
||||
val ratio: Double? = null
|
||||
val result = fragment.deviceRatioClassification(ratio)
|
||||
TestCase.assertEquals("Invalid", result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user