Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#457: Converted java to Kotlin #835

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
5 changes: 3 additions & 2 deletions android-gif-drawable/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'com.vanniktech.maven.publish'
apply plugin: 'kotlin-android'

group = 'pl.droidsonroids.gif'
description = 'Views and Drawable for displaying animated GIFs for Android'
Expand All @@ -9,8 +10,8 @@ android {
compileSdkVersion versions.compileSdk

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project does not compile for me when I move it back to 1.8

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll check this further ASAP.

targetCompatibility JavaVersion.VERSION_17
}

defaultConfig {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package pl.droidsonroids.gif

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import org.assertj.core.api.Assertions
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class AllocationByteCountTest {
@Test
@Throws(Exception::class)
fun allocationByteCountIsConsistent() {
val resources = getInstrumentation().context.resources
val drawable = GifDrawable(resources, pl.droidsonroids.gif.test.R.raw.test)
val metaData = GifAnimationMetaData(resources, pl.droidsonroids.gif.test.R.raw.test)
Assertions.assertThat(drawable.frameByteCount + metaData.allocationByteCount)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import Assertions.assertThat
here and in other similar files

.isEqualTo(drawable.allocationByteCount)
Assertions.assertThat(metaData.getDrawableAllocationByteCount(null, 1))
.isEqualTo(drawable.allocationByteCount)
Assertions.assertThat(metaData.getDrawableAllocationByteCount(drawable, 1))
.isEqualTo(drawable.allocationByteCount)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package pl.droidsonroids.gif

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import pl.droidsonroids.gif.GifIOException
import java.io.File

@RunWith(AndroidJUnit4::class)
class ErrnoMessageTest {
@get:Rule
var mExpectedException = ExpectedException.none()

@get:Rule
var mTemporaryFolder = TemporaryFolder()
@Test
@Throws(Exception::class)
fun errnoMessageAppendedToOpenFailed() {
mExpectedException.expect(GifIOException::class.java)
mExpectedException.expectMessage("GifError 101: Failed to open given input: No such file or directory")
val nonExistentFile = File(mTemporaryFolder.root, "non-existent")
GifDrawable(nonExistentFile)
}

@Test
@Throws(Exception::class)
fun errnoMessageAppendedToReadFailed() {
mExpectedException.expect(GifIOException::class.java)
mExpectedException.expectMessage("GifError 102: Failed to read from given input: Is a directory")
GifDrawable(mTemporaryFolder.root)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package pl.droidsonroids.gif

import android.graphics.drawable.Drawable
import org.assertj.core.api.AbstractAssert
import org.assertj.core.api.Assertions
import pl.droidsonroids.gif.GifDrawable

internal class GifDrawableAssert private constructor(actual: GifDrawable) :
AbstractAssert<GifDrawableAssert?, GifDrawable?>(actual, GifDrawableAssert::class.java) {
fun hasLoopCountEqualTo(loopCount: Int): GifDrawableAssert {
Assertions.assertThat(actual!!.loopCount).isEqualTo(loopCount)
return this
}

companion object {
fun assertThat(actual: Drawable): GifDrawableAssert {
Assertions.assertThat(actual).isInstanceOf(GifDrawable::class.java)
return GifDrawableAssert(actual as GifDrawable)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package pl.droidsonroids.gif

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.hamcrest.CoreMatchers
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class GifDrawableExceptionTest {
@get:Rule
var expectedException = ExpectedException.none()
private var gifDrawable: GifDrawable? = null
@Before
@Throws(Exception::class)
fun setUp() {
val resources = InstrumentationRegistry.getInstrumentation().context.resources
gifDrawable = GifDrawable(resources, pl.droidsonroids.gif.test.R.raw.test)
}

@After
fun tearDown() {
gifDrawable!!.recycle()
}

@Test
@Throws(Exception::class)
fun frameIndexOutOfBoundsMessageContainsRange() {
val numberOfFrames = gifDrawable!!.numberOfFrames
val invalidFrameIndex = numberOfFrames + 10
expectedException.expectMessage(CoreMatchers.containsString(Integer.toString(numberOfFrames)))
expectedException.expect(IndexOutOfBoundsException::class.java)
gifDrawable!!.getFrameDuration(invalidFrameIndex)
}

@Test
@Throws(Exception::class)
fun exceptionThrownWhenPixelsArrayTooSmall() {
expectedException.expect(ArrayIndexOutOfBoundsException::class.java)
gifDrawable!!.getPixels(IntArray(0))
}

@Test
@Throws(Exception::class)
fun exceptionThrownWhenPixelCoordinateXOutOfRange() {
expectedException.expect(IllegalArgumentException::class.java)
gifDrawable!!.getPixel(gifDrawable!!.intrinsicWidth, 0)
}

@Test
@Throws(Exception::class)
fun exceptionThrownWhenPixelCoordinateYOutOfRange() {
expectedException.expect(IllegalArgumentException::class.java)
gifDrawable!!.getPixel(0, gifDrawable!!.intrinsicHeight)
}
}

This file was deleted.

Loading