Skip to content

Commit

Permalink
Merge branch 'release/0.11.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
sangcomz committed Oct 31, 2019
2 parents ccf3539 + 827f2d9 commit 89b8b0a
Show file tree
Hide file tree
Showing 76 changed files with 1,914 additions and 1,700 deletions.
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@

Submit a pull-request
---------------------
I actively welcome your pull requests.

1. Fork the repo and create your branch from `develop`.
2. If you've added code that should be tested, add tests.
3. New pull request to `develop`.

How to report a bug
-------------------

please check [template to report a bug](https://github.com/sangcomz/FishBun/blob/master/.github/ISSUE_TEMPLATE/bug_report.md)


How to request feature
-------------------

please check [template to request feature](https://github.com/sangcomz/FishBun/blob/master/.github/ISSUE_TEMPLATE/feature_request.md)

18 changes: 17 additions & 1 deletion FishBun/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'jacoco-android'
apply plugin: 'kotlin-android-extensions'

buildscript {
repositories {
Expand Down Expand Up @@ -28,6 +30,13 @@ android {
consumerProguardFile('proguard-rules.pro')
versionCode gradle.versionCode
versionName gradle.versionName

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
testCoverageEnabled true
}
}
}

Expand All @@ -38,14 +47,21 @@ apply plugin: 'co.riiid.gradle'
apply from: '../gradle/release.gradle'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compileOnly "androidx.appcompat:appcompat:$rootProject.androidx_version"
compile "androidx.constraintlayout:constraintlayout:$rootProject.constraint_version"
compile "com.google.android.material:material:$rootProject.material_version"
compile "androidx.recyclerview:recyclerview:$rootProject.recyclerview_version"

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.8.9'
testImplementation 'org.mockito:mockito-core:3.0.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'org.mockito:mockito-android:3.0.0'

compileOnly "com.squareup.picasso:picasso:$rootProject.picasso_version"
compileOnly "com.github.bumptech.glide:glide:$rootProject.glide_version"
}

tasks.withType(Javadoc).all {
enabled = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package com.sangcomz.fishbun.util;

import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Rect
import android.graphics.drawable.Drawable
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock
import org.mockito.Mockito.*
import org.mockito.MockitoAnnotations
import org.mockito.internal.verification.Times

class RadioWithTextButtonTest {
private lateinit var radioWithTextButton: RadioWithTextButton
private lateinit var context: Context

@Mock
private lateinit var mockTextPaint: Paint

@Mock
private lateinit var mockStrokePaint: Paint

@Mock
private lateinit var mockCirclePaint: Paint

@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
context = InstrumentationRegistry.getInstrumentation().context
radioWithTextButton = RadioWithTextButton(context, mockTextPaint, mockStrokePaint, mockCirclePaint)

doNothing().`when`(mockStrokePaint).setStrokeWidth(anyFloat())
doNothing().`when`(mockStrokePaint).setStyle(Paint.Style.STROKE)

}

@After
fun tearDown(){
}

@Test
fun onDraw_drawCircle() {
val mockCanvas = mock(Canvas::class.java)
radioWithTextButton.draw(mockCanvas)

verify(mockStrokePaint, Times(1)).setStyle(Paint.Style.STROKE)
verify(mockCanvas, Times(1)).drawCircle(
radioWithTextButton.width.toCircleXY(),
radioWithTextButton.height.toCircleXY(),
radioWithTextButton.width.toCircleRadio(),
mockStrokePaint)
}

@Test
fun onDraw_drawDrawable() {
val mockDrawable = mock(Drawable::class.java)
radioWithTextButton.setDrawable(mockDrawable)

val mockCanvas = mock(Canvas::class.java)
doNothing().`when`(mockCanvas).drawCircle(anyFloat(), anyFloat(), anyFloat(), any(Paint::class.java))

radioWithTextButton.draw(mockCanvas)
verify(mockCanvas, Times(1)).drawCircle(
radioWithTextButton.width.toCircleXY(),
radioWithTextButton.height.toCircleXY(),
radioWithTextButton.width.toCircleRadio(),
mockCirclePaint)
verify(mockDrawable, Times(1)).setBounds(any(Rect::class.java))
verify(mockDrawable, Times(1)).draw(mockCanvas)
}

@Test
fun onDraw_drawText() {
val text = "test"

val mockCanvas = mock(Canvas::class.java)
radioWithTextButton.setText(text)

radioWithTextButton.draw(mockCanvas)
verify(mockCanvas, Times(1)).drawCircle(
radioWithTextButton.width.toCircleXY(),
radioWithTextButton.height.toCircleXY(),
radioWithTextButton.width.toCircleRadio(),
mockCirclePaint)
verify(mockCanvas, Times(1)).drawText(
text,
radioWithTextButton.width.toCircleXY(),
radioWithTextButton.height.toCircleXY(),
mockTextPaint)
}

@Test
fun setTextSizeForWidth_doNotDraw() {
val mockPaint = mock(Paint::class.java)
doNothing().`when`(mockPaint).setTextSize(anyFloat())
doNothing().`when`(mockPaint).getTextBounds(anyString(), anyInt(), anyInt(), any(Rect::class.java))
val desiredWidth = 10f
val text = "test"

mockPaint.setTextSizeForWidth(text, desiredWidth)
verify(mockPaint).setTextSize(anyFloat())
verify(mockPaint).getTextBounds(eq(text), anyInt(), anyInt(), any(Rect::class.java))
verifyNoMoreInteractions(mockPaint)
}

@Test
fun setTextSizeForWidth_draw() {
val mockPaint = mock(Paint::class.java)
doNothing().`when`(mockPaint).setTextSize(anyFloat())
doNothing().`when`(mockPaint).getTextBounds(anyString(), anyInt(), anyInt(), any(Rect::class.java))
val desiredWidth = 1f
val text = "test"

mockPaint.setTextSizeForWidth(text, desiredWidth)
verify(mockPaint).setTextSize(anyFloat())
verify(mockPaint).getTextBounds(eq(text), anyInt(), anyInt(), any(Rect::class.java))
verify(mockPaint).setTextSize(anyFloat())
}

private fun Int.toCircleXY() = (this / 2).toFloat()
private fun Int.toCircleRadio() = (this / 3).toFloat()
}
5 changes: 2 additions & 3 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import android.os.Build;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Window;

import androidx.appcompat.app.AppCompatActivity;

import com.sangcomz.fishbun.define.Define;
import com.sangcomz.fishbun.util.UiUtil;

public abstract class BaseActivity extends AppCompatActivity {
protected Define define = new Define();
protected UiUtil uiUtil = new UiUtil();
protected Fishton fishton;

@Override
Expand Down
2 changes: 0 additions & 2 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.view.ViewGroup;

import com.sangcomz.fishbun.define.Define;
import com.sangcomz.fishbun.util.UiUtil;

/**
* Created by sangcomz on 04/06/2017.
Expand All @@ -17,7 +16,6 @@
public class BaseFragment extends Fragment {

protected Define define = new Define();
protected UiUtil uiUtil = new UiUtil();

@Nullable
@Override
Expand Down
27 changes: 0 additions & 27 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseProperty.java

This file was deleted.

24 changes: 24 additions & 0 deletions FishBun/src/main/java/com/sangcomz/fishbun/BaseProperty.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.sangcomz.fishbun

import android.net.Uri

/**
* Created by sangcomz on 13/05/2017.
*/
interface BaseProperty {
fun setSelectedImages(selectedImages: ArrayList<Uri>): FishBunCreator

fun setPickerCount(count: Int): FishBunCreator

fun setMaxCount(count: Int): FishBunCreator

fun setMinCount(count: Int): FishBunCreator

fun setRequestCode(requestCode: Int): FishBunCreator

fun setReachLimitAutomaticClose(isAutomaticClose: Boolean): FishBunCreator

fun exceptGif(isExcept: Boolean): FishBunCreator

fun startAlbum()
}

This file was deleted.

Loading

0 comments on commit 89b8b0a

Please sign in to comment.