Skip to content

Commit 3763a8d

Browse files
committed
fix tests and code style
1 parent 123e532 commit 3763a8d

File tree

8 files changed

+32
-23
lines changed

8 files changed

+32
-23
lines changed

app/src/androidTest/java/com/example/util/simpletimetracker/ChangeUntrackedTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import com.example.util.simpletimetracker.utils.tryAction
1919
import com.example.util.simpletimetracker.utils.withCardColor
2020
import com.example.util.simpletimetracker.utils.withTag
2121
import dagger.hilt.android.testing.HiltAndroidTest
22+
import kotlinx.coroutines.runBlocking
2223
import org.hamcrest.CoreMatchers.allOf
2324
import org.hamcrest.Matcher
2425
import org.junit.Test
@@ -35,6 +36,7 @@ class ChangeUntrackedTest : BaseUiTest() {
3536
val icon = firstIcon
3637

3738
// Add activity
39+
runBlocking { prefsInteractor.setShowUntrackedInRecords(true) }
3840
testUtils.addActivity(name = name, color = color, icon = icon)
3941

4042
// Open edit view

app/src/androidTest/java/com/example/util/simpletimetracker/MainScreenEmptyTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.example.util.simpletimetracker.utils.longClickOnViewWithId
2121
import com.example.util.simpletimetracker.utils.tryAction
2222
import com.example.util.simpletimetracker.utils.typeTextIntoView
2323
import dagger.hilt.android.testing.HiltAndroidTest
24+
import kotlinx.coroutines.runBlocking
2425
import org.hamcrest.CoreMatchers.allOf
2526
import org.junit.Test
2627
import org.junit.runner.RunWith
@@ -54,6 +55,8 @@ class MainScreenEmptyTest : BaseUiTest() {
5455

5556
@Test
5657
fun recordsEmpty() {
58+
runBlocking { prefsInteractor.setShowUntrackedInRecords(true) }
59+
5760
NavUtils.openRecordsScreen()
5861
checkViewIsDisplayed(
5962
allOf(

app/src/androidTest/java/com/example/util/simpletimetracker/RecordsRangesTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.example.util.simpletimetracker.utils.clickOnViewWithId
1818
import com.example.util.simpletimetracker.utils.clickOnViewWithText
1919
import com.example.util.simpletimetracker.utils.longClickOnViewWithId
2020
import dagger.hilt.android.testing.HiltAndroidTest
21+
import kotlinx.coroutines.runBlocking
2122
import org.hamcrest.CoreMatchers.allOf
2223
import org.hamcrest.CoreMatchers.equalTo
2324
import org.junit.Test
@@ -34,6 +35,8 @@ class RecordsRangesTest : BaseUiTest() {
3435
fun recordsRanges() {
3536
val name = "Test"
3637

38+
runBlocking { prefsInteractor.setShowUntrackedInRecords(true) }
39+
3740
// Add activity
3841
NavUtils.addActivity(name)
3942

app/src/androidTest/java/com/example/util/simpletimetracker/SettingsTest.kt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import com.example.util.simpletimetracker.utils.tryAction
5050
import com.example.util.simpletimetracker.utils.unconstrainedClickOnView
5151
import com.example.util.simpletimetracker.utils.withPluralText
5252
import dagger.hilt.android.testing.HiltAndroidTest
53+
import kotlinx.coroutines.runBlocking
5354
import org.hamcrest.CoreMatchers.allOf
5455
import org.hamcrest.CoreMatchers.equalTo
5556
import org.hamcrest.Matcher
@@ -71,40 +72,40 @@ class SettingsTest : BaseUiTest() {
7172
// Add activity
7273
testUtils.addActivity(name = name, color = color, icon = icon)
7374

74-
// Untracked is shown
75+
// Untracked is not shown
7576
NavUtils.openRecordsScreen()
76-
checkViewIsDisplayed(allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed()))
77+
checkViewDoesNotExist(
78+
allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed())
79+
)
7780

7881
// Change setting
7982
NavUtils.openSettingsScreen()
8083
onView(withId(R.id.checkboxSettingsShowUntracked)).perform(nestedScrollTo())
81-
onView(withId(R.id.checkboxSettingsShowUntracked)).check(matches(isChecked()))
82-
unconstrainedClickOnView(withId(R.id.checkboxSettingsShowUntracked))
8384
onView(withId(R.id.checkboxSettingsShowUntracked)).check(matches(isNotChecked()))
85+
unconstrainedClickOnView(withId(R.id.checkboxSettingsShowUntracked))
86+
onView(withId(R.id.checkboxSettingsShowUntracked)).check(matches(isChecked()))
8487

85-
// Untracked is not shown
88+
// Untracked is shown
8689
NavUtils.openRecordsScreen()
87-
checkViewDoesNotExist(
88-
allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed())
89-
)
90+
checkViewIsDisplayed(allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed()))
9091

9192
// Add record
9293
NavUtils.addRecord(name)
93-
checkViewDoesNotExist(
94-
allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed())
95-
)
94+
checkViewIsDisplayed(allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed()))
9695
checkViewIsDisplayed(allOf(withText(name), isCompletelyDisplayed()))
9796

9897
// Change setting
9998
NavUtils.openSettingsScreen()
10099
onView(withId(R.id.checkboxSettingsShowUntracked)).perform(nestedScrollTo())
101-
onView(withId(R.id.checkboxSettingsShowUntracked)).check(matches(isNotChecked()))
102-
unconstrainedClickOnView(withId(R.id.checkboxSettingsShowUntracked))
103100
onView(withId(R.id.checkboxSettingsShowUntracked)).check(matches(isChecked()))
101+
unconstrainedClickOnView(withId(R.id.checkboxSettingsShowUntracked))
102+
onView(withId(R.id.checkboxSettingsShowUntracked)).check(matches(isNotChecked()))
104103

105-
// Untracked is shown
104+
// Untracked is not shown
106105
NavUtils.openRecordsScreen()
107-
checkViewIsDisplayed(allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed()))
106+
checkViewDoesNotExist(
107+
allOf(withText(R.string.untracked_time_name), isCompletelyDisplayed())
108+
)
108109
checkViewIsDisplayed(allOf(withText(name), isCompletelyDisplayed()))
109110
}
110111

@@ -807,6 +808,7 @@ class SettingsTest : BaseUiTest() {
807808
val name = "Test"
808809

809810
// Add data
811+
runBlocking { prefsInteractor.setShowUntrackedInRecords(true) }
810812
testUtils.addActivity(name)
811813
val calendar = Calendar.getInstance().apply {
812814
setToStartOfDay()

app/src/androidTest/java/com/example/util/simpletimetracker/StatisticsDetailTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ class StatisticsDetailTest : BaseUiTest() {
617617
checkRangeAverages(
618618
rangeId = R.string.statistics_detail_chart_weekly,
619619
checkAverage = false,
620-
averageNonEmpty = "2$hourString 0$minuteString"
620+
averageNonEmpty = "3$hourString 0$minuteString"
621621
)
622622
clickOnViewWithId(R.id.btnStatisticsDetailPrevious)
623623
clickOnChartGrouping(R.string.statistics_detail_chart_daily)

core/src/main/java/com/example/util/simpletimetracker/core/interactor/RemoveRunningRecordMediator.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class RemoveRunningRecordMediator @Inject constructor(
1818
) {
1919

2020
suspend fun removeWithRecordAdd(runningRecord: RunningRecord) {
21-
val duration = TimeUnit.MILLISECONDS.toSeconds(
22-
System.currentTimeMillis() - runningRecord.timeStarted
23-
)
21+
val durationToIgnore = prefsInteractor.getIgnoreShortRecordsDuration()
22+
val duration = TimeUnit.MILLISECONDS
23+
.toSeconds(System.currentTimeMillis() - runningRecord.timeStarted)
2424

25-
if (duration > prefsInteractor.getIgnoreShortRecordsDuration()) {
25+
if (duration > durationToIgnore || durationToIgnore == 0L) {
2626
recordInteractor.add(
2727
typeId = runningRecord.id,
2828
timeStarted = runningRecord.timeStarted,

data_local/src/main/java/com/example/util/simpletimetracker/data_local/repo/RecordRepoImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class RecordRepoImpl @Inject constructor(
3535
}
3636

3737
override suspend fun searchComments(
38-
typeIds: List<Long>, text: String,
38+
typeIds: List<Long>,
39+
text: String,
3940
): List<Record> = withContext(Dispatchers.IO) {
4041
Timber.d("searchComments")
4142
recordDao.searchComments(typeIds, text)

features/feature_change_record/src/main/java/com/example/util/simpletimetracker/feature_change_record/interactor/ChangeRecordViewDataInteractor.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import com.example.util.simpletimetracker.domain.interactor.RecordTagInteractor
77
import com.example.util.simpletimetracker.domain.interactor.RecordTypeInteractor
88
import com.example.util.simpletimetracker.domain.model.Record
99
import com.example.util.simpletimetracker.feature_base_adapter.ViewHolderType
10-
import com.example.util.simpletimetracker.feature_base_adapter.info.InfoViewData
11-
import com.example.util.simpletimetracker.feature_change_record.R
1210
import com.example.util.simpletimetracker.feature_change_record.mapper.ChangeRecordViewDataMapper
1311
import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordCommentViewData
1412
import com.example.util.simpletimetracker.feature_change_record.viewData.ChangeRecordViewData

0 commit comments

Comments
 (0)