Skip to content

Commit

Permalink
Merge pull request #200 from stepstone-tech/develop
Browse files Browse the repository at this point in the history
Release 4.2.0
  • Loading branch information
zawadz88 authored Sep 13, 2017
2 parents 8868474 + 85d7e47 commit f831bed
Show file tree
Hide file tree
Showing 35 changed files with 1,811 additions and 94 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.2.0]
### Added
- A new artifact `espresso-material-stepper` with useful Espresso actions and matchers for testing `StepperLayout` with Espresso.

### Fixed
- Maven dependencies so that `material-stepper` depends on `AppCompat` after migration to Gradle 4.1.

## [4.1.0]
### Added
- An option to show a subtitle in each tab
Expand All @@ -23,5 +30,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- **Breaking change:** Changed `setNextButtonLabel` methods in `StepViewModel.Builder` to `setEndButtonLabel` so that it works for both Next and Complete buttons (issue #107)
- **Breaking change:** Split `content` stepper feedback type into `content_progress` and `content_fade`.

[4.2.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.1.0...v4.2.0
[4.1.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.0.0...v4.1.0
[4.0.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v3.3.0...v4.0.0
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src ="./art/material-stepper-logo.png" width="256" height="256"/>
</p>

# Android Material Stepper [![CircleCI](https://circleci.com/gh/stepstone-tech/android-material-stepper.svg?style=svg)](https://circleci.com/gh/stepstone-tech/android-material-stepper) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20Material%20Stepper-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5138) [![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23243-brightgreen.svg)](http://androidweekly.net/issues/issue-243)
# Android Material Stepper [![CircleCI](https://circleci.com/gh/stepstone-tech/android-material-stepper.svg?style=svg)](https://circleci.com/gh/stepstone-tech/android-material-stepper) [![codecov](https://codecov.io/gh/stepstone-tech/android-material-stepper/branch/master/graph/badge.svg)](https://codecov.io/gh/stepstone-tech/android-material-stepper) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20Material%20Stepper-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5138) [![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23243-brightgreen.svg)](http://androidweekly.net/issues/issue-243)

This library allows to use Material steppers inside Android applications.

Expand Down Expand Up @@ -33,6 +33,8 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati
- [View attributes](#view-attributes)
- [StepperLayout style attributes](#stepperlayout-style-attributes)
- [Changelog](#changelog)
- [Espresso tests](#espresso-tests)
- [Contributing](#contributing)
- [License](#license)

## Supported steppers
Expand Down Expand Up @@ -64,10 +66,10 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati

### Download (from JCenter)
```groovy
compile 'com.stepstone.stepper:material-stepper:4.1.0'
compile 'com.stepstone.stepper:material-stepper:4.2.0'
```

*Note:* This adds a transitive dependency to AppCompat `25.4.0`
*Note:* This library adds a transitive dependency to AppCompat `25.4.0`
which is the minimum Android Support library version compatible with the Stepper library.

### Create layout in XML
Expand Down Expand Up @@ -526,6 +528,36 @@ A list of `ms_stepperLayoutTheme` attributes responsible for styling of StepperL
## Changelog
See [changelog](CHANGELOG.md)

## Espresso tests
If you wish to run Espresso tests on a screen containing a `StepperLayout` you might want to use
`espresso-material-stepper` which contains useful Espresso actions and matchers such as clicking on
navigation buttons & tabs.
To do so add a Gradle dependency:

```groovy
androidTestCompile 'com.stepstone.stepper:espresso-material-stepper:X.X.X'
```

Please see the sample app which uses it in instrumentation tests for more details.

## Contributing
All contributions are welcome and encouraged!

If you wish to contribute please create an issue first explaining the proposed changes.

Project is built on Circle CI on which we run static code analysis as well as unit & instrumentation tests
to ensure that the latest changes don't break anything.
To check if your changes pass execute:
```
./gradlew checkWithUiTests
```
Or on a device below Marshmallow:
```
./gradlew checkWithUiTests -Ptest.integration.options.adbInstallOptions=-r
```
## License
Copyright 2016 StepStone Services
Expand Down
34 changes: 29 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext.gradleAndroidVersion = '3.0.0-beta2'
ext.gradleAndroidVersion = '3.0.0-beta4'
ext.kotlinVersion = '1.1.3-2'
ext.bintrayVersion = '1.4'
ext.mavenGradlePluginVersion = '1.4.1'
ext.bintrayVersion = '1.7.3'
ext.mavenGradlePluginVersion = '2.0'

repositories {
jcenter()
Expand Down Expand Up @@ -39,8 +39,9 @@ configure(allprojects) {
robolectricVersion = '3.3.1'
assertjVersion = '1.1.1'

supportTestVersion = '1.0.0'
espressoVersion = '3.0.0'
supportTestVersion = '1.0.1'
espressoVersion = '3.0.1'
testButlerVersion = '1.3.1'

/* Sample only */
butterknifeVersion = '8.5.1'
Expand All @@ -52,3 +53,26 @@ configure(allprojects) {
task clean(type: Delete) {
delete rootProject.buildDir
}

ext {
bintrayRepo = 'maven'
bintrayName = POM_ARTIFACT_ID

publishedGroupId = POM_GROUP_ID
libraryName = 'Android Material Stepper'

libraryDescription = 'This library allows to use Material steppers inside Android applications.'

siteUrl = 'https://github.com/stepstone-tech/android-material-stepper'
gitUrl = 'https://github.com/stepstone-tech/android-material-stepper.git'

libraryVersion = POM_VERSION

developerId = 'zawadz88'
developerName = 'Piotr Zawadzki'
developerEmail = '[email protected]'

licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
20 changes: 12 additions & 8 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ machine:
environment:
PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-4.1/bin:$PATH"
TERM: "dumb"
ADB_INSTALL_TIMEOUT: "10"
ADB_INSTALL_TIMEOUT: "20"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
_JAVA_OPTIONS: "-Xms512m -Xmx1024m -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -XX:ParallelGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2"

Expand All @@ -23,13 +23,13 @@ dependencies:
test:
override:
# run static analysis and unit tests with coverage
- ./gradlew checkWithCoverage --stacktrace --no-daemon
- ./gradlew checkWithCoverage :sample:lintDebug --stacktrace --no-daemon

# Create SD card (needed for screenshots)
- mksdcard -l sdcard 200M sdcard.img

# start the emulator
- emulator -avd circleci-android22 -sdcard sdcard.img -no-audio -no-window:
- emulator -avd circleci-android22 -sdcard sdcard.img -memory 2048 -no-audio -no-window:
background: true
parallel: true
# wait for it to have booted
Expand All @@ -38,12 +38,16 @@ test:
# unlock the emulator screen
- adb shell input keyevent 82

# run instrumentation tests with coverage & lint for the sample app
- ./gradlew :sample:lintDebug mergedJacocoTestReport --stacktrace --no-daemon -Ptest.integration.options.adbInstallOptions=-r
- ./gradlew install --no-daemon
# run instrumentation tests with coverage
- ./gradlew mergedJacocoTestReport --info --stacktrace --no-daemon -Ptest.integration.options.adbInstallOptions=-r

# upload code coverage reports to Codecov.io
- bash <(curl -s https://codecov.io/bash)
# Grab the screen from device at the end (useful if tests fail)
- adb shell screencap -p /sdcard/after_tests.png && adb pull /sdcard/after_tests.png sample/build/reports

- ./gradlew install --no-daemon --stacktrace

# upload merged code coverage report to Codecov.io
- bash <(curl -s https://codecov.io/bash) -f sample/build/reports/jacoco/mergedJacocoTestReport/mergedJacocoTestReport.xml

post:
# copy the test results to the test results directory
Expand Down
1 change: 1 addition & 0 deletions espresso-material-stepper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions espresso-material-stepper/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apply plugin: 'com.android.library'
apply plugin: 'maven'

android {
compileSdkVersion project.androidCompileSdkVersion
buildToolsVersion("$androidBuildToolsVersion")

defaultConfig {
minSdkVersion project.androidMinSdkVersion
targetSdkVersion project.androidTargetSdkVersion
}

lintOptions {
warningsAsErrors true
}
}

dependencies {
api project(':material-stepper')
api "com.android.support.test.espresso:espresso-core:$espressoVersion"
}

gradle.taskGraph.beforeTask { Task task ->
if (task instanceof Javadoc) {
def releaseVariant = android.libraryVariants.find { it.buildType.name == 'release' }
Javadoc javadocTask = (Javadoc) task
javadocTask.source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
javadocTask.classpath = files(releaseVariant.javaCompile.classpath.files) + files(ext.androidJar)
}
}

ext {
artifact = POM_TEST_ARTIFACT_ID
}

apply from: '../installv1.gradle'
apply from: '../bintrayv1.gradle'
2 changes: 2 additions & 0 deletions espresso-material-stepper/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stepstone.stepper.test" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.stepstone.stepper.test;

import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.test.espresso.matcher.BoundedMatcher;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.stepstone.stepper.StepperLayout;
import com.stepstone.stepper.internal.widget.StepTab;

import org.hamcrest.Description;
import org.hamcrest.Matcher;

/**
* Checks the subtitle of a {@link StepTab} at a specified position.
*
* @author Piotr Zawadzki
*/
public class StepperLayoutTabSubtitleMatcher extends BoundedMatcher<View, StepperLayout> {

private static final String TAG = "StepperLayoutTabSubtMa";

@IntRange(from = 0)
private final int tabPosition;

@NonNull
private final Matcher<View> subtitleMatcher;

private StepperLayoutTabSubtitleMatcher(@IntRange(from = 0) int tabPosition, @NonNull Matcher<View> subtitleMatcher) {
super(StepperLayout.class);
this.tabPosition = tabPosition;
this.subtitleMatcher = subtitleMatcher;
}

@Override
public void describeTo(Description description) {
description
.appendText(" at position: ")
.appendValue(tabPosition)
.appendText(" with message: ")
.appendValue(subtitleMatcher);
}

@Override
protected boolean matchesSafely(StepperLayout view) {
ViewGroup tabsContainer = (ViewGroup) view.findViewById(com.stepstone.stepper.R.id.ms_stepTabsInnerContainer);
int childCount = tabsContainer.getChildCount();

if (childCount == 0) {
Log.e(TAG, "No tabs found!");
return false;
}

if (tabPosition < 0 || tabPosition >= childCount) {
Log.e(TAG, "Invalid tab position: " + tabPosition);
return false;
}

StepTab stepTab = (StepTab) tabsContainer.getChildAt(tabPosition);
TextView subtitleTextView = (TextView) stepTab.findViewById(com.stepstone.stepper.R.id.ms_stepSubtitle);

return subtitleMatcher.matches(subtitleTextView);
}

public static Matcher<View> tabAtPositionHasSubtitle(@IntRange(from = 0) int tabPosition, @NonNull Matcher<View> subtitleMatcher) {
return new StepperLayoutTabSubtitleMatcher(tabPosition, subtitleMatcher);
}

}
Loading

0 comments on commit f831bed

Please sign in to comment.