Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
71ded784
Commit
71ded784
authored
Jun 04, 2019
by
Christian Sadilek
Committed by
Jonathan Almeida
Jun 04, 2019
Browse files
Closes #3247: QrScanner: Remove image cropping before processing
parent
8359dd2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/feature/qr/src/main/java/mozilla/components/feature/qr/QrFragment.kt
View file @
71ded784
...
...
@@ -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
())
...
...
components/feature/qr/src/test/java/mozilla/components/feature/qr/QrFragmentTest.kt
View file @
71ded784
...
...
@@ -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
)))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment