Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ dependencies {
implementation 'androidx.fragment:fragment-ktx:1.8.9'
implementation 'androidx.graphics:graphics-core:1.0.4'
implementation 'androidx.input:input-motionprediction:1.0.0'
implementation 'androidx.test.ext:junit-ktx:1.3.0'

//implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation('com.onyx.android.sdk:onyxsdk-device:1.3.5') {
Expand Down Expand Up @@ -174,6 +175,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
androidTestImplementation "io.mockk:mockk-android:1.14.11"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
Expand Down
Binary file added app/src/androidTest/assets/test_notebook.xopp
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package android.app;

/**
* Stub class to prevent NoClassDefFoundError during MockK reflection on API < 31.
* This class is bundled only in the test APK and satisfies the class loader when
* it scans Activity methods like onPictureInPictureUiStateChanged(PictureInPictureUiState).
*/
public final class PictureInPictureUiState {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.junit.runner.RunWith
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
@Test(timeout = 10000)
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
Expand Down
17 changes: 17 additions & 0 deletions app/src/androidTest/java/com/ethran/notable/SimpleAndroidTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ethran.notable

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class SimpleAndroidTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.ethran.notable", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EmptyIdEdgeCaseTest {
db.close()
}

@Test
@Test(timeout = 30000)
fun insertAndRead_notebookWithEmptyPageIdList() = runBlocking {
val notebook = Notebook(
id = "notebook-1",
Expand All @@ -48,7 +48,7 @@ class EmptyIdEdgeCaseTest {
assertEquals("", loaded.pageIds[1])
}

@Test
@Test(timeout = 30000)
fun insertAndRead_pageWithEmptyId() = runBlocking {
val emptyIdPage = Page(
id = "", // Empty ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlin.math.pow
import kotlin.math.sqrt

class EncodingTest {
@Test
@Test(timeout = 30000)
fun simpleTest() {

fun assertAlmostEqual(expected: List<Float>, actual: List<Float>, precision: Int) {
Expand Down
16 changes: 8 additions & 8 deletions app/src/androidTest/java/com/ethran/notable/db/MigrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.io.IOException
@RunWith(AndroidJUnit4::class)
class MigrationTest {

@Test
@Test(timeout = 10000)
fun simpleTest() {
assertTrue(true)
}
Expand All @@ -33,7 +33,7 @@ class MigrationTest {
FrameworkSQLiteOpenHelperFactory()
)

@Test
@Test(timeout = 60000)
@Throws(IOException::class)
fun migrate30To31_autoMigration() {
val dbName = "migration-test"
Expand Down Expand Up @@ -100,18 +100,18 @@ class MigrationTest {

db.close()

// 2. Reopen DB with version 31 to trigger migration
val migratedDb = Room.databaseBuilder(context, AppDatabase::class.java, dbName)
.build().openHelper.writableDatabase
// 2. Reopen DB with version 31 (latest AppDatabase version) to trigger migration
val roomDb = Room.databaseBuilder(context, AppDatabase::class.java, dbName).build()
val migratedDb = roomDb.openHelper.writableDatabase

// 3. Verify renamed column exists with expected data
val cursor = migratedDb.query("SELECT background FROM Page WHERE id = 'page1'")
cursor.use {
assertTrue(it.moveToFirst())
val background = it.getString(0)
val background = it.getString(it.getColumnIndexOrThrow("background"))
assertEquals("grid", background)
}
}


roomDb.close()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ethran.notable.editor

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.ethran.notable.sync.SyncOrchestrator
import io.mockk.mockk
import org.junit.Assert.assertNotNull
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class EditorMockKTest {
@Test
fun simpleMockKTest() {
val orchestrator = mockk<SyncOrchestrator>(relaxed = true)
assertNotNull(orchestrator)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.ethran.notable.editor

import android.content.Context
import androidx.test.core.app.ApplicationProvider
import com.ethran.notable.data.db.AppDatabase
import com.ethran.notable.testing.TestDatabaseFactory
import com.ethran.notable.testing.TestNotebookSeeder
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import org.junit.After
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test

class EditorSeedingTests {

private lateinit var db: AppDatabase

@Before
fun setUp() {
val context = ApplicationProvider.getApplicationContext<Context>()
db = TestDatabaseFactory.createInMemory(context)
}

@After
fun tearDown() {
db.close()
}

@Test(timeout = 60000)
fun seededNotebook_hasNonBlankPages() {
runBlocking {
withTimeout(30_000) {
val seeded = TestNotebookSeeder.seedNotebook(db, pageCount = 3, strokesPerPage = 10)
val pages = db.pageDao().getByIds(seeded.pageIds)
assertTrue(pages.size == 3)

val firstPageWithData = db.pageDao().getPageWithDataById(seeded.pageIds.first())
requireNotNull(firstPageWithData)
assertTrue(firstPageWithData.strokes.isNotEmpty())
}
}
}
}
Loading
Loading