Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1546744 - Ensure we are testing for the correct things when valid…
Browse files Browse the repository at this point in the history
…ating screenshots r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D28983
  • Loading branch information
Emily Toop committed Apr 26, 2019
1 parent f0b936f commit 914fc39
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import android.graphics.*
import android.support.test.filters.MediumTest
import android.support.test.runner.AndroidJUnit4
import android.view.Surface
import org.hamcrest.Matchers.notNullValue
import org.hamcrest.Matchers.nullValue
import org.hamcrest.Matchers.*
import org.junit.Assert.fail
import org.junit.Rule
import org.junit.Test
Expand All @@ -19,6 +18,7 @@ import org.junit.runner.RunWith
import org.mozilla.geckoview.GeckoResult
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ReuseSession
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
import java.nio.ByteBuffer

private const val SCREEN_HEIGHT = 100
private const val SCREEN_WIDTH = 100
Expand All @@ -44,7 +44,15 @@ class ScreenshotTest : BaseSessionTest() {
sessionRule.waitForResult(result).let {
assertThat("Screenshot is not null",
it, notNullValue())
assert(it.sameAs(comparisonImage)) { "Screenshots are the same" }
assertThat("Widths are the same", comparisonImage.width, equalTo(it.width))
assertThat("Heights are the same", comparisonImage.height, equalTo(it.height))
assertThat("Byte counts are the same", comparisonImage.byteCount, equalTo(it.byteCount))
assertThat("Configs are the same", comparisonImage.config, equalTo(it.config))
val comparisonPixels: ByteBuffer = ByteBuffer.allocate(comparisonImage.byteCount)
comparisonImage.copyPixelsToBuffer(comparisonPixels)
val itPixels: ByteBuffer = ByteBuffer.allocate(it.byteCount)
it.copyPixelsToBuffer(itPixels)
assertThat("Bytes are the same", comparisonPixels, equalTo(itPixels))
}
}

Expand Down

0 comments on commit 914fc39

Please sign in to comment.