[android] - build and test wear module on CI, cleanup gradle file, added make target, added unit test (#7534)
This commit is contained in:
16
Makefile
16
Makefile
@@ -511,7 +511,7 @@ run-android-core-test-$1: android-test-lib-$1
|
||||
# Compile main sources and extract the classes (using the test app to get all transitive dependencies in one place)
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:assembleDebug
|
||||
unzip -o platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug.apk classes.dex -d build/android-$1/$(BUILDTYPE)
|
||||
|
||||
|
||||
#Compile Test runner
|
||||
find platform/android/src/test -name "*.java" > build/android-$1/$(BUILDTYPE)/java-sources.txt
|
||||
javac -sourcepath platform/android/src/test -d build/android-$1/$(BUILDTYPE) -source 1.7 -target 1.7 @build/android-$1/$(BUILDTYPE)/java-sources.txt
|
||||
@@ -540,7 +540,7 @@ run-android-core-test-$1: android-test-lib-$1
|
||||
|
||||
.PHONY: run-android-$1
|
||||
run-android-$1: android-$1
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:installDebug && adb shell am start -n com.mapbox.mapboxsdk.testapp/.activity.FeatureOverviewActivity
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:installDebug && adb shell am start -n com.mapbox.mapboxsdk.testapp/.activity.FeatureOverviewActivity
|
||||
|
||||
apackage: android-lib-$1
|
||||
endef
|
||||
@@ -552,18 +552,22 @@ android: android-arm-v7
|
||||
|
||||
.PHONY: run-android
|
||||
run-android: run-android-arm-v7
|
||||
|
||||
|
||||
.PHONY: run-android-unit-test
|
||||
run-android-unit-test:
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:testDebugUnitTest --continue
|
||||
|
||||
.PHONY: run-android-wear-unit-test
|
||||
run-android-wear-unit-test:
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKWearTestApp:testDebugUnitTest --continue
|
||||
|
||||
.PHONY: android-ui-test
|
||||
android-ui-test:
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:assembleDebug --continue && ./gradlew :MapboxGLAndroidSDKTestApp:assembleAndroidTest --continue
|
||||
|
||||
.PHONY: run-android-ui-test
|
||||
run-android-ui-test:
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:connectedAndroidTest -i
|
||||
cd platform/android && ./gradlew :MapboxGLAndroidSDKTestApp:connectedAndroidTest -i
|
||||
|
||||
.PHONY: run-android-ui-test-aws
|
||||
run-android-ui-test-aws:
|
||||
@@ -583,9 +587,9 @@ test-code-android:
|
||||
|
||||
.PHONY: android-ndk-stack
|
||||
android-ndk-stack:
|
||||
adb logcat | ndk-stack -sym build/android-arm-v7/Debug
|
||||
adb logcat | ndk-stack -sym build/android-arm-v7/Debug
|
||||
|
||||
.PHONY: android-checkstyle
|
||||
.PHONY: android-checkstyle
|
||||
android-checkstyle:
|
||||
cd platform/android && ./gradlew checkstyle
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
ext {
|
||||
wearableVersion = '2.0.0-alpha3'
|
||||
leakCanaryVersion = '1.5'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.0"
|
||||
buildToolsVersion "25.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.mapbox.mapboxsdk.testapp"
|
||||
@@ -13,6 +18,9 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
testCoverageEnabled = true
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
@@ -27,13 +35,17 @@ dependencies {
|
||||
|
||||
// Wear
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.google.android.support:wearable:2.0.0-alpha3'
|
||||
provided 'com.google.android.wearable:wearable:2.0.0-alpha3'
|
||||
compile "com.google.android.support:wearable:${wearableVersion}"
|
||||
provided "com.google.android.wearable:wearable:${wearableVersion}"
|
||||
|
||||
// Leak Canary
|
||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
|
||||
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
|
||||
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
|
||||
debugCompile "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
|
||||
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
|
||||
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
|
||||
|
||||
// Testing dependencies
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.mockito:mockito-core:2.2.27'
|
||||
}
|
||||
|
||||
apply from: 'gradle-config.gradle'
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mapbox.weartestapp.utils;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class OffsettingHelperTest {
|
||||
|
||||
private static final double DELTA = 1e-15;
|
||||
|
||||
@InjectMocks
|
||||
View view = mock(View.class);
|
||||
|
||||
@Test
|
||||
public void testAnchorOffset() {
|
||||
float[] offset = new float[2];
|
||||
int viewHeight = 50;
|
||||
when(view.getHeight()).thenReturn(viewHeight);
|
||||
OffsettingHelper offsettingHelper = new OffsettingHelper();
|
||||
offsettingHelper.adjustAnchorOffsetXY(view, offset);
|
||||
assertEquals("Offset of " + viewHeight + " should be divided by 2: ", viewHeight / 2, offset[0], DELTA);
|
||||
}
|
||||
}
|
||||
@@ -83,13 +83,21 @@ workflows:
|
||||
echo "Compiling core tests:"
|
||||
BUILDTYPE=Debug make android-test-lib-arm-v7
|
||||
- script:
|
||||
title: Run local JVM Unit tests
|
||||
title: Run local JVM Unit tests on phone module
|
||||
run_if: '{{enveq "SKIPCI" "false"}}'
|
||||
inputs:
|
||||
- content: |-
|
||||
#!/bin/bash
|
||||
echo "Running unit tests from testapp/src/test:"
|
||||
echo "Running unit tests from MapboxGLAndroidSDKTestApp/src/test:"
|
||||
make run-android-unit-test
|
||||
- script:
|
||||
title: Run local JVM Unit tests on wear module
|
||||
run_if: '{{enveq "SKIPCI" "false"}}'
|
||||
inputs:
|
||||
- content: |-
|
||||
#!/bin/bash
|
||||
echo "Running unit tests from MapboxGLAndroidSDKWearTestApp/src/test:"
|
||||
make run-android-wear-unit-test
|
||||
- script:
|
||||
title: Generate Espresso sanity tests
|
||||
run_if: '{{enveq "SKIPCI" "false"}}'
|
||||
|
||||
Reference in New Issue
Block a user