parent
cc72056684
commit
714d228168
@ -1,26 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import androidx.test.filters.SmallTest; |
||||
import androidx.test.runner.AndroidJUnit4; |
||||
|
||||
import org.junit.runner.RunWith; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class) |
||||
@SmallTest |
||||
public class MapperTest extends BaseTest { |
||||
|
||||
private Mapper mapper = new Mapper() { |
||||
<T> T map(Flash flash) { return null; } |
||||
<T> T map(Facing facing) { return null; } |
||||
<T> T map(WhiteBalance whiteBalance) { return null; } |
||||
<T> T map(Hdr hdr) { return null; } |
||||
<T> Flash unmapFlash(T cameraConstant) { return null; } |
||||
<T> Facing unmapFacing(T cameraConstant) { return null; } |
||||
<T> WhiteBalance unmapWhiteBalance(T cameraConstant) { return null; } |
||||
<T> Hdr unmapHdr(T cameraConstant) { return null; } |
||||
}; |
||||
} |
@ -1,51 +0,0 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.graphics.Rect; |
||||
|
||||
import androidx.test.filters.SmallTest; |
||||
import androidx.test.runner.AndroidJUnit4; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
import static org.junit.Assert.assertFalse; |
||||
import static org.junit.Assert.assertNotEquals; |
||||
import static org.junit.Assert.assertTrue; |
||||
import static org.mockito.Matchers.any; |
||||
import static org.mockito.Mockito.mock; |
||||
|
||||
@RunWith(AndroidJUnit4.class) |
||||
@SmallTest |
||||
public class YuvHelperTest extends BaseTest { |
||||
|
||||
@Test |
||||
public void testCrop() { |
||||
testCrop(new Size(1600, 1600), AspectRatio.of(16, 16)); |
||||
testCrop(new Size(1600, 1600), AspectRatio.of(16, 9)); |
||||
testCrop(new Size(1600, 1600), AspectRatio.of(9, 16)); |
||||
} |
||||
|
||||
private void testCrop(final Size inSize, final AspectRatio outRatio) { |
||||
AspectRatio inRatio = AspectRatio.of(inSize.getWidth(), inSize.getHeight()); |
||||
Rect out = YuvHelper.computeCrop(inSize, outRatio); |
||||
Size outSize = new Size(out.width(), out.height()); |
||||
assertTrue(outRatio.matches(outSize)); |
||||
|
||||
if (outRatio.matches(inSize)) { |
||||
// They are equal.
|
||||
assertEquals(outSize.getWidth(), inSize.getWidth()); |
||||
assertEquals(outSize.getHeight(), inSize.getHeight()); |
||||
} else if (outRatio.toFloat() > inRatio.toFloat()) { |
||||
// Width must match.
|
||||
assertEquals(outSize.getWidth(), inSize.getWidth()); |
||||
assertNotEquals(outSize.getHeight(), inSize.getHeight()); |
||||
} else { |
||||
// Height must match.
|
||||
assertEquals(outSize.getHeight(), inSize.getHeight()); |
||||
assertNotEquals(outSize.getWidth(), inSize.getWidth()); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue