-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julian Raj
committed
Feb 29, 2016
1 parent
7804473
commit 78fef0d
Showing
10 changed files
with
210 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
general: | ||
artifacts: | ||
- /home/ubuntu/your-app-name/app/build/outputs/apk/ | ||
|
||
machine: | ||
environment: | ||
ANDROID_HOME: /usr/local/android-sdk-linux | ||
|
||
dependencies: | ||
pre: | ||
- echo y | android update sdk --no-ui --all --filter tool,extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository,android-23 | ||
- echo y | android update sdk --no-ui --all --filter build-tools-23.0.2 | ||
|
||
test: | ||
override: | ||
- (./gradlew assemble): | ||
timeout: 360 | ||
- ./gradlew runUnitTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
...utlayout/src/androidTest/java/com/julianraj/validatedinputtextlayout/ApplicationTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...xtinputlayout/src/test/java/com/julianraj/validatedinputtextlayout/BaseValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.julianraj.validatedinputtextlayout; | ||
|
||
import com.julianraj.validatedinputtextlayout.validator.BaseValidator; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
/** | ||
* To work on unit tests, switch the Test Artifact in the Build Variants view. | ||
*/ | ||
public class BaseValidatorTest { | ||
|
||
BaseValidator mValidator; | ||
|
||
public static final String ERROR_MESSAGE = "I am error message."; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
mValidator = new BaseValidator(ERROR_MESSAGE) { | ||
@Override | ||
public boolean isValid(String pText) { | ||
return false; | ||
} | ||
}; | ||
} | ||
|
||
@Test | ||
public void baseValidator_Constructor() { | ||
assertThat(mValidator.getErrorMessage(), is(ERROR_MESSAGE)); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
...textinputlayout/src/test/java/com/julianraj/validatedinputtextlayout/ExampleUnitTest.java
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
...inputlayout/src/test/java/com/julianraj/validatedinputtextlayout/LengthValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.julianraj.validatedinputtextlayout; | ||
|
||
import com.julianraj.validatedinputtextlayout.validator.LengthValidator; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.CALLS_REAL_METHODS; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.withSettings; | ||
|
||
/** | ||
* To work on unit tests, switch the Test Artifact in the Build Variants view. | ||
*/ | ||
public class LengthValidatorTest { | ||
|
||
@Mock | ||
LengthValidator mValidator; | ||
|
||
public static final int MIN_LENGTH = 4; | ||
public static final int MAX_LENGTH = 10; | ||
|
||
public static final String CORRECT_SAMPLE = "test me"; | ||
public static final String INCORRECT_SAMPLE1 = "me"; | ||
public static final String INCORRECT_SAMPLE2 = "test me wrong"; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
//MockitoAnnotations.initMocks(this); | ||
mValidator = mock(LengthValidator.class, withSettings().defaultAnswer(CALLS_REAL_METHODS)); | ||
} | ||
|
||
@Test | ||
public void lengthValidator_ReturnsTrue() { | ||
mValidator.setMaximumLength(LengthValidator.LENGTH_INDEFINITE); | ||
mValidator.setMinimumLength(MIN_LENGTH); | ||
assertThat(mValidator.isValid(CORRECT_SAMPLE), is(true)); | ||
|
||
mValidator.setMaximumLength(MAX_LENGTH); | ||
mValidator.setMinimumLength(LengthValidator.LENGTH_ZERO); | ||
assertThat(mValidator.isValid(CORRECT_SAMPLE), is(true)); | ||
|
||
mValidator.setMaximumLength(MAX_LENGTH); | ||
mValidator.setMinimumLength(MIN_LENGTH); | ||
assertThat(mValidator.isValid(CORRECT_SAMPLE), is(true)); | ||
} | ||
|
||
@Test | ||
public void lengthValidator_ReturnsFalse() { | ||
assertThat(mValidator.isValid(INCORRECT_SAMPLE1), is(false)); | ||
assertThat(mValidator.isValid(INCORRECT_SAMPLE2), is(false)); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...putlayout/src/test/java/com/julianraj/validatedinputtextlayout/RequiredValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.julianraj.validatedinputtextlayout; | ||
|
||
import com.julianraj.validatedinputtextlayout.validator.RequiredValidator; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.Mockito.CALLS_REAL_METHODS; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.withSettings; | ||
|
||
/** | ||
* To work on unit tests, switch the Test Artifact in the Build Variants view. | ||
*/ | ||
public class RequiredValidatorTest { | ||
|
||
@Mock | ||
RequiredValidator mValidator; | ||
|
||
public static final String CORRECT_SAMPLE = "test string"; | ||
public static final String INCORRECT_SAMPLE1 = ""; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
//MockitoAnnotations.initMocks(this); | ||
mValidator = mock(RequiredValidator.class, withSettings().defaultAnswer(CALLS_REAL_METHODS)); | ||
} | ||
|
||
@Test | ||
public void requiredValidator_ReturnsTrue() { | ||
assertThat(mValidator.isValid(CORRECT_SAMPLE), is(true)); | ||
} | ||
|
||
@Test | ||
public void requiredValidator_ReturnsFalse() { | ||
assertThat(mValidator.isValid(INCORRECT_SAMPLE1), is(false)); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
} | ||
} |