Skip to content

Commit 50cb18a

Browse files
Update tests for latest pre-release
1 parent ce2232a commit 50cb18a

11 files changed

+47
-6
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
minSdkVersion 24
1212
compileSdk 35
1313
targetSdkVersion 35
14-
versionCode 15
15-
versionName "0.93.0-alpha10"
14+
versionCode 16
15+
versionName "0.93.0-alpha11"
1616

1717
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1818
testInstrumentationRunnerArguments useTestStorageService: "true"

app/src/androidTest/kotlin/eu/fliegendewurst/triliumdroid/InitialSyncTest.kt

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import org.junit.rules.TestName
4545
import org.junit.runner.RunWith
4646
import org.junit.runners.MethodSorters
4747
import java.io.IOException
48+
import java.lang.ref.WeakReference
4849

4950

5051
@RunWith(AndroidJUnit4::class)
@@ -274,7 +275,7 @@ class InitialSyncTest {
274275
.perform(click())
275276
Thread.sleep(2000) // wait until ready
276277
saveScreenshot()
277-
for (text in arrayOf("root", "Trilium Demo Title Edited!", "Journal", "2021", "12 - December")) {
278+
for (text in arrayOf("root", "Journal", "2021", "12 - December")) {
278279
onView(
279280
allOf(
280281
withText(text),
@@ -379,8 +380,15 @@ class InitialSyncTest {
379380
Thread.sleep(5000)
380381
onView(withId(R.id.drawer_layout))
381382
.perform(DrawerActions.open(Gravity.START))
382-
onView(withText("Journal"))
383+
onView(
384+
allOf(
385+
withText("Trilium Demo Title Edited!"),
386+
hasSibling(withId(R.id.note_icon))
387+
)
388+
)
383389
.perform(longClick())
390+
// onView(withText("Journal"))
391+
// .perform(longClick())
384392
onView(withText("2021"))
385393
.perform(click())
386394
// wait for note to load
@@ -400,6 +408,13 @@ class InitialSyncTest {
400408
Thread.sleep(5000)
401409
onView(withId(R.id.drawer_layout))
402410
.perform(DrawerActions.open(Gravity.START))
411+
onView(
412+
allOf(
413+
withText("Trilium Demo Title Edited!"),
414+
hasSibling(withId(R.id.note_icon))
415+
)
416+
)
417+
.perform(longClick())
403418
saveScreenshot()
404419
}
405420

@@ -410,6 +425,8 @@ class InitialSyncTest {
410425
.perform(DrawerActions.open(Gravity.START))
411426
onView(withText("Books"))
412427
.perform(longClick())
428+
onView(withText("Formatting examples"))
429+
.perform(longClick())
413430
Thread.sleep(500)
414431
saveScreenshot()
415432
onView(withText("The Last Question"))
@@ -504,6 +521,7 @@ class InitialSyncTest {
504521
private fun withIndex(matcher: Matcher<View>, index: Int): Matcher<View> {
505522
return object : TypeSafeMatcher<View>() {
506523
var currentIndex: Int = 0
524+
var matched: WeakReference<View> = WeakReference(null)
507525

508526
override fun describeTo(description: Description) {
509527
description.appendText("with index: ")
@@ -512,7 +530,28 @@ private fun withIndex(matcher: Matcher<View>, index: Int): Matcher<View> {
512530
}
513531

514532
override fun matchesSafely(view: View): Boolean {
515-
return matcher.matches(view) && currentIndex++ == index
533+
val previous = matched.get()
534+
if (previous == view) {
535+
return true
536+
}
537+
if (matcher.matches(view) && currentIndex++ == index) {
538+
matched = WeakReference(view)
539+
return true
540+
}
541+
return false
542+
}
543+
}
544+
}
545+
546+
private fun hasCoordinateX(x: Float): Matcher<View> {
547+
return object : TypeSafeMatcher<View>() {
548+
override fun describeTo(description: Description) {
549+
description.appendText("with x: ")
550+
description.appendValue(x)
551+
}
552+
553+
override fun matchesSafely(view: View): Boolean {
554+
return view.x == x
516555
}
517556
}
518557
}
96 Bytes
Loading
6 Bytes
Loading
-1.05 KB
Loading
-507 Bytes
Loading
85 Bytes
Loading
731 Bytes
Loading
501 Bytes
Loading
-289 Bytes
Loading

0 commit comments

Comments
 (0)