<?xml version="1.0" ?>

<makefile>
    <!--
        The use of PCH is disabled for samples by default but we do want to use
        them for the test as this dramatically speeds up its compilation.
     -->
    <set var="WX_ENABLE_PRECOMP_HEADERS">1</set>

    <include file="../build/bakefiles/common_samples.bkl"/>

    <template id="wx_test">
        <include>$(TOP_SRCDIR)3rdparty/catch/single_include</include>

        <if cond="WX_DISABLE_PRECOMP_HEADERS=='0'">
            <if cond="FORMAT!='autoconf' and PLATFORM_WIN32=='1'">
                <sources>dummy.cpp</sources>
                <precomp-headers-gen>dummy.cpp</precomp-headers-gen>
            </if>
            <precomp-headers-header>testprec.h</precomp-headers-header>
            <precomp-headers>on</precomp-headers>
            <precomp-headers-file>testprec_$(id)</precomp-headers-file>
        </if>
    </template>

    <exe id="test" template="wx_sample_console,wx_test"
                   template_append="wx_append_base">
        <sources>
            test.cpp
            any/anytest.cpp
            archive/archivetest.cpp
            archive/ziptest.cpp
            archive/tartest.cpp
            arrays/arrays.cpp
            base64/base64.cpp
            cmdline/cmdlinetest.cpp
            config/config.cpp
            config/fileconf.cpp
            config/regconf.cpp
            datetime/datetimetest.cpp
            events/evthandler.cpp
            events/evtlooptest.cpp
            events/evtsource.cpp
            events/stopwatch.cpp
            events/timertest.cpp
            exec/exec.cpp
            file/dir.cpp
            file/filefn.cpp
            file/filetest.cpp
            filekind/filekind.cpp
            filename/filenametest.cpp
            filesys/filesystest.cpp
            fontmap/fontmaptest.cpp
            formatconverter/formatconvertertest.cpp
            fswatcher/fswatchertest.cpp
            hashes/hashes.cpp
            interactive/output.cpp
            interactive/input.cpp
            intl/intltest.cpp
            lists/lists.cpp
            log/logtest.cpp
            longlong/longlongtest.cpp
            mbconv/convautotest.cpp
            mbconv/mbconvtest.cpp
            misc/dynamiclib.cpp
            misc/environ.cpp
            misc/metatest.cpp
            misc/misctests.cpp
            misc/module.cpp
            misc/pathlist.cpp
            misc/typeinfotest.cpp
            net/ipc.cpp
            net/socket.cpp
            net/webrequest.cpp
            regex/regextest.cpp
            regex/wxregextest.cpp
            scopeguard/scopeguardtest.cpp
            strings/iostream.cpp
            strings/numformatter.cpp
            strings/strings.cpp
            strings/stdstrings.cpp
            strings/tokenizer.cpp
            strings/unichar.cpp
            strings/unicode.cpp
            strings/vararg.cpp
            strings/crt.cpp
            strings/vsnprintf.cpp
            strings/hexconv.cpp
            streams/datastreamtest.cpp
            streams/ffilestream.cpp
            streams/fileback.cpp
            streams/filestream.cpp
            streams/iostreams.cpp
            streams/largefile.cpp
            streams/lzmastream.cpp
            streams/memstream.cpp
            streams/socketstream.cpp
            streams/sstream.cpp
            streams/stdstream.cpp
            streams/tempfile.cpp
            streams/textstreamtest.cpp
            streams/zlibstream.cpp
            textfile/textfiletest.cpp
            thread/atomic.cpp
            thread/misc.cpp
            thread/queue.cpp
            thread/tls.cpp
            uris/ftp.cpp
            uris/uris.cpp
            uris/url.cpp
            weakref/evtconnection.cpp
            weakref/weakref.cpp
            xlocale/xlocale.cpp
            xml/xmltest.cpp
        </sources>
        <wx-lib>net</wx-lib>
        <wx-lib>xml</wx-lib>
        <wx-lib>base</wx-lib>
    </exe>

    <!--
      This test program is targeted to "headless GUI" tests, tests which are
      typically tied to the "core" component but that should run nicely in a
      console only program. This program should be executable from a console
      only Unix session (such as telnet or ssh) although it uses graphics
      contexts, so if you modify this project, please check that it can still
      be ran in such configuration and doesn't require an X server connection.
      -->
    <exe id="test_drawing" template="wx_sample_console,wx_test"
                           template_append="wx_append"
         cond="USE_GUI=='1'">
        <sources>
            test.cpp
            drawing/drawing.cpp
            drawing/plugindriver.cpp
            drawing/basictest.cpp
            drawing/fonttest.cpp
        </sources>
        <wx-lib>core</wx-lib>
        <wx-lib>net</wx-lib>
        <wx-lib>base</wx-lib>
    </exe>

    <!--
      This is a sample plugin, it simply uses a wxImage based
      wxGraphicsContext. It should render the same as the built-in test. Use
      the WX_TEST_SUITE_GC_DRAWING_PLUGINS variable to specify the location of
      the produced DLL/so to get it loaded and tested. To make your own plugin,
      you can copy this sample and link toward your own implementation of
      wxGraphicsContext interface, building the appropriate DrawingTestGCFactory
      -->
    <module id="test_drawingplugin" template="wx"
                                    template_append="wx_append"
            cond="USE_GUI=='1' and SHARED=='1'">
        <define>$(DLLFLAG)</define>
        <sources>
            drawing/pluginsample.cpp
        </sources>
        <wx-lib>core</wx-lib>
        <wx-lib>base</wx-lib>
    </module>

    <template id="stc_append">
        <if cond="OUT_OF_TREE_MAKEFILES=='0'">
            <sys-lib>$(LIB_SCINTILLA)</sys-lib>
            <sys-lib>$(LIB_LEXILLA)</sys-lib>
        </if>
    </template>

    <exe id="test_gui" template="wx_sample,wx_test"
                       template_append="stc_append,wx_append"
         cond="USE_GUI=='1'">

        <!-- link against GUI libraries, but be a console app: -->
        <app-type>console</app-type>

        <sources>
            asserthelper.cpp
            test.cpp
            testableframe.cpp
            geometry/rect.cpp
            geometry/size.cpp
            geometry/point.cpp
            geometry/region.cpp
            graphics/bitmap.cpp
            graphics/bmpbundle.cpp
            graphics/colour.cpp
            graphics/ellipsization.cpp
            graphics/measuring.cpp
            graphics/affinematrix.cpp
            graphics/boundingbox.cpp
            graphics/clipper.cpp
            graphics/clippingbox.cpp
            graphics/coords.cpp
            graphics/graphbitmap.cpp
            graphics/graphmatrix.cpp
            graphics/graphpath.cpp
            graphics/imagelist.cpp
            <!--
                Duplicate this file here to compile a GUI test in it too.
             -->
            config/config.cpp
            controls/auitest.cpp
            controls/bitmapcomboboxtest.cpp
            controls/bitmaptogglebuttontest.cpp
            controls/bookctrlbasetest.cpp
            controls/buttontest.cpp
            controls/checkboxtest.cpp
            controls/checklistboxtest.cpp
            controls/choicebooktest.cpp
            controls/choicetest.cpp
            controls/comboboxtest.cpp
            controls/dataviewctrltest.cpp
            controls/datepickerctrltest.cpp
            controls/frametest.cpp
            controls/gaugetest.cpp
            controls/gridtest.cpp
            controls/headerctrltest.cpp
            controls/htmllboxtest.cpp
            controls/hyperlinkctrltest.cpp
            controls/itemcontainertest.cpp
            controls/label.cpp
            controls/listbasetest.cpp
            controls/listbooktest.cpp
            controls/listboxtest.cpp
            controls/listctrltest.cpp
            controls/listviewtest.cpp
            controls/markuptest.cpp
            controls/notebooktest.cpp
            controls/ownerdrawncomboboxtest.cpp
            controls/pickerbasetest.cpp
            controls/pickertest.cpp
            controls/propgridtest.cpp
            controls/radioboxtest.cpp
            controls/radiobuttontest.cpp
            controls/rearrangelisttest.cpp
            controls/richtextctrltest.cpp
            controls/searchctrltest.cpp
            controls/simplebooktest.cpp
            controls/slidertest.cpp
            controls/spinctrldbltest.cpp
            controls/spinctrltest.cpp
            controls/styledtextctrltest.cpp
            controls/textctrltest.cpp
            controls/textentrytest.cpp
            controls/togglebuttontest.cpp
            controls/toolbooktest.cpp
            controls/treebooktest.cpp
            controls/treectrltest.cpp
            controls/treelistctrltest.cpp
            controls/virtlistctrltest.cpp
            controls/webtest.cpp
            controls/windowtest.cpp
            controls/dialogtest.cpp
            events/clone.cpp
            <!--
                Duplicate this file here to test GUI event loops too.
             -->
            events/evtlooptest.cpp
            events/propagation.cpp
            events/keyboard.cpp
            <!--
                And duplicate this one too as wxExecute behaves differently in
                console and GUI applications.
             -->
            exec/exec.cpp
            font/fonttest.cpp
            image/image.cpp
            image/rawbmp.cpp
            html/htmlparser.cpp
            html/htmlwindow.cpp
            html/htmprint.cpp
            menu/accelentry.cpp
            menu/menu.cpp
            misc/guifuncs.cpp
            misc/selstoretest.cpp
            misc/garbage.cpp
            misc/safearrayconverttest.cpp
            misc/settings.cpp
            <!--
                This one is intentionally duplicated here (it is also part of
                non-GUI test) as sockets behave differently in console and GUI
                applications.
             -->
            net/socket.cpp
            persistence/tlw.cpp
            persistence/dataview.cpp
            rowheightcache/rowheightcachetest.cpp
            sizers/boxsizer.cpp
            sizers/gridsizer.cpp
            sizers/wrapsizer.cpp
            toplevel/toplevel.cpp
            validators/valnum.cpp
            validators/valtext.cpp
            window/clientsize.cpp
            window/setsize.cpp
            xml/xrctest.cpp
        </sources>
        <!--
            Can't use <wx-lib> here as it doesn't work with conditionally
            defined variables, so fall back <sys-lib> as we must not link with
            inexisting webview library to be able to run tests even if
            wxWebView is not available.
         -->
        <sys-lib>$(WXLIB_WEBVIEW)</sys-lib>
        <ldlibs>$(EXTRALIBS_WEBVIEW)</ldlibs>
        <wx-lib>stc</wx-lib>
        <wx-lib>aui</wx-lib>
        <wx-lib>richtext</wx-lib>
        <wx-lib>media</wx-lib>
        <wx-lib>xrc</wx-lib>
        <wx-lib>xml</wx-lib>
        <wx-lib>html</wx-lib>
        <wx-lib>propgrid</wx-lib>
        <wx-lib>core</wx-lib>
        <wx-lib>net</wx-lib>
        <wx-lib>base</wx-lib>
    </exe>

    <exe id="test_allheaders" template="wx_sample,wx_test"
                              template_append="stc_append,wx_append"
         cond="USE_GUI=='1'">
        <!-- link against GUI libraries, but be a console app: -->
        <app-type>console</app-type>

        <sources>
            asserthelper.cpp
            test.cpp
            allheaders.cpp
            testableframe.cpp
        </sources>
        <!--
            Can't use <wx-lib> here as it doesn't work with conditionally
            defined variables, so fall back <sys-lib> as we must not link with
            inexisting webview library to be able to run tests even if
            wxWebView is not available.
         -->
        <sys-lib>$(WXLIB_WEBVIEW)</sys-lib>
        <ldlibs>$(EXTRALIBS_WEBVIEW)</ldlibs>
        <wx-lib>stc</wx-lib>
        <wx-lib>core</wx-lib>
        <wx-lib>net</wx-lib>
        <wx-lib>base</wx-lib>
    </exe>


    <wx-data id="data">
        <files>testdata.conf horse.svg</files>
    </wx-data>

    <wx-data id="data-image-sample">
        <!-- test data for image/image.cpp test unit: -->
        <files>horse.ani  horse.bmp  horse.cur  horse.gif  horse.ico  horse.jpg
               horse.pcx  horse.png  horse.pnm  horse.tga  horse.tif  horse.xpm</files>
    </wx-data>

    <wx-data id="data-images">
        <srcdir>$(SRCDIR)/image</srcdir>
        <dstdir>image</dstdir>
        <!--
            Don't forget to update build/cmake/tests/gui/CMakeLists.txt when
            adding new files here!
         -->
        <files>
            bitfields.bmp
            bitfields-alpha.bmp
            8bpp-colorsused-large.bmp
            8bpp-colorsused-negative.bmp
            rle4-delta-320x240.bmp
            rle8-delta-320x240.bmp
            rle8-delta-320x240-expected.bmp

            horse_grey.bmp horse_grey_flipped.bmp
            horse_rle4.bmp horse_rle4_flipped.bmp
            horse_rle8.bmp horse_rle8_flipped.bmp

            horse_bicubic_50x50.png
            horse_bicubic_100x100.png
            horse_bicubic_150x150.png
            horse_bicubic_300x300.png

            horse_bilinear_50x50.png
            horse_bilinear_100x100.png
            horse_bilinear_150x150.png
            horse_bilinear_300x300.png

            horse_box_average_50x50.png
            horse_box_average_100x100.png
            horse_box_average_150x150.png
            horse_box_average_300x300.png

            cross_bicubic_256x256.png
            cross_bilinear_256x256.png
            cross_box_average_256x256.png
            cross_nearest_neighb_256x256.png

            paste_input_background.png
            paste_input_black.png
            paste_input_overlay_transparent_border_opaque_square.png
            paste_input_overlay_transparent_border_semitransparent_circle.png
            paste_input_overlay_transparent_border_semitransparent_square.png
            paste_result_background_plus_circle_plus_square.png
            paste_result_background_plus_overlay_transparent_border_opaque_square.png
            paste_result_background_plus_overlay_transparent_border_semitransparent_square.png
            paste_result_no_background_square_over_circle.png

            wx.png

            toucan.png
            toucan_hue_0.538.png
            toucan_sat_-0.41.png
            toucan_bright_-0.259.png
            toucan_hsv_0.538_-0.41_-0.259.png
            toucan_light_46.png
            toucan_dis_240.png
            toucan_grey.png
            toucan_mono_255_255_255.png

            width-times-height-overflow.bmp
            width_height_32_bit_overflow.pgm

            bad_truncated.gif
        </files>
    </wx-data>

    <template id="catalog">
        <dstdir>$(BUILDDIR)/intl/$(id)</dstdir>
        <srcdir>$(SRCDIR)/intl/$(id)</srcdir>
        <files>internat.po internat.mo</files>
    </template>

    <wx-data id="en_GB" template="catalog"/>
    <wx-data id="fr" template="catalog"/>
    <wx-data id="ja" template="catalog"/>


    <fragment format="autoconf">
failtest: failtest_combobox failtest_evthandler failtest_weakref failtest_allheaders

failtest_combobox:
	@$(RM) test_gui_comboboxtest.o
	if $(MAKE) CPPFLAGS=-DTEST_INVALID_COMBOBOX_ISEMPTY test_gui_comboboxtest.o 2>/dev/null; then \
	    echo "*** Compilation with TEST_INVALID_COMBOBOX_ISEMPTY unexpectedly succeeded.">&amp;2; \
	    exit 1; \
	fi; \
	exit 0

failtest_evthandler:
	@$(RM) test_evthandler.o
	@for d in BIND_GLOBAL BIND_STATIC BIND_METHOD BIND_FUNCTOR BIND_NO_HANDLER BIND_DERIVED BIND_WRONG_CLASS EVENT_CREATION; do \
	    if $(MAKE) CPPFLAGS=-DTEST_INVALID_$$d test_evthandler.o 2>/dev/null; then \
	        echo "*** Compilation with TEST_INVALID_$$d unexpectedly succeeded.">&amp;2; \
	        exit 1; \
	    fi; \
	done; \
	exit 0

failtest_weakref:
	@$(RM) test_weakref.o
	if $(MAKE) CPPFLAGS=-DTEST_INVALID_INCOMPLETE_WEAKREF test_weakref.o 2>/dev/null; then \
	    echo "*** Compilation with TEST_INVALID_INCOMPLETE_WEAKREF unexpectedly succeeded.">&amp;2; \
	    exit 1; \
	fi; \
	exit 0

failtest_allheaders:
	@$(RM) test_allheaders.o
	if $(MAKE) CPPFLAGS=-DwxNO_IMPLICIT_WXSTRING_ENCODING -DTEST_IMPLICIT_WXSTRING_ENCODING test_allheaders.o 2>/dev/null; then \
	    echo "*** Compilation with TEST_IMPLICIT_WXSTRING_ENCODING unexpectedly succeeded.">&amp;2; \
	    exit 1; \
	fi; \
	exit 0

.PHONY: failtest failtest_combobox failtest_evthandler failtest_weakref failtest_allheaders
    </fragment>

</makefile>
