From f635b1be3ea9c3a3892936e95e9306b121d1bb5e Mon Sep 17 00:00:00 2001 From: enselic Date: Thu, 11 Sep 2008 18:16:12 +0000 Subject: src/Makefile.am: Added a better-than-nothing RectInsert() regression test src/test-rectinsert.c src/test-rectinsert-data.c src/test-rectinsert-data.h src/test-rectinsert-types.h: Files for the test git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@507 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- recordmydesktop/src/Makefile.am | 93 ++++--- recordmydesktop/src/test-rectinsert-data.c | 380 ++++++++++++++++++++++++++++ recordmydesktop/src/test-rectinsert-data.h | 30 +++ recordmydesktop/src/test-rectinsert-types.h | 39 +++ recordmydesktop/src/test-rectinsert.c | 174 +++++++++++++ 5 files changed, 678 insertions(+), 38 deletions(-) create mode 100644 recordmydesktop/src/test-rectinsert-data.c create mode 100644 recordmydesktop/src/test-rectinsert-data.h create mode 100644 recordmydesktop/src/test-rectinsert-types.h create mode 100644 recordmydesktop/src/test-rectinsert.c (limited to 'recordmydesktop/src') diff --git a/recordmydesktop/src/Makefile.am b/recordmydesktop/src/Makefile.am index c3046b5..48ac3bc 100644 --- a/recordmydesktop/src/Makefile.am +++ b/recordmydesktop/src/Makefile.am @@ -1,45 +1,62 @@ bin_PROGRAMS = recordmydesktop +recordmydesktop_SOURCES = \ + bgr_to_yuv.c \ + cache_audio.c \ + cache_frame.c \ + capture_sound.c \ + cleanup.c \ + encode_cache.c \ + encode_image_buffer.c \ + encode_sound_buffer.c \ + flush_to_ogg.c \ + get_frame.c \ + getzpixmap.c \ + init_encoder.c \ + initialize_data.c \ + load_cache.c \ + make_dummy_pointer.c \ + opendev.c \ + parseargs.c \ + poll_events.c \ + queryextensions.c \ + recordmydesktop.c \ + rectinsert.c \ + register_callbacks.c \ + rmd_cache.c \ + rmd_error.c \ + rmd_frame.c \ + rmd_jack.c \ + rmd_rescue.c \ + rmd_timer.c \ + rmdthreads.c \ + setbrwindow.c \ + shortcuts.c \ + skeleton.c \ + specsfile.c \ + update_image.c \ + wm_check.c -recordmydesktop_SOURCES= recordmydesktop.c\ - getzpixmap.c\ - parseargs.c\ - rectinsert.c\ - setbrwindow.c\ - queryextensions.c\ - register_callbacks.c\ - get_frame.c\ - update_image.c\ - poll_events.c\ - encode_image_buffer.c\ - bgr_to_yuv.c\ - flush_to_ogg.c\ - make_dummy_pointer.c\ - opendev.c\ - capture_sound.c\ - encode_sound_buffer.c\ - init_encoder.c\ - cache_frame.c\ - cache_audio.c\ - rmd_cache.c\ - load_cache.c\ - wm_check.c\ - encode_cache.c\ - rmdthreads.c\ - initialize_data.c\ - rmd_jack.c\ - cleanup.c\ - specsfile.c\ - shortcuts.c\ - rmd_error.c\ - rmd_frame.c\ - rmd_timer.c\ - rmd_rescue.c\ - skeleton.c - - -INCLUDES= $(all_includes) -I$(top_srcdir)/include +INCLUDES = $(all_includes) -I$(top_srcdir)/include recordmydesktop_LDFLAGS = @X_LIBS@ @X_EXTRA_LIBS@ @X_PRE_LIBS@ recordmydesktop_CFLAGS = -D_THREAD_SAFE -pthread -Wall + + +# RectInsert test +TESTS = test-rectinsert +EXTRA_PROGRAMS = test-rectinsert +CLEANFILES = $(EXTRA_PROGRAMS) + +test_rectinsert_SOURCES = \ + test-rectinsert.c \ + test-rectinsert-data.c \ + test-rectinsert-data.h \ + test-rectinsert-types.h \ + rectinsert.c + +test_rectinsert_CPPFLAGS = \ + -I$(top_srcdir)/include + +test_rectinsert_CFLAGS = -Wall diff --git a/recordmydesktop/src/test-rectinsert-data.c b/recordmydesktop/src/test-rectinsert-data.c new file mode 100644 index 0000000..45ed23a --- /dev/null +++ b/recordmydesktop/src/test-rectinsert-data.c @@ -0,0 +1,380 @@ +/****************************************************************************** +* for recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2008 Martin Nordholts * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program 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 General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +******************************************************************************/ + +#include "test-rectinsert-types.h" +#include "test-rectinsert-data.h" + + +// Defines to increase readability of test data +#define O FALSE +#define E TRUE + + +RectInsertTestdataEntry rectinsert_test_data[] = { + + // Test #1 + + { "Put a geom in place", + + { 2, 2, 2, 2 }, + + { O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #2 + + { "Put a geom in place and make sure it gets an even size and position", + + { 15, 2, 4, 3 }, + + { O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #3 + + { "Put a new geom within an existing geom", + + { 14, 2, 4, 2 }, + + { O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #4 + + { "Put a new geom over an existing geom and make sure it beocomes even", + + { 1, 1, 3, 3 }, + + { E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + + // Test #5 + + { "Put a new geom that partly covers an existing geom", + + { 10, 4, 6, 6 }, + + { E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #6 + + { "Put new small heighted but wide geom over an existing geom area", + + { 0, 8, 20, 2 }, + + { E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #7 + + { "Put new small widthed but high geom over two existing geom areas", + + { 2, 2, 2, 18 }, + + { E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #8 + + { "Prepare for test 10", + + { 8, 14, 4, 4 }, + + { E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,O,O,O,O, + + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #9 + + { "Prepare for test 10 (again)", + + { 16, 14, 2, 2 }, + + { E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,E,E,O,O, + + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,E,E,O,O, + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,E,E, E,E,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O } }, + + + // Test #10 + + { "Put a geom that covers two separate geoms", + + { 6, 12, 14, 8 }, + + { E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + E,E,E,E,O, O,O,O,O,O, O,O,O,O,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, E,E,E,E,E, E,O,O,O,O, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,O,O,O,O, O,O,O,O,O, O,O,O,O,O, + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + O,O,E,E,O, O,E,E,E,E, E,E,E,E,E, E,E,E,E,E } }, + + + // Test #11 + + { "Cover the whole area", + + { 0, 0, 20, 20 }, + + { E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, + E,E,E,E,E, E,E,E,E,E, E,E,E,E,E, E,E,E,E,E } }, + + + // Mark end of tests + + { NULL, } +}; + diff --git a/recordmydesktop/src/test-rectinsert-data.h b/recordmydesktop/src/test-rectinsert-data.h new file mode 100644 index 0000000..7957b30 --- /dev/null +++ b/recordmydesktop/src/test-rectinsert-data.h @@ -0,0 +1,30 @@ +/****************************************************************************** +* for recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2008 Martin Nordholts * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program 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 General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +******************************************************************************/ + +#ifndef TEST_RECTINSERT_DATA_H +#define TEST_RECTINSERT_DATA_H + +#include "test-rectinsert-types.h" + +extern RectInsertTestdataEntry rectinsert_test_data[]; + +#endif /* TEST_RECTINSERT_DATA_H */ diff --git a/recordmydesktop/src/test-rectinsert-types.h b/recordmydesktop/src/test-rectinsert-types.h new file mode 100644 index 0000000..f0edc45 --- /dev/null +++ b/recordmydesktop/src/test-rectinsert-types.h @@ -0,0 +1,39 @@ +/****************************************************************************** +* for recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2008 Martin Nordholts * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program 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 General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +******************************************************************************/ + +#ifndef TEST_RECTINSERT_TYPES_H +#define TEST_RECTINSERT_TYPES_H + +// FIXME: Include recordmydesktop-types.h when available +#include "recordmydesktop.h" + +#define STATE_WIDTH 20 +#define STATE_HEIGHT 20 + +typedef struct RectInsertTestdataEntry { + const char *description; + WGeometry new_geom; + boolean expected_state[STATE_WIDTH * STATE_HEIGHT]; +} RectInsertTestdataEntry; + + +#endif /* TEST_RECTINSERT_TYPES_H */ diff --git a/recordmydesktop/src/test-rectinsert.c b/recordmydesktop/src/test-rectinsert.c new file mode 100644 index 0000000..8830bf5 --- /dev/null +++ b/recordmydesktop/src/test-rectinsert.c @@ -0,0 +1,174 @@ +/****************************************************************************** +* for recordMyDesktop * +******************************************************************************* +* * +* Copyright (C) 2008 Martin Nordholts * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program 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 General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * +* * +******************************************************************************/ + +#include "recordmydesktop.h" + +#include "test-rectinsert-types.h" +#include "test-rectinsert-data.h" + + +static void SetPixel(boolean *state, int x, int y, boolean value) { + int index = y * STATE_WIDTH + x; + + // Guard against non-optimal implementations + if (index < 0 || index >= STATE_WIDTH * STATE_HEIGHT) { + return; + } + + state[y * STATE_WIDTH + x] = value; +} + +static boolean GetPixel(boolean *state, int x, int y) { + int index = y * STATE_WIDTH + x; + + // Guard against non-optimal implementations + if (index < 0 || index >= STATE_WIDTH * STATE_HEIGHT) { + return FALSE; + } + + return state[y * STATE_WIDTH + x]; +} + +static void WriteGeomToState(WGeometry *geom, boolean *state) { + int x, y; + + for (y = geom->y; y < geom->y + geom->height; y++) { + for (x = geom->x; x < geom->x + geom->width; x++) { + SetPixel(state, x, y, TRUE); + } + } +} + +static void ClearState(boolean *state) { + int x, y; + + for (y = 0; y < STATE_HEIGHT; y++) { + for (x = 0; x < STATE_WIDTH; x++) { + SetPixel(state, x, y, FALSE); + } + } +} + +static void WarnIfNonOptimal(WGeometry *geom) { + if (geom->x < 0 || geom->x >= STATE_WIDTH || + geom->y < 0 || geom->y >= STATE_HEIGHT || + geom->width < 0 || geom->width > STATE_WIDTH || + geom->height < 0 || geom->height > STATE_HEIGHT) + { + // The RectInsert() implementation is not optimal + printf(" Non-optimal geom (and RectInsert() implementation) encountered!\n" + " geom x = %d, y = %d, width = %d, height = %d\n", + geom->x, + geom->y, + geom->width, + geom->height); + } +} + +static void GetState(RectArea *root, boolean *state) { + RectArea *current = root; + + ClearState(state); + + while (current) + { + WarnIfNonOptimal(¤t->geom); + + WriteGeomToState(¤t->geom, state); + + current = current->next; + } +} + +static boolean StatesEqual(boolean *a, boolean *b) { + int x, y; + + for (y = 0; y < STATE_HEIGHT; y++) { + for (x = 0; x < STATE_WIDTH; x++) { + if (GetPixel(a, x, y) != GetPixel(b, x, y)) { + return FALSE; + } + } + } + + return TRUE; +} + +static void PrintState(boolean *state) { + int x, y; + + for (y = 0; y < STATE_HEIGHT; y++) { + printf(" "); + + for (x = 0; x < STATE_WIDTH; x++) { + printf(GetPixel(state, x, y) ? "X" : "O"); + printf(x != STATE_WIDTH - 1 ? "," : ""); + printf((x + 1) % 5 == 0 ? " " : ""); + } + + printf("\n"); + printf((y + 1) % 5 == 0 ? "\n" : ""); + } +} + +/** + * This program tests the RectInsert() functionality by calling + * RectInsert() with various testdata and after each call comparing + * the current state with a predefied set of expected states. + */ +int main(int argc, char **argv) { + boolean current_state[STATE_WIDTH * STATE_HEIGHT]; + RectArea *root = NULL; + int i = 0; + int result = 0; + + printf("== Testing RectInsert() ==\n"); + + // Run until there we find end of tests data + while (rectinsert_test_data[i].description != NULL) { + + printf("Test #%d: %s\n", i + 1, rectinsert_test_data[i].description); + RectInsert(&root, &rectinsert_test_data[i].new_geom); + GetState(root, current_state); + + if (!StatesEqual(current_state, rectinsert_test_data[i].expected_state)) { + printf(" FAILURE!\n"); + printf(" Current state:\n"); + PrintState(current_state); + + printf(" Expected state:\n"); + PrintState(rectinsert_test_data[i].expected_state); + + // Just set to failure and keep going... + result = -1; + } + else { + printf(" PASS\n"); + } + + // Run next test + printf("\n"); + i++; + } + + return result; +} -- cgit v1.2.1