Java test fix. Eclipse test execution fix.

This commit is contained in:
Alexander Smorkalov 2012-11-09 11:46:14 +04:00
parent 4d059e9e5b
commit baef62b4d2
5 changed files with 87 additions and 37 deletions

View File

@ -28,6 +28,8 @@ public class OpenCVTestCase extends TestCase {
//change to 'true' to unblock fail on fail("Not yet implemented")
public static final boolean passNYI = true;
protected static boolean isEnabled = true;
protected static final int matSize = 10;
protected static final double EPS = 0.001;
protected static final double weakEPS = 0.5;

View File

@ -2,9 +2,9 @@ package org.opencv.test;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
//import java.util.Iterator;
import junit.framework.TestCase;
//import junit.framework.TestCase;
import junit.framework.Assert;
import org.opencv.android.Utils;
@ -72,15 +72,17 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
//List<TestCase> testCases = androidTestRunner.getTestCases();
//Collections.shuffle(testCases); //shuffle the tests order
if(OpenCVTestCase.passNYI) {
// turn off problematic camera tests
Iterator<TestCase> it = androidTestRunner.getTestCases().iterator();
while (it.hasNext()) {
String name = it.next().toString();
if (name.contains("VideoCaptureTest"))
it.remove();
}
}
// Note: VideoCapture tests turned off by flag field in VideoCaptureTest class
// if(OpenCVTestCase.passNYI) {
// // turn off problematic camera tests
// Iterator<TestCase> it = androidTestRunner.getTestCases().iterator();
// while (it.hasNext()) {
// String name = it.next().toString();
// if (name.contains("VideoCaptureTest"))
// it.remove();
// }
// }
super.onStart();

View File

@ -13,6 +13,8 @@ import org.opencv.features2d.KeyPoint;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import android.util.Log;
public class FASTFeatureDetectorTest extends OpenCVTestCase {
FeatureDetector detector;
@ -127,9 +129,9 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n</opencv_storage>\n";
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n<type>2</type>\n</opencv_storage>\n";
String data = readFile(filename);
Log.d("qqq", "\"" + data + "\"");
assertEquals(truth, data);
}
@ -138,9 +140,10 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\n";
String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\ntype: 2\n";
String data = readFile(filename);
Log.d("qqq", "\"" + data + "\"");
assertEquals(truth, data);
}
}

View File

@ -22,10 +22,10 @@ public class HighguiTest extends OpenCVTestCase {
public void testImencodeStringMatListOfByteListOfInteger() {
MatOfInt params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40);
MatOfInt params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90);
/* or
/* or
MatOfInt params = new MatOfInt();
params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
*/
params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
*/
MatOfByte buff40 = new MatOfByte();
MatOfByte buff90 = new MatOfByte();

View File

@ -19,13 +19,17 @@ public class VideoCaptureTest extends OpenCVTestCase {
super.setUp();
capture = null;
isEnabled = false;
isSucceed = false;
isOpened = false;
}
public void testGet() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
double frameWidth = capture.get(Highgui.CV_CAP_PROP_FRAME_WIDTH);
assertTrue(0 != frameWidth);
@ -35,8 +39,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testGetSupportedPreviewSizes() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
List<Size> sizes = capture.getSupportedPreviewSizes();
assertNotNull(sizes);
@ -47,12 +54,20 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testGrab() {
if (!isEnabled) {
fail("Not yet implemented");
}
capture = new VideoCapture();
isSucceed = capture.grab();
assertFalse(isSucceed);
}
public void testGrabFromRealCamera() {
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
isSucceed = capture.grab();
@ -63,13 +78,20 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testIsOpened() {
if (!isEnabled) {
fail("Not yet implemented");
}
capture = new VideoCapture();
assertFalse(capture.isOpened());
}
public void testIsOpenedRealCamera() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
isOpened = capture.isOpened();
assertTrue(isOpened);
@ -79,8 +101,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testOpen() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture();
capture.open(Highgui.CV_CAP_ANDROID);
isOpened = capture.isOpened();
@ -91,8 +116,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testRead() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
isSucceed = capture.read(dst);
assertTrue(isSucceed);
@ -104,8 +132,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testRelease() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.release();
assertFalse(capture.isOpened());
@ -116,8 +147,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testRetrieveMat() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.grab();
isSucceed = capture.retrieve(dst);
@ -130,8 +164,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testRetrieveMatInt() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.grab();
isSucceed = capture.retrieve(dst, Highgui.CV_CAP_ANDROID_GREY_FRAME);
@ -144,8 +181,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testSet() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
capture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 480);
@ -165,8 +205,11 @@ public class VideoCaptureTest extends OpenCVTestCase {
}
public void testVideoCaptureInt() {
try
{
if (!isEnabled) {
fail("Not yet implemented");
}
try {
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
assertNotNull(capture);
assertTrue(capture.isOpened());