mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Fix UUID generation
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2020 Álinson Santos Xavier <isoron@gmail.com>
|
||||||
|
*
|
||||||
|
* 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.acceptance
|
||||||
|
|
||||||
|
import androidx.test.filters.*
|
||||||
|
import org.isoron.uhabits.*
|
||||||
|
import org.isoron.uhabits.acceptance.steps.*
|
||||||
|
import org.isoron.uhabits.acceptance.steps.CommonSteps.*
|
||||||
|
import org.junit.*
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
class BackupTest : BaseUserInterfaceTest() {
|
||||||
|
@Test
|
||||||
|
fun shouldExportAndImportBackup() {
|
||||||
|
launchApp()
|
||||||
|
clearDownloadFolder()
|
||||||
|
clearBackupFolder()
|
||||||
|
exportFullBackup()
|
||||||
|
copyBackupToDownloadFolder()
|
||||||
|
|
||||||
|
longClickText("Wake up early")
|
||||||
|
ListHabitsSteps.clickMenu(ListHabitsSteps.MenuItem.DELETE)
|
||||||
|
clickYes()
|
||||||
|
verifyDoesNotDisplayText("Wake up early")
|
||||||
|
|
||||||
|
importBackupFromDownloadFolder()
|
||||||
|
|
||||||
|
verifyDisplaysText("Wake up early")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,7 +89,7 @@ public class HabitsTest extends BaseUserInterfaceTest
|
|||||||
verifyShowsScreen(LIST_HABITS);
|
verifyShowsScreen(LIST_HABITS);
|
||||||
longClickText("Track time");
|
longClickText("Track time");
|
||||||
clickMenu(DELETE);
|
clickMenu(DELETE);
|
||||||
clickOK();
|
clickYes();
|
||||||
verifyDoesNotDisplayText("Track time");
|
verifyDoesNotDisplayText("Track time");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2020 Álinson Santos Xavier <isoron@gmail.com>
|
||||||
|
*
|
||||||
|
* 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.acceptance.steps
|
||||||
|
|
||||||
|
import androidx.test.uiautomator.*
|
||||||
|
import org.isoron.uhabits.acceptance.steps.CommonSteps.*
|
||||||
|
import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.*
|
||||||
|
import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.MenuItem.*
|
||||||
|
|
||||||
|
const val BACKUP_FOLDER = "/sdcard/Android/data/org.isoron.uhabits/files/Backups/"
|
||||||
|
const val DOWNLOAD_FOLDER = "/sdcard/Download/"
|
||||||
|
|
||||||
|
fun exportFullBackup() {
|
||||||
|
clickMenu(SETTINGS)
|
||||||
|
clickText("Export full backup")
|
||||||
|
device.pressBack()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearDownloadFolder() {
|
||||||
|
device.executeShellCommand("rm -rf /sdcard/Download/")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearBackupFolder() {
|
||||||
|
device.executeShellCommand("rm -rf $BACKUP_FOLDER")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun copyBackupToDownloadFolder() {
|
||||||
|
device.executeShellCommand("mv $BACKUP_FOLDER $DOWNLOAD_FOLDER")
|
||||||
|
device.executeShellCommand("chown root $DOWNLOAD_FOLDER")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun importBackupFromDownloadFolder() {
|
||||||
|
clickMenu(SETTINGS)
|
||||||
|
clickText("Import data")
|
||||||
|
device.findObject(UiSelector().textContains("Loop")).click()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearAppData() {
|
||||||
|
openLauncher()
|
||||||
|
device.findObject(UiSelector().textContains("Habits")).longClick()
|
||||||
|
device.findObject(UiSelector().textContains("App info")).click()
|
||||||
|
device.findObject(UiSelector().textContains("Storage")).click()
|
||||||
|
device.findObject(UiSelector().textContains("Clear storage")).click()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun openLauncher() {
|
||||||
|
device.pressHome()
|
||||||
|
device.waitForIdle()
|
||||||
|
val h = device.displayHeight
|
||||||
|
val w = device.displayWidth
|
||||||
|
device.swipe(w / 2, h / 2, w / 2, 0, 8)
|
||||||
|
}
|
||||||
@@ -43,9 +43,9 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
public class CommonSteps extends BaseUserInterfaceTest
|
public class CommonSteps extends BaseUserInterfaceTest
|
||||||
{
|
{
|
||||||
public static void clickOK()
|
public static void clickYes()
|
||||||
{
|
{
|
||||||
clickText("OK");
|
clickText("Yes");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pressBack()
|
public static void pressBack()
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ListHabitsRegressionTest : BaseUserInterfaceTest() {
|
|||||||
verifyShowsScreen(LIST_HABITS)
|
verifyShowsScreen(LIST_HABITS)
|
||||||
longClickText("Track time")
|
longClickText("Track time")
|
||||||
clickMenu(DELETE)
|
clickMenu(DELETE)
|
||||||
clickOK()
|
clickYes()
|
||||||
|
|
||||||
clickMenu(ADD)
|
clickMenu(ADD)
|
||||||
verifyShowsScreen(SELECT_HABIT_TYPE)
|
verifyShowsScreen(SELECT_HABIT_TYPE)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package org.isoron.uhabits.core.models
|
package org.isoron.uhabits.core.models
|
||||||
|
|
||||||
import org.isoron.uhabits.core.utils.*
|
import org.isoron.uhabits.core.utils.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
data class Habit(
|
data class Habit(
|
||||||
var color: PaletteColor = PaletteColor(8),
|
var color: PaletteColor = PaletteColor(8),
|
||||||
@@ -40,6 +41,10 @@ data class Habit(
|
|||||||
val scores: ScoreList,
|
val scores: ScoreList,
|
||||||
val streaks: StreakList,
|
val streaks: StreakList,
|
||||||
) {
|
) {
|
||||||
|
init {
|
||||||
|
if(uuid == null) this.uuid = UUID.randomUUID().toString().replace("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
var observable = ModelObservable()
|
var observable = ModelObservable()
|
||||||
|
|
||||||
val isNumerical: Boolean
|
val isNumerical: Boolean
|
||||||
|
|||||||
@@ -40,6 +40,16 @@ public class HabitTest extends BaseUnitTest
|
|||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUuidGeneration()
|
||||||
|
{
|
||||||
|
Habit habit1 = modelFactory.buildHabit();
|
||||||
|
Habit habit2 = modelFactory.buildHabit();
|
||||||
|
assertNotNull(habit1.getUuid());
|
||||||
|
assertNotNull(habit2.getUuid());
|
||||||
|
assertNotEquals(habit1.getUuid(), habit2.getUuid());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_copyAttributes()
|
public void test_copyAttributes()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user