Fix UUID generation

pull/699/head
Alinson S. Xavier 5 years ago
parent c744d945a4
commit bd70746278

@ -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);
longClickText("Track time");
clickMenu(DELETE);
clickOK();
clickYes();
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 static void clickOK()
public static void clickYes()
{
clickText("OK");
clickText("Yes");
}
public static void pressBack()

@ -41,7 +41,7 @@ class ListHabitsRegressionTest : BaseUserInterfaceTest() {
verifyShowsScreen(LIST_HABITS)
longClickText("Track time")
clickMenu(DELETE)
clickOK()
clickYes()
clickMenu(ADD)
verifyShowsScreen(SELECT_HABIT_TYPE)

@ -19,6 +19,7 @@
package org.isoron.uhabits.core.models
import org.isoron.uhabits.core.utils.*
import java.util.*
data class Habit(
var color: PaletteColor = PaletteColor(8),
@ -40,6 +41,10 @@ data class Habit(
val scores: ScoreList,
val streaks: StreakList,
) {
init {
if(uuid == null) this.uuid = UUID.randomUUID().toString().replace("-", "");
}
var observable = ModelObservable()
val isNumerical: Boolean

@ -40,6 +40,16 @@ public class HabitTest extends BaseUnitTest
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
public void test_copyAttributes()
{

Loading…
Cancel
Save