-
Notifications
You must be signed in to change notification settings - Fork 38
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
77a5453
commit 8022726
Showing
12 changed files
with
348 additions
and
106 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
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="28" /> | ||
|
||
<instrumentation android:targetPackage="rs.ruffle" | ||
android:name="androidx.test.runner.AndroidJUnitRunner"/> | ||
|
||
<application tools:replace="label" android:label="SmokeTest" /> | ||
</manifest> |
22 changes: 0 additions & 22 deletions
22
app/src/androidTest/java/rs/ruffle/ExampleInstrumentedTest.kt
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
package rs.ruffle | ||
|
||
import android.R | ||
import android.content.ComponentName | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.espresso.matcher.ViewMatchers.assertThat | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.Until | ||
import java.io.File | ||
import org.hamcrest.CoreMatchers.equalTo | ||
import org.hamcrest.CoreMatchers.notNullValue | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
private const val BASIC_SAMPLE_PACKAGE = "rs.ruffle" | ||
private const val LAUNCH_TIMEOUT = 5000L | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class SmokeTest { | ||
private lateinit var device: UiDevice | ||
private lateinit var traceOutput: File | ||
private lateinit var swfFile: File | ||
|
||
@Before | ||
fun startMainActivityFromHomeScreen() { | ||
// Initialize UiDevice instance | ||
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
|
||
// Start from the home screen | ||
device.pressHome() | ||
|
||
// Wait for launcher | ||
val launcherPackage: String = device.launcherPackageName | ||
assertThat(launcherPackage, notNullValue()) | ||
device.wait( | ||
Until.hasObject(By.pkg(launcherPackage).depth(0)), | ||
LAUNCH_TIMEOUT | ||
) | ||
|
||
// Launch the app | ||
val context = ApplicationProvider.getApplicationContext<Context>() | ||
traceOutput = File.createTempFile("trace", ".txt", context.cacheDir) | ||
swfFile = File.createTempFile("movie", ".swf", context.cacheDir) | ||
val inStream = InstrumentationRegistry.getInstrumentation().context.resources.openRawResource( | ||
rs.ruffle.test.R.raw.helloflash | ||
) | ||
val bytes = inStream.readBytes() | ||
swfFile.writeBytes(bytes) | ||
val intent = context.packageManager.getLaunchIntentForPackage( | ||
BASIC_SAMPLE_PACKAGE | ||
)?.apply { | ||
component = ComponentName("rs.ruffle", "rs.ruffle.PlayerActivity") | ||
data = Uri.fromFile(swfFile) | ||
putExtra("traceOutput", traceOutput.absolutePath) | ||
// Clear out any previous instances | ||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) | ||
} | ||
context.startActivity(intent) | ||
|
||
// Wait for the app to appear | ||
device.wait( | ||
Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)), | ||
LAUNCH_TIMEOUT | ||
) | ||
} | ||
|
||
@Test | ||
fun emulatorRunsASwf() { | ||
device.waitForWindowUpdate(null, 1000) | ||
assertThat(device, notNullValue()) | ||
|
||
val trace = traceOutput.readLines() | ||
assertThat(trace, equalTo(listOf("Hello from Flash!"))) | ||
} | ||
} |
Binary file not shown.
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
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
Oops, something went wrong.