[android] - build and test wear module on CI, cleanup gradle file, added make target, added unit test (#7534)

This commit is contained in:
Tobrun
2016-12-28 15:16:18 +01:00
committed by GitHub
parent 65c28deefe
commit eefbb754d0
4 changed files with 66 additions and 14 deletions

View File

@@ -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'

View File

@@ -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);
}
}