blob: 1ef738969851cffe01a8f6b3af2a96b60eacaaf1 [file] [log] [blame]
package androidx.webgpu
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.webgpu.helper.Util
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@SmallTest
class ObjectTest {
init {
Util // Hack to force library initialization.
}
@Test
fun sameObjectCompare() {
val surface = createInstance().createSurface(SurfaceDescriptor(
surfaceSourceAndroidNativeWindow =
SurfaceSourceAndroidNativeWindow(0)
))
val texture1 = surface.getCurrentTexture().texture
val texture2 = surface.getCurrentTexture().texture
assert(texture1 == texture2) {
"== matches two Kotlin objects representing the same Dawn object"
}
assert(texture1.equals(texture2)) {
".equals() matches two Kotlin objects representing the same Dawn object"
}
}
@Test
fun differentObjectCompare() {
val instance = createInstance()
val surfaceDescriptor = SurfaceDescriptor(
surfaceSourceAndroidNativeWindow =
SurfaceSourceAndroidNativeWindow(0)
)
val surface1 = instance.createSurface(surfaceDescriptor)
val surface2 = instance.createSurface(surfaceDescriptor)
assert(!(surface1 == surface2)) {
"== fails to match two Kotlin objects representing different Dawn objects"
}
assert(!surface1.equals(surface2)) {
".equals fails to match two Kotlin objects representing different Dawn objects"
}
}
}