-
Notifications
You must be signed in to change notification settings - Fork 144
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
Showing
76 changed files
with
1,914 additions
and
1,700 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
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) | ||
|
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
126 changes: 126 additions & 0 deletions
126
FishBun/src/androidTest/java/com/sangcomz/fishbun/util/RadioWithTextButtonTest.kt
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,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() | ||
} |
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
27 changes: 0 additions & 27 deletions
27
FishBun/src/main/java/com/sangcomz/fishbun/BaseProperty.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
FishBun/src/main/java/com/sangcomz/fishbun/BaseProperty.kt
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,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() | ||
} |
61 changes: 0 additions & 61 deletions
61
FishBun/src/main/java/com/sangcomz/fishbun/CustomizationProperty.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.