Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
task/scale-type-rename: More references updated to previewScaleType
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairsykes committed Jun 17, 2021
1 parent 793c2f3 commit 5dd2d1e
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualWidthTaller_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 100, 250)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -355,15 +356,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualWidthShorter_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 100, 150)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -376,15 +378,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualHeightWider_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 150, 200)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -397,15 +400,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualHeightNarrower_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 50, 200)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -418,15 +422,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualWidthTaller_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 250, 100)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -439,15 +444,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualWidthShorter_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 150, 100)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -460,15 +466,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualHeightWider_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 200, 150)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -481,15 +488,16 @@ internal class BarcodeViewTest {
@Test
fun centerInside_viewEqualHeightNarrower_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_INSIDE
val previewScaleType = BarcodeView.CENTER_INSIDE
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 200, 50)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -502,15 +510,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualWidthTaller_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 100, 250)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -523,15 +532,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualWidthShorter_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 100, 150)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -544,15 +554,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualHeightWider_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 150, 200)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -565,15 +576,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualHeightNarrower_portrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 50, 200)
doReturn(true).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -586,15 +598,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualWidthTaller_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 250, 100)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -607,15 +620,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualWidthShorter_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 150, 100)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -628,15 +642,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualHeightWider_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 200, 150)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand All @@ -649,15 +664,16 @@ internal class BarcodeViewTest {
@Test
fun centerCrop_viewEqualHeightNarrower_notPortrait__calculateRectForChild__isCorrect() {
// GIVEN
val scaleType = BarcodeView.CENTER_CROP
val previewScaleType = BarcodeView.CENTER_CROP
whenever(barcodeScanner.getOutputSize()).thenReturn(Size(200, 100))
val viewRect = Rect(0, 0, 200, 50)
doReturn(false).whenever(barcodeView).isPortraitMode()

// WHEN
val result = barcodeView.calculateRectForChild(
scaleType = scaleType, left = viewRect.left, top = viewRect.top, right = viewRect.right,
bottom = viewRect.bottom
previewScaleType = previewScaleType,
left = viewRect.left, top = viewRect.top,
right = viewRect.right, bottom = viewRect.bottom
)

// THEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public class BarcodeScanner internal constructor(
frameProcessor.barcodesSort = comparator
}

override fun setPreviewScaleType(@BarcodeView.ScaleType scaleType: Int) {
Timber.v("ScaleType has no affect on ${BarcodeScanner::class.java.simpleName}")
override fun setPreviewScaleType(@BarcodeView.PreviewScaleType previewScaleType: Int) {
Timber.v("PreviewScaleType has no affect on ${BarcodeScanner::class.java.simpleName}")
}

@Throws(IllegalArgumentException::class)
Expand Down
Loading

0 comments on commit 5dd2d1e

Please sign in to comment.