Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
Release 2.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sankarbhavanib committed Feb 22, 2016
1 parent 81a2400 commit e77fe11
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The PayPal Android SDK makes it easy to add PayPal and credit card payments to m
The PayPal Android SDK is now available at [Maven Repository](https://repo1.maven.org/maven2/com/paypal/sdk/paypal-android-sdk/). The latest version is available via `mavenCentral()`. Just add the following dependency from `mavenCentral()`:

```
compile 'com.paypal.sdk:paypal-android-sdk:2.13.1'
compile 'com.paypal.sdk:paypal-android-sdk:2.13.2'
```


Expand Down Expand Up @@ -160,7 +160,7 @@ If you want to disable credit card completely:
1. Exclude card.io library in your application build.gradle file:
```
dependencies {
compile('com.paypal.sdk:paypal-android-sdk:2.13.1') {
compile('com.paypal.sdk:paypal-android-sdk:2.13.2') {
exclude group: 'io.card'
}
}
Expand Down
25 changes: 22 additions & 3 deletions SampleApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:1.2.3'
}
}

repositories {
maven {
// Used for downloading dependency com.github.lkorth:device-automator
url "https://jitpack.io"
}
mavenCentral()
}

Expand All @@ -18,8 +22,9 @@ android {
buildToolsVersion '23.0.1'

defaultConfig {
minSdkVersion 10
minSdkVersion 18
targetSdkVersion 23
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}

signingConfigs {
Expand Down Expand Up @@ -67,10 +72,24 @@ android {
}
}

configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:23.0.1'
}


dependencies {
if (parent != null) {
compile project(path: ':androidSDK', configuration: 'generalDebug')
} else {
compile('com.paypal.sdk:paypal-android-sdk:2.13.1')
compile('com.paypal.sdk:paypal-android-sdk:2.13.2')
}
compile 'com.google.android.gms:play-services-wallet:8.1.0'

testCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.github.lkorth:device-automator:30238040d8'
testCompile 'com.google.dexmaker:dexmaker-mockito:1.1'
testCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
testCompile 'com.android.support.test.espresso:espresso-web:2.2.1'
testCompile 'com.android.support.test:runner:0.4.1'
testCompile 'com.android.support.test:rules:0.4.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.paypal.example.paypalandroidsdkexample.test;

import android.test.suitebuilder.annotation.LargeTest;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import android.support.test.runner.AndroidJUnit4;

import static com.lukekorth.deviceautomator.AutomatorAction.click;
import static com.lukekorth.deviceautomator.AutomatorAssertion.text;
import static com.lukekorth.deviceautomator.UiObjectMatcher.withText;
import static com.lukekorth.deviceautomator.UiObjectMatcher.withTextStartingWith;
import static com.paypal.example.paypalandroidsdkexample.test.TestHelper.onDeviceWithScreenShot;
import static com.paypal.example.paypalandroidsdkexample.test.TestHelper.onLogin;
import static com.paypal.example.paypalandroidsdkexample.test.TestHelper.onAgree;
import static com.paypal.example.paypalandroidsdkexample.test.TestHelper.takeScreenshot;
import static org.hamcrest.CoreMatchers.containsString;


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

@Before
public void setup() {
TestHelper.setup();
}

/**
* Makes a Single Payment
*/
@Test(timeout = 60000)
public void buyAThing() {
onDeviceWithScreenShot(withText("Buy a Thing")).perform(click());
onDeviceWithScreenShot(withText("Pay with")).perform(click());
onLogin();
// Payment Confirmation
onDeviceWithScreenShot(withText("Pay")).perform(click());
// Confirm Result Success
onDeviceWithScreenShot(withTextStartingWith("Result :")).check(text(containsString("PaymentConfirmation")));
}

/**
* Gets a Future Payment Consent
*/
@Test(timeout = 60000)
public void futurePaymentConsent() {
takeScreenshot("futurePaymentConsent");
onDeviceWithScreenShot(withText("Future Payment Consent")).perform(click());
onLogin();
onAgree();
// Confirm Result Success
onDeviceWithScreenShot(withTextStartingWith("Result :")).check(text(containsString("Future Payment")));

}

/**
* Makes a Future Payment Purchase
*/
@Test(timeout = 60000)
public void futurePaymentPurchase() {
takeScreenshot("futurePaymentPurchase");
onDeviceWithScreenShot(withText("Future Payment Purchase")).perform(click());
// Confirm Result Success
onDeviceWithScreenShot(withTextStartingWith("Result :")).check(text(containsString("Client Metadata Id")));
}

/**
* Gets Profile Sharing Consent
*/
@Test(timeout = 60000)
public void profileSharingConsent() {
takeScreenshot("profileSharingConsent");
onDeviceWithScreenShot(withText("Profile Sharing Consent")).perform(click());
onLogin();
onAgree();
// Confirm Result Success
onDeviceWithScreenShot(withTextStartingWith("Result :")).check(text(containsString("Profile Sharing code")));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.paypal.example.paypalandroidsdkexample.test;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
import android.support.test.runner.lifecycle.Stage;
import android.text.format.DateFormat;
import android.view.View;

import com.lukekorth.deviceautomator.DeviceAutomator;
import com.lukekorth.deviceautomator.UiObjectMatcher;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;

import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.InstrumentationRegistry.getTargetContext;
import static com.lukekorth.deviceautomator.AutomatorAction.click;
import static com.lukekorth.deviceautomator.AutomatorAction.setText;
import static com.lukekorth.deviceautomator.DeviceAutomator.onDevice;
import static com.lukekorth.deviceautomator.UiObjectMatcher.withContentDescription;
import static com.lukekorth.deviceautomator.UiObjectMatcher.withText;

/**
* This helper class provides with methods to help write better tests.
*/
public abstract class TestHelper {

public static final String PAYPAL_SAMPLE_APP_PACKAGE_NAME = "com.paypal.example.paypalandroidsdkexample.debug";
public static final String PAYPAL_SANDBOX_USERNAME = "[email protected]";
public static final String PAYPAL_SANDBOX_PASSWORD = "123123123";

public static void setup() {
PreferenceManager.getDefaultSharedPreferences(getTargetContext())
.edit()
.clear()
.commit();
onDevice().onHomeScreen().launchApp(PAYPAL_SAMPLE_APP_PACKAGE_NAME);
}

public static DeviceAutomator onDeviceWithScreenShot() {
DeviceAutomator result = onDevice();
takeScreenshot(null);
return result;
}

public static DeviceAutomator onDeviceWithScreenShot(UiObjectMatcher matcher) {
DeviceAutomator result = onDevice(matcher);
takeScreenshot(null);
return result;
}

public static void takeScreenshot(String name) {
if (name == null) {
Date now = new Date();
DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
name = String.valueOf(now.getTime());
}
// In Testdroid Cloud, taken screenshots are always stored
// under /test-screenshots/ folder and this ensures those screenshots
// be shown under Test Results
String path =
Environment.getExternalStorageDirectory().getAbsolutePath() + "/test-screenshots/" + name + ".png";
OutputStream out = null;

try {
View scrView = getActivityInstance().getWindow().getDecorView().getRootView();
scrView.setDrawingCacheEnabled(true);
Bitmap bm = scrView.getDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(bm);
scrView.setDrawingCacheEnabled(false);

File imageFile = new File(path);
out = new FileOutputStream(imageFile);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
} catch (Exception ex) {
// Ignore any exceptions as this is just for debugging purposes
} finally {
try {
if (out != null) {
out.close();
}
} catch (Exception ex) {
// Nothing to do here
}
}
}

public static Activity getActivityInstance() {
final Activity[] currentActivity = new Activity[1];
getInstrumentation().waitForIdleSync();
getInstrumentation().runOnMainSync(new Runnable() {
public void run() {
Collection resumedActivities = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED);
Iterator<Activity> iterator = resumedActivities.iterator();
while (iterator.hasNext()) {
currentActivity[0] = (Activity) iterator.next();
}
}
});
return currentActivity[0];
}

public static void onLogin() {
onDeviceWithScreenShot(withContentDescription("Email")).perform(click(), setText(PAYPAL_SANDBOX_USERNAME));
onDeviceWithScreenShot().pressDPadDown().typeText(PAYPAL_SANDBOX_PASSWORD);
onDeviceWithScreenShot(withText("Log In")).perform(click());
}

public static void onAgree() {
try {
onDeviceWithScreenShot(withText("Agree")).perform(click());
} catch (RuntimeException ex) {
// This may mean, he has already agreed to it before.
}
}
}
3 changes: 2 additions & 1 deletion SampleApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.paypal.example.paypalandroidsdkexample">

<!-- WRITE_EXTERNAL_STORAGE permission is only used for testing purposes to store screenshots -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
Expand Down
7 changes: 7 additions & 0 deletions SampleApp/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
android:layout_marginTop="20dp"
android:onClick="onProfileSharingPressed"
android:text="Profile Sharing Consent" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="@+id/txtResult" />
</LinearLayout>

</RelativeLayout>
Binary file removed aars/PayPalAndroidSDK-2.13.1.aar
Binary file not shown.
Binary file added aars/PayPalAndroidSDK-2.13.2.aar
Binary file not shown.
4 changes: 4 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
PayPal Android SDK release notes
================================

2.13.2
------
* Fixes issue related to okhttp v3.1.2 [#258](https://github.com/paypal/PayPal-Android-SDK/issues/258)

2.13.1
------
* Fix issue preventing the SDK from app-switching to newer versions of the PayPal App.
Expand Down

0 comments on commit e77fe11

Please sign in to comment.