Added test-projects to solution and upgraded build to latest tools.

This commit is contained in:
Alexander Pacha
2016-05-01 21:09:14 +02:00
parent 312d0d7d71
commit a9b030cd72
6 changed files with 137 additions and 12 deletions

View File

@@ -2,22 +2,35 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "org.hitlabnz.sensor_fusion_demo"
minSdkVersion 11
minSdkVersion 18
targetSdkVersion 23
versionCode 4
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:support-v4:23.3.0'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.android.support:support-annotations:23.3.0'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
}

17
app/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/alex/Library/Developer/Xamarin/android-sdk-macosx/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 *;
#}

View File

@@ -0,0 +1,66 @@
package org.hitlabnz.sensor_fusion_demo.androidTest;
import android.app.Application;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.ApplicationTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import org.hitlabnz.sensor_fusion_demo.R;
import org.hitlabnz.sensor_fusion_demo.SensorSelectionActivity;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.hasLinks;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
///**
// * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
// */
//public class ApplicationTest extends ApplicationTestCase<Application> {
// public ApplicationTest() {
// super(Application.class);
// }
//}
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ApplicationTest {
@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule<>(
SensorSelectionActivity.class);
@Test
public void checkAssertMenuExists(){
DiscardGyroscopeWarning();
// Act & Assert
AssertThatAboutActionMenuExists();
}
@Test
public void clickAboutMenu_expectAboutToBeDisplayed(){
DiscardGyroscopeWarning();
// Act
onView(withId(R.id.action_about)).perform(click());
onView(withId(R.id.webViewAbout)).check(matches(ViewMatchers.isDisplayed()));
}
public void AssertThatAboutActionMenuExists() {
onView(withId(R.id.action_about)).check(matches(withText("About")));
}
public static void DiscardGyroscopeWarning() {
onView(withText("OK")).perform(click());
}
}

View File

@@ -1,12 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.hitlabnz.sensor_fusion_demo"
android:versionCode="3"
android:versionName="1.2" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
package="org.hitlabnz.sensor_fusion_demo" >
<application
android:allowBackup="false"
@@ -19,7 +13,6 @@
android:screenOrientation="nosensor" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

View File

@@ -0,0 +1,30 @@
package org.hitlabnz.sensor_fusion_demo.test;
import org.hitlabnz.sensor_fusion_demo.representation.Quaternion;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class QuaternionTest {
@Test
public void quaternion_loadUnityQuaternion_expectCorrectValues() throws Exception {
// Arrange
Quaternion q = new Quaternion();
// Act
q.loadIdentityQuat();
// Assert
assertThat(q.w(), is(equalTo(1.0f)));
assertThat(q.x(), is(equalTo(0.0f)));
assertThat(q.y(), is(equalTo(0.0f)));
assertThat(q.z(), is(equalTo(0.0f)));
}
}

View File

@@ -2,6 +2,7 @@
buildscript {
repositories {
jcenter()
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
@@ -11,5 +12,10 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url 'http://repo1.maven.org/maven2' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}