Skip to content

Commit f831bed

Browse files
authored
Merge pull request #200 from stepstone-tech/develop
Release 4.2.0
2 parents 8868474 + 85d7e47 commit f831bed

35 files changed

+1811
-94
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [4.2.0]
8+
### Added
9+
- A new artifact `espresso-material-stepper` with useful Espresso actions and matchers for testing `StepperLayout` with Espresso.
10+
11+
### Fixed
12+
- Maven dependencies so that `material-stepper` depends on `AppCompat` after migration to Gradle 4.1.
13+
714
## [4.1.0]
815
### Added
916
- An option to show a subtitle in each tab
@@ -23,5 +30,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2330
- **Breaking change:** Changed `setNextButtonLabel` methods in `StepViewModel.Builder` to `setEndButtonLabel` so that it works for both Next and Complete buttons (issue #107)
2431
- **Breaking change:** Split `content` stepper feedback type into `content_progress` and `content_fade`.
2532

33+
[4.2.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.1.0...v4.2.0
2634
[4.1.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.0.0...v4.1.0
2735
[4.0.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v3.3.0...v4.0.0

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src ="./art/material-stepper-logo.png" width="256" height="256"/>
33
</p>
44

5-
# 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)
5+
# 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)
66

77
This library allows to use Material steppers inside Android applications.
88

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

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

6567
### Download (from JCenter)
6668
```groovy
67-
compile 'com.stepstone.stepper:material-stepper:4.1.0'
69+
compile 'com.stepstone.stepper:material-stepper:4.2.0'
6870
```
6971

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

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

531+
## Espresso tests
532+
If you wish to run Espresso tests on a screen containing a `StepperLayout` you might want to use
533+
`espresso-material-stepper` which contains useful Espresso actions and matchers such as clicking on
534+
navigation buttons & tabs.
535+
To do so add a Gradle dependency:
536+
537+
```groovy
538+
androidTestCompile 'com.stepstone.stepper:espresso-material-stepper:X.X.X'
539+
```
540+
541+
Please see the sample app which uses it in instrumentation tests for more details.
542+
543+
## Contributing
544+
All contributions are welcome and encouraged!
545+
546+
If you wish to contribute please create an issue first explaining the proposed changes.
547+
548+
Project is built on Circle CI on which we run static code analysis as well as unit & instrumentation tests
549+
to ensure that the latest changes don't break anything.
550+
To check if your changes pass execute:
551+
552+
```
553+
./gradlew checkWithUiTests
554+
```
555+
556+
Or on a device below Marshmallow:
557+
```
558+
./gradlew checkWithUiTests -Ptest.integration.options.adbInstallOptions=-r
559+
```
560+
529561
## License
530562
Copyright 2016 StepStone Services
531563

build.gradle

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
buildscript {
2-
ext.gradleAndroidVersion = '3.0.0-beta2'
2+
ext.gradleAndroidVersion = '3.0.0-beta4'
33
ext.kotlinVersion = '1.1.3-2'
4-
ext.bintrayVersion = '1.4'
5-
ext.mavenGradlePluginVersion = '1.4.1'
4+
ext.bintrayVersion = '1.7.3'
5+
ext.mavenGradlePluginVersion = '2.0'
66

77
repositories {
88
jcenter()
@@ -39,8 +39,9 @@ configure(allprojects) {
3939
robolectricVersion = '3.3.1'
4040
assertjVersion = '1.1.1'
4141

42-
supportTestVersion = '1.0.0'
43-
espressoVersion = '3.0.0'
42+
supportTestVersion = '1.0.1'
43+
espressoVersion = '3.0.1'
44+
testButlerVersion = '1.3.1'
4445

4546
/* Sample only */
4647
butterknifeVersion = '8.5.1'
@@ -52,3 +53,26 @@ configure(allprojects) {
5253
task clean(type: Delete) {
5354
delete rootProject.buildDir
5455
}
56+
57+
ext {
58+
bintrayRepo = 'maven'
59+
bintrayName = POM_ARTIFACT_ID
60+
61+
publishedGroupId = POM_GROUP_ID
62+
libraryName = 'Android Material Stepper'
63+
64+
libraryDescription = 'This library allows to use Material steppers inside Android applications.'
65+
66+
siteUrl = 'https://github.com/stepstone-tech/android-material-stepper'
67+
gitUrl = 'https://github.com/stepstone-tech/android-material-stepper.git'
68+
69+
libraryVersion = POM_VERSION
70+
71+
developerId = 'zawadz88'
72+
developerName = 'Piotr Zawadzki'
73+
developerEmail = 'piotr.zawadzki@stepstone.com'
74+
75+
licenseName = 'The Apache Software License, Version 2.0'
76+
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
77+
allLicenses = ["Apache-2.0"]
78+
}

circle.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ machine:
22
environment:
33
PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-4.1/bin:$PATH"
44
TERM: "dumb"
5-
ADB_INSTALL_TIMEOUT: "10"
5+
ADB_INSTALL_TIMEOUT: "20"
66
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
77
_JAVA_OPTIONS: "-Xms512m -Xmx1024m -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -XX:ParallelGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2"
88

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

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

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

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

45-
# upload code coverage reports to Codecov.io
46-
- bash <(curl -s https://codecov.io/bash)
44+
# Grab the screen from device at the end (useful if tests fail)
45+
- adb shell screencap -p /sdcard/after_tests.png && adb pull /sdcard/after_tests.png sample/build/reports
46+
47+
- ./gradlew install --no-daemon --stacktrace
48+
49+
# upload merged code coverage report to Codecov.io
50+
- bash <(curl -s https://codecov.io/bash) -f sample/build/reports/jacoco/mergedJacocoTestReport/mergedJacocoTestReport.xml
4751

4852
post:
4953
# copy the test results to the test results directory

espresso-material-stepper/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'maven'
3+
4+
android {
5+
compileSdkVersion project.androidCompileSdkVersion
6+
buildToolsVersion("$androidBuildToolsVersion")
7+
8+
defaultConfig {
9+
minSdkVersion project.androidMinSdkVersion
10+
targetSdkVersion project.androidTargetSdkVersion
11+
}
12+
13+
lintOptions {
14+
warningsAsErrors true
15+
}
16+
}
17+
18+
dependencies {
19+
api project(':material-stepper')
20+
api "com.android.support.test.espresso:espresso-core:$espressoVersion"
21+
}
22+
23+
gradle.taskGraph.beforeTask { Task task ->
24+
if (task instanceof Javadoc) {
25+
def releaseVariant = android.libraryVariants.find { it.buildType.name == 'release' }
26+
Javadoc javadocTask = (Javadoc) task
27+
javadocTask.source = android.sourceSets.main.java.srcDirs
28+
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
29+
javadocTask.classpath = files(releaseVariant.javaCompile.classpath.files) + files(ext.androidJar)
30+
}
31+
}
32+
33+
ext {
34+
artifact = POM_TEST_ARTIFACT_ID
35+
}
36+
37+
apply from: '../installv1.gradle'
38+
apply from: '../bintrayv1.gradle'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.stepstone.stepper.test" />
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.stepstone.stepper.test;
2+
3+
import android.support.annotation.IntRange;
4+
import android.support.annotation.NonNull;
5+
import android.support.test.espresso.matcher.BoundedMatcher;
6+
import android.util.Log;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.TextView;
10+
11+
import com.stepstone.stepper.StepperLayout;
12+
import com.stepstone.stepper.internal.widget.StepTab;
13+
14+
import org.hamcrest.Description;
15+
import org.hamcrest.Matcher;
16+
17+
/**
18+
* Checks the subtitle of a {@link StepTab} at a specified position.
19+
*
20+
* @author Piotr Zawadzki
21+
*/
22+
public class StepperLayoutTabSubtitleMatcher extends BoundedMatcher<View, StepperLayout> {
23+
24+
private static final String TAG = "StepperLayoutTabSubtMa";
25+
26+
@IntRange(from = 0)
27+
private final int tabPosition;
28+
29+
@NonNull
30+
private final Matcher<View> subtitleMatcher;
31+
32+
private StepperLayoutTabSubtitleMatcher(@IntRange(from = 0) int tabPosition, @NonNull Matcher<View> subtitleMatcher) {
33+
super(StepperLayout.class);
34+
this.tabPosition = tabPosition;
35+
this.subtitleMatcher = subtitleMatcher;
36+
}
37+
38+
@Override
39+
public void describeTo(Description description) {
40+
description
41+
.appendText(" at position: ")
42+
.appendValue(tabPosition)
43+
.appendText(" with message: ")
44+
.appendValue(subtitleMatcher);
45+
}
46+
47+
@Override
48+
protected boolean matchesSafely(StepperLayout view) {
49+
ViewGroup tabsContainer = (ViewGroup) view.findViewById(com.stepstone.stepper.R.id.ms_stepTabsInnerContainer);
50+
int childCount = tabsContainer.getChildCount();
51+
52+
if (childCount == 0) {
53+
Log.e(TAG, "No tabs found!");
54+
return false;
55+
}
56+
57+
if (tabPosition < 0 || tabPosition >= childCount) {
58+
Log.e(TAG, "Invalid tab position: " + tabPosition);
59+
return false;
60+
}
61+
62+
StepTab stepTab = (StepTab) tabsContainer.getChildAt(tabPosition);
63+
TextView subtitleTextView = (TextView) stepTab.findViewById(com.stepstone.stepper.R.id.ms_stepSubtitle);
64+
65+
return subtitleMatcher.matches(subtitleTextView);
66+
}
67+
68+
public static Matcher<View> tabAtPositionHasSubtitle(@IntRange(from = 0) int tabPosition, @NonNull Matcher<View> subtitleMatcher) {
69+
return new StepperLayoutTabSubtitleMatcher(tabPosition, subtitleMatcher);
70+
}
71+
72+
}

0 commit comments

Comments
 (0)