Skip to content

Commit

Permalink
Add the Android interop test App.
Browse files Browse the repository at this point in the history
So far, it is built separately from the other gRpc components.
  • Loading branch information
Xudong Ma committed Jun 26, 2015
1 parent a479c91 commit f88779e
Show file tree
Hide file tree
Showing 22 changed files with 2,392 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
build
gradle.properties
.gradle
local.properties

# IntelliJ IDEA
.idea
Expand Down
46 changes: 46 additions & 0 deletions android-interop-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
gRPC Android test App
=======================

Implements gRPC integration tests in an Android App.

TODO(madongfly) integrate this App into the gRPC-Java build system.

In order to build this app, you need a local.properties file under this directory which specifies
the location of your android sdk:
```
sdk.dir=/somepath/somepath/sdk
```

Connect your Android device or start the emulator:
```
$ ./start-emulator.sh <AVD name> & ./wait-for-emulator.sh
```

Manually test
-------------

Install the App by:
```
$ ../gradlew installDebug
```
Then manually test it with the UI.


Commandline test
----------------

Run the test with arguments:
```
$ adb shell am instrument -w -e server_host <hostname or ip address> -e server_port 8030 -e server_host_override foo.test.google.fr -e use_tls true -e use_test_ca true -e test_case all io.grpc.android.integrationtest/.TesterInstrumentation
```

If the test passed successfully, it will output:
```
INSTRUMENTATION_RESULT: grpc test result=Succeed!!!
INSTRUMENTATION_CODE: 0
```
otherwise, output something like:
```
INSTRUMENTATION_RESULT: grpc test result=Failed... : <exception stacktrace if applicable>
INSTRUMENTATION_CODE: 1
```
34 changes: 34 additions & 0 deletions android-interop-testing/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion '22.0.1'

defaultConfig {
applicationId "io.grpc.android.integrationtest"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services-base:7.3.0'
compile 'com.google.code.findbugs:jsr305:3.0.0'
compile 'com.google.guava:guava:18.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
testCompile 'junit:junit:4.12'
// You need to build grpc-java to obtain these libraries below.
compile 'io.grpc:grpc-core:0.8.0-SNAPSHOT'
compile 'io.grpc:grpc-protobuf-nano:0.8.0-SNAPSHOT'
compile 'io.grpc:grpc-okhttp:0.8.0-SNAPSHOT'
compile 'io.grpc:grpc-stub:0.8.0-SNAPSHOT'
}
17 changes: 17 additions & 0 deletions android-interop-testing/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/thagikura/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
32 changes: 32 additions & 0 deletions android-interop-testing/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.grpc.android.integrationtest" >

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Base.V7.Theme.AppCompat.Light" >
<activity
android:name=".TesterActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>

<instrumentation android:functionalTest="true"
android:label="@string/app_name"
android:name=".TesterInstrumentation"
android:targetPackage="io.grpc.android.integrationtest" />

</manifest>

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

Loading

0 comments on commit f88779e

Please sign in to comment.