mirror of https://github.com/iSoron/uhabits.git
parent
e65ed032a9
commit
bad674dd36
@ -1,37 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "org.isoron.uhabits",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 20202,
|
||||
"versionName": "2.2.2",
|
||||
"outputFile": "uhabits-android-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File",
|
||||
"baselineProfiles": [
|
||||
{
|
||||
"minApi": 28,
|
||||
"maxApi": 30,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/1/uhabits-android-release.dm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minApi": 31,
|
||||
"maxApi": 2147483647,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/0/uhabits-android-release.dm"
|
||||
]
|
||||
}
|
||||
],
|
||||
"minSdkVersionForDexing": 28
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.core.commands
|
||||
|
||||
import org.isoron.uhabits.core.BaseUnitTest
|
||||
import org.isoron.uhabits.core.models.HabitGroup
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class ArchiveHabitGroupsCommandTest : BaseUnitTest() {
|
||||
private lateinit var command: ArchiveHabitGroupsCommand
|
||||
private lateinit var hgr: HabitGroup
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
hgr = groupFixtures.createGroupWithShortHabits()
|
||||
habitGroupList.add(hgr)
|
||||
command = ArchiveHabitGroupsCommand(habitGroupList, listOf(hgr))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExecute() {
|
||||
assertFalse(hgr.isArchived)
|
||||
command.run()
|
||||
assertTrue(hgr.isArchived)
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.core.commands
|
||||
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.isoron.uhabits.core.BaseUnitTest
|
||||
import org.isoron.uhabits.core.models.HabitGroup
|
||||
import org.isoron.uhabits.core.models.PaletteColor
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.LinkedList
|
||||
|
||||
class ChangeHabitGroupColorCommandTest : BaseUnitTest() {
|
||||
private lateinit var command: ChangeHabitGroupColorCommand
|
||||
private lateinit var selected: LinkedList<HabitGroup>
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
selected = LinkedList()
|
||||
for (i in 0..2) {
|
||||
val hgr = groupFixtures.createGroupWithShortHabits()
|
||||
hgr.color = PaletteColor(i + 1)
|
||||
selected.add(hgr)
|
||||
habitGroupList.add(hgr)
|
||||
}
|
||||
command = ChangeHabitGroupColorCommand(habitGroupList, selected, PaletteColor(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExecute() {
|
||||
checkOriginalColors()
|
||||
command.run()
|
||||
checkNewColors()
|
||||
}
|
||||
|
||||
private fun checkNewColors() {
|
||||
for (hgr in selected) {
|
||||
assertThat(hgr.color, equalTo(PaletteColor(0)))
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkOriginalColors() {
|
||||
var k = 0
|
||||
for (hgr in selected)
|
||||
assertThat(hgr.color, equalTo(PaletteColor(++k)))
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.core.commands
|
||||
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.isoron.uhabits.core.BaseUnitTest
|
||||
import org.isoron.uhabits.core.models.HabitGroup
|
||||
import org.isoron.uhabits.core.models.Reminder
|
||||
import org.isoron.uhabits.core.models.WeekdayList
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class CreateHabitGroupCommandTest : BaseUnitTest() {
|
||||
private lateinit var command: CreateHabitGroupCommand
|
||||
private lateinit var model: HabitGroup
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
model = groupFixtures.createEmptyHabitGroup()
|
||||
model.name = "New habit group"
|
||||
model.reminder = Reminder(8, 30, WeekdayList.EVERY_DAY)
|
||||
command = CreateHabitGroupCommand(modelFactory, habitGroupList, model)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExecute() {
|
||||
assertTrue(habitGroupList.isEmpty)
|
||||
command.run()
|
||||
assertThat(habitGroupList.size(), equalTo(1))
|
||||
val hgr = habitGroupList.getByPosition(0)
|
||||
assertThat(hgr.name, equalTo(model.name))
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.core.commands
|
||||
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.isoron.uhabits.core.BaseUnitTest
|
||||
import org.isoron.uhabits.core.models.HabitGroup
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class DeleteHabitGroupsCommandTest : BaseUnitTest() {
|
||||
private lateinit var command: DeleteHabitGroupsCommand
|
||||
private lateinit var selected: LinkedList<HabitGroup>
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
selected = LinkedList()
|
||||
|
||||
// Habits that should be deleted
|
||||
for (i in 0..2) {
|
||||
val hgr = groupFixtures.createGroupWithShortHabits()
|
||||
habitGroupList.add(hgr)
|
||||
selected.add(hgr)
|
||||
}
|
||||
|
||||
// Extra habit that should not be deleted
|
||||
val extraHgr = groupFixtures.createGroupWithShortHabits()
|
||||
extraHgr.name = "extra"
|
||||
habitGroupList.add(extraHgr)
|
||||
command = DeleteHabitGroupsCommand(habitGroupList, selected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExecute() {
|
||||
assertThat(habitGroupList.size(), equalTo(4))
|
||||
command.run()
|
||||
assertThat(habitGroupList.size(), equalTo(1))
|
||||
assertThat(habitGroupList.getByPosition(0).name, equalTo("extra"))
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.core.commands
|
||||
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.hamcrest.Matchers.equalTo
|
||||
import org.isoron.uhabits.core.BaseUnitTest
|
||||
import org.isoron.uhabits.core.models.HabitGroup
|
||||
import org.isoron.uhabits.core.models.Timestamp
|
||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class EditHabitGroupCommandTest : BaseUnitTest() {
|
||||
private lateinit var command: EditHabitGroupCommand
|
||||
private lateinit var hgr: HabitGroup
|
||||
private lateinit var modified: HabitGroup
|
||||
private lateinit var today: Timestamp
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
hgr = groupFixtures.createGroupWithShortHabits()
|
||||
hgr.name = "original"
|
||||
hgr.recompute()
|
||||
habitGroupList.add(hgr)
|
||||
modified = groupFixtures.createEmptyHabitGroup()
|
||||
modified.copyFrom(hgr)
|
||||
modified.name = "modified"
|
||||
habitGroupList.add(modified)
|
||||
today = getTodayWithOffset()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExecute() {
|
||||
command = EditHabitGroupCommand(habitGroupList, hgr.id!!, modified)
|
||||
val originalScore = hgr.scores[today].value
|
||||
assertThat(hgr.name, equalTo("original"))
|
||||
command.run()
|
||||
assertThat(hgr.name, equalTo("modified"))
|
||||
assertThat(hgr.scores[today].value, equalTo(originalScore))
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.core.commands
|
||||
|
||||
import org.isoron.uhabits.core.BaseUnitTest
|
||||
import org.isoron.uhabits.core.models.HabitGroup
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class UnarchiveHabitGroupsCommandTest : BaseUnitTest() {
|
||||
private lateinit var command: UnarchiveHabitGroupsCommand
|
||||
private lateinit var hgr: HabitGroup
|
||||
|
||||
@Before
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
hgr = groupFixtures.createGroupWithShortHabits()
|
||||
hgr.isArchived = true
|
||||
habitGroupList.add(hgr)
|
||||
command = UnarchiveHabitGroupsCommand(habitGroupList, listOf(hgr))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExecuteUndoRedo() {
|
||||
assertTrue(hgr.isArchived)
|
||||
command.run()
|
||||
assertFalse(hgr.isArchived)
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||
*
|
||||
* This file is part of Loop Habit Tracker.
|
||||
*
|
||||
* Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.isoron.uhabits.core.ui.screens.habits.show
|
||||
|
||||
import org.isoron.uhabits.core.BaseUnitTest
|
||||
import org.isoron.uhabits.core.models.HabitGroup
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.verify
|
||||
|
||||
class ShowHabitGroupMenuPresenterTest : BaseUnitTest() {
|
||||
private lateinit var screen: ShowHabitGroupMenuPresenter.Screen
|
||||
private lateinit var hgr: HabitGroup
|
||||
private lateinit var menu: ShowHabitGroupMenuPresenter
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
screen = mock()
|
||||
hgr = groupFixtures.createGroupWithShortHabits()
|
||||
menu = ShowHabitGroupMenuPresenter(
|
||||
commandRunner,
|
||||
hgr,
|
||||
habitGroupList,
|
||||
screen
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnEditHabit() {
|
||||
menu.onEditHabitGroup()
|
||||
verify(screen).showEditHabitGroupScreen(hgr)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue