Skip to content

Commit

Permalink
Merge pull request #79 from isuPatches/develop
Browse files Browse the repository at this point in the history
Fix travis build
  • Loading branch information
isuPatches authored Jul 24, 2017
2 parents 74442f7 + 9181c12 commit eb415e7
Show file tree
Hide file tree
Showing 46 changed files with 147 additions and 334 deletions.
36 changes: 24 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
sudo: required
dist: precise
language: android
jdk: oraclejdk8
sudo: false

jdk:
- oraclejdk8

env:
global:
- TARGET_SDK=26
- BUILD_TOOLS_VERSION=26.0.0
matrix:
- EMULATOR_SDK=android-19 ABI=armeabi-v7a

android:
components:
- tools
- platform-tools
- tools
- build-tools-26.0.0
- android-22
- android-26
- sys-img-armeabi-v7a-android-22
- android-${TARGET_SDK}
- build-tools-${BUILD_TOOLS_VERSION}
- extra-android-m2repository
- extra-android-support
- extra-google-m2repository

before_script:
# Create and start emulator
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-update-sdk --components=sys-img-$ABI-$EMULATOR_SDK --accept-licenses='android-sdk-license-[0-9a-f]{8}'
- echo no | android create avd --force -n test -t $EMULATOR_SDK --abi $ABI
- emulator -avd test -no-audio -no-window &
- ./gradlew clean assembleDebug assembleDebugAndroidTest
- android-wait-for-emulator
- adb shell input keyevent 82 &

script: travis_wait 90 ./gradlew clean connectedAndroidTest -PdisablePreDex --stacktrace
script:
- travis_wait 60 ./gradlew jacocoDebugTestReport

after_success:
- bash <(curl -s https://codecov.io/bash)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Wifi configuration and util library built for Android.
>
> <br/>Supports Android SDK levels 16-26<br/><br/>
[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230) [![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) <a href="http://www.methodscount.com/?lib=com.isupatches%3Awisefy%3A2.0.0"><img src="https://img.shields.io/badge/Methods and size-291 | 49 KB-e91e63.svg"/></a>
[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230) [![Build Status](https://travis-ci.org/isuPatches/WiseFy.svg?branch=master)](https://travis-ci.org/isuPatches/WiseFy) [ ![Download](https://api.bintray.com/packages/isupatches/Maven/wisefy/images/download.svg) ](https://bintray.com/isupatches/Maven/wisefy/_latestVersion) <a href="http://www.methodscount.com/?lib=com.isupatches%3Awisefy%3A2.0.0"><img src="https://img.shields.io/badge/Methods and size-291 | 49 KB-e91e63.svg"/></a> [![codecov.io](https://codecov.io/github/codecov/wisefy/branch/2.x/graph/badge.svg)](https://codecov.io/github/codecov/wisefy)

## What's New in 2.x

Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ subprojects {
}

ext {
travisBuild = System.getenv("TRAVIS") == "true"
// allows for -Dpre-dex=false to be set
preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))

GROUP = "com.isupatches"
VERSION_NAME = "2.0.0"

Expand Down
11 changes: 10 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
org.gradle.daemon=true

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
Expand All @@ -15,4 +19,9 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.parallel=true

# Enables new incubating mode that makes Gradle selective when configuring projects.
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true
6 changes: 3 additions & 3 deletions gradle/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def classDirs = fileTree(
'**/*$Builder*'])

task jacocoDebugTestReport(type: JacocoReport) {
dependsOn = ["connectedDebugAndroidTest"]
dependsOn = ["connectedDebugAndroidTest", "testDebugUnitTest"]
group = "Reporting"
description = "Run tests and generate Jacoco coverage report for debug"
classDirectories = classDirs
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec')])
executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')])

reports {
xml.enabled = true
Expand All @@ -37,7 +37,7 @@ task jacocoDebugReport(type: JacocoReport) {
classDirectories = classDirs
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec')])
executionData = files([fileTree(dir: 'build/outputs/code-coverage/connected', include: '**/*.ec'), fileTree(dir: 'build/jacoco', include: '**/*.exec')])

reports {
xml.enabled = true
Expand Down
5 changes: 5 additions & 0 deletions wisefy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ dexcount {

android {

dexOptions {
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
preDexLibraries = preDexEnabled && !travisBuild
}

adbOptions {
timeOutInMs 15 * 60 * 1000 // 15 minutes
installOptions "-d","-t"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import android.net.wifi.WifiConfiguration;
import com.isupatches.wisefy.callbacks.AddOpenNetworkCallbacks;
import com.isupatches.wisefy.constants.WiseFyCodes;
import com.isupatches.wisefy.base.TestActivity;
import org.junit.Assert;
import org.junit.Test;
import static com.isupatches.wisefy.base.TestUtils.OPEN_NETWORK_SSID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.*;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
Expand All @@ -18,11 +18,7 @@
import static org.mockito.Mockito.when;


public class AddOpenNetworkTests extends BaseTestClass<TestActivity> {

public AddOpenNetworkTests() {
super(TestActivity.class);
}
public class AddOpenNetworkTests extends BaseAndroidJUnit4TestClass {

@Test
public void noCallbacks_failure() {
Expand All @@ -33,7 +29,7 @@ public void noCallbacks_failure() {

@Test
public void noCallbacks_failure_nullSSIDParam() {
assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null));
Assert.assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addOpenNetwork(null));
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@


import android.net.wifi.WifiConfiguration;
import com.isupatches.wisefy.base.TestActivity;
import com.isupatches.wisefy.base.TestUtils;
import com.isupatches.wisefy.callbacks.AddWEPNetworkCallbacks;
import com.isupatches.wisefy.constants.WiseFyCodes;
import org.junit.Test;
import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_PASSWORD;
import static com.isupatches.wisefy.base.TestUtils.WEP_NETWORK_SSID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
Expand All @@ -19,57 +17,53 @@
import static org.mockito.Mockito.when;


public class AddWEPNetworkTests extends BaseTestClass<TestActivity> {

public AddWEPNetworkTests() {
super(TestActivity.class);
}
public class AddWEPNetworkTests extends BaseAndroidJUnit4TestClass {

@Test
public void noCallbacks_failure() {
when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE);
assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD));
assertEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD));
verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class));
}

@Test
public void noCallbacks_failure_nullPasswordParam() {
assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null));
assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null));
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}

@Test
public void noCallbacks_failure_nullSSIDParam() {
assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD));
assertEquals(WiseFyCodes.MISSING_PARAMETER, mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD));
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}

@Test
public void noCallbacks_failure_missingPrerequisite() {
missingPrerequisite();
assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD));
assertEquals(WiseFyCodes.MISSING_PREREQUISITE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD));
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}

@Test
public void noCallbacks_success() {
when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0);
assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD));
assertNotEquals(WiseFy.WIFI_MANAGER_FAILURE, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD));
verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class));
}

@Test
public void noCallbacks_success_alreadyConfigured() {
networkAlreadyInConfigurationList();
assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD));
assertEquals(WiseFyCodes.NETWORK_ALREADY_CONFIGURED, mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD));
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}

@Test
public void callbacks_failure() {
when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE);
AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class);
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks);
verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).failureAddingWEPNetwork(WiseFy.WIFI_MANAGER_FAILURE);
verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class));
}
Expand All @@ -79,7 +73,7 @@ public void callbacks_failure_nullCallback() {
when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(WiseFy.WIFI_MANAGER_FAILURE);

try {
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
} catch (NullPointerException npe) {
fail();
Expand All @@ -89,15 +83,15 @@ public void callbacks_failure_nullCallback() {
@Test
public void callbacks_failure_nullPasswordParam() {
AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class);
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, mockCallbacks);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null, mockCallbacks);
verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}

@Test
public void callbacks_failure_nullPasswordParam_nullCallback() {
try {
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, null, null);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, null, null);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
} catch (NullPointerException npe) {
fail();
Expand All @@ -107,15 +101,15 @@ public void callbacks_failure_nullPasswordParam_nullCallback() {
@Test
public void callbacks_failure_nullSSIDParam() {
AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class);
mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, mockCallbacks);
mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks);
verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PARAMETER);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}

@Test
public void callbacks_failure_nullSSIDParam_nullCallback() {
try {
mWiseFy.addWEPNetwork(null, WEP_NETWORK_PASSWORD, null);
mWiseFy.addWEPNetwork(null, TestUtils.WEP_NETWORK_PASSWORD, null);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
} catch (NullPointerException npe) {
fail();
Expand All @@ -126,7 +120,7 @@ public void callbacks_failure_nullSSIDParam_nullCallback() {
public void callbacks_failure_missingPrerequisite() {
missingPrerequisite();
AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class);
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks);
verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.MISSING_PREREQUISITE);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}
Expand All @@ -136,7 +130,7 @@ public void callbacks_failure_missingPrerequisite_nullCallback() {
missingPrerequisite();

try {
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
} catch (NullPointerException npe) {
fail();
Expand All @@ -147,7 +141,7 @@ public void callbacks_failure_missingPrerequisite_nullCallback() {
public void callbacks_success() {
when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0);
AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class);
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks);
verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).wepNetworkAdded(any(WifiConfiguration.class));
verify(mMockWiFiManager, timeout(VERIFICATION_TIMEOUT)).addNetwork(any(WifiConfiguration.class));
}
Expand All @@ -157,7 +151,7 @@ public void callbacks_success_nullCallback() {
when(mMockWiFiManager.addNetwork(any(WifiConfiguration.class))).thenReturn(0);

try {
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
} catch (NullPointerException npe) {
fail();
Expand All @@ -169,7 +163,7 @@ public void callbacks_success_alreadyConfigured() {
networkAlreadyInConfigurationList();

AddWEPNetworkCallbacks mockCallbacks = mock(AddWEPNetworkCallbacks.class);
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, mockCallbacks);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, mockCallbacks);
verify(mockCallbacks, timeout(VERIFICATION_TIMEOUT)).addWEPNetworkWiseFyFailure(WiseFyCodes.NETWORK_ALREADY_CONFIGURED);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
}
Expand All @@ -179,7 +173,7 @@ public void callbacks_success_alreadyConfigured_nullCallback() {
networkAlreadyInConfigurationList();

try {
mWiseFy.addWEPNetwork(WEP_NETWORK_SSID, WEP_NETWORK_PASSWORD, null);
mWiseFy.addWEPNetwork(TestUtils.WEP_NETWORK_SSID, TestUtils.WEP_NETWORK_PASSWORD, null);
verify(mMockWiFiManager, never()).addNetwork(any(WifiConfiguration.class));
} catch (NullPointerException npe) {
fail();
Expand Down
Loading

0 comments on commit eb415e7

Please sign in to comment.