mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Add DrawableUtilTests for testing overlaying icons
Signed-off-by: Alper Ozturk <alperozturk@lions-macbook.local> Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
1f391397c1
commit
29e934fdce
1 changed files with 42 additions and 0 deletions
|
@ -0,0 +1,42 @@
|
|||
package com.owncloud.android.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.After
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class DrawableUtilTests {
|
||||
|
||||
private var sut: DrawableUtil? = null
|
||||
private var context: Context? = null
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
sut = DrawableUtil()
|
||||
context = InstrumentationRegistry.getInstrumentation().context
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAddDrawableAsOverlayWhenGivenValidDrawablesShouldContainTwoDrawable() {
|
||||
val bitmap: Bitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888)
|
||||
val drawable = BitmapDrawable(context?.resources, bitmap)
|
||||
|
||||
val layerDrawable = sut?.addDrawableAsOverlay(drawable, drawable)
|
||||
|
||||
if (layerDrawable == null) {
|
||||
fail("Layer drawable expected to be not null")
|
||||
}
|
||||
|
||||
assert(layerDrawable?.numberOfLayers == 2)
|
||||
}
|
||||
|
||||
@After
|
||||
fun destroy() {
|
||||
sut = null
|
||||
context = null
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue