mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-08 10:08:51 -06:00
Compare commits
1 Commits
ef22dd058b
...
830e28ca8e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
830e28ca8e |
@@ -1,8 +1,9 @@
|
|||||||
plugins {
|
plugins {
|
||||||
val kotlinVersion = "1.7.21"
|
val kotlinVersion = "1.7.21"
|
||||||
id("com.android.application") version "7.4.2" apply (false)
|
id("com.android.application") version ("7.4.2") apply (false)
|
||||||
id("org.jetbrains.kotlin.android") version kotlinVersion apply (false)
|
id("org.jetbrains.kotlin.android") version kotlinVersion apply (false)
|
||||||
id("org.jetbrains.kotlin.kapt") version kotlinVersion apply (false)
|
id("org.jetbrains.kotlin.kapt") version kotlinVersion apply (false)
|
||||||
|
id("org.jetbrains.kotlin.android.extensions") version kotlinVersion apply (false)
|
||||||
id("org.jetbrains.kotlin.multiplatform") version kotlinVersion apply (false)
|
id("org.jetbrains.kotlin.multiplatform") version kotlinVersion apply (false)
|
||||||
id("org.jlleitschuh.gradle.ktlint") version "11.4.2"
|
id("org.jlleitschuh.gradle.ktlint") version "11.4.2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,10 @@
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.github.triplet.play") version "3.7.0"
|
id("com.github.triplet.play") version "3.7.0"
|
||||||
id("com.android.application") version "7.4.2"
|
id("com.android.application")
|
||||||
id("org.jetbrains.kotlin.android")
|
id("org.jetbrains.kotlin.android")
|
||||||
id("org.jetbrains.kotlin.kapt")
|
id("org.jetbrains.kotlin.kapt")
|
||||||
|
id("org.jetbrains.kotlin.android.extensions")
|
||||||
id("org.jlleitschuh.gradle.ktlint")
|
id("org.jlleitschuh.gradle.ktlint")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ android {
|
|||||||
versionCode = 20200
|
versionCode = 20200
|
||||||
versionName = "2.2.0"
|
versionName = "2.2.0"
|
||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 32
|
targetSdk = 31
|
||||||
applicationId = "org.isoron.uhabits"
|
applicationId = "org.isoron.uhabits"
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -95,7 +96,7 @@ dependencies {
|
|||||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||||
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
|
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
|
||||||
androidTestImplementation("androidx.test:rules:1.5.0")
|
androidTestImplementation("androidx.test:rules:1.5.0")
|
||||||
androidTestImplementation("org.mockito.kotlin:mockito-kotlin:2.2.11")
|
androidTestImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
|
||||||
compileOnly("javax.annotation:jsr250-api:1.0")
|
compileOnly("javax.annotation:jsr250-api:1.0")
|
||||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
|
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
|
||||||
implementation("com.github.AppIntro:AppIntro:6.2.0")
|
implementation("com.github.AppIntro:AppIntro:6.2.0")
|
||||||
@@ -119,7 +120,7 @@ dependencies {
|
|||||||
kaptAndroidTest("com.google.dagger:dagger-compiler:$daggerVersion")
|
kaptAndroidTest("com.google.dagger:dagger-compiler:$daggerVersion")
|
||||||
testImplementation("com.google.dagger:dagger:$daggerVersion")
|
testImplementation("com.google.dagger:dagger:$daggerVersion")
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
testImplementation("org.mockito.kotlin:mockito-kotlin:2.2.11")
|
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
kapt {
|
kapt {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits
|
package org.isoron.uhabits
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
import dagger.Component
|
import dagger.Component
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
@@ -34,7 +35,6 @@ import org.isoron.uhabits.inject.ActivityScope
|
|||||||
import org.isoron.uhabits.inject.HabitModule
|
import org.isoron.uhabits.inject.HabitModule
|
||||||
import org.isoron.uhabits.inject.HabitsActivityModule
|
import org.isoron.uhabits.inject.HabitsActivityModule
|
||||||
import org.isoron.uhabits.inject.HabitsApplicationComponent
|
import org.isoron.uhabits.inject.HabitsApplicationComponent
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
class TestModule {
|
class TestModule {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package org.isoron.uhabits.acceptance.steps
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Build.VERSION.SDK_INT
|
import android.os.Build.VERSION.SDK_INT
|
||||||
|
import android.os.Build.VERSION_CODES
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.test.espresso.Espresso
|
import androidx.test.espresso.Espresso
|
||||||
@@ -32,11 +33,11 @@ import androidx.test.espresso.matcher.ViewMatchers
|
|||||||
import androidx.test.uiautomator.By
|
import androidx.test.uiautomator.By
|
||||||
import androidx.test.uiautomator.UiSelector
|
import androidx.test.uiautomator.UiSelector
|
||||||
import androidx.test.uiautomator.Until
|
import androidx.test.uiautomator.Until
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.CoreMatchers
|
import org.hamcrest.CoreMatchers
|
||||||
import org.isoron.uhabits.BaseUserInterfaceTest
|
import org.isoron.uhabits.BaseUserInterfaceTest
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.activities.habits.list.ListHabitsActivity
|
import org.isoron.uhabits.activities.habits.list.ListHabitsActivity
|
||||||
import org.junit.Assert.assertTrue
|
|
||||||
|
|
||||||
object CommonSteps : BaseUserInterfaceTest() {
|
object CommonSteps : BaseUserInterfaceTest() {
|
||||||
fun pressBack() {
|
fun pressBack() {
|
||||||
@@ -147,19 +148,15 @@ object CommonSteps : BaseUserInterfaceTest() {
|
|||||||
Screen.LIST_HABITS ->
|
Screen.LIST_HABITS ->
|
||||||
Espresso.onView(ViewMatchers.withClassName(CoreMatchers.endsWith("ListHabitsRootView")))
|
Espresso.onView(ViewMatchers.withClassName(CoreMatchers.endsWith("ListHabitsRootView")))
|
||||||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
||||||
|
|
||||||
Screen.SHOW_HABIT ->
|
Screen.SHOW_HABIT ->
|
||||||
Espresso.onView(ViewMatchers.withId(R.id.subtitleCard))
|
Espresso.onView(ViewMatchers.withId(R.id.subtitleCard))
|
||||||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
||||||
|
|
||||||
Screen.EDIT_HABIT ->
|
Screen.EDIT_HABIT ->
|
||||||
Espresso.onView(ViewMatchers.withId(R.id.questionInput))
|
Espresso.onView(ViewMatchers.withId(R.id.questionInput))
|
||||||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
||||||
|
|
||||||
Screen.SELECT_HABIT_TYPE ->
|
Screen.SELECT_HABIT_TYPE ->
|
||||||
Espresso.onView(ViewMatchers.withText(R.string.yes_or_no_example))
|
Espresso.onView(ViewMatchers.withText(R.string.yes_or_no_example))
|
||||||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
||||||
|
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ package org.isoron.uhabits.acceptance.steps
|
|||||||
import android.os.Build.VERSION.SDK_INT
|
import android.os.Build.VERSION.SDK_INT
|
||||||
import androidx.test.uiautomator.UiScrollable
|
import androidx.test.uiautomator.UiScrollable
|
||||||
import androidx.test.uiautomator.UiSelector
|
import androidx.test.uiautomator.UiSelector
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.isoron.uhabits.BaseUserInterfaceTest
|
import org.isoron.uhabits.BaseUserInterfaceTest
|
||||||
import org.junit.Assert.assertFalse
|
|
||||||
import org.junit.Assert.assertTrue
|
|
||||||
|
|
||||||
object WidgetSteps {
|
object WidgetSteps {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ package org.isoron.uhabits.activities.habits.list.views
|
|||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.MediumTest
|
import androidx.test.filters.MediumTest
|
||||||
|
import com.nhaarman.mockitokotlin2.doReturn
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import org.isoron.uhabits.BaseViewTest
|
import org.isoron.uhabits.BaseViewTest
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.kotlin.doReturn
|
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.verifyNoMoreInteractions
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@MediumTest
|
@MediumTest
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ package org.isoron.uhabits.activities.habits.list.views
|
|||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.filters.MediumTest
|
import androidx.test.filters.MediumTest
|
||||||
|
import com.nhaarman.mockitokotlin2.doReturn
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.BaseViewTest
|
import org.isoron.uhabits.BaseViewTest
|
||||||
@@ -27,9 +30,6 @@ import org.isoron.uhabits.core.ui.screens.habits.list.HintList
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.kotlin.doReturn
|
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@MediumTest
|
@MediumTest
|
||||||
|
|||||||
@@ -22,101 +22,97 @@ package org.isoron.uhabits.activities.common.dialogs
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatDialogFragment
|
import androidx.appcompat.app.AppCompatDialogFragment
|
||||||
|
import kotlinx.android.synthetic.main.frequency_picker_dialog.view.*
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.databinding.FrequencyPickerDialogBinding
|
|
||||||
|
|
||||||
class FrequencyPickerDialog(
|
class FrequencyPickerDialog(
|
||||||
var freqNumerator: Int,
|
var freqNumerator: Int,
|
||||||
var freqDenominator: Int
|
var freqDenominator: Int
|
||||||
) : AppCompatDialogFragment() {
|
) : AppCompatDialogFragment() {
|
||||||
private var _binding: FrequencyPickerDialogBinding? = null
|
|
||||||
private val binding get() = _binding!!
|
|
||||||
|
|
||||||
|
lateinit var contentView: View
|
||||||
var onFrequencyPicked: (num: Int, den: Int) -> Unit = { _, _ -> }
|
var onFrequencyPicked: (num: Int, den: Int) -> Unit = { _, _ -> }
|
||||||
|
|
||||||
constructor() : this(1, 1)
|
constructor() : this(1, 1)
|
||||||
|
|
||||||
override fun onDestroyView() {
|
|
||||||
super.onDestroyView()
|
|
||||||
_binding = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
_binding = FrequencyPickerDialogBinding.inflate(LayoutInflater.from(requireActivity()))
|
val inflater = LayoutInflater.from(requireActivity())
|
||||||
|
contentView = inflater.inflate(R.layout.frequency_picker_dialog, null)
|
||||||
|
|
||||||
addBeforeAfterText(
|
addBeforeAfterText(
|
||||||
this.getString(R.string.every_x_days),
|
this.getString(R.string.every_x_days),
|
||||||
binding.everyXDaysContainer
|
contentView.everyXDaysContainer
|
||||||
)
|
)
|
||||||
|
|
||||||
addBeforeAfterText(
|
addBeforeAfterText(
|
||||||
this.getString(R.string.x_times_per_week),
|
this.getString(R.string.x_times_per_week),
|
||||||
binding.xTimesPerWeekContainer
|
contentView.xTimesPerWeekContainer
|
||||||
)
|
)
|
||||||
|
|
||||||
addBeforeAfterText(
|
addBeforeAfterText(
|
||||||
this.getString(R.string.x_times_per_month),
|
this.getString(R.string.x_times_per_month),
|
||||||
binding.xTimesPerMonthContainer
|
contentView.xTimesPerMonthContainer
|
||||||
)
|
)
|
||||||
|
|
||||||
addBeforeAfterText(
|
addBeforeAfterText(
|
||||||
this.getString(R.string.x_times_per_y_days),
|
this.getString(R.string.x_times_per_y_days),
|
||||||
binding.xTimesPerYDaysContainer
|
contentView.xTimesPerYDaysContainer
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.everyDayRadioButton.setOnClickListener {
|
contentView.everyDayRadioButton.setOnClickListener {
|
||||||
check(binding.everyDayRadioButton)
|
check(contentView.everyDayRadioButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.everyXDaysRadioButton.setOnClickListener {
|
contentView.everyXDaysRadioButton.setOnClickListener {
|
||||||
check(binding.everyXDaysRadioButton)
|
check(contentView.everyXDaysRadioButton)
|
||||||
val everyXDaysTextView = binding.everyXDaysTextView
|
val everyXDaysTextView = contentView.everyXDaysTextView
|
||||||
selectInputField(everyXDaysTextView)
|
selectInputField(everyXDaysTextView)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.everyXDaysTextView.setOnFocusChangeListener { v, hasFocus ->
|
contentView.everyXDaysTextView.setOnFocusChangeListener { v, hasFocus ->
|
||||||
if (hasFocus) check(binding.everyXDaysRadioButton)
|
if (hasFocus) check(contentView.everyXDaysRadioButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.xTimesPerWeekRadioButton.setOnClickListener {
|
contentView.xTimesPerWeekRadioButton.setOnClickListener {
|
||||||
check(binding.xTimesPerWeekRadioButton)
|
check(contentView.xTimesPerWeekRadioButton)
|
||||||
selectInputField(binding.xTimesPerWeekTextView)
|
selectInputField(contentView.xTimesPerWeekTextView)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.xTimesPerWeekTextView.setOnFocusChangeListener { v, hasFocus ->
|
contentView.xTimesPerWeekTextView.setOnFocusChangeListener { v, hasFocus ->
|
||||||
if (hasFocus) check(binding.xTimesPerWeekRadioButton)
|
if (hasFocus) check(contentView.xTimesPerWeekRadioButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.xTimesPerMonthRadioButton.setOnClickListener {
|
contentView.xTimesPerMonthRadioButton.setOnClickListener {
|
||||||
check(binding.xTimesPerMonthRadioButton)
|
check(contentView.xTimesPerMonthRadioButton)
|
||||||
selectInputField(binding.xTimesPerMonthTextView)
|
selectInputField(contentView.xTimesPerMonthTextView)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.xTimesPerMonthTextView.setOnFocusChangeListener { v, hasFocus ->
|
contentView.xTimesPerMonthTextView.setOnFocusChangeListener { v, hasFocus ->
|
||||||
if (hasFocus) check(binding.xTimesPerMonthRadioButton)
|
if (hasFocus) check(contentView.xTimesPerMonthRadioButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.xTimesPerYDaysRadioButton.setOnClickListener {
|
contentView.xTimesPerYDaysRadioButton.setOnClickListener {
|
||||||
check(binding.xTimesPerYDaysRadioButton)
|
check(contentView.xTimesPerYDaysRadioButton)
|
||||||
selectInputField(binding.xTimesPerYDaysXTextView)
|
selectInputField(contentView.xTimesPerYDaysXTextView)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.xTimesPerYDaysXTextView.setOnFocusChangeListener { v, hasFocus ->
|
contentView.xTimesPerYDaysXTextView.setOnFocusChangeListener { v, hasFocus ->
|
||||||
if (hasFocus) check(binding.xTimesPerYDaysRadioButton)
|
if (hasFocus) check(contentView.xTimesPerYDaysRadioButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.xTimesPerYDaysYTextView.setOnFocusChangeListener { v, hasFocus ->
|
contentView.xTimesPerYDaysYTextView.setOnFocusChangeListener { v, hasFocus ->
|
||||||
if (hasFocus) check(binding.xTimesPerYDaysRadioButton)
|
if (hasFocus) check(contentView.xTimesPerYDaysRadioButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
return AlertDialog.Builder(requireActivity())
|
return AlertDialog.Builder(requireActivity())
|
||||||
.setView(binding.root)
|
.setView(contentView)
|
||||||
.setPositiveButton(R.string.save) { _, _ -> onSaveClicked() }
|
.setPositiveButton(R.string.save) { _, _ -> onSaveClicked() }
|
||||||
.create()
|
.create()
|
||||||
}
|
}
|
||||||
@@ -138,35 +134,31 @@ class FrequencyPickerDialog(
|
|||||||
var numerator = 1
|
var numerator = 1
|
||||||
var denominator = 1
|
var denominator = 1
|
||||||
when {
|
when {
|
||||||
binding.everyDayRadioButton.isChecked -> {
|
contentView.everyDayRadioButton.isChecked -> {
|
||||||
// NOP
|
// NOP
|
||||||
}
|
}
|
||||||
|
contentView.everyXDaysRadioButton.isChecked -> {
|
||||||
binding.everyXDaysRadioButton.isChecked -> {
|
if (contentView.everyXDaysTextView.text.isNotEmpty()) {
|
||||||
if (binding.everyXDaysTextView.text.isNotEmpty()) {
|
denominator = Integer.parseInt(contentView.everyXDaysTextView.text.toString())
|
||||||
denominator = Integer.parseInt(binding.everyXDaysTextView.text.toString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
contentView.xTimesPerWeekRadioButton.isChecked -> {
|
||||||
binding.xTimesPerWeekRadioButton.isChecked -> {
|
if (contentView.xTimesPerWeekTextView.text.isNotEmpty()) {
|
||||||
if (binding.xTimesPerWeekTextView.text.isNotEmpty()) {
|
numerator = Integer.parseInt(contentView.xTimesPerWeekTextView.text.toString())
|
||||||
numerator = Integer.parseInt(binding.xTimesPerWeekTextView.text.toString())
|
|
||||||
denominator = 7
|
denominator = 7
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
contentView.xTimesPerYDaysRadioButton.isChecked -> {
|
||||||
binding.xTimesPerYDaysRadioButton.isChecked -> {
|
if (contentView.xTimesPerYDaysXTextView.text.isNotEmpty() && contentView.xTimesPerYDaysYTextView.text.isNotEmpty()) {
|
||||||
if (binding.xTimesPerYDaysXTextView.text.isNotEmpty() && binding.xTimesPerYDaysYTextView.text.isNotEmpty()) {
|
|
||||||
numerator =
|
numerator =
|
||||||
Integer.parseInt(binding.xTimesPerYDaysXTextView.text.toString())
|
Integer.parseInt(contentView.xTimesPerYDaysXTextView.text.toString())
|
||||||
denominator =
|
denominator =
|
||||||
Integer.parseInt(binding.xTimesPerYDaysYTextView.text.toString())
|
Integer.parseInt(contentView.xTimesPerYDaysYTextView.text.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
if (binding.xTimesPerMonthTextView.text.isNotEmpty()) {
|
if (contentView.xTimesPerMonthTextView.text.isNotEmpty()) {
|
||||||
numerator = Integer.parseInt(binding.xTimesPerMonthTextView.text.toString())
|
numerator = Integer.parseInt(contentView.xTimesPerMonthTextView.text.toString())
|
||||||
denominator = 30
|
denominator = 30
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,27 +185,27 @@ class FrequencyPickerDialog(
|
|||||||
private fun populateViews() {
|
private fun populateViews() {
|
||||||
uncheckAll()
|
uncheckAll()
|
||||||
if (freqDenominator == 30 || freqDenominator == 31) {
|
if (freqDenominator == 30 || freqDenominator == 31) {
|
||||||
binding.xTimesPerMonthRadioButton.isChecked = true
|
contentView.xTimesPerMonthRadioButton.isChecked = true
|
||||||
binding.xTimesPerMonthTextView.setText(freqNumerator.toString())
|
contentView.xTimesPerMonthTextView.setText(freqNumerator.toString())
|
||||||
selectInputField(binding.xTimesPerMonthTextView)
|
selectInputField(contentView.xTimesPerMonthTextView)
|
||||||
} else {
|
} else {
|
||||||
if (freqNumerator == 1) {
|
if (freqNumerator == 1) {
|
||||||
if (freqDenominator == 1) {
|
if (freqDenominator == 1) {
|
||||||
binding.everyDayRadioButton.isChecked = true
|
contentView.everyDayRadioButton.isChecked = true
|
||||||
} else {
|
} else {
|
||||||
binding.everyXDaysRadioButton.isChecked = true
|
contentView.everyXDaysRadioButton.isChecked = true
|
||||||
binding.everyXDaysTextView.setText(freqDenominator.toString())
|
contentView.everyXDaysTextView.setText(freqDenominator.toString())
|
||||||
selectInputField(binding.everyXDaysTextView)
|
selectInputField(contentView.everyXDaysTextView)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (freqDenominator == 7) {
|
if (freqDenominator == 7) {
|
||||||
binding.xTimesPerWeekRadioButton.isChecked = true
|
contentView.xTimesPerWeekRadioButton.isChecked = true
|
||||||
binding.xTimesPerWeekTextView.setText(freqNumerator.toString())
|
contentView.xTimesPerWeekTextView.setText(freqNumerator.toString())
|
||||||
selectInputField(binding.xTimesPerWeekTextView)
|
selectInputField(contentView.xTimesPerWeekTextView)
|
||||||
} else {
|
} else {
|
||||||
binding.xTimesPerYDaysRadioButton.isChecked = true
|
contentView.xTimesPerYDaysRadioButton.isChecked = true
|
||||||
binding.xTimesPerYDaysXTextView.setText(freqNumerator.toString())
|
contentView.xTimesPerYDaysXTextView.setText(freqNumerator.toString())
|
||||||
binding.xTimesPerYDaysYTextView.setText(freqDenominator.toString())
|
contentView.xTimesPerYDaysYTextView.setText(freqDenominator.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,10 +216,10 @@ class FrequencyPickerDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun uncheckAll() {
|
private fun uncheckAll() {
|
||||||
binding.everyDayRadioButton.isChecked = false
|
contentView.everyDayRadioButton.isChecked = false
|
||||||
binding.everyXDaysRadioButton.isChecked = false
|
contentView.everyXDaysRadioButton.isChecked = false
|
||||||
binding.xTimesPerWeekRadioButton.isChecked = false
|
contentView.xTimesPerWeekRadioButton.isChecked = false
|
||||||
binding.xTimesPerMonthRadioButton.isChecked = false
|
contentView.xTimesPerMonthRadioButton.isChecked = false
|
||||||
binding.xTimesPerYDaysRadioButton.isChecked = false
|
contentView.xTimesPerYDaysRadioButton.isChecked = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.android.datetimepicker.time.RadialPickerLayout
|
import com.android.datetimepicker.time.RadialPickerLayout
|
||||||
import com.android.datetimepicker.time.TimePickerDialog
|
import com.android.datetimepicker.time.TimePickerDialog
|
||||||
|
import kotlinx.android.synthetic.main.activity_edit_habit.nameInput
|
||||||
|
import kotlinx.android.synthetic.main.activity_edit_habit.notesInput
|
||||||
|
import kotlinx.android.synthetic.main.activity_edit_habit.questionInput
|
||||||
|
import kotlinx.android.synthetic.main.activity_edit_habit.targetInput
|
||||||
|
import kotlinx.android.synthetic.main.activity_edit_habit.unitInput
|
||||||
import org.isoron.platform.gui.toInt
|
import org.isoron.platform.gui.toInt
|
||||||
import org.isoron.uhabits.HabitsApplication
|
import org.isoron.uhabits.HabitsApplication
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
@@ -266,9 +271,9 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
habit.copyFrom(original)
|
habit.copyFrom(original)
|
||||||
}
|
}
|
||||||
|
|
||||||
habit.name = binding.nameInput.text.trim().toString()
|
habit.name = nameInput.text.trim().toString()
|
||||||
habit.question = binding.questionInput.text.trim().toString()
|
habit.question = questionInput.text.trim().toString()
|
||||||
habit.description = binding.notesInput.text.trim().toString()
|
habit.description = notesInput.text.trim().toString()
|
||||||
habit.color = color
|
habit.color = color
|
||||||
if (reminderHour >= 0) {
|
if (reminderHour >= 0) {
|
||||||
habit.reminder = Reminder(reminderHour, reminderMin, reminderDays)
|
habit.reminder = Reminder(reminderHour, reminderMin, reminderDays)
|
||||||
@@ -278,9 +283,9 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
habit.frequency = Frequency(freqNum, freqDen)
|
habit.frequency = Frequency(freqNum, freqDen)
|
||||||
if (habitType == HabitType.NUMERICAL) {
|
if (habitType == HabitType.NUMERICAL) {
|
||||||
habit.targetValue = binding.targetInput.text.toString().toDouble()
|
habit.targetValue = targetInput.text.toString().toDouble()
|
||||||
habit.targetType = targetType
|
habit.targetType = targetType
|
||||||
habit.unit = binding.unitInput.text.trim().toString()
|
habit.unit = unitInput.text.trim().toString()
|
||||||
}
|
}
|
||||||
habit.type = habitType
|
habit.type = habitType
|
||||||
|
|
||||||
@@ -303,13 +308,13 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun validate(): Boolean {
|
private fun validate(): Boolean {
|
||||||
var isValid = true
|
var isValid = true
|
||||||
if (binding.nameInput.text.isEmpty()) {
|
if (nameInput.text.isEmpty()) {
|
||||||
binding.nameInput.error = getFormattedValidationError(R.string.validation_cannot_be_blank)
|
nameInput.error = getFormattedValidationError(R.string.validation_cannot_be_blank)
|
||||||
isValid = false
|
isValid = false
|
||||||
}
|
}
|
||||||
if (habitType == HabitType.NUMERICAL) {
|
if (habitType == HabitType.NUMERICAL) {
|
||||||
if (binding.targetInput.text.isEmpty()) {
|
if (targetInput.text.isEmpty()) {
|
||||||
binding.targetInput.error = getString(R.string.validation_cannot_be_blank)
|
targetInput.error = getString(R.string.validation_cannot_be_blank)
|
||||||
isValid = false
|
isValid = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits
|
package org.isoron.uhabits
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.spy
|
||||||
import org.isoron.uhabits.core.commands.CommandRunner
|
import org.isoron.uhabits.core.commands.CommandRunner
|
||||||
import org.isoron.uhabits.core.models.HabitList
|
import org.isoron.uhabits.core.models.HabitList
|
||||||
import org.isoron.uhabits.core.models.memory.MemoryModelFactory
|
import org.isoron.uhabits.core.models.memory.MemoryModelFactory
|
||||||
@@ -30,7 +31,6 @@ import org.junit.Before
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.junit.MockitoJUnitRunner
|
import org.mockito.junit.MockitoJUnitRunner
|
||||||
import org.mockito.kotlin.spy
|
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner::class)
|
@RunWith(MockitoJUnitRunner::class)
|
||||||
open class BaseAndroidJVMTest {
|
open class BaseAndroidJVMTest {
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.receivers
|
package org.isoron.uhabits.receivers
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||||
import org.isoron.uhabits.BaseAndroidJVMTest
|
import org.isoron.uhabits.BaseAndroidJVMTest
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.isoron.uhabits.core.models.Timestamp
|
import org.isoron.uhabits.core.models.Timestamp
|
||||||
@@ -25,9 +28,6 @@ import org.isoron.uhabits.core.preferences.Preferences
|
|||||||
import org.isoron.uhabits.core.reminders.ReminderScheduler
|
import org.isoron.uhabits.core.reminders.ReminderScheduler
|
||||||
import org.isoron.uhabits.core.ui.NotificationTray
|
import org.isoron.uhabits.core.ui.NotificationTray
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.verifyNoMoreInteractions
|
|
||||||
|
|
||||||
class ReminderControllerTest : BaseAndroidJVMTest() {
|
class ReminderControllerTest : BaseAndroidJVMTest() {
|
||||||
private lateinit var controller: ReminderController
|
private lateinit var controller: ReminderController
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ kotlin {
|
|||||||
implementation("org.xerial:sqlite-jdbc:3.40.0.0")
|
implementation("org.xerial:sqlite-jdbc:3.40.0.0")
|
||||||
implementation("org.hamcrest:hamcrest:2.2")
|
implementation("org.hamcrest:hamcrest:2.2")
|
||||||
implementation("org.apache.commons:commons-io:1.3.2")
|
implementation("org.apache.commons:commons-io:1.3.2")
|
||||||
implementation("org.mockito.kotlin:mockito-kotlin:2.2.11")
|
implementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
|
||||||
implementation("org.junit.jupiter:junit-jupiter:5.8.1")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ class JavaUserFile(val path: Path) : UserFile {
|
|||||||
@Suppress("NewApi")
|
@Suppress("NewApi")
|
||||||
class JavaFileOpener : FileOpener {
|
class JavaFileOpener : FileOpener {
|
||||||
override fun openUserFile(path: String): UserFile {
|
override fun openUserFile(path: String): UserFile {
|
||||||
val resolvedPath = Paths.get("/tmp/$path")
|
val path = Paths.get("/tmp/$path")
|
||||||
return JavaUserFile(resolvedPath)
|
return JavaUserFile(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openResourceFile(path: String): ResourceFile {
|
override fun openResourceFile(path: String): ResourceFile {
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ internal class Tokenizer(
|
|||||||
if (s == null || s.isEmpty()) {
|
if (s == null || s.isEmpty()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (s[0].code != mCurrent) {
|
if (s[0].toInt() != mCurrent) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
val len = s.length
|
val len = s.length
|
||||||
mStream.mark(len - 1)
|
mStream.mark(len - 1)
|
||||||
for (n in 1 until len) {
|
for (n in 1 until len) {
|
||||||
val value = mStream.read()
|
val value = mStream.read()
|
||||||
if (value != s[n].code) {
|
if (value != s[n].toInt()) {
|
||||||
mStream.reset()
|
mStream.reset()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -68,9 +68,10 @@ object SQLParser {
|
|||||||
private const val STATE_COMMENT_BLOCK = 3
|
private const val STATE_COMMENT_BLOCK = 3
|
||||||
|
|
||||||
fun parse(stream: InputStream): List<String> {
|
fun parse(stream: InputStream): List<String> {
|
||||||
|
val buffer = BufferedInputStream(stream)
|
||||||
val commands: MutableList<String> = ArrayList()
|
val commands: MutableList<String> = ArrayList()
|
||||||
val sb = StringBuffer()
|
val sb = StringBuffer()
|
||||||
BufferedInputStream(stream).use { buffer ->
|
buffer.use { buffer ->
|
||||||
val tokenizer = Tokenizer(buffer)
|
val tokenizer = Tokenizer(buffer)
|
||||||
var state = STATE_NONE
|
var state = STATE_NONE
|
||||||
while (tokenizer.hasNext()) {
|
while (tokenizer.hasNext()) {
|
||||||
|
|||||||
@@ -25,5 +25,5 @@ fun interface Task {
|
|||||||
fun onAttached(runner: TaskRunner) {}
|
fun onAttached(runner: TaskRunner) {}
|
||||||
fun onPostExecute() {}
|
fun onPostExecute() {}
|
||||||
fun onPreExecute() {}
|
fun onPreExecute() {}
|
||||||
fun onProgressUpdate(currentPosition: Int) {}
|
fun onProgressUpdate(value: Int) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class HabitListHeader(
|
|||||||
|
|
||||||
repeat(nButtons) { index ->
|
repeat(nButtons) { index ->
|
||||||
val date = today.minus(nButtons - index - 1)
|
val date = today.minus(nButtons - index - 1)
|
||||||
val name = fmt.shortWeekdayName(date).uppercase()
|
val name = fmt.shortWeekdayName(date).toUpperCase()
|
||||||
val number = date.day.toString()
|
val number = date.day.toString()
|
||||||
|
|
||||||
val x = width - (index + 1) * buttonSize + buttonSize / 2
|
val x = width - (index + 1) * buttonSize + buttonSize / 2
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package org.isoron.platform.gui
|
package org.isoron.platform.gui
|
||||||
|
|
||||||
|
import junit.framework.Assert.fail
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.isoron.platform.io.JavaFileOpener
|
import org.isoron.platform.io.JavaFileOpener
|
||||||
import org.junit.Assert.fail
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.awt.image.BufferedImage
|
import java.awt.image.BufferedImage
|
||||||
import java.awt.image.BufferedImage.TYPE_INT_ARGB
|
import java.awt.image.BufferedImage.TYPE_INT_ARGB
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core
|
package org.isoron.uhabits.core
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.spy
|
||||||
|
import com.nhaarman.mockitokotlin2.validateMockitoUsage
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.isoron.uhabits.core.commands.CommandRunner
|
import org.isoron.uhabits.core.commands.CommandRunner
|
||||||
import org.isoron.uhabits.core.database.Database
|
import org.isoron.uhabits.core.database.Database
|
||||||
@@ -38,8 +40,6 @@ import org.junit.Before
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.junit.MockitoJUnitRunner
|
import org.mockito.junit.MockitoJUnitRunner
|
||||||
import org.mockito.kotlin.spy
|
|
||||||
import org.mockito.kotlin.validateMockitoUsage
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.commands
|
package org.isoron.uhabits.core.commands
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class ArchiveHabitsCommandTest : BaseUnitTest() {
|
class ArchiveHabitsCommandTest : BaseUnitTest() {
|
||||||
private lateinit var command: ArchiveHabitsCommand
|
private lateinit var command: ArchiveHabitsCommand
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.commands
|
package org.isoron.uhabits.core.commands
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -26,7 +27,6 @@ import org.isoron.uhabits.core.models.Reminder
|
|||||||
import org.isoron.uhabits.core.models.WeekdayList
|
import org.isoron.uhabits.core.models.WeekdayList
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class CreateHabitCommandTest : BaseUnitTest() {
|
class CreateHabitCommandTest : BaseUnitTest() {
|
||||||
private lateinit var command: CreateHabitCommand
|
private lateinit var command: CreateHabitCommand
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.commands
|
package org.isoron.uhabits.core.commands
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertEquals
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.models.Entry
|
import org.isoron.uhabits.core.models.Entry
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
@@ -25,7 +26,6 @@ import org.isoron.uhabits.core.models.Timestamp
|
|||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertEquals
|
|
||||||
|
|
||||||
class CreateRepetitionCommandTest : BaseUnitTest() {
|
class CreateRepetitionCommandTest : BaseUnitTest() {
|
||||||
private lateinit var command: CreateRepetitionCommand
|
private lateinit var command: CreateRepetitionCommand
|
||||||
|
|||||||
@@ -23,13 +23,18 @@ import org.hamcrest.MatcherAssert.assertThat
|
|||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.util.*
|
import org.junit.rules.ExpectedException
|
||||||
|
import java.util.LinkedList
|
||||||
|
|
||||||
class DeleteHabitsCommandTest : BaseUnitTest() {
|
class DeleteHabitsCommandTest : BaseUnitTest() {
|
||||||
private lateinit var command: DeleteHabitsCommand
|
private lateinit var command: DeleteHabitsCommand
|
||||||
private lateinit var selected: LinkedList<Habit>
|
private lateinit var selected: LinkedList<Habit>
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
var thrown = ExpectedException.none()!!
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.commands
|
package org.isoron.uhabits.core.commands
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class UnarchiveHabitsCommandTest : BaseUnitTest() {
|
class UnarchiveHabitsCommandTest : BaseUnitTest() {
|
||||||
private lateinit var command: UnarchiveHabitsCommand
|
private lateinit var command: UnarchiveHabitsCommand
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.database
|
package org.isoron.uhabits.core.database
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertNull
|
||||||
import org.apache.commons.lang3.builder.EqualsBuilder
|
import org.apache.commons.lang3.builder.EqualsBuilder
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder
|
import org.apache.commons.lang3.builder.HashCodeBuilder
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder
|
import org.apache.commons.lang3.builder.ToStringBuilder
|
||||||
@@ -26,7 +27,6 @@ import org.hamcrest.core.IsEqual.equalTo
|
|||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertNull
|
|
||||||
|
|
||||||
class RepositoryTest : BaseUnitTest() {
|
class RepositoryTest : BaseUnitTest() {
|
||||||
private lateinit var repository: Repository<ThingRecord>
|
private lateinit var repository: Repository<ThingRecord>
|
||||||
|
|||||||
@@ -27,10 +27,13 @@ import org.isoron.uhabits.core.database.Database
|
|||||||
import org.isoron.uhabits.core.database.MigrationHelper
|
import org.isoron.uhabits.core.database.MigrationHelper
|
||||||
import org.isoron.uhabits.core.models.sqlite.SQLModelFactory
|
import org.isoron.uhabits.core.models.sqlite.SQLModelFactory
|
||||||
import org.isoron.uhabits.core.test.HabitFixtures
|
import org.isoron.uhabits.core.test.HabitFixtures
|
||||||
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.jupiter.api.Assertions.assertThrows
|
import org.junit.rules.ExpectedException
|
||||||
|
|
||||||
class Version22Test : BaseUnitTest() {
|
class Version22Test : BaseUnitTest() {
|
||||||
|
@get:Rule
|
||||||
|
var exception = ExpectedException.none()!!
|
||||||
private lateinit var db: Database
|
private lateinit var db: Database
|
||||||
private lateinit var helper: MigrationHelper
|
private lateinit var helper: MigrationHelper
|
||||||
|
|
||||||
@@ -73,8 +76,8 @@ class Version22Test : BaseUnitTest() {
|
|||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testDisallowNewRepsWithInvalidRef() {
|
fun testDisallowNewRepsWithInvalidRef() {
|
||||||
helper.migrateTo(22)
|
helper.migrateTo(22)
|
||||||
val exception = assertThrows(java.lang.RuntimeException::class.java) { db.execute("insert into Repetitions(habit, timestamp, value) values (99999, 100, 2)") }
|
exception.expectMessage(Matchers.containsString("SQLITE_CONSTRAINT"))
|
||||||
assertThat(exception.message, Matchers.containsString("SQLITE_CONSTRAINT"))
|
db.execute("insert into Repetitions(habit, timestamp, value) values (99999, 100, 2)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -94,14 +97,10 @@ class Version22Test : BaseUnitTest() {
|
|||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testDisallowNullTimestamp() {
|
fun testDisallowNullTimestamp() {
|
||||||
helper.migrateTo(22)
|
helper.migrateTo(22)
|
||||||
|
exception.expectMessage(Matchers.containsString("SQLITE_CONSTRAINT"))
|
||||||
val exception = assertThrows(java.lang.RuntimeException::class.java) {
|
|
||||||
db.execute("insert into Repetitions(habit, value) " + "values (0, 2)")
|
db.execute("insert into Repetitions(habit, value) " + "values (0, 2)")
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(exception.message, Matchers.containsString("SQLITE_CONSTRAINT"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testRemoveRepetitionsWithNullHabit() {
|
fun testRemoveRepetitionsWithNullHabit() {
|
||||||
@@ -119,14 +118,10 @@ class Version22Test : BaseUnitTest() {
|
|||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testDisallowNullHabit() {
|
fun testDisallowNullHabit() {
|
||||||
helper.migrateTo(22)
|
helper.migrateTo(22)
|
||||||
|
exception.expectMessage(Matchers.containsString("SQLITE_CONSTRAINT"))
|
||||||
val exception = assertThrows(java.lang.RuntimeException::class.java) {
|
|
||||||
db.execute("insert into Repetitions(timestamp, value) " + "values (5, 2)")
|
db.execute("insert into Repetitions(timestamp, value) " + "values (5, 2)")
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(exception.message, Matchers.containsString("SQLITE_CONSTRAINT"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testRemoveDuplicateRepetitions() {
|
fun testRemoveDuplicateRepetitions() {
|
||||||
@@ -147,11 +142,7 @@ class Version22Test : BaseUnitTest() {
|
|||||||
fun testDisallowNewDuplicateTimestamps() {
|
fun testDisallowNewDuplicateTimestamps() {
|
||||||
helper.migrateTo(22)
|
helper.migrateTo(22)
|
||||||
db.execute("insert into repetitions(habit, timestamp, value)values (0, 100, 2)")
|
db.execute("insert into repetitions(habit, timestamp, value)values (0, 100, 2)")
|
||||||
|
exception.expectMessage(Matchers.containsString("SQLITE_CONSTRAINT"))
|
||||||
val exception = assertThrows(java.lang.RuntimeException::class.java) {
|
|
||||||
db.execute("insert into repetitions(habit, timestamp, value)values (0, 100, 5)")
|
db.execute("insert into repetitions(habit, timestamp, value)values (0, 100, 5)")
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(exception.message, Matchers.containsString("SQLITE_CONSTRAINT"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.io
|
package org.isoron.uhabits.core.io
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -28,9 +29,8 @@ import java.io.File
|
|||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.util.*
|
import java.util.LinkedList
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class HabitsCSVExporterTest : BaseUnitTest() {
|
class HabitsCSVExporterTest : BaseUnitTest() {
|
||||||
private lateinit var baseDir: File
|
private lateinit var baseDir: File
|
||||||
@@ -102,8 +102,9 @@ class HabitsCSVExporterTest : BaseUnitTest() {
|
|||||||
private fun assertAbsolutePathExists(s: String) {
|
private fun assertAbsolutePathExists(s: String) {
|
||||||
val file = File(s)
|
val file = File(s)
|
||||||
assertTrue(
|
assertTrue(
|
||||||
String.format("File %s should exist", file.absolutePath)
|
String.format("File %s should exist", file.absolutePath),
|
||||||
) { file.exists() }
|
file.exists()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assertFileAndReferenceAreEqual(s: String) {
|
private fun assertFileAndReferenceAreEqual(s: String) {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.io
|
package org.isoron.uhabits.core.io
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.core.IsEqual.equalTo
|
import org.hamcrest.core.IsEqual.equalTo
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -32,8 +34,6 @@ import org.junit.Before
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class ImportTest : BaseUnitTest() {
|
class ImportTest : BaseUnitTest() {
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
@@ -18,19 +18,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.models
|
package org.isoron.uhabits.core.models
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertEquals
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertNull
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.CoreMatchers.not
|
import org.hamcrest.CoreMatchers.not
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.junit.Assert.assertThrows
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.junit.rules.ExpectedException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
import kotlin.test.assertEquals
|
import java.util.ArrayList
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertNull
|
|
||||||
|
|
||||||
class HabitListTest : BaseUnitTest() {
|
class HabitListTest : BaseUnitTest() {
|
||||||
|
@get:Rule
|
||||||
|
var thrown = ExpectedException.none()!!
|
||||||
private lateinit var habitsArray: ArrayList<Habit>
|
private lateinit var habitsArray: ArrayList<Habit>
|
||||||
private lateinit var activeHabits: HabitList
|
private lateinit var activeHabits: HabitList
|
||||||
private lateinit var reminderHabits: HabitList
|
private lateinit var reminderHabits: HabitList
|
||||||
@@ -169,10 +173,9 @@ class HabitListTest : BaseUnitTest() {
|
|||||||
fun testReorder_withInvalidArguments() {
|
fun testReorder_withInvalidArguments() {
|
||||||
val h1 = habitsArray[0]
|
val h1 = habitsArray[0]
|
||||||
val h2 = fixtures.createEmptyHabit()
|
val h2 = fixtures.createEmptyHabit()
|
||||||
assertThrows(IllegalArgumentException::class.java) {
|
thrown.expect(IllegalArgumentException::class.java)
|
||||||
habitList.reorder(h1, h2)
|
habitList.reorder(h1, h2)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testOrder_inherit() {
|
fun testOrder_inherit() {
|
||||||
@@ -232,28 +235,25 @@ class HabitListTest : BaseUnitTest() {
|
|||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testAdd_withFilteredList() {
|
fun testAdd_withFilteredList() {
|
||||||
assertThrows(IllegalStateException::class.java) {
|
thrown.expect(IllegalStateException::class.java)
|
||||||
activeHabits.add(fixtures.createEmptyHabit())
|
activeHabits.add(fixtures.createEmptyHabit())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testRemove_onFilteredList() {
|
fun testRemove_onFilteredList() {
|
||||||
assertThrows(IllegalStateException::class.java) {
|
thrown.expect(IllegalStateException::class.java)
|
||||||
activeHabits.remove(fixtures.createEmptyHabit())
|
activeHabits.remove(fixtures.createEmptyHabit())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testReorder_onFilteredList() {
|
fun testReorder_onFilteredList() {
|
||||||
val h1 = fixtures.createEmptyHabit()
|
val h1 = fixtures.createEmptyHabit()
|
||||||
val h2 = fixtures.createEmptyHabit()
|
val h2 = fixtures.createEmptyHabit()
|
||||||
assertThrows(IllegalStateException::class.java) {
|
thrown.expect(IllegalStateException::class.java)
|
||||||
activeHabits.reorder(h1, h2)
|
activeHabits.reorder(h1, h2)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
@@ -261,8 +261,7 @@ class HabitListTest : BaseUnitTest() {
|
|||||||
habitList.primaryOrder = HabitList.Order.BY_SCORE_DESC
|
habitList.primaryOrder = HabitList.Order.BY_SCORE_DESC
|
||||||
val h1 = habitsArray[1]
|
val h1 = habitsArray[1]
|
||||||
val h2 = habitsArray[2]
|
val h2 = habitsArray[2]
|
||||||
assertThrows(IllegalStateException::class.java) {
|
thrown.expect(IllegalStateException::class.java)
|
||||||
habitList.reorder(h1, h2)
|
habitList.reorder(h1, h2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,18 +18,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.models
|
package org.isoron.uhabits.core.models
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.CoreMatchers.`is`
|
import org.hamcrest.CoreMatchers.`is`
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
|
||||||
import org.hamcrest.core.IsEqual.equalTo
|
import org.hamcrest.core.IsEqual.equalTo
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
||||||
import org.junit.Assert.assertNotEquals
|
import org.junit.Assert.assertNotEquals
|
||||||
|
import org.junit.Assert.assertThat
|
||||||
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertEquals
|
import org.junit.rules.ExpectedException
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class HabitTest : BaseUnitTest() {
|
class HabitTest : BaseUnitTest() {
|
||||||
|
@get:Rule
|
||||||
|
val exception = ExpectedException.none()!!
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
@@ -52,7 +55,7 @@ class HabitTest : BaseUnitTest() {
|
|||||||
model.reminder = Reminder(8, 30, WeekdayList(1))
|
model.reminder = Reminder(8, 30, WeekdayList(1))
|
||||||
val habit = modelFactory.buildHabit()
|
val habit = modelFactory.buildHabit()
|
||||||
habit.copyFrom(model)
|
habit.copyFrom(model)
|
||||||
assertEquals(habit.isArchived, model.isArchived)
|
assertTrue(habit.isArchived == model.isArchived)
|
||||||
assertThat(habit.isArchived, `is`(model.isArchived))
|
assertThat(habit.isArchived, `is`(model.isArchived))
|
||||||
assertThat(habit.color, `is`(model.color))
|
assertThat(habit.color, `is`(model.color))
|
||||||
assertThat(habit.frequency, equalTo(model.frequency))
|
assertThat(habit.frequency, equalTo(model.frequency))
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.models
|
package org.isoron.uhabits.core.models
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.number.IsCloseTo
|
import org.hamcrest.number.IsCloseTo
|
||||||
import org.hamcrest.number.OrderingComparison
|
import org.hamcrest.number.OrderingComparison
|
||||||
@@ -27,7 +28,6 @@ import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
open class BaseScoreListTest : BaseUnitTest() {
|
open class BaseScoreListTest : BaseUnitTest() {
|
||||||
protected lateinit var habit: Habit
|
protected lateinit var habit: Habit
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.models
|
package org.isoron.uhabits.core.models
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.Matchers.equalTo
|
import org.hamcrest.Matchers.equalTo
|
||||||
import org.hamcrest.Matchers.greaterThan
|
import org.hamcrest.Matchers.greaterThan
|
||||||
@@ -25,8 +27,6 @@ import org.hamcrest.Matchers.lessThan
|
|||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class TimestampTest : BaseUnitTest() {
|
class TimestampTest : BaseUnitTest() {
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.models
|
package org.isoron.uhabits.core.models
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class WeekdayListTest : BaseUnitTest() {
|
class WeekdayListTest : BaseUnitTest() {
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.core.models.sqlite
|
package org.isoron.uhabits.core.models.sqlite
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertEquals
|
||||||
|
import junit.framework.Assert.assertNull
|
||||||
import org.isoron.uhabits.core.BaseUnitTest.Companion.buildMemoryDatabase
|
import org.isoron.uhabits.core.BaseUnitTest.Companion.buildMemoryDatabase
|
||||||
import org.isoron.uhabits.core.database.Repository
|
import org.isoron.uhabits.core.database.Repository
|
||||||
import org.isoron.uhabits.core.models.Entry
|
import org.isoron.uhabits.core.models.Entry
|
||||||
@@ -28,8 +30,6 @@ import org.isoron.uhabits.core.models.sqlite.records.EntryRecord
|
|||||||
import org.isoron.uhabits.core.utils.DateUtils
|
import org.isoron.uhabits.core.utils.DateUtils
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertEquals
|
|
||||||
import kotlin.test.assertNull
|
|
||||||
|
|
||||||
class SQLiteEntryListTest {
|
class SQLiteEntryListTest {
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.models.sqlite
|
package org.isoron.uhabits.core.models.sqlite
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import junit.framework.Assert.assertNull
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -31,14 +34,14 @@ import org.isoron.uhabits.core.models.Reminder
|
|||||||
import org.isoron.uhabits.core.models.WeekdayList
|
import org.isoron.uhabits.core.models.WeekdayList
|
||||||
import org.isoron.uhabits.core.models.sqlite.records.HabitRecord
|
import org.isoron.uhabits.core.models.sqlite.records.HabitRecord
|
||||||
import org.isoron.uhabits.core.test.HabitFixtures
|
import org.isoron.uhabits.core.test.HabitFixtures
|
||||||
import org.junit.Assert.assertThrows
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
import org.junit.rules.ExpectedException
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import kotlin.test.assertNull
|
|
||||||
|
|
||||||
class SQLiteHabitListTest : BaseUnitTest() {
|
class SQLiteHabitListTest : BaseUnitTest() {
|
||||||
|
@get:Rule
|
||||||
|
var exception = ExpectedException.none()!!
|
||||||
private lateinit var repository: Repository<HabitRecord>
|
private lateinit var repository: Repository<HabitRecord>
|
||||||
private var listener: ModelObservable.Listener = mock()
|
private var listener: ModelObservable.Listener = mock()
|
||||||
private lateinit var habitsArray: ArrayList<Habit>
|
private lateinit var habitsArray: ArrayList<Habit>
|
||||||
@@ -87,10 +90,9 @@ class SQLiteHabitListTest : BaseUnitTest() {
|
|||||||
val habit = modelFactory.buildHabit()
|
val habit = modelFactory.buildHabit()
|
||||||
habitList.add(habit)
|
habitList.add(habit)
|
||||||
verify(listener).onModelChange()
|
verify(listener).onModelChange()
|
||||||
assertThrows(IllegalArgumentException::class.java) {
|
exception.expect(IllegalArgumentException::class.java)
|
||||||
habitList.add(habit)
|
habitList.add(habit)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAdd_withId() {
|
fun testAdd_withId() {
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.preferences
|
package org.isoron.uhabits.core.preferences
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertNull
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -26,11 +30,7 @@ import org.isoron.uhabits.core.models.Timestamp.Companion.ZERO
|
|||||||
import org.isoron.uhabits.core.ui.ThemeSwitcher
|
import org.isoron.uhabits.core.ui.ThemeSwitcher
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertNull
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class PreferencesTest : BaseUnitTest() {
|
class PreferencesTest : BaseUnitTest() {
|
||||||
private lateinit var prefs: Preferences
|
private lateinit var prefs: Preferences
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.preferences
|
package org.isoron.uhabits.core.preferences
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertEquals
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -25,9 +28,6 @@ import org.junit.Before
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Arrays
|
import java.util.Arrays
|
||||||
import kotlin.test.assertEquals
|
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class PropertiesStorageTest : BaseUnitTest() {
|
class PropertiesStorageTest : BaseUnitTest() {
|
||||||
private lateinit var storage: PropertiesStorage
|
private lateinit var storage: PropertiesStorage
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.reminders
|
package org.isoron.uhabits.core.reminders
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.eq
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.isoron.uhabits.core.models.Reminder
|
import org.isoron.uhabits.core.models.Reminder
|
||||||
@@ -33,10 +37,6 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.ArgumentMatchers.anyLong
|
import org.mockito.ArgumentMatchers.anyLong
|
||||||
import org.mockito.junit.MockitoJUnitRunner
|
import org.mockito.junit.MockitoJUnitRunner
|
||||||
import org.mockito.kotlin.eq
|
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.tasks
|
package org.isoron.uhabits.core.tasks
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.inOrder
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.JUnit4
|
import org.junit.runners.JUnit4
|
||||||
import org.mockito.kotlin.inOrder
|
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
|
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
class SingleThreadTaskRunnerTest : BaseUnitTest() {
|
class SingleThreadTaskRunnerTest : BaseUnitTest() {
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.ui.screens.habits.list
|
package org.isoron.uhabits.core.ui.screens.habits.list
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.reset
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -26,10 +30,6 @@ import org.isoron.uhabits.core.commands.DeleteHabitsCommand
|
|||||||
import org.isoron.uhabits.core.models.Entry
|
import org.isoron.uhabits.core.models.Entry
|
||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.reset
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.verifyNoMoreInteractions
|
|
||||||
|
|
||||||
class HabitCardListCacheTest : BaseUnitTest() {
|
class HabitCardListCacheTest : BaseUnitTest() {
|
||||||
private lateinit var cache: HabitCardListCache
|
private lateinit var cache: HabitCardListCache
|
||||||
|
|||||||
@@ -18,6 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.ui.screens.habits.list
|
package org.isoron.uhabits.core.ui.screens.habits.list
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertNull
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.Matchers.equalTo
|
import org.hamcrest.Matchers.equalTo
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -25,12 +31,6 @@ import org.isoron.uhabits.core.models.Timestamp
|
|||||||
import org.isoron.uhabits.core.preferences.Preferences
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertNull
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class HintListTest : BaseUnitTest() {
|
class HintListTest : BaseUnitTest() {
|
||||||
private lateinit var hintList: HintList
|
private lateinit var hintList: HintList
|
||||||
|
|||||||
@@ -18,6 +18,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.ui.screens.habits.list
|
package org.isoron.uhabits.core.ui.screens.habits.list
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.KArgumentCaptor
|
||||||
|
import com.nhaarman.mockitokotlin2.any
|
||||||
|
import com.nhaarman.mockitokotlin2.argumentCaptor
|
||||||
|
import com.nhaarman.mockitokotlin2.clearInvocations
|
||||||
|
import com.nhaarman.mockitokotlin2.eq
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.core.IsEqual.equalTo
|
import org.hamcrest.core.IsEqual.equalTo
|
||||||
@@ -29,18 +39,8 @@ import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
|||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.KArgumentCaptor
|
|
||||||
import org.mockito.kotlin.any
|
|
||||||
import org.mockito.kotlin.argumentCaptor
|
|
||||||
import org.mockito.kotlin.clearInvocations
|
|
||||||
import org.mockito.kotlin.eq
|
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class ListHabitsBehaviorTest : BaseUnitTest() {
|
class ListHabitsBehaviorTest : BaseUnitTest() {
|
||||||
private val dirFinder: ListHabitsBehavior.DirFinder = mock()
|
private val dirFinder: ListHabitsBehavior.DirFinder = mock()
|
||||||
|
|||||||
@@ -18,6 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.ui.screens.habits.list
|
package org.isoron.uhabits.core.ui.screens.habits.list
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.KArgumentCaptor
|
||||||
|
import com.nhaarman.mockitokotlin2.any
|
||||||
|
import com.nhaarman.mockitokotlin2.argumentCaptor
|
||||||
|
import com.nhaarman.mockitokotlin2.clearInvocations
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.never
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.Matchers.equalTo
|
import org.hamcrest.Matchers.equalTo
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -26,17 +37,6 @@ import org.isoron.uhabits.core.models.HabitMatcher
|
|||||||
import org.isoron.uhabits.core.preferences.Preferences
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
import org.isoron.uhabits.core.ui.ThemeSwitcher
|
import org.isoron.uhabits.core.ui.ThemeSwitcher
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.KArgumentCaptor
|
|
||||||
import org.mockito.kotlin.any
|
|
||||||
import org.mockito.kotlin.argumentCaptor
|
|
||||||
import org.mockito.kotlin.clearInvocations
|
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.never
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.verifyNoMoreInteractions
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class ListHabitsMenuBehaviorTest : BaseUnitTest() {
|
class ListHabitsMenuBehaviorTest : BaseUnitTest() {
|
||||||
private lateinit var behavior: ListHabitsMenuBehavior
|
private lateinit var behavior: ListHabitsMenuBehavior
|
||||||
|
|||||||
@@ -18,6 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.ui.screens.habits.list
|
package org.isoron.uhabits.core.ui.screens.habits.list
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.KArgumentCaptor
|
||||||
|
import com.nhaarman.mockitokotlin2.argumentCaptor
|
||||||
|
import com.nhaarman.mockitokotlin2.eq
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertNull
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.Matchers.equalTo
|
import org.hamcrest.Matchers.equalTo
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -26,15 +35,6 @@ import org.isoron.uhabits.core.models.PaletteColor
|
|||||||
import org.isoron.uhabits.core.ui.callbacks.OnColorPickedCallback
|
import org.isoron.uhabits.core.ui.callbacks.OnColorPickedCallback
|
||||||
import org.isoron.uhabits.core.ui.callbacks.OnConfirmedCallback
|
import org.isoron.uhabits.core.ui.callbacks.OnConfirmedCallback
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.KArgumentCaptor
|
|
||||||
import org.mockito.kotlin.argumentCaptor
|
|
||||||
import org.mockito.kotlin.eq
|
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
import kotlin.test.assertFalse
|
|
||||||
import kotlin.test.assertNull
|
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class ListHabitsSelectionMenuBehaviorTest : BaseUnitTest() {
|
class ListHabitsSelectionMenuBehaviorTest : BaseUnitTest() {
|
||||||
private val screen: ListHabitsSelectionMenuBehavior.Screen = mock()
|
private val screen: ListHabitsSelectionMenuBehavior.Screen = mock()
|
||||||
|
|||||||
@@ -18,15 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.ui.screens.habits.show
|
package org.isoron.uhabits.core.ui.screens.habits.show
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
|
||||||
class ShowHabitMenuPresenterTest : BaseUnitTest() {
|
class ShowHabitMenuPresenterTest : BaseUnitTest() {
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.core.ui.views
|
package org.isoron.uhabits.core.ui.views
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.reset
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.isoron.platform.gui.assertRenders
|
import org.isoron.platform.gui.assertRenders
|
||||||
import org.isoron.platform.time.DayOfWeek
|
import org.isoron.platform.time.DayOfWeek
|
||||||
@@ -31,10 +35,6 @@ import org.isoron.uhabits.core.ui.views.HistoryChart.Square.HATCHED
|
|||||||
import org.isoron.uhabits.core.ui.views.HistoryChart.Square.OFF
|
import org.isoron.uhabits.core.ui.views.HistoryChart.Square.OFF
|
||||||
import org.isoron.uhabits.core.ui.views.HistoryChart.Square.ON
|
import org.isoron.uhabits.core.ui.views.HistoryChart.Square.ON
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.reset
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.verifyNoMoreInteractions
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class HistoryChartTest {
|
class HistoryChartTest {
|
||||||
|
|||||||
@@ -18,6 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.ui.widgets
|
package org.isoron.uhabits.core.ui.widgets
|
||||||
|
|
||||||
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
|
import com.nhaarman.mockitokotlin2.reset
|
||||||
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.verifyZeroInteractions
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
|
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
|
||||||
import org.isoron.uhabits.core.models.Entry
|
import org.isoron.uhabits.core.models.Entry
|
||||||
@@ -29,11 +34,6 @@ import org.isoron.uhabits.core.ui.NotificationTray
|
|||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.kotlin.mock
|
|
||||||
import org.mockito.kotlin.reset
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import org.mockito.kotlin.verifyZeroInteractions
|
|
||||||
import org.mockito.kotlin.whenever
|
|
||||||
|
|
||||||
class WidgetBehaviorTest : BaseUnitTest() {
|
class WidgetBehaviorTest : BaseUnitTest() {
|
||||||
private lateinit var notificationTray: NotificationTray
|
private lateinit var notificationTray: NotificationTray
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.core.utils
|
package org.isoron.uhabits.core.utils
|
||||||
|
|
||||||
|
import junit.framework.Assert.assertEquals
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
import org.hamcrest.core.IsEqual.equalTo
|
import org.hamcrest.core.IsEqual.equalTo
|
||||||
import org.isoron.uhabits.core.BaseUnitTest
|
import org.isoron.uhabits.core.BaseUnitTest
|
||||||
@@ -39,7 +40,6 @@ import java.util.Calendar
|
|||||||
import java.util.GregorianCalendar
|
import java.util.GregorianCalendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
import kotlin.test.assertEquals
|
|
||||||
|
|
||||||
class DateUtilsTest : BaseUnitTest() {
|
class DateUtilsTest : BaseUnitTest() {
|
||||||
var firstWeekday = Calendar.SUNDAY
|
var firstWeekday = Calendar.SUNDAY
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ dependencies {
|
|||||||
implementation("io.prometheus:simpleclient_httpserver:0.16.0")
|
implementation("io.prometheus:simpleclient_httpserver:0.16.0")
|
||||||
implementation("io.prometheus:simpleclient_hotspot:0.16.0")
|
implementation("io.prometheus:simpleclient_hotspot:0.16.0")
|
||||||
testImplementation("io.ktor:ktor-server-tests:$ktorVersion")
|
testImplementation("io.ktor:ktor-server-tests:$ktorVersion")
|
||||||
testImplementation("org.mockito.kotlin:mockito-kotlin:2.2.11")
|
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
testImplementation(kotlin("test-junit"))
|
testImplementation(kotlin("test-junit"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.sync.app
|
package org.isoron.uhabits.sync.app
|
||||||
|
|
||||||
import org.mockito.kotlin.mock
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
import io.ktor.application.*
|
import io.ktor.application.*
|
||||||
import org.isoron.uhabits.sync.server.*
|
import org.isoron.uhabits.sync.server.*
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.sync.app
|
package org.isoron.uhabits.sync.app
|
||||||
|
|
||||||
import org.mockito.kotlin.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import io.ktor.http.ContentType
|
import io.ktor.http.ContentType
|
||||||
import io.ktor.http.HttpHeaders
|
import io.ktor.http.HttpHeaders
|
||||||
import io.ktor.http.HttpMethod
|
import io.ktor.http.HttpMethod
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.sync.app
|
package org.isoron.uhabits.sync.app
|
||||||
|
|
||||||
import org.mockito.kotlin.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import io.ktor.http.HttpMethod
|
import io.ktor.http.HttpMethod
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.server.testing.handleRequest
|
import io.ktor.server.testing.handleRequest
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.sync.app
|
package org.isoron.uhabits.sync.app
|
||||||
|
|
||||||
import org.mockito.kotlin.verify
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
import org.mockito.kotlin.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.testing.*
|
import io.ktor.server.testing.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|||||||
Reference in New Issue
Block a user