1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
/* test-barcodes.c
*
* Copyright 2020 James Westman <james@flyingpimonster.net>
*
* This file is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <glib.h>
#include <aperture.h>
#include "utils.h"
#include "dummy-device-provider.h"
static void
test_barcodes_enum ()
{
g_assert_cmpint (aperture_barcode_type_from_string ("COMPOSITE"), ==, APERTURE_BARCODE_COMPOSITE);
g_assert_cmpint (aperture_barcode_type_from_string ("DataBar"), ==, APERTURE_BARCODE_DATABAR);
g_assert_cmpint (aperture_barcode_type_from_string ("QR-Code"), ==, APERTURE_BARCODE_QR);
g_assert_cmpint (aperture_barcode_type_from_string ("I2/5"), ==, APERTURE_BARCODE_I25);
g_assert_cmpint (aperture_barcode_type_from_string ("three zebras walking into a bar"), ==, APERTURE_BARCODE_UNKNOWN);
}
static void
test_barcodes_enabled ()
{
g_test_summary ("Test that barcode detection is enabled in the test environment");
#ifdef BARCODE_TESTS_SKIPPABLE
if (!aperture_is_barcode_detection_enabled ()) {
g_test_skip ("Skipping test that requires barcode detection, because it is not available");
return;
}
#endif
g_assert_true (aperture_is_barcode_detection_enabled ());
}
static void
barcode_detected_cb (TestUtilsCallback *cb, ApertureBarcode barcode, char *data)
{
g_assert_cmpstr (data, ==, "hello world");
g_assert_cmpint (barcode, ==, APERTURE_BARCODE_QR);
testutils_callback_call (cb);
}
void
add_barcodes_tests ()
{
g_test_add_func ("/barcodes/enum", test_barcodes_enum);
g_test_add_func ("/barcodes/enabled", test_barcodes_enabled);
}
|