Unverified Commit 1cb804c3 authored by Igor Demin's avatar Igor Demin Committed by GitHub

Fix screenshot tests (#285)

* Fix screenshot test

readPixels doesn't actually work.

Thanks Aleksandr Veselov for noticing!

* Remove cleanTest. It doesn't exist on macOs. Don't know why

* Fix test "render text (MacOs)"
parent 6ed2752f
......@@ -472,6 +472,7 @@ class SkiaWindowTest {
window.layer.skikoView = object : SkikoView {
override fun onRender(canvas: Canvas, width: Int, height: Int, nanoTime: Long) {
canvas.clear(Color.WHITE.rgb)
paragraph.layout(Float.POSITIVE_INFINITY)
paragraph.paint(canvas, 0f, 0f)
}
......
package org.jetbrains.skiko.util
import org.jetbrains.skia.ByteBuffer
import org.jetbrains.skia.Image
import org.jetbrains.skia.Pixmap
import java.awt.Color
......@@ -12,8 +13,20 @@ fun isContentSame(img1: Image, img2: Image, sensitivity: Double): Boolean {
if (img1.width == img2.width && img1.height == img2.height) {
val pixMap1 = Pixmap()
val pixMap2 = Pixmap()
img1.readPixels(pixMap1, 0, 0, false)
img2.readPixels(pixMap2, 0, 0, false)
pixMap1.reset(
img1.imageInfo,
ByteBuffer.allocateDirect(img1.bytesPerPixel * img1.width * img1.height),
img1.bytesPerPixel * img1.width
)
pixMap2.reset(
img2.imageInfo,
ByteBuffer.allocateDirect(img2.bytesPerPixel * img2.width * img2.height),
img2.bytesPerPixel * img2.width
)
check(img1.readPixels(pixMap1, 0, 0, false))
check(img2.readPixels(pixMap2, 0, 0, false))
for (y in 0 until img1.height) {
for (x in 0 until img1.width) {
val color1 = Color(pixMap1.getColor(x, y))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment