Skip to content
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

Enable Travis CI #80

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copied from https://github.com/leviwilson/android-travis-ci-example
language: java
jdk:
- openjdk6
before_install:
# needed to run SDK on x64 systems
- sudo apt-get update -qq
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch; fi
# download the latest android sdk and unzip
- ifconfig
- export SDK_TAR=android-sdk_r21-linux.tgz
- wget http://dl.google.com/android/$SDK_TAR
- tar -zxf $SDK_TAR
# setup ANDROID_HOME and PATH environment variables
- export ANDROID_HOME=`pwd`/android-sdk-linux
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
# only update the sdk for the platform-tool
# and the api level you are building for.
# run "android list sdk --extended" to get the full list.
# android-14 = 4.0 or API level 14
- android update sdk --filter sysimg-16,platform-tool,android-14,android-16 --obsolete --no-ui --force
install: echo "Skip install"
before_script:
- echo no | android create avd -n emulator16DE -t android-16 -c 50M --abi x86 --skin WVGA800 --force
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 6 # give xvfb some time to start
- emulator -avd emulator16DE -prop persist.sys.language=en -prop persist.sys.country=US -noaudio -no-boot-anim &
- sleep 60
- adb kill-server
- adb start-server
- adb devices
script:
- mvn clean install
after_script:
- adb kill-server
- killall -r emulator*
8 changes: 4 additions & 4 deletions agit-integration-tests/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us --><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.32-SNAPSHOT" package="com.madgag.agit.tests">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.35-SNAPSHOT" package="com.madgag.agit.tests">

<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
<application>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="16"/>
<application android:allowBackup="true">
<uses-library android:name="android.test.runner"/>
</application>

Expand All @@ -14,5 +15,4 @@
"adb shell am instrument -w com.example.android.apis.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:label="Tests for Agit" android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.madgag.agit"/>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
</manifest>
</manifest>
3 changes: 3 additions & 0 deletions agit-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
val ipAddresses = java.net.NetworkInterface.getNetworkInterfaces().filter { !_.isLoopback }.flatMap { _.getInetAddresses }.map { _.getHostAddress }.mkString(",")
AndroidDebugBridge.init(false)
val androidDebugBridge = AndroidDebugBridge.createBridge
// skipping emulator here,
// 10.0.2.2 is used for emulator
// see agit-test-utils/src/main/java/com/madgag/agit/GitTestUtils.java
androidDebugBridge.getDevices.filter { !_.isEmulator } foreach { d =&gt;
val command = "echo gitserver.host.address="+ipAddresses+" &gt; "+d.getMountPoint(IDevice.MNT_EXTERNAL_STORAGE)+"/agit-integration-test.properties"

Expand Down
14 changes: 14 additions & 0 deletions agit-integration-tests/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-7
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@

import roboguice.RoboGuice;

class OperationThreadError {
private String error;
public OperationThreadError() {
error = "";
}
public String get() {
return error;
}
public void set(String newError) {
error = newError;
}
}

public class GitAsyncTaskTest extends ActivityInstrumentationTestCase2<DashboardActivity> {

private static final String TAG = "GitAsyncTaskTest";
Expand Down Expand Up @@ -239,7 +252,8 @@ private Repository executeAndWaitFor(final GitOperation operation)
throws InterruptedException, IOException {
final CountDownLatch latch = new CountDownLatch(1);
Log.d(TAG, "About to start " + operation);
new Thread() {
final OperationThreadError operationThreadError = new OperationThreadError();
Thread operationThread = new Thread() {
public void run() {
Looper.prepare();
Log.d(TAG, "In run method for " + operation);
Expand All @@ -253,7 +267,8 @@ public void publish(Progress progress) {
}

public void error(OpNotification notification) {
Log.i(TAG, "Errored " + operation + " with " + notification);
operationThreadError.set("Errored " + operation + " with " + notification);
Log.i(TAG, operationThreadError.get());
}

public void success(OpNotification completionNotification) {
Expand All @@ -268,7 +283,8 @@ public void completed(OpNotification completionNotification) {
Log.d(TAG, "Called execute() on task for " + operation);
Looper.loop();
}
}.start();
};
operationThread.start();
long startTime = currentTimeMillis();
Log.i(TAG, "Waiting for " + operation + " to complete - currentThread=" + currentThread());
// http://stackoverflow.com/questions/5497324/why-arent-java-util-concurrent-timeunit-types-greater-than
Expand All @@ -277,6 +293,7 @@ public void completed(OpNotification completionNotification) {
long duration = currentTimeMillis() - startTime;
Log.i(TAG, "Finished waiting - timeout=" + timeout + " duration=" + duration);
assertThat("Timeout for " + operation, timeout, is(false));
assertEquals("", operationThreadError.get());
return new FileRepository(operation.getGitDir());
}

Expand Down
30 changes: 23 additions & 7 deletions agit/src/main/java/com/madgag/agit/operations/OpNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ public class OpNotification {
private final CharSequence tickerText, eventTitle, eventDetail;
private final boolean successful;

public OpNotification(int icon, CharSequence tickerText, CharSequence eventDetail) {
public OpNotification(int icon, CharSequence tickerText,
CharSequence eventDetail) {
this(icon, tickerText, tickerText, eventDetail, true);
}

public OpNotification(int icon, CharSequence tickerText, CharSequence eventTitle, CharSequence eventDetail) {
public OpNotification(int icon, CharSequence tickerText,
CharSequence eventTitle, CharSequence eventDetail) {
this(icon, tickerText, eventTitle, eventDetail, true);
}

public OpNotification(int icon, CharSequence tickerText, CharSequence eventTitle, CharSequence eventDetail,
boolean successful) {
public OpNotification(int icon, CharSequence tickerText,
CharSequence eventTitle, CharSequence eventDetail,
boolean successful) {
this.icon = icon;
this.tickerText = tickerText;
this.eventTitle = eventTitle;
Expand All @@ -59,12 +62,25 @@ public CharSequence getEventDetail() {
return eventDetail;
}

public static OpNotification alert(CharSequence eventTitle, CharSequence eventDetail) {
public String toString() {
String repr = "";
repr += eventTitle;
repr += ", ";
repr += tickerText;
repr += ", ";
repr += eventDetail;
return repr;
}

public static OpNotification alert(CharSequence eventTitle,
CharSequence eventDetail) {
return alert(eventDetail, eventTitle, eventDetail);
}

public static OpNotification alert(CharSequence tickerText, CharSequence eventTitle, CharSequence eventDetail) {
return new OpNotification(stat_sys_warning, tickerText, eventTitle, eventDetail);
public static OpNotification alert(CharSequence tickerText,
CharSequence eventTitle, CharSequence eventDetail) {
return new OpNotification(stat_sys_warning, tickerText, eventTitle,
eventDetail);
}

}