From 8972f2d03d0337414d1faaf62fdf4330c85f0cdd Mon Sep 17 00:00:00 2001 From: Alinson Xavier Date: Wed, 10 Apr 2019 05:35:56 -0500 Subject: [PATCH] Move most tests to commonTest --- .../kotlin/org/isoron/BaseTest.kt} | 13 ++- .../kotlin/org/isoron/DependencyResolver.kt} | 15 ++-- .../org/isoron/platform/gui/CanvasTest.kt | 14 +-- .../org/isoron/platform/io/DatabaseTest.kt | 6 +- .../org/isoron/platform/io/FilesTest.kt | 4 +- .../uhabits/models/CheckmarkRepositoryTest.kt | 8 +- .../uhabits/models/HabitRepositoryTest.kt | 5 +- .../models/PreferencesRepositoryTest.kt | 5 +- .../kotlin/org/isoron/DependencyResolver.kt} | 16 ++-- ...sDatabaseTest.kt => DependencyResolver.kt} | 27 ++++-- .../org/isoron/platform/gui/HtmlCanvasTest.kt | 37 -------- .../uhabits/models/JsHabitRepositoryTest.kt | 35 -------- ...avaCanvasTest.kt => DependencyResolver.kt} | 32 ++++--- .../{JavaDatesTest.kt => DatesTest.kt} | 2 +- .../uhabits/{Base.kt => BaseViewTest.kt} | 27 +----- .../org/isoron/uhabits/backend/BackendTest.kt | 89 ------------------- .../uhabits/models/JavaHabitRepositoryTest.kt | 40 --------- web/src/test/canvas.html | 22 ----- web/src/test/index.html | 7 ++ 19 files changed, 95 insertions(+), 309 deletions(-) rename core/src/{jsTest/kotlin/org/isoron/platform/io/JsFilesTest.kt => commonTest/kotlin/org/isoron/BaseTest.kt} (82%) rename core/src/{jvmTest/kotlin/org/isoron/platform/JavaFilesTest.kt => commonTest/kotlin/org/isoron/DependencyResolver.kt} (75%) rename core/src/{jvmTest => commonTest}/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt (93%) rename core/src/{jvmTest => commonTest}/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt (95%) rename core/src/{jvmTest/kotlin/org/isoron/platform/io/JavaDatabaseTest.kt => iosTest/kotlin/org/isoron/DependencyResolver.kt} (71%) rename core/src/jsTest/kotlin/org/isoron/{platform/io/JsDatabaseTest.kt => DependencyResolver.kt} (55%) delete mode 100644 core/src/jsTest/kotlin/org/isoron/platform/gui/HtmlCanvasTest.kt delete mode 100644 core/src/jsTest/kotlin/org/isoron/uhabits/models/JsHabitRepositoryTest.kt rename core/src/jvmTest/kotlin/org/isoron/{platform/JavaCanvasTest.kt => DependencyResolver.kt} (55%) rename core/src/jvmTest/kotlin/org/isoron/platform/{JavaDatesTest.kt => DatesTest.kt} (99%) rename core/src/jvmTest/kotlin/org/isoron/uhabits/{Base.kt => BaseViewTest.kt} (83%) delete mode 100644 core/src/jvmTest/kotlin/org/isoron/uhabits/backend/BackendTest.kt delete mode 100644 core/src/jvmTest/kotlin/org/isoron/uhabits/models/JavaHabitRepositoryTest.kt delete mode 100644 web/src/test/canvas.html diff --git a/core/src/jsTest/kotlin/org/isoron/platform/io/JsFilesTest.kt b/core/src/commonTest/kotlin/org/isoron/BaseTest.kt similarity index 82% rename from core/src/jsTest/kotlin/org/isoron/platform/io/JsFilesTest.kt rename to core/src/commonTest/kotlin/org/isoron/BaseTest.kt index 0cfe2829..e2b608ba 100644 --- a/core/src/jsTest/kotlin/org/isoron/platform/io/JsFilesTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/BaseTest.kt @@ -17,13 +17,10 @@ * with this program. If not, see . */ -package org.isoron.platform.io +package org.isoron -import kotlin.test.* - -class JsFilesTest { - @Test - fun testReadLines() { - FilesTest(JsFileOpener()).testReadLines() - } +open class BaseTest { + val resolver = DependencyResolver() + val fileOpener = resolver.getFileOpener() + val db = resolver.getDatabase() } \ No newline at end of file diff --git a/core/src/jvmTest/kotlin/org/isoron/platform/JavaFilesTest.kt b/core/src/commonTest/kotlin/org/isoron/DependencyResolver.kt similarity index 75% rename from core/src/jvmTest/kotlin/org/isoron/platform/JavaFilesTest.kt rename to core/src/commonTest/kotlin/org/isoron/DependencyResolver.kt index d5c10d43..ae521f93 100644 --- a/core/src/jvmTest/kotlin/org/isoron/platform/JavaFilesTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/DependencyResolver.kt @@ -17,15 +17,14 @@ * with this program. If not, see . */ -package org.isoron.platform +package org.isoron +import org.isoron.platform.gui.* import org.isoron.platform.io.* -import org.isoron.uhabits.* -import org.junit.* -class JavaFilesTest : BaseTest() { - @Test - fun testReadLines() { - FilesTest(fileOpener).testReadLines() - } +expect class DependencyResolver() { + fun getFileOpener(): FileOpener + fun getDatabase(): Database + fun createCanvas(width: Int, height: Int): Canvas + fun exportCanvas(canvas: Canvas, filename: String) } \ No newline at end of file diff --git a/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt b/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt index 2e84f3d9..6198ea60 100644 --- a/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/platform/gui/CanvasTest.kt @@ -19,14 +19,14 @@ package org.isoron.platform.gui -class CanvasTest(val platform: Platform) { - interface Platform { - fun createCanvas(width: Int, height: Int): Canvas - fun writePng(canvas: Canvas, filename: String) - } +import org.isoron.* +import kotlin.test.* +class CanvasTest() : BaseTest() { + + @Test fun testDrawing() { - val canvas = platform.createCanvas(500, 400) + val canvas = resolver.createCanvas(500, 400) canvas.setColor(Color(0x303030)) canvas.fillRect(0.0, 0.0, 500.0, 400.0) @@ -66,6 +66,6 @@ class CanvasTest(val platform: Platform) { canvas.setFont(Font.FONT_AWESOME) canvas.drawText(FontAwesome.CHECK, 250.0, 300.0) - platform.writePng(canvas, "CanvasTest.png") + resolver.exportCanvas(canvas, "CanvasTest.png") } } \ No newline at end of file diff --git a/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt b/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt index 9b0dfe1e..e3849f0b 100644 --- a/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/platform/io/DatabaseTest.kt @@ -19,9 +19,11 @@ package org.isoron.platform.io -import kotlin.test.assertEquals +import org.isoron.* +import kotlin.test.* -class DatabaseTest(val db: Database) { +class DatabaseTest() : BaseTest() { + @Test fun testUsage() { db.setVersion(0) assertEquals(0, db.getVersion()) diff --git a/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt b/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt index 9bda950e..7b3e5c01 100644 --- a/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/platform/io/FilesTest.kt @@ -19,9 +19,11 @@ package org.isoron.platform.io +import org.isoron.* import kotlin.test.* -class FilesTest(val fileOpener: FileOpener) { +class FilesTest() : BaseTest() { + @Test fun testReadLines() { val hello = fileOpener.openResourceFile("hello.txt") var lines = hello.readLines() diff --git a/core/src/jvmTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt b/core/src/commonTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt similarity index 93% rename from core/src/jvmTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt rename to core/src/commonTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt index 55c09bf3..8e225e26 100644 --- a/core/src/jvmTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/uhabits/models/CheckmarkRepositoryTest.kt @@ -19,10 +19,10 @@ package org.isoron.uhabits.models -import junit.framework.TestCase.* +import org.isoron.* import org.isoron.platform.time.* -import org.isoron.uhabits.* -import org.junit.* +import kotlin.test.* + class CheckmarkRepositoryTest : BaseTest() { @Test @@ -45,7 +45,7 @@ class CheckmarkRepositoryTest : BaseTest() { for (c in checkmarksB) repository.insert(habitB, c) assertEquals(checkmarksA, repository.findAll(habitA)) assertEquals(checkmarksB, repository.findAll(habitB)) - assertEquals(listOf(), repository.findAll(999)) + assertEquals(listOf(), repository.findAll(999)) checkmarksA = listOf(Checkmark(LocalDate(2019, 1, 15), 100), Checkmark(LocalDate(2019, 1, 1), 900)) diff --git a/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt b/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt index d8d7f23a..ab733c79 100644 --- a/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/uhabits/models/HabitRepositoryTest.kt @@ -19,17 +19,19 @@ package org.isoron.uhabits.models +import org.isoron.* import org.isoron.platform.gui.* import org.isoron.platform.io.* import kotlin.test.* -class HabitRepositoryTest(val db: Database) { +class HabitRepositoryTest() : BaseTest() { lateinit var repository: HabitRepository lateinit private var original0: Habit lateinit private var original1: Habit lateinit private var original2: Habit + @BeforeTest fun setUp() { original0 = Habit(id = 0, name = "Wake up early", @@ -67,6 +69,7 @@ class HabitRepositoryTest(val db: Database) { repository = HabitRepository(db) } + @Test fun testFindAll() { var habits = repository.findAll() assertEquals(0, repository.nextId()) diff --git a/core/src/jvmTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt b/core/src/commonTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt similarity index 95% rename from core/src/jvmTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt rename to core/src/commonTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt index 6787f8dd..9f7b673e 100644 --- a/core/src/jvmTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt +++ b/core/src/commonTest/kotlin/org/isoron/uhabits/models/PreferencesRepositoryTest.kt @@ -19,9 +19,8 @@ package org.isoron.uhabits.models -import junit.framework.TestCase.* -import org.isoron.uhabits.* -import org.junit.* +import org.isoron.* +import kotlin.test.* class PreferencesRepositoryTest : BaseTest() { @Test diff --git a/core/src/jvmTest/kotlin/org/isoron/platform/io/JavaDatabaseTest.kt b/core/src/iosTest/kotlin/org/isoron/DependencyResolver.kt similarity index 71% rename from core/src/jvmTest/kotlin/org/isoron/platform/io/JavaDatabaseTest.kt rename to core/src/iosTest/kotlin/org/isoron/DependencyResolver.kt index d5a88c52..93b74aff 100644 --- a/core/src/jvmTest/kotlin/org/isoron/platform/io/JavaDatabaseTest.kt +++ b/core/src/iosTest/kotlin/org/isoron/DependencyResolver.kt @@ -17,16 +17,14 @@ * with this program. If not, see . */ -package org.isoron.platform.io +package org.isoron +import org.isoron.platform.gui.* import org.isoron.platform.io.* -import org.isoron.uhabits.BaseTest -import org.junit.Test -import kotlin.test.assertEquals -class JavaDatabaseTest : BaseTest() { - @Test - fun testUsage() { - DatabaseTest(db).testUsage() - } +actual class DependencyResolver { + actual fun getFileOpener(): FileOpener = TODO() + actual fun getDatabase(): Database = TODO() + actual fun createCanvas(width: Int, height: Int): Canvas = TODO() + actual fun exportCanvas(canvas: Canvas, filename: String): Unit = TODO() } \ No newline at end of file diff --git a/core/src/jsTest/kotlin/org/isoron/platform/io/JsDatabaseTest.kt b/core/src/jsTest/kotlin/org/isoron/DependencyResolver.kt similarity index 55% rename from core/src/jsTest/kotlin/org/isoron/platform/io/JsDatabaseTest.kt rename to core/src/jsTest/kotlin/org/isoron/DependencyResolver.kt index 7f7a8456..56263c50 100644 --- a/core/src/jsTest/kotlin/org/isoron/platform/io/JsDatabaseTest.kt +++ b/core/src/jsTest/kotlin/org/isoron/DependencyResolver.kt @@ -17,14 +17,29 @@ * with this program. If not, see . */ -package org.isoron.platform.io +package org.isoron -import kotlin.test.* +import org.isoron.platform.gui.* +import org.isoron.platform.io.* +import org.w3c.dom.* +import kotlin.browser.* -class JsDatabaseTest { - @Test - fun testUsage() { +actual class DependencyResolver { + actual fun getFileOpener(): FileOpener = JsFileOpener() + + actual fun getDatabase(): Database { val db = eval("new SQL.Database()") - DatabaseTest(JsDatabase(db)).testUsage() + return JsDatabase(db) + } + + actual fun createCanvas(width: Int, height: Int): Canvas { + val canvasElement = document.getElementById("canvas") as HTMLCanvasElement + canvasElement.style.width = "${width}px" + canvasElement.style.height = "${height}px" + return HtmlCanvas(canvasElement) + } + + actual fun exportCanvas(canvas: Canvas, filename: String) { + // do nothing } } \ No newline at end of file diff --git a/core/src/jsTest/kotlin/org/isoron/platform/gui/HtmlCanvasTest.kt b/core/src/jsTest/kotlin/org/isoron/platform/gui/HtmlCanvasTest.kt deleted file mode 100644 index ed6da9f1..00000000 --- a/core/src/jsTest/kotlin/org/isoron/platform/gui/HtmlCanvasTest.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * 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 . - */ - -package org.isoron.platform.gui - -import org.w3c.dom.* - -class HtmlCanvasTest(val canvas: HTMLCanvasElement) : CanvasTest.Platform { - - override fun createCanvas(width: Int, height: Int): Canvas { - return HtmlCanvas(canvas) - } - - override fun writePng(canvas: Canvas, filename: String) { - } - - fun testDrawing() { - val test = CanvasTest(this) - test.testDrawing() - } -} \ No newline at end of file diff --git a/core/src/jsTest/kotlin/org/isoron/uhabits/models/JsHabitRepositoryTest.kt b/core/src/jsTest/kotlin/org/isoron/uhabits/models/JsHabitRepositoryTest.kt deleted file mode 100644 index 94c77a64..00000000 --- a/core/src/jsTest/kotlin/org/isoron/uhabits/models/JsHabitRepositoryTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * 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 . - */ - -package org.isoron.uhabits.models - -import org.isoron.platform.io.* -import kotlin.test.* - -class JsHabitRepositoryTest { - - val db = JsDatabase(eval("new SQL.Database()")) - val commonTest = HabitRepositoryTest(db) - - @Test - fun testFindAll() { -// commonTest.setUp() -// commonTest.testFindAll() - } -} \ No newline at end of file diff --git a/core/src/jvmTest/kotlin/org/isoron/platform/JavaCanvasTest.kt b/core/src/jvmTest/kotlin/org/isoron/DependencyResolver.kt similarity index 55% rename from core/src/jvmTest/kotlin/org/isoron/platform/JavaCanvasTest.kt rename to core/src/jvmTest/kotlin/org/isoron/DependencyResolver.kt index dbb24582..363dd049 100644 --- a/core/src/jvmTest/kotlin/org/isoron/platform/JavaCanvasTest.kt +++ b/core/src/jvmTest/kotlin/org/isoron/DependencyResolver.kt @@ -17,28 +17,38 @@ * with this program. If not, see . */ -package org.isoron.platform +package org.isoron import org.isoron.platform.gui.* -import org.junit.* +import org.isoron.platform.io.* +import org.isoron.uhabits.* import java.awt.image.* import java.io.* import javax.imageio.* +actual class DependencyResolver actual constructor() { -class JavaCanvasTest : CanvasTest.Platform { - private val commonTest = CanvasTest(this) + val log = StandardLog() + val fileOpener = JavaFileOpener() + val databaseOpener = JavaDatabaseOpener(log) - @Test - fun testDrawing() = commonTest.testDrawing() + actual fun getFileOpener(): FileOpener = fileOpener - override fun createCanvas(width: Int, height: Int): Canvas { - val image = BufferedImage(width, height, BufferedImage.TYPE_INT_RGB) - return JavaCanvas(image, pixelScale=1.0) + actual fun getDatabase(): Database { + val dbFile = fileOpener.openUserFile("test.sqlite3") + if (dbFile.exists()) dbFile.delete() + val db = databaseOpener.open(dbFile) + db.migrateTo(LOOP_DATABASE_VERSION, fileOpener, log) + return db } - override fun writePng(canvas: Canvas, filename: String) { + actual fun createCanvas(width: Int, height: Int): Canvas { + val image = BufferedImage(width, height, BufferedImage.TYPE_INT_RGB) + return JavaCanvas(image, pixelScale = 1.0) + } + + actual fun exportCanvas(canvas: Canvas, filename: String) { val javaCanvas = canvas as JavaCanvas - ImageIO.write(javaCanvas.image, "png", File("/tmp/JavaCanvasTest.png")) + ImageIO.write(javaCanvas.image, "png", File("/tmp/$filename")) } } \ No newline at end of file diff --git a/core/src/jvmTest/kotlin/org/isoron/platform/JavaDatesTest.kt b/core/src/jvmTest/kotlin/org/isoron/platform/DatesTest.kt similarity index 99% rename from core/src/jvmTest/kotlin/org/isoron/platform/JavaDatesTest.kt rename to core/src/jvmTest/kotlin/org/isoron/platform/DatesTest.kt index e74d7b64..c8a9f52e 100644 --- a/core/src/jvmTest/kotlin/org/isoron/platform/JavaDatesTest.kt +++ b/core/src/jvmTest/kotlin/org/isoron/platform/DatesTest.kt @@ -26,7 +26,7 @@ import java.util.* import java.util.Calendar.* -class JavaDatesTest { +class DatesTest { private val d1 = LocalDate(2019, 3, 25) private val d2 = LocalDate(2019, 4, 4) private val d3 = LocalDate(2019, 5, 12) diff --git a/core/src/jvmTest/kotlin/org/isoron/uhabits/Base.kt b/core/src/jvmTest/kotlin/org/isoron/uhabits/BaseViewTest.kt similarity index 83% rename from core/src/jvmTest/kotlin/org/isoron/uhabits/Base.kt rename to core/src/jvmTest/kotlin/org/isoron/uhabits/BaseViewTest.kt index 14d26630..7c54db8a 100644 --- a/core/src/jvmTest/kotlin/org/isoron/uhabits/Base.kt +++ b/core/src/jvmTest/kotlin/org/isoron/uhabits/BaseViewTest.kt @@ -19,41 +19,18 @@ package org.isoron.uhabits -import org.isoron.platform.concurrency.* import org.isoron.platform.gui.* import org.isoron.platform.io.* -import org.isoron.platform.time.* import org.isoron.uhabits.components.* -import org.junit.* import java.awt.image.* import java.io.* import javax.imageio.* import kotlin.math.* -open class BaseTest { - - val fileOpener = JavaFileOpener() - - val log = StandardLog() - - val databaseOpener = JavaDatabaseOpener(log) - - val taskRunner = SequentialTaskRunner() - - lateinit var db: Database - - @Before - open fun setUp() { - val dbFile = fileOpener.openUserFile("test.sqlite3") - if (dbFile.exists()) dbFile.delete() - db = databaseOpener.open(dbFile) - db.migrateTo(LOOP_DATABASE_VERSION, fileOpener, log) - } -} - open class BaseViewTest { val theme = LightTheme() - fun distance(actual: BufferedImage, + + private fun distance(actual: BufferedImage, expected: BufferedImage): Double { if (actual.width != expected.width) return Double.POSITIVE_INFINITY diff --git a/core/src/jvmTest/kotlin/org/isoron/uhabits/backend/BackendTest.kt b/core/src/jvmTest/kotlin/org/isoron/uhabits/backend/BackendTest.kt deleted file mode 100644 index 48eca06d..00000000 --- a/core/src/jvmTest/kotlin/org/isoron/uhabits/backend/BackendTest.kt +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * 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 . - */ - -package org.isoron.uhabits.backend - -import junit.framework.TestCase.* -import org.isoron.platform.gui.* -import org.isoron.uhabits.* -import org.junit.* -import java.util.* -import java.util.concurrent.* - -class BackendTest : BaseTest() { - lateinit var backend: Backend - private val latch = CountDownLatch(1) - val dbFilename = "uhabits${Random().nextInt()}.db" - val dbFile = fileOpener.openUserFile(dbFilename) - -// @Before -// override fun setUp() { -// super.setUp() -// if (dbFile.exists()) dbFile.delete() -// backend = Backend(dbFilename, -// databaseOpener, -// fileOpener, -// log, -// taskRunner) -// } -// -// @After -// fun tearDown() { -// dbFile.delete() -// } - -// @Test -// fun testMainScreenDataSource() { -// val listener = object : MainScreenDataSource.Listener { -// override fun onDataChanged(newData: MainScreenDataSource.Data) { -// val expected = MainScreenDataSource.Data( -// ids = listOf(0, 10, 9, 2, 3, 4, 5, 11, 6, 7, 8), -// scores = listOf(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -// 0.0, 0.0, 0.0), -// names = listOf("Wake up early", "Eat healthy", "Floss", -// "Journal", "Track time", "Meditate", -// "Work out", "Take a walk", "Read books", -// "Learn French", "Play chess"), -// colors = listOf(PaletteColor(8), PaletteColor(8), -// PaletteColor(8), PaletteColor(11), -// PaletteColor(11), PaletteColor(15), -// PaletteColor(15), PaletteColor(15), -// PaletteColor(2), PaletteColor(2), -// PaletteColor(13)), -// checkmarks = listOf( -// listOf(2, 0, 0, 0, 0, 2, 0), -// listOf(0, 2, 2, 2, 2, 2, 0), -// listOf(0, 0, 0, 0, 2, 0, 0), -// listOf(0, 2, 0, 2, 0, 0, 0), -// listOf(2, 2, 2, 0, 2, 2, 2), -// listOf(2, 1, 1, 2, 1, 2, 2), -// listOf(2, 0, 2, 0, 2, 1, 2), -// listOf(0, 2, 2, 2, 2, 0, 0), -// listOf(0, 2, 2, 2, 2, 2, 0), -// listOf(0, 0, 2, 0, 2, 0, 2), -// listOf(0, 2, 0, 0, 2, 2, 0))) -// assertEquals(newData, expected) -// latch.countDown() -// } -// } -// backend.mainScreenDataSource.observable.addListener(listener) -// backend.mainScreenDataSource.requestData() -// assertTrue(latch.await(3, TimeUnit.SECONDS)) -// } -} diff --git a/core/src/jvmTest/kotlin/org/isoron/uhabits/models/JavaHabitRepositoryTest.kt b/core/src/jvmTest/kotlin/org/isoron/uhabits/models/JavaHabitRepositoryTest.kt deleted file mode 100644 index c101f083..00000000 --- a/core/src/jvmTest/kotlin/org/isoron/uhabits/models/JavaHabitRepositoryTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * 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 . - */ - -package org.isoron.uhabits.models - -import org.isoron.uhabits.* -import org.junit.* - -class JavaHabitRepositoryTest : BaseTest() { - - lateinit var commonTest: HabitRepositoryTest - - @Before - override fun setUp() { - super.setUp() - commonTest = HabitRepositoryTest(db) - commonTest.setUp() - } - - @Test - fun testFindAll() { - commonTest.testFindAll() - } -} \ No newline at end of file diff --git a/web/src/test/canvas.html b/web/src/test/canvas.html deleted file mode 100644 index 4867c19b..00000000 --- a/web/src/test/canvas.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - Canvas Test - - - - - - - - - diff --git a/web/src/test/index.html b/web/src/test/index.html index 16e019f6..a76c8884 100644 --- a/web/src/test/index.html +++ b/web/src/test/index.html @@ -4,9 +4,16 @@ Mocha Tests +
+