Commit 71ded784 authored by Christian Sadilek's avatar Christian Sadilek Committed by Jonathan Almeida
Browse files

Closes #3247: QrScanner: Remove image cropping before processing

parent 8359dd2c
......@@ -552,8 +552,7 @@ class QrFragment : Fragment() {
}
try {
val image = bitmap.crop(bitmap.width / 4, bitmap.height / 4, bitmap.width / 2, bitmap.height / 2)
val rawResult = multiFormatReader.decodeWithState(image)
val rawResult = multiFormatReader.decodeWithState(bitmap)
if (rawResult != null) {
qrState = STATE_QRCODE_EXIST
scanCompleteListener?.onScanComplete(rawResult.toString())
......
......@@ -16,10 +16,12 @@ import com.google.zxing.MultiFormatReader
import com.google.zxing.NotFoundException
import mozilla.components.support.base.android.view.AutoFitTextureView
import mozilla.components.support.test.any
import mozilla.components.support.test.argumentCaptor
import mozilla.components.support.test.eq
import mozilla.components.support.test.mock
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
......@@ -127,6 +129,21 @@ class QrFragmentTest {
verify(reader, never()).decodeWithState(any())
}
@Test
fun `async scanning decodes original unmodified image`() {
val listener = mock(QrFragment.OnScanCompleteListener::class.java)
val reader = mock(MultiFormatReader::class.java)
val task = QrFragment.AsyncScanningTask(listener, reader)
val imageCaptor = argumentCaptor<BinaryBitmap>()
val bitmap = mock(BinaryBitmap::class.java)
QrFragment.qrState = QrFragment.STATE_DECODE_PROGRESS
task.processImage(bitmap)
verify(reader).decodeWithState(imageCaptor.capture())
assertSame(bitmap, imageCaptor.value)
}
@Test
fun `camera is closed on disconnect and error`() {
val qrFragment = spy(QrFragment.newInstance(mock(QrFragment.OnScanCompleteListener::class.java)))
......
Supports Markdown
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