-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cda15d3
commit 50ac029
Showing
10 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
app/src/androidTest/kotlin/eu/fliegendewurst/triliumdroid/InitialSyncTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package eu.fliegendewurst.triliumdroid | ||
|
||
import android.graphics.Bitmap | ||
import android.graphics.BitmapFactory | ||
import androidx.test.core.graphics.writeToTestStorage | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.Espresso.onView | ||
import androidx.test.espresso.action.ViewActions.captureToBitmap | ||
import androidx.test.espresso.action.ViewActions.click | ||
import androidx.test.espresso.action.ViewActions.pressBack | ||
import androidx.test.espresso.action.ViewActions.typeText | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import eu.fliegendewurst.triliumdroid.activity.main.MainActivity | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.io.IOException | ||
|
||
import androidx.test.ext.junit.rules.activityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.FixMethodOrder | ||
import org.junit.rules.TestName | ||
import org.junit.runners.MethodSorters | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) | ||
class InitialSyncTest { | ||
|
||
@get:Rule | ||
var nameRule = TestName() | ||
|
||
@get:Rule | ||
val activityScenarioRule = activityScenarioRule<MainActivity>() | ||
|
||
@Test | ||
@Throws(IOException::class) | ||
fun test_010_initialSync() { | ||
var index = 1 | ||
onView(ViewMatchers.withId(R.id.button_setup_sync)) | ||
.perform(click()) | ||
onView(ViewMatchers.withId(R.id.server)) | ||
.perform(typeText("http://10.0.2.2:12391")) | ||
onView(ViewMatchers.withId(R.id.password)) | ||
.perform(typeText("1234")) | ||
Espresso.closeSoftKeyboard() | ||
Espresso.pressBack() | ||
Thread.sleep(10000) // wait for Sync to finish | ||
onView(ViewMatchers.isRoot()) | ||
.perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}_${index++}") }) | ||
onView(ViewMatchers.withText("Trilium Demo")) | ||
.perform(click()) | ||
Thread.sleep(1000) // wait for WebView to load | ||
onView(ViewMatchers.isRoot()) | ||
.perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}_${index++}") }) | ||
} | ||
|
||
@Test | ||
@Throws(IOException::class) | ||
fun test_015_renameDialog() { | ||
var index = 1 | ||
// click to open rename dialog | ||
onView(ViewMatchers.withId(R.id.toolbar_title)) | ||
.perform(click()) | ||
// wait for WebView to load | ||
Thread.sleep(1000) | ||
onView(ViewMatchers.isRoot()) | ||
.perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}_${index++}") }) | ||
onView(ViewMatchers.withId(R.id.note_title)) | ||
.perform(typeText(" Title Edited!")) | ||
onView(ViewMatchers.withId(R.id.button_rename_note)) | ||
.perform(click()) | ||
onView(ViewMatchers.isRoot()) | ||
.perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}_${index++}") }) | ||
} | ||
} |
Binary file added
BIN
+21.7 KB
app/src/androidTest/res/screenshots/InitialSyncTest_test_010_initialSync_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.1 KB
app/src/androidTest/res/screenshots/InitialSyncTest_test_010_initialSync_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.35 KB
app/src/androidTest/res/screenshots/InitialSyncTest_test_015_renameDialog_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42 KB
app/src/androidTest/res/screenshots/InitialSyncTest_test_015_renameDialog_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
# Use this script to compare current results against previously "blessed" results. | ||
|
||
for x in app/src/androidTest/res/screenshots/*; do | ||
f=$(basename "$x") | ||
[ ! -e "app/build/outputs/managed_device_android_test_additional_output/debug/pixel9api35/${f}scaled.png" ] \ | ||
&& magick "app/build/outputs/managed_device_android_test_additional_output/debug/pixel9api35/$f" \ | ||
-scale 25% "app/build/outputs/managed_device_android_test_additional_output/debug/pixel9api35/${f}scaled.png" | ||
echo -n "comparing $f.. " | ||
magick compare -metric mae "$x" \ | ||
"app/build/outputs/managed_device_android_test_additional_output/debug/pixel9api35/${f}scaled.png" "/tmp/diff_$f" | ||
echo | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
# Use this script to "bless" the current screenshot results. | ||
|
||
rm app/src/androidTest/res/screenshots/* 2>/dev/null | ||
cp app/build/outputs/managed_device_android_test_additional_output/debug/pixel9api35/* app/src/androidTest/res/screenshots/ | ||
for x in app/src/androidTest/res/screenshots/*; do | ||
magick "$x" -scale 25% "${x}scaled.png" | ||
mv "${x}scaled.png" "$x" | ||
done |