Skip to content

Commit

Permalink
Updated tools, Gradle wrapper, dependencies, TravisCI emulator ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Jun 5, 2020
1 parent b7f9396 commit 5a49aaa
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jdk: openjdk8

env:
global:
- ANDROID_API_LEVEL=28
- ANDROID_API_LEVEL=29
- ANDROID_EMULATOR_API_LEVEL=26
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
- ANDROID_ABI=armeabi-v7a
- ANDROID_BUILD_TOOLS_VERSION=29.0.2
- ANDROID_ABI=default/x86

addons:
sonarcloud:
Expand Down Expand Up @@ -37,7 +37,7 @@ android:
- extra-android-m2repository
- sys-img-x86-android-$ANDROID_EMULATOR_API_LEVEL

licenses:
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
Expand Down
13 changes: 8 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

buildscript {
repositories {
mavenLocal()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8"
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8'
classpath "com.hiya:jacoco-android:0.2"
}
// Exclude the version that the android plugin depends on.
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
Expand All @@ -33,8 +35,9 @@ allprojects {
repositories {
mavenLocal()
jcenter()
maven {url "https://jitpack.io"}
maven {url "http://dl.bintray.com/tbruyelle/tbruyelle" }
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com" }
maven { url "https://plugins.gradle.org/m2/" }
google()
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ VERSION_CODE=290
PACKAGE=it.feio.android.omninotes
MIN_SDK=19
TARGET_SDK=28
BUILD_TOOLS=28.0.3
BUILD_TOOLS=29.0.2

android.enableJetifier=true
android.useAndroidX=true
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Mar 15 18:24:16 CET 2020
#Thu Jun 04 17:45:18 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
12 changes: 6 additions & 6 deletions omniNotes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation ('androidx.test.espresso:espresso-intents:3.1.0') {
androidTestImplementation ('androidx.test.espresso:espresso-intents:3.2.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}

Expand All @@ -147,9 +147,9 @@ dependencies {
implementation "ch.acra:acra-toast:5.4.0"
implementation 'com.github.gabrielemariotti.changeloglib:changelog:2.0.0'
implementation 'com.appeaser.sublimepickerlibrary:sublimepickerlibrary:2.1.2'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.android.support:multidex:2.0.1'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'de.greenrobot:eventbus:2.4.0'
implementation 'com.pushbullet:android-extensions:1.0.4@aar'
implementation 'com.getbase:floatingactionbutton:1.10.1'
Expand Down Expand Up @@ -179,7 +179,7 @@ dependencies {
implementation 'com.pnikosis:materialish-progress:1.5'
implementation 'com.github.paolorotolo:appintro:1.3.0'
implementation 'io.reactivex:rxandroid:1.0.1'
implementation 'io.reactivex:rxjava:1.0.14'
implementation 'io.reactivex:rxjava:1.3.8'
implementation 'com.artemzin.rxjava:proguard-rules:1.0.14.2'
implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.4.2@aar'
implementation 'org.ocpsoft.prettytime:prettytime:3.2.7.Final'
Expand Down Expand Up @@ -243,14 +243,14 @@ android.productFlavors.each { flavor ->
flavor.buildConfigField 'String', 'MAPS_API_KEY', '"' + MAPS_API_KEY + '"'
}

apply plugin: 'jacoco-android'
apply plugin: 'com.hiya.jacoco-android'
jacocoAndroidUnitTestReport {
csv.enabled false
html.enabled false
xml.enabled true
}
jacoco {
toolVersion = "0.7.5.201505241946"
toolVersion = "0.8.4"
}

tasks.withType(Test) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package it.feio.android.omninotes;


import androidx.test.espresso.DataInteraction;
import androidx.test.espresso.ViewInteraction;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.pressBack;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.*;
import static androidx.test.espresso.assertion.ViewAssertions.*;
import static androidx.test.espresso.matcher.ViewMatchers.*;

import it.feio.android.omninotes.R;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.is;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {

@Rule
public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);

@Test
public void mainActivityTest() {
// Added a sleep statement to match the app's execution delay.
// The recommended way to handle such scenarios is to use Espresso idling resources:
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}

ViewInteraction viewInteraction = onView(
allOf(withId(R.id.fab_expand_menu_button),
childAtPosition(
allOf(withId(R.id.fab),
childAtPosition(
withClassName(is("android.widget.FrameLayout")),
2)),
3),
isDisplayed()));
viewInteraction.perform(click());

ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_note),
childAtPosition(
allOf(withId(R.id.fab),
childAtPosition(
withClassName(is("android.widget.FrameLayout")),
2)),
2),
isDisplayed()));
floatingActionButton.perform(click());

// Added a sleep statement to match the app's execution delay.
// The recommended way to handle such scenarios is to use Espresso idling resources:
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(7000);
} catch (InterruptedException e) {
e.printStackTrace();
}

ViewInteraction actionMenuItemView = onView(
allOf(withId(R.id.menu_category), withContentDescription("Category"),
childAtPosition(
childAtPosition(
withId(R.id.toolbar),
1),
1),
isDisplayed()));
actionMenuItemView.perform(click());

// Added a sleep statement to match the app's execution delay.
// The recommended way to handle such scenarios is to use Espresso idling resources:
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html
try {
Thread.sleep(7000);
} catch (InterruptedException e) {
e.printStackTrace();
}

ViewInteraction mDButton = onView(
allOf(withId(R.id.md_buttonDefaultPositive), withText("Add category"),
childAtPosition(
childAtPosition(
withId(android.R.id.content),
0),
4),
isDisplayed()));
mDButton.perform(click());

ViewInteraction appCompatEditText = onView(
allOf(withId(R.id.category_title),
childAtPosition(
childAtPosition(
withId(android.R.id.content),
0),
0),
isDisplayed()));
appCompatEditText.perform(replaceText("Asd"), closeSoftKeyboard());

ViewInteraction appCompatButton = onView(
allOf(withId(R.id.save), withText("Ok"),
childAtPosition(
childAtPosition(
withClassName(is("android.widget.LinearLayout")),
3),
1),
isDisplayed()));
appCompatButton.perform(click());
}

private static Matcher<View> childAtPosition(
final Matcher<View> parentMatcher, final int position) {

return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("Child at position " + position + " in parent ");
parentMatcher.describeTo(description);
}

@Override
public boolean matchesSafely(View view) {
ViewParent parent = view.getParent();
return parent instanceof ViewGroup && parentMatcher.matches(parent)
&& view.equals(((ViewGroup)parent).getChildAt(position));
}
};
}
}

0 comments on commit 5a49aaa

Please sign in to comment.