Skip to content

Commit

Permalink
Added API unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Potapov committed Oct 30, 2017
1 parent 8cbe6c3 commit 65fd8db
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 15 deletions.
2 changes: 2 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ dokka {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.5.1'

compile 'com.android.support:support-annotations:27.0.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
Expand Down
15 changes: 0 additions & 15 deletions library/src/test/java/com/antonpotapov/ExampleUnitTest.java

This file was deleted.

60 changes: 60 additions & 0 deletions library/src/test/java/com/antonpotapov/PoliwhirlApiTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.antonpotapov

import android.graphics.Bitmap
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner

/**
* ======================================
* Created by awesome potapov on 30.10.17.
* ======================================
*/
@RunWith(RobolectricTestRunner::class)
class PoliwhirlApiTests {

@Test(expected = IllegalArgumentException::class)
fun testApiAccuracy1() {
Poliwhirl().setAccuracy(0).generate(Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888))
}

@Test(expected = IllegalArgumentException::class)
fun testApiAccuracy2() {
Poliwhirl().setAccuracy(11).generate(Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888))
}

@Test(expected = IllegalArgumentException::class)
fun testApiDistance() {
Poliwhirl().setMinAvailableColorDistance(-1)
}

@Test(expected = IllegalArgumentException::class)
fun testApiHorizontalBorder1() {
Poliwhirl().setHorizontalBorderSizeDivideMultiplier(0)
}

@Test(expected = IllegalArgumentException::class)
fun testApiHorizontalBorder2() {
Poliwhirl().setHorizontalBorderSizeDivideMultiplier(1)
}

@Test(expected = IllegalArgumentException::class)
fun testApiVerticalBorder1() {
Poliwhirl().setVerticalBorderSizeDivideMultiplier(0)
}

@Test(expected = IllegalArgumentException::class)
fun testApiVerticalBorder2() {
Poliwhirl().setVerticalBorderSizeDivideMultiplier(1)
}

@Test(expected = IllegalArgumentException::class)
fun testApiBorder1() {
Poliwhirl().setBorderSizeDivideMultiplier(0)
}

@Test(expected = IllegalArgumentException::class)
fun testApiBorder2() {
Poliwhirl().setBorderSizeDivideMultiplier(1)
}
}

0 comments on commit 65fd8db

Please sign in to comment.