Skip to content

Commit

Permalink
Merge pull request #3 from alessandrojp/feature/test-code
Browse files Browse the repository at this point in the history
Adding test code
  • Loading branch information
alessandrojp committed Feb 20, 2017
2 parents 2073aba + 0f56b04 commit af14e84
Show file tree
Hide file tree
Showing 52 changed files with 5,253 additions and 969 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ env:
- ANDROID_BUILD_TOOLS_VERSION=25.0.1

android:
licenses:
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

components:
# Use the latest revision of Android SDK Tools
- tools # to get the new `repository-11.xml`
Expand Down Expand Up @@ -40,17 +44,21 @@ before_cache:
before_install:
- echo y | android update sdk --all --no-ui --force --filter build-tools-$ANDROID_BUILD_TOOLS_VERSION
- echo y | android update sdk --all --no-ui --force --filter android-$ANDROID_API_LEVEL
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

before_script:
# INSTRUMENTED TESTS ARE DISABLED - until Google or Travis fix the mess with emulation, only local tests are enabled
# - echo no | android create avd --force -n test -t "android-"$ANDROID_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG
# - echo no | android create avd --force -n test -t android-16 --abi $ANDROID_ABI
# - emulator -avd test -no-skin -no-audio -no-window &
# - android-wait-for-emulator
# - adb shell input keyevent 82 &

script:
- ./gradlew build jacocoTestReport assembleAndroidTest --stacktrace
# - ./gradlew connectedCheck --stacktrace
# - ./gradlew build connectedCheck jacocoTestReport --stacktrace
- ./gradlew build jacocoTestReport --stacktrace

after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
![API](https://img.shields.io/badge/API-9%2B-brightgreen.svg?style=flat)
[![Build Status](https://travis-ci.org/alessandrojp/easy-checkout.svg)](https://travis-ci.org/alessandrojp/easy-checkout)
[![Bintray](https://img.shields.io/bintray/v/alessandrojp/android/easy-checkout.svg)](https://bintray.com/alessandrojp/android/easy-checkout/view)
[![codecov](https://codecov.io/gh/alessandrojp/easy-checkout/branch/master/graph/badge.svg)](https://codecov.io/gh/alessandrojp/easy-checkout)
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

Fast and easy checkout library (Android In-App Billing) for Android apps with RxJava support.

This library supports both non-consumable/consumable items and upgrading/downgrading of subscriptions.
This library supports both non-consumable/consumable items and upgrading/downgrading of subscriptions.

For **RxJava** please check [here](https://github.com/alessandrojp/easy-checkout/tree/master/extension-rxjava).

Expand All @@ -20,11 +21,12 @@ The api version 5 automatically will be used only in this case.

* For Eclipse users, download the latest jar version on [Bintray][] and add it as a dependency.

* For Gradle users, add this into your build.gradle file:
* For Gradle users, the library is available in the jcenter and mavenCentral. Add this into your build.gradle file:

```groovy
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile 'jp.alessandro.android:easy-checkout:vX.X.X'
Expand Down Expand Up @@ -157,7 +159,7 @@ As a result you will get a [Purchase](#purchase-object) object.
```java
String itemId = "YOUR_ITEM_ID";

mBillingProcessor.consume(itemId, new ConsumeItemHandler() {
mBillingProcessor.consumePurchase(itemId, new ConsumeItemHandler() {
@Override
public void onSuccess() {
// Item was consumed successfully
Expand Down Expand Up @@ -207,7 +209,7 @@ As a result you will get a [Purchase](#purchase-object) object through of the Pu
```java
PurchaseType purchaseType = PurchaseType.IN_APP; // PurchaseType.SUBSCRIPTIONS for subscriptions
mBillingProcessor.getInventory(purchaseType, new InventoryHandler() {
mBillingProcessor.getPurchases(purchaseType, new PurchasesHandler() {
@Override
public void onSuccess(Purchases purchases) {
// Do your stuff with the list of purchases
Expand Down Expand Up @@ -244,6 +246,23 @@ mBillingProcessor.getItemDetails(purchaseType, itemIds, new ItemDetailListHandle
}
});
```
# Cancel
* Cancel the all purchase flows. It will clear the pending purchase flows and ignore any event until a new request.<br />If you don't need the BillingProcessor instance any more, call directly [Release](#release) instead.
<br />**Note: By canceling it will not cancel the purchase process since the purchase process is not controlled by the app.**

```java
mBillingProcessor.cancel();
```

# Release
* Release the handlers. Once you release it, you **MUST** to create a new instance.
<br />**Note: By releasing it will not cancel the purchase process since the purchase process is not controlled by the app.**

```java
mBillingProcessor.release();
```

As a result you will get a list of [Item](#item-object) detail objects.

# Check In-App Billing service availability
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}

allprojects {
repositories {
jcenter()
maven { url 'https://dl.bintray.com/alessanrojp/maven/' }
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<property name="max" value="150" />
</module>
<module name="MethodLength">
<property name="max" value="30" />
<property name="max" value="35" />
<property name="countEmpty" value="false" />
</module>
<module name="GenericWhitespace" />
Expand Down
62 changes: 41 additions & 21 deletions extension-rxjava/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@


### Installation
* Add this into your build.gradle file:
* For Eclipse users, download the latest jar version on [Bintray][] and add it as a dependency.

* For Gradle users, the library is available in the jcenter and mavenCentral. Add this into your build.gradle file:

```groovy
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile 'jp.alessandro.android:easy-checkout:vX.X.X'
compile 'jp.alessandro.android:easy-checkout-extension-rxjava:vX.X.X'
Expand Down Expand Up @@ -147,7 +151,7 @@ As a result you will get a [Purchase](#purchase-object) object through of the Pu
```java
String itemId = "YOUR_ITEM_ID";
mBillingProcessor.consume(itemId)
mBillingProcessor.consumePurchase(itemId)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Action1<Void>() {
Expand Down Expand Up @@ -201,7 +205,7 @@ As a result you will get a [Purchase](#purchase-object) object through of the Pu
```java
PurchaseType purchaseType = PurchaseType.IN_APP; // PurchaseType.SUBSCRIPTIONS for subscriptions

mBillingProcessor.getInventory(purchaseType)
mBillingProcessor.getPurchases(purchaseType)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Action1<PurchaseList>() {
Expand Down Expand Up @@ -246,6 +250,22 @@ mBillingProcessor.getItemDetails(purchaseType, itemIds)
```
As a result you will get a list of [Item](#item-object) detail objects.

# Cancel
* Cancel the all purchase flows. It will clear the pending purchase flows and ignore any event until a new request.<br />If you don't need the BillingProcessor instance any more, call directly [Release](#release) instead.
<br />**Note: By canceling it will not cancel the purchase process since the purchase process is not controlled by the app.**

```java
mBillingProcessor.cancel();
```

# Release
* Release the handlers. Once you release it, you **MUST** to create a new instance.
<br />**Note: By releasing it will not cancel the purchase process since the purchase process is not controlled by the app.**

```java
mBillingProcessor.release();
```

# Check In-App Billing service availability
* In some devices, In-App Billing may not be available.
Therefore, it is advisable to check whether it is available or not by calling `BillingProcessorObservable.isServiceAvailable` as follows:
Expand All @@ -261,28 +281,28 @@ if (!isAvailable) {
* This object contains all the information of a purchase

```java
public String getOriginalJson();
public String getOrderId();
public String getPackageName();
public String getSku();
public long getPurchaseTime();
public int getPurchaseState();
public String getDeveloperPayload();
public String getToken();
public boolean isAutoRenewing();
public String getSignature();
public String getOriginalJson();
public String getOrderId();
public String getPackageName();
public String getSku();
public long getPurchaseTime();
public int getPurchaseState();
public String getDeveloperPayload();
public String getToken();
public boolean isAutoRenewing();
public String getSignature();
```

# Item Object
* This object contains all the information of an item

```java
public String getOriginalJson();
public String getSku();
public String getType();
public String getTitle();
public String getDescription();
public String getCurrency();
public String getPrice();
public long getPriceMicros();
public String getOriginalJson();
public String getSku();
public String getType();
public String getTitle();
public String getDescription();
public String getCurrency();
public String getPrice();
public long getPriceMicros();
```
14 changes: 5 additions & 9 deletions extension-rxjava/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

apply plugin: 'com.android.library'
apply plugin: 'jacoco-android'

apply from: rootProject.file('gradle/jacoco.gradle')
apply from: rootProject.file('gradle/checkstyle.gradle')

android {
Expand All @@ -28,7 +28,8 @@ android {
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
testInstrumentationRunner rootProject.ext.testInstrumentationRunner
// testInstrumentationRunner rootProject.ext.testInstrumentationRunner
// multiDexEnabled true
}

buildTypes {
Expand Down Expand Up @@ -58,13 +59,8 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile dep.rxjava
compile dep.rxandroid

// Android Testing
testCompile dep.junit
androidTestCompile dep.testRunner
androidTestCompile dep.testRules
compile deps.rxjava
compile deps.rxandroid
}

android.libraryVariants.all { variant ->
Expand Down
1 change: 0 additions & 1 deletion extension-rxjava/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Contact email: alessandro@alessandro.jp
#
VERSION_NAME=v1.0.0
POM_ARTIFACT_ID=easy-checkout-extension-rxjava
POM_NAME=RxJava Extension
POM_DESCRIPTION=A RxJava extension for Easy Checkout Library
Expand Down
Loading

0 comments on commit af14e84

Please sign in to comment.