diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-09-25 18:18:23 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-09-25 18:18:23 +0200 |
commit | 3a45434834999e1ac7c7a99cdaa644d939b859b0 (patch) | |
tree | 8782e086aaaa4628852fc38878043b1aa1af6065 | |
parent | 468641280f9bd6771b5a565b526f40f7fb8e8fad (diff) | |
download | libuca-3a45434834999e1ac7c7a99cdaa644d939b859b0.tar.gz libuca-3a45434834999e1ac7c7a99cdaa644d939b859b0.tar.bz2 libuca-3a45434834999e1ac7c7a99cdaa644d939b859b0.tar.xz libuca-3a45434834999e1ac7c7a99cdaa644d939b859b0.zip |
Move tools from test/ to tools/ directory
-rw-r--r-- | test/CMakeLists.txt | 57 | ||||
-rw-r--r-- | test/test-all.c | 214 | ||||
-rw-r--r-- | tools/CMakeLists.txt | 20 | ||||
-rw-r--r-- | tools/benchmark.c (renamed from test/benchmark.c) | 0 | ||||
-rw-r--r-- | tools/grab-async.c (renamed from test/grab-async.c) | 0 | ||||
-rw-r--r-- | tools/grab.c (renamed from test/grab.c) | 2 | ||||
-rw-r--r-- | tools/gui/control.c (renamed from test/control.c) | 2 | ||||
-rw-r--r-- | tools/gui/control.glade (renamed from test/control.glade) | 0 | ||||
-rw-r--r-- | tools/gui/egg-property-cell-renderer.c (renamed from test/egg-property-cell-renderer.c) | 0 | ||||
-rw-r--r-- | tools/gui/egg-property-cell-renderer.h (renamed from test/egg-property-cell-renderer.h) | 0 | ||||
-rw-r--r-- | tools/gui/egg-property-tree-view.c (renamed from test/egg-property-tree-view.c) | 1 | ||||
-rw-r--r-- | tools/gui/egg-property-tree-view.h (renamed from test/egg-property-tree-view.h) | 0 | ||||
-rw-r--r-- | tools/perf-overhead.c (renamed from test/perf-overhead.c) | 0 |
13 files changed, 21 insertions, 275 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0f46c32..b579d1b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,12 +5,10 @@ add_definitions("--std=c99 -Wall") # --- Find packages and libraries --------------------------------------------- find_package(PkgConfig) -pkg_check_modules(GTK2 gtk+-2.0>=2.22) -pkg_check_modules(GTHREAD2 gthread-2.0) pkg_check_modules(GLIB2 glib-2.0>=2.24 REQUIRED) pkg_check_modules(GOBJECT2 gobject-2.0>=2.24 REQUIRED) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/control.glade ${CMAKE_CURRENT_BINARY_DIR}) +set(libs uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES}) # --- Build targets ----------------------------------------------------------- include_directories( @@ -20,59 +18,10 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) -if (HAVE_PYLON_CAMERA) - set(GENICAM_ROOT $ENV{PYLON_ROOT}/genicam) - # check for 32/64 bit - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(PYLON_LIB_DIRS $ENV{PYLON_ROOT}/lib64 $ENV{PYLON_ROOT}/bin ${GENICAM_ROOT}/bin/Linux64_x64 - ${GENICAM_ROOT}/bin/Linux64_x64/GenApi/Generic) - else() - set(PYLON_LIB_DIRS $ENV{PYLON_ROOT}/lib64 $ENV{PYLON_ROOT}/bin ${GENICAM_ROOT}/bin/Linux32_i86 - ${GENICAM_ROOT}/bin/Linux32_i86/GenApi/Generic) - endif() - link_directories(${PYLON_LIB_DIRS} ${LIBPYLONCAM_LIBDIR}) -endif() - -add_executable(grab grab.c) -add_executable(grab-async grab-async.c) -add_executable(benchmark benchmark.c) -add_executable(perf perf-overhead.c) - -target_link_libraries(benchmark uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES}) -target_link_libraries(grab uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES}) -target_link_libraries(grab-async uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES}) -target_link_libraries(perf uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES}) - -if (GTK2_FOUND) - include_directories(${GTK2_INCLUDE_DIRS}) - - add_executable(control - control.c - egg-property-cell-renderer.c - egg-property-tree-view.c) - - target_link_libraries(control uca - ${GTK2_LIBRARIES} ${GTHREAD2_LIBRARIES}) - - install(TARGETS control - RUNTIME DESTINATION bin) - - install(FILES control.glade - DESTINATION share/libuca) -endif() - if (HAVE_MOCK_CAMERA) add_executable(test-mock test-mock.c) - - target_link_libraries(test-mock - uca - ${GLIB2_LIBRARIES} - ${GOBJECT2_LIBRARIES}) + target_link_libraries(test-mock ${libs}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gtester.xsl - ${CMAKE_CURRENT_BINARY_DIR}/gtester.xsl) + ${CMAKE_CURRENT_BINARY_DIR}/gtester.xsl) endif() - -#add_executable(test-all test-all.c) -#target_link_libraries(test-all uca -# ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES}) diff --git a/test/test-all.c b/test/test-all.c deleted file mode 100644 index 9526d4f..0000000 --- a/test/test-all.c +++ /dev/null @@ -1,214 +0,0 @@ - -#include <glib.h> -#include "uca-camera.h" -#include "cameras/uca-mock-camera.h" - -typedef struct { - UcaCamera *camera; -} Fixture; - -typedef void (*UcaFixtureFunc) (Fixture *fixture, gconstpointer data); - -static void fixture_setup(Fixture *fixture, gconstpointer data) -{ - const gchar *type = (gchar *) data; - GError *error = NULL; - fixture->camera = uca_camera_new(type, &error); - g_assert_no_error(error); - g_assert(fixture->camera); -} - -static void fixture_teardown(Fixture *fixture, gconstpointer data) -{ - g_object_unref(fixture->camera); -} - -static void on_property_change(gpointer instance, GParamSpec *pspec, gpointer user_data) -{ - gboolean *success = (gboolean *) user_data; - *success = TRUE; -} - -static void test_factory() -{ - GError *error = NULL; - UcaCamera *camera = uca_camera_new("fox994m3a0yxmy", &error); - g_assert_error(error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_FOUND); - g_assert(camera == NULL); -} - -static void test_recording(Fixture *fixture, gconstpointer data) -{ - GError *error = NULL; - UcaCamera *camera = UCA_CAMERA(fixture->camera); - - uca_camera_stop_recording(camera, &error); - g_assert_error(error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING); - g_error_free(error); - - error = NULL; - gboolean success = FALSE; - g_signal_connect(G_OBJECT(camera), "notify::is-recording", - (GCallback) on_property_change, &success); - uca_camera_start_recording(camera, &error); - g_assert_no_error(error); - g_assert(success == TRUE); - - success = FALSE; - uca_camera_stop_recording(camera, &error); - g_assert_no_error(error); - g_assert(success == TRUE); -} - -static void grab_func(gpointer data, gpointer user_data) -{ - gboolean *success = (gboolean *) user_data; - *success = TRUE; -} - -static void test_recording_async(Fixture *fixture, gconstpointer data) -{ - UcaCamera *camera = UCA_CAMERA(fixture->camera); - - gboolean success = FALSE; - uca_camera_set_grab_func(camera, grab_func, &success); - - gfloat max_frame_rate = 1.0f; - g_object_get(G_OBJECT(camera), - "sensor-max-frame-rate", &max_frame_rate, - NULL); - g_assert(max_frame_rate != 0.0f); - - g_object_set(G_OBJECT(camera), - "transfer-asynchronously", TRUE, - NULL); - - GError *error = NULL; - uca_camera_start_recording(camera, &error); - g_assert_no_error(error); - - const gulong sleep_time = G_USEC_PER_SEC / ((gulong) (max_frame_rate / 2.0f)); - g_usleep(sleep_time); - - uca_camera_stop_recording(camera, &error); - g_assert_no_error(error); - g_assert(success == TRUE); -} - -static void test_recording_grab(Fixture *fixture, gconstpointer data) -{ - UcaCamera *camera = UCA_CAMERA(fixture->camera); - GError *error = NULL; - gpointer frame = NULL; - - uca_camera_start_recording(camera, &error); - g_assert_no_error(error); - - uca_camera_grab(camera, &frame, &error); - g_assert_no_error(error); - g_assert(frame != NULL); - - uca_camera_stop_recording(camera, &error); - g_assert_no_error(error); -} - -static void test_recording_property(Fixture *fixture, gconstpointer data) -{ - UcaCamera *camera = UCA_CAMERA(fixture->camera); - - gboolean is_recording = FALSE; - uca_camera_start_recording(camera, NULL); - g_object_get(G_OBJECT(camera), - "is-recording", &is_recording, - NULL); - g_assert(is_recording == TRUE); - - uca_camera_stop_recording(camera, NULL); - g_object_get(G_OBJECT(camera), - "is-recording", &is_recording, - NULL); - g_assert(is_recording == FALSE); -} - -static void test_base_properties(Fixture *fixture, gconstpointer data) -{ - UcaCamera *camera = UCA_CAMERA(fixture->camera); - guint n_properties = 0; - GParamSpec **properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(camera), &n_properties); - GValue val = {0}; - - for (guint i = 0; i < n_properties; i++) { - g_value_init(&val, properties[i]->value_type); - g_object_get_property(G_OBJECT(camera), properties[i]->name, &val); - g_value_unset(&val); - } - - g_free(properties); -} - -static void test_binnings_properties(Fixture *fixture, gconstpointer data) -{ - UcaCamera *camera = UCA_CAMERA(fixture->camera); - - GValueArray *array = NULL; - g_object_get(G_OBJECT(camera), - "sensor-horizontal-binnings", &array, - NULL); - - GValue *value = g_value_array_get_nth(array, 0); - g_assert(value != NULL); - g_assert(g_value_get_uint(value) == 1); -} - - -int main(int argc, char *argv[]) -{ - g_type_init(); - g_test_init(&argc, &argv, NULL); - g_test_bug_base("http://ufo.kit.edu/ufo/ticket"); - - g_test_add_func("/factory", test_factory); - - gchar **types = NULL; - types = argc > 1 ? argv + 1 : uca_camera_get_types(); - - /* - * paths and test_funcs MUST correspond! - */ - static const gchar *paths[] = { - "/recording", - "/recording/grab", - "/recording/asynchronous", - "/properties/base", - "/properties/recording", - "/properties/binnings", - NULL - }; - - static UcaFixtureFunc test_funcs[] = { - test_recording, - test_recording_grab, - test_recording_async, - test_base_properties, - test_recording_property, - test_binnings_properties, - }; - - for (guint i = 0; i < g_strv_length(types); i++) { - guint j = 0; - - while (paths[j] != NULL) { - gchar *new_path = g_strdup_printf("/%s%s", types[i], paths[j]); - g_test_add(new_path, Fixture, types[i], fixture_setup, test_funcs[j], fixture_teardown); - g_free(new_path); - j++; - } - } - - gint result = g_test_run(); - - if (argc == 1) - g_strfreev(types); - - return result; -} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 957fdbf..0e4d28e 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -16,9 +16,21 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) +set(libs uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES}) + add_executable(gen-doc gen-doc.c) +target_link_libraries(gen-doc ${libs}) -target_link_libraries(gen-doc uca - ${GLIB2_LIBRARIES} - ${GOBJECT2_LIBRARIES} - ) +add_executable(grab grab.c) +target_link_libraries(grab ${libs}) + +add_executable(grab-async grab-async.c) +target_link_libraries(grab-async ${libs}) + +add_executable(benchmark benchmark.c) +target_link_libraries(benchmark ${libs}) + +add_executable(perf perf-overhead.c) +target_link_libraries(perf ${libs}) + +add_subdirectory(gui) diff --git a/test/benchmark.c b/tools/benchmark.c index ef99fd1..ef99fd1 100644 --- a/test/benchmark.c +++ b/tools/benchmark.c diff --git a/test/grab-async.c b/tools/grab-async.c index 6132829..6132829 100644 --- a/test/grab-async.c +++ b/tools/grab-async.c diff --git a/test/grab.c b/tools/grab.c index e507d69..1f5c917 100644 --- a/test/grab.c +++ b/tools/grab.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) g_free(name); g_print("Sensor: %ix%i px\n", sensor_width, sensor_height); - g_print("ROI: %ix%i @ (%i, %i), steps: %i, %i\n", + g_print("ROI: %ix%i @ (%i, %i), steps: %i, %i\n", roi_width, roi_height, roi_x, roi_y, roi_width_multiplier, roi_height_multiplier); const int pixel_size = bits == 8 ? 1 : 2; diff --git a/test/control.c b/tools/gui/control.c index 5a7b702..75b3cde 100644 --- a/test/control.c +++ b/tools/gui/control.c @@ -55,7 +55,7 @@ enum { COLUMN_EDITABLE, NUM_COLUMNS }; - + static UcaPluginManager *plugin_manager; static void diff --git a/test/control.glade b/tools/gui/control.glade index d7ba2fc..d7ba2fc 100644 --- a/test/control.glade +++ b/tools/gui/control.glade diff --git a/test/egg-property-cell-renderer.c b/tools/gui/egg-property-cell-renderer.c index 9df5cc3..9df5cc3 100644 --- a/test/egg-property-cell-renderer.c +++ b/tools/gui/egg-property-cell-renderer.c diff --git a/test/egg-property-cell-renderer.h b/tools/gui/egg-property-cell-renderer.h index d4dbe02..d4dbe02 100644 --- a/test/egg-property-cell-renderer.h +++ b/tools/gui/egg-property-cell-renderer.h diff --git a/test/egg-property-tree-view.c b/tools/gui/egg-property-tree-view.c index f4ed2fb..52d1e10 100644 --- a/test/egg-property-tree-view.c +++ b/tools/gui/egg-property-tree-view.c @@ -111,4 +111,3 @@ egg_property_tree_view_init (EggPropertyTreeView *tree_view) tree_view->priv = priv = EGG_PROPERTY_TREE_VIEW_GET_PRIVATE (tree_view); priv->list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, GTK_TYPE_ADJUSTMENT); } - diff --git a/test/egg-property-tree-view.h b/tools/gui/egg-property-tree-view.h index e8fd0fe..e8fd0fe 100644 --- a/test/egg-property-tree-view.h +++ b/tools/gui/egg-property-tree-view.h diff --git a/test/perf-overhead.c b/tools/perf-overhead.c index f8bdcbd..f8bdcbd 100644 --- a/test/perf-overhead.c +++ b/tools/perf-overhead.c |