-
Notifications
You must be signed in to change notification settings - Fork 124
CI enable integration test on Android Emulator #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
fb6eedd
Enable test on android emulator automatically
sunmou99 b25f255
Add android gameloop app
sunmou99 e640949
Enable test on simulator
sunmou99 3b102cb
change Permission
sunmou99 2dd62e6
add flag that notify it's in ci
sunmou99 2ee8867
format summary log
sunmou99 14af2b9
Merge branch 'feature/test-on-android-emulator' of https://github.com…
sunmou99 93e3a10
fix ios simulator
sunmou99 75d0e80
fix ios simulator
sunmou99 c888cef
boot emulator in background
sunmou99 80a56ab
Update description
sunmou99 d5a6f3b
format test summary
sunmou99 2171e5c
format PATH
sunmou99 645154f
Update GameLoopUITest.kt
sunmou99 e143493
Update test timeout to 15 minutes
sunmou99 06c479a
update timeout
sunmou99 a2fe977
update report summary
sunmou99 f5d030b
Update summarize_test_results.py
sunmou99 96d59a5
Update platform name match
sunmou99 d0a2a87
update based on comments
sunmou99 32bc10b
update based on comments
sunmou99 06f938e
update based on comments
sunmou99 da73414
update based on comments
sunmou99 512f746
update based on comments
sunmou99 95e3968
update based on comments
sunmou99 ae2335d
fix typo
sunmou99 3ac7579
add return value description & put string into res
sunmou99 35faf86
Disable simulator test
sunmou99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
35 changes: 35 additions & 0 deletions
35
scripts/gha/integration_testing/gameloop_android/app/build.gradle
This file contains hidden or 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,35 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
sunmou99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
android { | ||
compileSdkVersion rootProject.compileSdk | ||
buildToolsVersion rootProject.buildTools | ||
|
||
defaultConfig { | ||
applicationId "com.google.firebase.gameloop" | ||
minSdkVersion rootProject.minSdk | ||
targetSdkVersion rootProject.targetSdk | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: "libs", include: ["*.jar"]) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
implementation 'androidx.core:core-ktx:1.1.0' | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
|
||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' | ||
} |
6 changes: 6 additions & 0 deletions
6
scripts/gha/integration_testing/gameloop_android/app/src/androidTest/AndroidManifest.xml
This file contains hidden or 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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.google.firebase.gameloop"> | ||
<uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator"/> | ||
</manifest> |
43 changes: 43 additions & 0 deletions
43
.../gameloop_android/app/src/androidTest/java/com/google/firebase/gameloop/GameLoopUITest.kt
This file contains hidden or 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,43 @@ | ||
package com.google.firebase.gameloop | ||
sunmou99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.filters.SdkSuppress | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.Until | ||
import junit.framework.Assert.assertNotNull | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
@SdkSuppress(minSdkVersion = 18) | ||
class GameLoopUITest { | ||
|
||
companion object { | ||
const val GAMELOOP_TIMEOUT = 7 * 60 * 1000L | ||
} | ||
|
||
private lateinit var device: UiDevice | ||
|
||
@get:Rule | ||
var activityRule: ActivityScenarioRule<MainActivity> | ||
= ActivityScenarioRule(MainActivity::class.java) | ||
|
||
@Before | ||
fun initDevice() { | ||
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
} | ||
|
||
@Test | ||
fun testLaunchGameLoop() { | ||
val element = device.wait( | ||
Until.findObject(By.text(getInstrumentation().targetContext.getString(R.string.test_complete))), | ||
GAMELOOP_TIMEOUT) | ||
assertNotNull(element) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
scripts/gha/integration_testing/gameloop_android/app/src/main/AndroidManifest.xml
This file contains hidden or 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,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.google.firebase.gameloop"> | ||
|
||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<provider | ||
android:authorities="com.google.firebase.gameloop.fileprovider" | ||
android:name="androidx.core.content.FileProvider" | ||
android:exported="false" | ||
android:grantUriPermissions="true"> | ||
<meta-data | ||
android:name="android.support.FILE_PROVIDER_PATHS" | ||
android:resource="@xml/file_paths"/> | ||
</provider> | ||
</application> | ||
|
||
</manifest> |
54 changes: 54 additions & 0 deletions
54
...n_testing/gameloop_android/app/src/main/java/com/google/firebase/gameloop/MainActivity.kt
This file contains hidden or 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,54 @@ | ||
package com.google.firebase.gameloop | ||
|
||
import android.content.Intent | ||
import android.content.pm.ResolveInfo | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.TextView | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.content.FileProvider | ||
import java.io.File | ||
|
||
|
||
class MainActivity : AppCompatActivity(R.layout.activity_main) { | ||
companion object { | ||
const val GAMELOOP_INTENT = "com.google.intent.action.TEST_LOOP" | ||
const val TEST_LOOP_REQUEST_CODE = 1 | ||
} | ||
|
||
private lateinit var testingTV: TextView | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
testingTV = findViewById(R.id.test) | ||
launchGame() | ||
} | ||
|
||
private fun launchGame() { | ||
val intent = Intent(GAMELOOP_INTENT, null) | ||
intent.addCategory(Intent.CATEGORY_DEFAULT) | ||
intent.type = "application/javascript" | ||
val pkgAppsList: List<ResolveInfo> = packageManager.queryIntentActivities(intent, 0) | ||
val gamePackageName = pkgAppsList[0].activityInfo.packageName | ||
sunmou99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
val dir = File(getExternalFilesDir(null), gamePackageName) | ||
if (!dir.exists()) dir.mkdirs() | ||
val filename = "Results1.json" | ||
val file = File(dir, filename) | ||
file.createNewFile() | ||
Log.d("TAG", "Test Result Path :" + file) | ||
val fileUri: Uri = FileProvider.getUriForFile(this, "com.google.firebase.gameloop.fileprovider", file) | ||
|
||
intent.setPackage(gamePackageName) | ||
.setDataAndType(fileUri, "application/javascript").flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION | ||
|
||
startActivityForResult(intent, TEST_LOOP_REQUEST_CODE) | ||
} | ||
|
||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | ||
super.onActivityResult(requestCode, resultCode, data) | ||
when (requestCode) { | ||
TEST_LOOP_REQUEST_CODE -> testingTV.text = getString(R.string.test_complete) | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
scripts/gha/integration_testing/gameloop_android/app/src/main/res/layout/activity_main.xml
This file contains hidden or 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,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/testing" | ||
android:id="@+id/test" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
Binary file added
BIN
+10.4 KB
...ration_testing/gameloop_android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
scripts/gha/integration_testing/gameloop_android/app/src/main/res/values/colors.xml
This file contains hidden or 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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#6200EE</color> | ||
<color name="colorPrimaryDark">#3700B3</color> | ||
<color name="colorAccent">#03DAC5</color> | ||
</resources> |
5 changes: 5 additions & 0 deletions
5
scripts/gha/integration_testing/gameloop_android/app/src/main/res/values/strings.xml
This file contains hidden or 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,5 @@ | ||
<resources> | ||
<string name="app_name">gameloop</string> | ||
<string name="testing">Testing</string> | ||
<string name="test_complete">Game Loop Complete</string> | ||
</resources> |
10 changes: 10 additions & 0 deletions
10
scripts/gha/integration_testing/gameloop_android/app/src/main/res/values/styles.xml
This file contains hidden or 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 @@ | ||
<resources> | ||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |
6 changes: 6 additions & 0 deletions
6
scripts/gha/integration_testing/gameloop_android/app/src/main/res/xml/file_paths.xml
This file contains hidden or 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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<paths> | ||
<external-path | ||
name="files" | ||
path="/"/> | ||
</paths> |
33 changes: 33 additions & 0 deletions
33
scripts/gha/integration_testing/gameloop_android/build.gradle
This file contains hidden or 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,33 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
ext.kotlin_version = "1.3.72" | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath "com.android.tools.build:gradle:4.0.1" | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
ext { | ||
compileSdk = 28 | ||
buildTools = '28.0.3' | ||
minSdk = 16 | ||
targetSdk = 28 | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
21 changes: 21 additions & 0 deletions
21
scripts/gha/integration_testing/gameloop_android/gradle.properties
This file contains hidden or 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,21 @@ | ||
# Project-wide Gradle settings. | ||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx2048m | ||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
# AndroidX package structure to make it clearer which packages are bundled with the | ||
# Android operating system, and which are packaged with your app"s APK | ||
# https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
android.useAndroidX=true | ||
sunmou99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Automatically convert third-party libraries to use AndroidX | ||
android.enableJetifier=true | ||
# Kotlin code style for this project: "official" or "obsolete": | ||
kotlin.code.style=official |
Binary file added
BIN
+53.1 KB
scripts/gha/integration_testing/gameloop_android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
scripts/gha/integration_testing/gameloop_android/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or 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,6 @@ | ||
#Sat Apr 03 15:11:30 PDT 2021 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.