Fix UUID generation

This commit is contained in:
2020-12-28 18:51:17 -06:00
parent c744d945a4
commit bd70746278
7 changed files with 135 additions and 4 deletions

View File

@@ -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")
}
}

View File

@@ -89,7 +89,7 @@ public class HabitsTest extends BaseUserInterfaceTest
verifyShowsScreen(LIST_HABITS);
longClickText("Track time");
clickMenu(DELETE);
clickOK();
clickYes();
verifyDoesNotDisplayText("Track time");
}

View File

@@ -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)
}

View File

@@ -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()

View File

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