initial commit
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
1353
libs/wxWidgets-3.3.1/tests/Makefile.in
Normal file
1353
libs/wxWidgets-3.3.1/tests/Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
13
libs/wxWidgets-3.3.1/tests/README.md
Normal file
13
libs/wxWidgets-3.3.1/tests/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
Tests
|
||||
-----
|
||||
|
||||
This directory contains tests for the library and is mostly useful for the
|
||||
library developers. See the `samples` subdirectory for the examples that are
|
||||
more useful to the application developers using the library.
|
||||
|
||||
If you do work on the library itself and would like to modify an existing or
|
||||
add a new test, please see `docs/contributing/how-to-write-unit-tests.md` for
|
||||
more information.
|
||||
|
||||
This file also contains the instructions for running the tests if you'd just
|
||||
like to do it to confirm that the library works correctly.
|
||||
430
libs/wxWidgets-3.3.1/tests/allheaders.cpp
Normal file
430
libs/wxWidgets-3.3.1/tests/allheaders.cpp
Normal file
@@ -0,0 +1,430 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/allheaders.cpp
|
||||
// Purpose: Compilation test for all headers
|
||||
// Author: Vadim Zeitlin, Arrigo Marchiori
|
||||
// Created: 2020-04-20
|
||||
// Copyright: (c) 2010,2020 Vadim Zeitlin, Wlodzimierz Skiba, Arrigo Marchiori
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Note: can't use wxCHECK_GCC_VERSION() here as it's not defined yet.
|
||||
#if defined(__GNUC__)
|
||||
#define CHECK_GCC_VERSION(major, minor) \
|
||||
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
|
||||
#else
|
||||
#define CHECK_GCC_VERSION(major, minor) 0
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
// As above, we can't reuse wxCONCAT() and wxSTRINGIZE macros from wx/cpp.h
|
||||
// here, so define their equivalents here.
|
||||
#define CONCAT_HELPER(x, y) x ## y
|
||||
#define CONCAT(x1, x2) CONCAT_HELPER(x1, x2)
|
||||
|
||||
#define STRINGIZE_HELPER(x) #x
|
||||
#define STRINGIZE(x) STRINGIZE_HELPER(x)
|
||||
|
||||
#define WARNING_TURN_ON(comp, warn) \
|
||||
_Pragma(STRINGIZE(comp diagnostic error STRINGIZE(CONCAT(-W,warn))))
|
||||
#define WARNING_TURN_OFF(comp, warn) \
|
||||
_Pragma(STRINGIZE(comp diagnostic ignored STRINGIZE(CONCAT(-W,warn))))
|
||||
|
||||
// Test for clang before gcc as clang defines __GNUC__ too.
|
||||
#if defined(__clang__)
|
||||
#define CLANG_TURN_ON(warn) WARNING_TURN_ON(clang, warn)
|
||||
#define CLANG_TURN_OFF(warn) WARNING_TURN_OFF(clang, warn)
|
||||
#elif defined(__GNUC__)
|
||||
#define GCC_TURN_ON(warn) WARNING_TURN_ON(GCC, warn)
|
||||
#define GCC_TURN_OFF(warn) WARNING_TURN_OFF(GCC, warn)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// We have to include this one first in order to check for wxUSE_XXX below.
|
||||
#include "wx/setup.h"
|
||||
|
||||
// Normally this is done in wx/defs.h, but as we don't include it here, we need
|
||||
// to do it manually to avoid warnings inside the standard headers included
|
||||
// from catch.hpp.
|
||||
#if defined(__CYGWIN__) && defined(__WINDOWS__)
|
||||
#define __USE_W32_SOCKETS
|
||||
#endif
|
||||
|
||||
#include "catch2/catch.hpp"
|
||||
|
||||
#if defined(__WXQT__)
|
||||
// Include this one before enabling the warnings as doing it later, as it
|
||||
// happens when it's included from wx/fontutil.h, results in -Wsign-promo.
|
||||
#include <QtGui/QFont>
|
||||
#endif
|
||||
|
||||
|
||||
// Enable max warning level for headers if possible, using gcc pragmas.
|
||||
#ifdef GCC_TURN_ON
|
||||
// Enable all the usual "maximal" warnings.
|
||||
GCC_TURN_ON(all)
|
||||
GCC_TURN_ON(extra)
|
||||
GCC_TURN_ON(pedantic)
|
||||
|
||||
// Enable all the individual warnings not enabled by one of the warnings
|
||||
// above.
|
||||
|
||||
// Start of semi-auto-generated part, don't modify it manually.
|
||||
//
|
||||
// Manual changes:
|
||||
// - Globally replace HANDLE_GCC_WARNING with GCC_TURN_ON.
|
||||
// - Add v6 check for -Wabi, gcc < 6 don't seem to support turning it off
|
||||
// once it's turned on and gives it for the standard library symbols.
|
||||
// - Remove GCC_TURN_ON(system-headers) from the list because this option
|
||||
// will enable the warnings to be thrown inside the system headers that
|
||||
// should instead be ignored.
|
||||
// {{{
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(abi)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(abi-tag)
|
||||
GCC_TURN_ON(address)
|
||||
GCC_TURN_ON(aggregate-return)
|
||||
#if CHECK_GCC_VERSION(7,1)
|
||||
GCC_TURN_ON(alloc-zero)
|
||||
#endif // 7.1
|
||||
#if CHECK_GCC_VERSION(7,1)
|
||||
GCC_TURN_ON(alloca)
|
||||
#endif // 7.1
|
||||
#if CHECK_GCC_VERSION(10,1)
|
||||
GCC_TURN_ON(arith-conversion)
|
||||
#endif // 10.1
|
||||
GCC_TURN_ON(array-bounds)
|
||||
GCC_TURN_ON(builtin-macro-redefined)
|
||||
GCC_TURN_ON(cast-align)
|
||||
#if CHECK_GCC_VERSION(8,1)
|
||||
GCC_TURN_ON(cast-align=strict)
|
||||
#endif // 8.1
|
||||
GCC_TURN_ON(cast-qual)
|
||||
GCC_TURN_ON(char-subscripts)
|
||||
#if CHECK_GCC_VERSION(9,1)
|
||||
GCC_TURN_ON(chkp)
|
||||
#endif // 9.1
|
||||
#if CHECK_GCC_VERSION(8,1)
|
||||
GCC_TURN_ON(class-memaccess)
|
||||
#endif // 8.1
|
||||
GCC_TURN_ON(clobbered)
|
||||
#if CHECK_GCC_VERSION(10,1)
|
||||
GCC_TURN_ON(comma-subscript)
|
||||
#endif // 10.1
|
||||
GCC_TURN_ON(comment)
|
||||
#if CHECK_GCC_VERSION(4,9)
|
||||
GCC_TURN_ON(conditionally-supported)
|
||||
#endif // 4.9
|
||||
GCC_TURN_ON(conversion)
|
||||
GCC_TURN_ON(ctor-dtor-privacy)
|
||||
#if CHECK_GCC_VERSION(4,9)
|
||||
GCC_TURN_ON(date-time)
|
||||
#endif // 4.9
|
||||
GCC_TURN_ON(delete-non-virtual-dtor)
|
||||
#if CHECK_GCC_VERSION(9,1)
|
||||
GCC_TURN_ON(deprecated-copy)
|
||||
#endif // 9.1
|
||||
#if CHECK_GCC_VERSION(9,1)
|
||||
GCC_TURN_ON(deprecated-copy-dtor)
|
||||
#endif // 9.1
|
||||
GCC_TURN_ON(disabled-optimization)
|
||||
GCC_TURN_ON(double-promotion)
|
||||
#if CHECK_GCC_VERSION(7,1)
|
||||
GCC_TURN_ON(duplicated-branches)
|
||||
#endif // 7.1
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(duplicated-cond)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(empty-body)
|
||||
GCC_TURN_ON(endif-labels)
|
||||
GCC_TURN_ON(enum-compare)
|
||||
#if CHECK_GCC_VERSION(8,1)
|
||||
GCC_TURN_ON(extra-semi)
|
||||
#endif // 8.1
|
||||
GCC_TURN_ON(float-equal)
|
||||
GCC_TURN_ON(format)
|
||||
GCC_TURN_ON(format-contains-nul)
|
||||
GCC_TURN_ON(format-extra-args)
|
||||
GCC_TURN_ON(format-nonliteral)
|
||||
GCC_TURN_ON(format-security)
|
||||
#if CHECK_GCC_VERSION(5,1)
|
||||
GCC_TURN_ON(format-signedness)
|
||||
#endif // 5.1
|
||||
GCC_TURN_ON(format-zero-length)
|
||||
GCC_TURN_ON(ignored-qualifiers)
|
||||
GCC_TURN_ON(init-self)
|
||||
GCC_TURN_ON(inline)
|
||||
GCC_TURN_ON(invalid-pch)
|
||||
GCC_TURN_ON(literal-suffix)
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(logical-op)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(long-long)
|
||||
GCC_TURN_ON(main)
|
||||
GCC_TURN_ON(maybe-uninitialized)
|
||||
#if CHECK_GCC_VERSION(10,1)
|
||||
GCC_TURN_ON(mismatched-tags)
|
||||
#endif // 10.1
|
||||
GCC_TURN_ON(missing-braces)
|
||||
GCC_TURN_ON(missing-declarations)
|
||||
GCC_TURN_ON(missing-field-initializers)
|
||||
GCC_TURN_ON(missing-format-attribute)
|
||||
GCC_TURN_ON(missing-include-dirs)
|
||||
GCC_TURN_ON(missing-noreturn)
|
||||
GCC_TURN_ON(multichar)
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(namespaces)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(narrowing)
|
||||
GCC_TURN_ON(noexcept)
|
||||
#if CHECK_GCC_VERSION(7,1)
|
||||
GCC_TURN_ON(noexcept-type)
|
||||
#endif // 7.1
|
||||
GCC_TURN_ON(non-virtual-dtor)
|
||||
GCC_TURN_ON(nonnull)
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(null-dereference)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(old-style-cast)
|
||||
GCC_TURN_ON(overlength-strings)
|
||||
GCC_TURN_ON(overloaded-virtual)
|
||||
GCC_TURN_ON(packed)
|
||||
GCC_TURN_ON(packed-bitfield-compat)
|
||||
GCC_TURN_ON(padded)
|
||||
GCC_TURN_ON(parentheses)
|
||||
#if CHECK_GCC_VERSION(9,1)
|
||||
GCC_TURN_ON(pessimizing-move)
|
||||
#endif // 9.1
|
||||
GCC_TURN_ON(pointer-arith)
|
||||
GCC_TURN_ON(redundant-decls)
|
||||
#if CHECK_GCC_VERSION(10,1)
|
||||
GCC_TURN_ON(redundant-tags)
|
||||
#endif // 10.1
|
||||
#if CHECK_GCC_VERSION(7,1)
|
||||
GCC_TURN_ON(register)
|
||||
#endif // 7.1
|
||||
GCC_TURN_ON(reorder)
|
||||
#if CHECK_GCC_VERSION(7,1)
|
||||
GCC_TURN_ON(restrict)
|
||||
#endif // 7.1
|
||||
GCC_TURN_ON(return-type)
|
||||
GCC_TURN_ON(sequence-point)
|
||||
GCC_TURN_ON(shadow)
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(shift-negative-value)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(sign-compare)
|
||||
GCC_TURN_ON(sign-conversion)
|
||||
GCC_TURN_ON(sign-promo)
|
||||
GCC_TURN_ON(stack-protector)
|
||||
GCC_TURN_ON(strict-aliasing)
|
||||
GCC_TURN_ON(strict-null-sentinel)
|
||||
GCC_TURN_ON(strict-overflow)
|
||||
#if CHECK_GCC_VERSION(10,1)
|
||||
GCC_TURN_ON(string-compare)
|
||||
#endif // 10.1
|
||||
#if CHECK_GCC_VERSION(8,1)
|
||||
GCC_TURN_ON(stringop-truncation)
|
||||
#endif // 8.1
|
||||
#if CHECK_GCC_VERSION(8,1)
|
||||
GCC_TURN_ON(suggest-attribute=cold)
|
||||
#endif // 8.1
|
||||
GCC_TURN_ON(suggest-attribute=const)
|
||||
GCC_TURN_ON(suggest-attribute=format)
|
||||
#if CHECK_GCC_VERSION(8,1)
|
||||
GCC_TURN_ON(suggest-attribute=malloc)
|
||||
#endif // 8.1
|
||||
GCC_TURN_ON(suggest-attribute=noreturn)
|
||||
GCC_TURN_ON(suggest-attribute=pure)
|
||||
#if CHECK_GCC_VERSION(5,1)
|
||||
GCC_TURN_ON(suggest-final-methods)
|
||||
#endif // 5.1
|
||||
#if CHECK_GCC_VERSION(5,1)
|
||||
GCC_TURN_ON(suggest-final-types)
|
||||
#endif // 5.1
|
||||
#if CHECK_GCC_VERSION(5,1)
|
||||
GCC_TURN_ON(suggest-override)
|
||||
#endif // 5.1
|
||||
GCC_TURN_ON(switch)
|
||||
GCC_TURN_ON(switch-default)
|
||||
GCC_TURN_ON(switch-enum)
|
||||
GCC_TURN_ON(synth)
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(templates)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(trampolines)
|
||||
GCC_TURN_ON(trigraphs)
|
||||
GCC_TURN_ON(type-limits)
|
||||
GCC_TURN_ON(undef)
|
||||
GCC_TURN_ON(uninitialized)
|
||||
GCC_TURN_ON(unknown-pragmas)
|
||||
GCC_TURN_ON(unreachable-code)
|
||||
GCC_TURN_ON(unsafe-loop-optimizations)
|
||||
GCC_TURN_ON(unused)
|
||||
GCC_TURN_ON(unused-but-set-parameter)
|
||||
GCC_TURN_ON(unused-but-set-variable)
|
||||
GCC_TURN_ON(unused-function)
|
||||
GCC_TURN_ON(unused-label)
|
||||
GCC_TURN_ON(unused-local-typedefs)
|
||||
GCC_TURN_ON(unused-macros)
|
||||
GCC_TURN_ON(unused-parameter)
|
||||
GCC_TURN_ON(unused-value)
|
||||
GCC_TURN_ON(unused-variable)
|
||||
GCC_TURN_ON(useless-cast)
|
||||
GCC_TURN_ON(variadic-macros)
|
||||
GCC_TURN_ON(vector-operation-performance)
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_ON(virtual-inheritance)
|
||||
#endif // 6.1
|
||||
GCC_TURN_ON(vla)
|
||||
#if CHECK_GCC_VERSION(10,1)
|
||||
GCC_TURN_ON(volatile)
|
||||
#endif // 10.1
|
||||
GCC_TURN_ON(volatile-register-var)
|
||||
GCC_TURN_ON(write-strings)
|
||||
GCC_TURN_ON(zero-as-null-pointer-constant)
|
||||
// }}}
|
||||
|
||||
#undef GCC_TURN_ON
|
||||
|
||||
/*
|
||||
Some warnings still must be disabled, so turn them back off explicitly:
|
||||
*/
|
||||
|
||||
// Those are potentially useful warnings, but there are just too many
|
||||
// occurrences of them in our code currently.
|
||||
GCC_TURN_OFF(conversion)
|
||||
GCC_TURN_OFF(sign-compare)
|
||||
GCC_TURN_OFF(sign-conversion)
|
||||
|
||||
GCC_TURN_OFF(old-style-cast)
|
||||
GCC_TURN_OFF(useless-cast)
|
||||
|
||||
#if CHECK_GCC_VERSION(10,1)
|
||||
GCC_TURN_OFF(redundant-tags) // "struct tm" triggers this
|
||||
#endif // 10.1
|
||||
|
||||
// These ones could be useful to explore, but for now we don't use "final"
|
||||
// at all anywhere.
|
||||
#if CHECK_GCC_VERSION(5,1)
|
||||
GCC_TURN_OFF(suggest-final-methods)
|
||||
GCC_TURN_OFF(suggest-final-types)
|
||||
#endif // 5.1
|
||||
|
||||
// wxWARNING_SUPPRESS_MISSING_OVERRIDE() inside wxRTTI macros is just
|
||||
// ignored by gcc up to 9.x for some reason, so we have no choice but to
|
||||
// disable it.
|
||||
#if CHECK_GCC_VERSION(5,1) && !CHECK_GCC_VERSION(9,0)
|
||||
GCC_TURN_OFF(suggest-override)
|
||||
#endif
|
||||
|
||||
// The rest are the warnings that we don't ever want to enable.
|
||||
|
||||
// This one is given whenever inheriting from std:: classes without using
|
||||
// C++11 ABI tag explicitly, probably harmless.
|
||||
GCC_TURN_OFF(abi-tag)
|
||||
|
||||
// This can be used to ask the compiler to explain why some function is not
|
||||
// inlined, but it's perfectly normal for some functions not to be inlined.
|
||||
GCC_TURN_OFF(inline)
|
||||
|
||||
// All those are about using perfectly normal C++ features that are
|
||||
// actually used in our code.
|
||||
GCC_TURN_OFF(aggregate-return)
|
||||
GCC_TURN_OFF(long-long)
|
||||
#if CHECK_GCC_VERSION(6,1)
|
||||
GCC_TURN_OFF(namespaces)
|
||||
GCC_TURN_OFF(multiple-inheritance)
|
||||
GCC_TURN_OFF(templates)
|
||||
#endif // 6.1
|
||||
|
||||
// This warns about missing "default" label in exhaustive switches over
|
||||
// enums, so it's completely useless.
|
||||
GCC_TURN_OFF(switch-default)
|
||||
|
||||
// We don't care about padding being added to our structs.
|
||||
GCC_TURN_OFF(padded)
|
||||
#endif // gcc >= 4.6
|
||||
|
||||
// Do the same for clang too except here most of the useful warnings are
|
||||
// already included in -Wall, so we just need a few more.
|
||||
#ifdef CLANG_TURN_ON
|
||||
CLANG_TURN_ON(all)
|
||||
CLANG_TURN_ON(extra)
|
||||
CLANG_TURN_ON(pedantic)
|
||||
|
||||
CLANG_TURN_ON(shorten-64-to-32)
|
||||
#endif // clang
|
||||
|
||||
|
||||
// UTF-8-only build is the only one in which we actually want to use implicit
|
||||
// encoding (UTF-8).
|
||||
#if !wxUSE_UTF8_LOCALE_ONLY
|
||||
#define wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||
#endif
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#include "allheaders.h"
|
||||
|
||||
// Check that using wx macros doesn't result in -Wsuggest-override or
|
||||
// equivalent warnings in classes using and not using "override".
|
||||
struct Base : wxEvtHandler
|
||||
{
|
||||
virtual ~Base() { }
|
||||
|
||||
virtual void Foo() { }
|
||||
};
|
||||
|
||||
struct DerivedWithoutOverride : Base
|
||||
{
|
||||
void OnIdle(wxIdleEvent&) { }
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(DerivedWithoutOverride);
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
struct DerivedWithOverride : Base
|
||||
{
|
||||
virtual void Foo() override { }
|
||||
|
||||
void OnIdle(wxIdleEvent&) { }
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY(DerivedWithOverride);
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#ifdef GCC_TURN_OFF
|
||||
// Just using REQUIRE() below triggers -Wparentheses, so avoid it.
|
||||
GCC_TURN_OFF(parentheses)
|
||||
#endif
|
||||
|
||||
TEST_CASE("wxNO_IMPLICIT_WXSTRING_ENCODING", "[string]")
|
||||
{
|
||||
wxString s = wxASCII_STR("Hello, ASCII");
|
||||
REQUIRE(s == L"Hello, ASCII");
|
||||
#ifdef TEST_IMPLICIT_WXSTRING_ENCODING
|
||||
// Compilation of this should fail, because the macro
|
||||
// wxNO_IMPLICIT_WXSTRING_ENCODING must be set
|
||||
s = "Hello, implicit encoding";
|
||||
#endif
|
||||
|
||||
wxLogSysError(wxASCII_STR("Bogus error for testing"));
|
||||
|
||||
// Check that all translation macros expand to compilable
|
||||
// code also when wxNO_IMPLICIT_WXSTRING_ENCODING is enabled.
|
||||
|
||||
_("some text");
|
||||
wxPLURAL("singular", "plural", 2);
|
||||
wxGETTEXT_IN_CONTEXT("context", "text");
|
||||
wxGETTEXT_IN_CONTEXT_PLURAL("context", "singular", "plural", 3);
|
||||
|
||||
// Also wide strings can be used:
|
||||
_(L"item");
|
||||
wxGETTEXT_IN_CONTEXT(L"context", L"item");
|
||||
wxPLURAL(L"sing", L"plur", 3);
|
||||
wxGETTEXT_IN_CONTEXT_PLURAL(L"context", L"sing", L"plur", 3);
|
||||
}
|
||||
455
libs/wxWidgets-3.3.1/tests/allheaders.h
Normal file
455
libs/wxWidgets-3.3.1/tests/allheaders.h
Normal file
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
This file should list all the header files in the include/wx directory
|
||||
that can be directly included from the user code.
|
||||
|
||||
Excluded headers:
|
||||
|
||||
#include <wx/aui/aui.h>
|
||||
#include <wx/build.h>
|
||||
#include <wx/catch_cppunit.h>
|
||||
#include <wx/chkconf.h>
|
||||
#include <wx/dvrenderers.h>
|
||||
#include <wx/features.h>
|
||||
#include <wx/fmappriv.h>
|
||||
#include <wx/memory.h>
|
||||
#include <wx/setup_inc.h>
|
||||
#include <wx/setup_redirect.h>
|
||||
#include <wx/variantbase.h>
|
||||
#include <wx/vms_x_fix.h>
|
||||
#include <wx/webview_chromium_impl.h>
|
||||
#include <wx/xpmhand.h>
|
||||
#include <wx/xti2.h>
|
||||
*/
|
||||
|
||||
// BEGIN STANDALONE CHECK
|
||||
|
||||
#include <wx/beforestd.h>
|
||||
#include <wx/afterstd.h>
|
||||
|
||||
#include <wx/aboutdlg.h>
|
||||
#include <wx/accel.h>
|
||||
#include <wx/access.h>
|
||||
#include <wx/activityindicator.h>
|
||||
#include <wx/addremovectrl.h>
|
||||
#include <wx/affinematrix2dbase.h>
|
||||
#include <wx/affinematrix2d.h>
|
||||
#include <wx/anidecod.h>
|
||||
#include <wx/animate.h>
|
||||
#include <wx/animdecod.h>
|
||||
#include <wx/anybutton.h>
|
||||
#include <wx/any.h>
|
||||
#include <wx/anystr.h>
|
||||
#include <wx/app.h>
|
||||
#include <wx/appprogress.h>
|
||||
#include <wx/apptrait.h>
|
||||
#include <wx/archive.h>
|
||||
#include <wx/arrstr.h>
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/atomic.h>
|
||||
#include <wx/bannerwindow.h>
|
||||
#include <wx/base64.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/bmpbndl.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/bmpcbox.h>
|
||||
#include <wx/bookctrl.h>
|
||||
#include <wx/brush.h>
|
||||
#include <wx/buffer.h>
|
||||
#include <wx/busycursor.h>
|
||||
#include <wx/busyinfo.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/calctrl.h>
|
||||
#include <wx/caret.h>
|
||||
#include <wx/chartype.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/checkeddelete.h>
|
||||
#include <wx/checklst.h>
|
||||
#include <wx/choicdlg.h>
|
||||
#include <wx/choicebk.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/clntdata.h>
|
||||
#include <wx/clrpicker.h>
|
||||
#include <wx/cmdargs.h>
|
||||
#include <wx/cmdline.h>
|
||||
#include <wx/cmdproc.h>
|
||||
#include <wx/cmndata.h>
|
||||
#include <wx/collheaderctrl.h>
|
||||
#include <wx/collpane.h>
|
||||
#include <wx/colordlg.h>
|
||||
#include <wx/colourdata.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/combo.h>
|
||||
#include <wx/commandlinkbutton.h>
|
||||
#include <wx/compiler.h>
|
||||
#include <wx/compositebookctrl.h>
|
||||
#include <wx/compositewin.h>
|
||||
#include <wx/confbase.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/containr.h>
|
||||
#include <wx/control.h>
|
||||
#include <wx/convauto.h>
|
||||
#include <wx/cpp.h>
|
||||
#include <wx/creddlg.h>
|
||||
#include <wx/crt.h>
|
||||
#include <wx/cshelp.h>
|
||||
#include <wx/ctrlsub.h>
|
||||
#include <wx/cursor.h>
|
||||
#include <wx/custombgwin.h>
|
||||
#include <wx/dataobj.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/datectrl.h>
|
||||
#include <wx/dateevt.h>
|
||||
#include <wx/datetimectrl.h>
|
||||
#include <wx/datetime.h>
|
||||
#include <wx/datstrm.h>
|
||||
#include <wx/dcbuffer.h>
|
||||
#include <wx/dcclient.h>
|
||||
#include <wx/dcgraph.h>
|
||||
#include <wx/dc.h>
|
||||
#include <wx/dcmemory.h>
|
||||
#include <wx/dcmirror.h>
|
||||
#include <wx/dcprint.h>
|
||||
#include <wx/dcps.h>
|
||||
#include <wx/dcscreen.h>
|
||||
#include <wx/dcsvg.h>
|
||||
#include <wx/debug.h>
|
||||
#include <wx/debugrpt.h>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/dialup.h>
|
||||
#include <wx/dirctrl.h>
|
||||
#include <wx/dirdlg.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/display.h>
|
||||
#include <wx/dlimpexp.h>
|
||||
#include <wx/dlist.h>
|
||||
#include <wx/dnd.h>
|
||||
#include <wx/docmdi.h>
|
||||
#include <wx/docview.h>
|
||||
#include <wx/dragimag.h>
|
||||
#include <wx/dynarray.h>
|
||||
#include <wx/dynlib.h>
|
||||
#include <wx/dynload.h>
|
||||
#include <wx/editlbox.h>
|
||||
#include <wx/encconv.h>
|
||||
#include <wx/encinfo.h>
|
||||
#include <wx/eventfilter.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/evtloop.h>
|
||||
#include <wx/evtloopsrc.h>
|
||||
#include <wx/except.h>
|
||||
#include <wx/fdrepdlg.h>
|
||||
#include <wx/ffile.h>
|
||||
#include <wx/fileconf.h>
|
||||
#include <wx/filectrl.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/filedlgcustomize.h>
|
||||
#include <wx/filefn.h>
|
||||
#include <wx/file.h>
|
||||
#include <wx/filehistory.h>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/filepicker.h>
|
||||
#include <wx/filesys.h>
|
||||
#include <wx/flags.h>
|
||||
#include <wx/fontdata.h>
|
||||
#include <wx/fontdlg.h>
|
||||
#include <wx/fontenc.h>
|
||||
#include <wx/fontenum.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/fontmap.h>
|
||||
#include <wx/fontpicker.h>
|
||||
#include <wx/fontutil.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/fs_arc.h>
|
||||
#include <wx/fs_data.h>
|
||||
#include <wx/fs_filter.h>
|
||||
#include <wx/fs_inet.h>
|
||||
#include <wx/fs_mem.h>
|
||||
#include <wx/fswatcher.h>
|
||||
#include <wx/fs_zip.h>
|
||||
#include <wx/gauge.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/gdiobj.h>
|
||||
#include <wx/geometry.h>
|
||||
#include <wx/gifdecod.h>
|
||||
#include <wx/glcanvas.h>
|
||||
#include <wx/graphics.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/hash.h>
|
||||
#include <wx/hashmap.h>
|
||||
#include <wx/hashset.h>
|
||||
#include <wx/headercol.h>
|
||||
#include <wx/headerctrl.h>
|
||||
#include <wx/helpbase.h>
|
||||
#include <wx/help.h>
|
||||
#include <wx/helphtml.h>
|
||||
#include <wx/helpwin.h>
|
||||
#include <wx/htmllbox.h>
|
||||
#include <wx/hyperlink.h>
|
||||
#include <wx/iconbndl.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/iconloc.h>
|
||||
#include <wx/imagbmp.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/imaggif.h>
|
||||
#include <wx/imagiff.h>
|
||||
#include <wx/imagjpeg.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/imagpcx.h>
|
||||
#include <wx/imagpng.h>
|
||||
#include <wx/imagpnm.h>
|
||||
#include <wx/imagtga.h>
|
||||
#include <wx/imagtiff.h>
|
||||
#include <wx/imagwebp.h>
|
||||
#include <wx/imagxpm.h>
|
||||
#include <wx/infobar.h>
|
||||
#include <wx/init.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/iosfwrap.h>
|
||||
#include <wx/ioswrap.h>
|
||||
#include <wx/ipcbase.h>
|
||||
#include <wx/ipc.h>
|
||||
#include <wx/itemattr.h>
|
||||
#include <wx/itemid.h>
|
||||
#include <wx/joystick.h>
|
||||
#include <wx/kbdstate.h>
|
||||
#include <wx/language.h>
|
||||
#include <wx/layout.h>
|
||||
#include <wx/laywin.h>
|
||||
#include <wx/link.h>
|
||||
#include <wx/listbase.h>
|
||||
#include <wx/listbook.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/list.h>
|
||||
#include <wx/localedefs.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/longlong.h>
|
||||
#include <wx/lzmastream.h>
|
||||
#include <wx/math.h>
|
||||
#include <wx/matrix.h>
|
||||
#include <wx/mdi.h>
|
||||
#include <wx/mediactrl.h>
|
||||
#include <wx/memconf.h>
|
||||
#include <wx/memtext.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/menuitem.h>
|
||||
#include <wx/metafile.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/minifram.h>
|
||||
#include <wx/modalhook.h>
|
||||
#include <wx/module.h>
|
||||
#include <wx/mousemanager.h>
|
||||
#include <wx/mousestate.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/msgout.h>
|
||||
#include <wx/msgqueue.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/nativewin.h>
|
||||
#include <wx/nonownedwnd.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/notifmsg.h>
|
||||
#include <wx/numdlg.h>
|
||||
#include <wx/numformatter.h>
|
||||
#include <wx/object.h>
|
||||
#include <wx/odcombo.h>
|
||||
#include <wx/overlay.h>
|
||||
#include <wx/ownerdrw.h>
|
||||
#include <wx/palette.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/paper.h>
|
||||
#include <wx/pen.h>
|
||||
#include <wx/peninfobase.h>
|
||||
#include <wx/persist.h>
|
||||
#include <wx/persist/bookctrl.h>
|
||||
#include <wx/persist/checkbox.h>
|
||||
#include <wx/persist/combobox.h>
|
||||
#include <wx/persist/dataview.h>
|
||||
#include <wx/persist/radiobut.h>
|
||||
#include <wx/persist/splitter.h>
|
||||
#include <wx/persist/toplevel.h>
|
||||
#include <wx/persist/treebook.h>
|
||||
#include <wx/persist/window.h>
|
||||
#include <wx/pickerbase.h>
|
||||
#include <wx/platform.h>
|
||||
#include <wx/platinfo.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/position.h>
|
||||
#include <wx/power.h>
|
||||
#include <wx/preferences.h>
|
||||
#include <wx/printdlg.h>
|
||||
#include <wx/print.h>
|
||||
#include <wx/prntbase.h>
|
||||
#include <wx/process.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <wx/propdlg.h>
|
||||
#include <wx/ptr_scpd.h>
|
||||
#include <wx/ptr_shrd.h>
|
||||
#include <wx/quantize.h>
|
||||
#include <wx/radiobox.h>
|
||||
#include <wx/radiobut.h>
|
||||
#include <wx/range.h>
|
||||
#include <wx/rawbmp.h>
|
||||
#include <wx/rearrangectrl.h>
|
||||
#include <wx/recguard.h>
|
||||
#include <wx/regex.h>
|
||||
#include <wx/region.h>
|
||||
#include <wx/renderer.h>
|
||||
#include <wx/richmsgdlg.h>
|
||||
#include <wx/richtooltip.h>
|
||||
#include <wx/rtti.h>
|
||||
#include <wx/sashwin.h>
|
||||
#include <wx/sckaddr.h>
|
||||
#include <wx/sckipc.h>
|
||||
#include <wx/sckstrm.h>
|
||||
#include <wx/scopedarray.h>
|
||||
#include <wx/scopedptr.h>
|
||||
#include <wx/scopeguard.h>
|
||||
#include <wx/scrolbar.h>
|
||||
#include <wx/scrolwin.h>
|
||||
#include <wx/secretstore.h>
|
||||
#include <wx/selstore.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/sharedptr.h>
|
||||
#include <wx/simplebook.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/slider.h>
|
||||
#include <wx/snglinst.h>
|
||||
#include <wx/socket.h>
|
||||
#include <wx/sound.h>
|
||||
#include <wx/spinbutt.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/splash.h>
|
||||
#include <wx/splitter.h>
|
||||
#include <wx/srchctrl.h>
|
||||
#include <wx/sstream.h>
|
||||
#include <wx/stack.h>
|
||||
#include <wx/stackwalk.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/statusbr.h>
|
||||
#include <wx/stc/stc.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/stdstream.h>
|
||||
#include <wx/stockitem.h>
|
||||
#include <wx/stopwatch.h>
|
||||
#include <wx/strconv.h>
|
||||
#include <wx/stream.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/stringops.h>
|
||||
#include <wx/strvararg.h>
|
||||
#include <wx/sysopt.h>
|
||||
#include <wx/systhemectrl.h>
|
||||
#include <wx/tarstrm.h>
|
||||
#include <wx/taskbarbutton.h>
|
||||
#include <wx/taskbar.h>
|
||||
#include <wx/tbarbase.h>
|
||||
#include <wx/testing.h>
|
||||
#include <wx/textbuf.h>
|
||||
#include <wx/textcompleter.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/textdlg.h>
|
||||
#include <wx/textentry.h>
|
||||
#include <wx/textfile.h>
|
||||
#include <wx/textwrapper.h>
|
||||
#include <wx/tglbtn.h>
|
||||
#include <wx/thread.h>
|
||||
#include <wx/timectrl.h>
|
||||
#include <wx/time.h>
|
||||
#include <wx/timer.h>
|
||||
#include <wx/tipdlg.h>
|
||||
#include <wx/tipwin.h>
|
||||
#include <wx/tls.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/toolbar.h>
|
||||
#include <wx/toolbook.h>
|
||||
#include <wx/tooltip.h>
|
||||
#include <wx/toplevel.h>
|
||||
#include <wx/tracker.h>
|
||||
#include <wx/translation.h>
|
||||
#include <wx/treebase.h>
|
||||
#include <wx/treebook.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <wx/treelist.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/typeinfo.h>
|
||||
#include <wx/types.h>
|
||||
#include <wx/uiaction.h>
|
||||
#include <wx/uilocale.h>
|
||||
#include <wx/unichar.h>
|
||||
#include <wx/uri.h>
|
||||
#include <wx/url.h>
|
||||
#include <wx/ustring.h>
|
||||
#include <wx/utils.h>
|
||||
#include <wx/valgen.h>
|
||||
#include <wx/validate.h>
|
||||
#include <wx/valnum.h>
|
||||
#include <wx/valtext.h>
|
||||
#include <wx/variant.h>
|
||||
#include <wx/vector.h>
|
||||
#include <wx/version.h>
|
||||
#include <wx/versioninfo.h>
|
||||
#include <wx/vidmode.h>
|
||||
#include <wx/vlbox.h>
|
||||
#include <wx/volume.h>
|
||||
#include <wx/vscroll.h>
|
||||
#include <wx/weakref.h>
|
||||
#include <wx/webpdecoder.h>
|
||||
#include <wx/webrequest.h>
|
||||
#include <wx/webview_chromium.h>
|
||||
#include <wx/webviewarchivehandler.h>
|
||||
#include <wx/webviewfshandler.h>
|
||||
#include <wx/webview.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/window.h>
|
||||
#include <wx/windowid.h>
|
||||
#include <wx/windowptr.h>
|
||||
#include <wx/withimages.h>
|
||||
#include <wx/wizard.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
#include <wx/wupdlock.h>
|
||||
#include <wx/wxchar.h>
|
||||
#include <wx/wxcrtbase.h>
|
||||
#include <wx/wxcrt.h>
|
||||
#include <wx/wxcrtvararg.h>
|
||||
#include <wx/wx.h>
|
||||
#include <wx/wxhtml.h>
|
||||
#include <wx/wxprec.h>
|
||||
#include <wx/xlocale.h>
|
||||
#include <wx/xpmdecod.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/xtictor.h>
|
||||
#include <wx/xti.h>
|
||||
#include <wx/xtihandler.h>
|
||||
#include <wx/xtiprop.h>
|
||||
#include <wx/xtistrm.h>
|
||||
#include <wx/xtitypes.h>
|
||||
#include <wx/xtixml.h>
|
||||
#include <wx/zipstrm.h>
|
||||
#include <wx/zstream.h>
|
||||
#include <wx/aui/auibar.h>
|
||||
#include <wx/aui/auibook.h>
|
||||
#include <wx/aui/barartmsw.h>
|
||||
#include <wx/aui/dockart.h>
|
||||
#include <wx/aui/floatpane.h>
|
||||
#include <wx/aui/framemanager.h>
|
||||
#include <wx/aui/serializer.h>
|
||||
#include <wx/aui/tabart.h>
|
||||
#include <wx/aui/tabartgtk.h>
|
||||
#include <wx/aui/tabartmsw.h>
|
||||
#include <wx/aui/tabmdi.h>
|
||||
#include <wx/propgrid/advprops.h>
|
||||
#include <wx/propgrid/editors.h>
|
||||
#include <wx/propgrid/manager.h>
|
||||
#include <wx/propgrid/propgrid.h>
|
||||
|
||||
// END STANDALONE CHECK
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
#include <wx/dde.h>
|
||||
#endif
|
||||
739
libs/wxWidgets-3.3.1/tests/any/anytest.cpp
Normal file
739
libs/wxWidgets-3.3.1/tests/any/anytest.cpp
Normal file
@@ -0,0 +1,739 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/any/anytest.cpp
|
||||
// Purpose: Test the wxAny classes
|
||||
// Author: Jaakko Salli
|
||||
// Copyright: (c) the wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_ANY
|
||||
|
||||
#include "wx/any.h"
|
||||
#include "wx/datetime.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/vector.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
template <>
|
||||
struct StringMaker<wxVariant>
|
||||
{
|
||||
static std::string convert(const wxVariant& v)
|
||||
{
|
||||
return v.MakeString().ToStdString(wxConvUTF8);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxAnyTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
wxAnyTestCase();
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( wxAnyTestCase );
|
||||
CPPUNIT_TEST( CheckType );
|
||||
CPPUNIT_TEST( Equality );
|
||||
CPPUNIT_TEST( As );
|
||||
CPPUNIT_TEST( GetAs );
|
||||
CPPUNIT_TEST( Null );
|
||||
CPPUNIT_TEST( wxVariantConversions );
|
||||
CPPUNIT_TEST( CustomTemplateSpecialization );
|
||||
CPPUNIT_TEST( Misc );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void CheckType();
|
||||
void Equality();
|
||||
void As();
|
||||
void GetAs();
|
||||
void Null();
|
||||
void wxVariantConversions();
|
||||
void CustomTemplateSpecialization();
|
||||
void Misc();
|
||||
|
||||
wxDateTime m_testDateTime;
|
||||
|
||||
wxAny m_anySignedChar1;
|
||||
wxAny m_anySignedShort1;
|
||||
wxAny m_anySignedInt1;
|
||||
wxAny m_anySignedLong1;
|
||||
wxAny m_anySignedLongLong1;
|
||||
wxAny m_anyUnsignedChar1;
|
||||
wxAny m_anyUnsignedShort1;
|
||||
wxAny m_anyUnsignedInt1;
|
||||
wxAny m_anyUnsignedLong1;
|
||||
wxAny m_anyUnsignedLongLong1;
|
||||
wxAny m_anyStringString1;
|
||||
wxAny m_anyCharString1;
|
||||
wxAny m_anyWcharString1;
|
||||
wxAny m_anyBool1;
|
||||
wxAny m_anyFloatDouble1;
|
||||
wxAny m_anyDoubleDouble1;
|
||||
wxAny m_anyWxObjectPtr1;
|
||||
wxAny m_anyVoidPtr1;
|
||||
wxAny m_anyDateTime1;
|
||||
wxAny m_anyUniChar1;
|
||||
|
||||
wxAny m_anySignedChar2;
|
||||
wxAny m_anySignedShort2;
|
||||
wxAny m_anySignedInt2;
|
||||
wxAny m_anySignedLong2;
|
||||
wxAny m_anySignedLongLong2;
|
||||
wxAny m_anyUnsignedChar2;
|
||||
wxAny m_anyUnsignedShort2;
|
||||
wxAny m_anyUnsignedInt2;
|
||||
wxAny m_anyUnsignedLong2;
|
||||
wxAny m_anyUnsignedLongLong2;
|
||||
wxAny m_anyStringString2;
|
||||
wxAny m_anyCharString2;
|
||||
wxAny m_anyWcharString2;
|
||||
wxAny m_anyBool2;
|
||||
wxAny m_anyFloatDouble2;
|
||||
wxAny m_anyDoubleDouble2;
|
||||
wxAny m_anyWxObjectPtr2;
|
||||
wxAny m_anyVoidPtr2;
|
||||
wxAny m_anyDateTime2;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxAnyTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( wxAnyTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( wxAnyTestCase, "wxAnyTestCase" );
|
||||
|
||||
// Let's use a number with first digit after decimal dot less than 5,
|
||||
// so that we don't have to worry about whether conversion from float
|
||||
// to int truncates or rounds.
|
||||
const float TEST_FLOAT_CONST = 123.456f;
|
||||
const double TEST_DOUBLE_CONST = 123.456;
|
||||
|
||||
const double FEQ_DELTA = 0.001;
|
||||
|
||||
wxObject* dummyWxObjectPointer = reinterpret_cast<wxObject*>(1234);
|
||||
void* dummyVoidPointer = reinterpret_cast<void*>(1234);
|
||||
|
||||
|
||||
//
|
||||
// Test both 'creation' methods
|
||||
wxAnyTestCase::wxAnyTestCase()
|
||||
: m_anySignedChar1((signed char)15),
|
||||
m_anySignedShort1((signed short)15),
|
||||
m_anySignedInt1((signed int)15),
|
||||
m_anySignedLong1((signed long)15),
|
||||
m_anySignedLongLong1((wxLongLong_t)15),
|
||||
m_anyUnsignedChar1((unsigned char)15),
|
||||
m_anyUnsignedShort1((unsigned short)15),
|
||||
m_anyUnsignedInt1((unsigned int)15),
|
||||
m_anyUnsignedLong1((unsigned long)15),
|
||||
m_anyUnsignedLongLong1((wxULongLong_t)15),
|
||||
m_anyStringString1(wxString("abc")),
|
||||
m_anyCharString1("abc"),
|
||||
m_anyWcharString1(L"abc"),
|
||||
m_anyBool1(true),
|
||||
m_anyFloatDouble1(TEST_FLOAT_CONST),
|
||||
m_anyDoubleDouble1(TEST_DOUBLE_CONST),
|
||||
m_anyWxObjectPtr1(dummyWxObjectPointer),
|
||||
m_anyVoidPtr1(dummyVoidPointer),
|
||||
m_anyDateTime1(wxDateTime::Now())
|
||||
{
|
||||
m_testDateTime = wxDateTime::Now();
|
||||
m_anySignedChar2 = (signed char)15;
|
||||
m_anySignedShort2 = (signed short)15;
|
||||
m_anySignedInt2 = (signed int)15;
|
||||
m_anySignedLong2 = (signed long)15;
|
||||
m_anySignedLongLong2 = (wxLongLong_t)15;
|
||||
m_anyUnsignedChar2 = (unsigned char)15;
|
||||
m_anyUnsignedShort2 = (unsigned short)15;
|
||||
m_anyUnsignedInt2 = (unsigned int)15;
|
||||
m_anyUnsignedLong2 = (unsigned long)15;
|
||||
m_anyUnsignedLongLong2 = (wxULongLong_t)15;
|
||||
m_anyStringString2 = wxString("abc");
|
||||
m_anyCharString2 = "abc";
|
||||
m_anyWcharString2 = L"abc";
|
||||
m_anyBool2 = true;
|
||||
m_anyFloatDouble2 = TEST_FLOAT_CONST;
|
||||
m_anyDoubleDouble2 = TEST_DOUBLE_CONST;
|
||||
m_anyDateTime2 = m_testDateTime;
|
||||
m_anyUniChar1 = wxUniChar('A');
|
||||
m_anyWxObjectPtr2 = dummyWxObjectPointer;
|
||||
m_anyVoidPtr2 = dummyVoidPointer;
|
||||
}
|
||||
|
||||
void wxAnyTestCase::CheckType()
|
||||
{
|
||||
wxAny nullAny;
|
||||
CPPUNIT_ASSERT(!wxANY_CHECK_TYPE(nullAny, wxString));
|
||||
|
||||
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(m_anyCharString2, const char*));
|
||||
CPPUNIT_ASSERT(!wxANY_CHECK_TYPE(m_anyCharString2, wxString));
|
||||
CPPUNIT_ASSERT(!wxANY_CHECK_TYPE(m_anyCharString2, const wchar_t*));
|
||||
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(m_anyWcharString2, const wchar_t*));
|
||||
CPPUNIT_ASSERT(!wxANY_CHECK_TYPE(m_anyWcharString2, wxString));
|
||||
CPPUNIT_ASSERT(!wxANY_CHECK_TYPE(m_anyWcharString2, const char*));
|
||||
|
||||
// HasSameType()
|
||||
CPPUNIT_ASSERT( m_anyWcharString1.HasSameType(m_anyWcharString2) );
|
||||
CPPUNIT_ASSERT( !m_anyWcharString1.HasSameType(m_anyBool1) );
|
||||
}
|
||||
|
||||
void wxAnyTestCase::Equality()
|
||||
{
|
||||
//
|
||||
// Currently this should work
|
||||
CPPUNIT_ASSERT(m_anyUnsignedLong1 == 15L);
|
||||
CPPUNIT_ASSERT(m_anyUnsignedLong1 != 30L);
|
||||
CPPUNIT_ASSERT(m_anyUnsignedLong1 == 15UL);
|
||||
CPPUNIT_ASSERT(m_anyUnsignedLong1 != 30UL);
|
||||
CPPUNIT_ASSERT(m_anyStringString1 == wxString("abc"));
|
||||
CPPUNIT_ASSERT(m_anyStringString1 != wxString("ABC"));
|
||||
CPPUNIT_ASSERT(m_anyStringString1 == "abc");
|
||||
CPPUNIT_ASSERT(m_anyStringString1 != "ABC");
|
||||
CPPUNIT_ASSERT(m_anyStringString1 == L"abc");
|
||||
CPPUNIT_ASSERT(m_anyStringString1 != L"ABC");
|
||||
CPPUNIT_ASSERT(m_anyBool1 == true);
|
||||
CPPUNIT_ASSERT(m_anyBool1 != false);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(m_anyFloatDouble1.As<double>(),
|
||||
m_anyDoubleDouble1.As<double>(),
|
||||
FEQ_DELTA);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(m_anyFloatDouble1.As<double>(),
|
||||
TEST_FLOAT_CONST,
|
||||
FEQ_DELTA);
|
||||
CPPUNIT_ASSERT(m_anyWxObjectPtr1.As<wxObject*>()
|
||||
== dummyWxObjectPointer);
|
||||
CPPUNIT_ASSERT(m_anyVoidPtr1.As<void*>() == dummyVoidPointer);
|
||||
|
||||
CPPUNIT_ASSERT(m_anySignedLong2 == 15);
|
||||
CPPUNIT_ASSERT(m_anyStringString2 == wxString("abc"));
|
||||
CPPUNIT_ASSERT(m_anyStringString2 == "abc");
|
||||
CPPUNIT_ASSERT(m_anyStringString2 == L"abc");
|
||||
CPPUNIT_ASSERT(m_anyBool2 == true);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(m_anyFloatDouble2.As<double>(),
|
||||
m_anyDoubleDouble2.As<double>(),
|
||||
FEQ_DELTA);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(m_anyFloatDouble2.As<double>(),
|
||||
TEST_FLOAT_CONST,
|
||||
FEQ_DELTA);
|
||||
CPPUNIT_ASSERT(m_anyWxObjectPtr2.As<wxObject*>()
|
||||
== dummyWxObjectPointer);
|
||||
CPPUNIT_ASSERT(m_anyVoidPtr2.As<void*>() == dummyVoidPointer);
|
||||
|
||||
// Test sub-type system type compatibility
|
||||
CPPUNIT_ASSERT(m_anySignedShort1.GetType()->
|
||||
IsSameType(m_anySignedLongLong1.GetType()));
|
||||
CPPUNIT_ASSERT(m_anyUnsignedShort1.GetType()->
|
||||
IsSameType(m_anyUnsignedLongLong1.GetType()));
|
||||
}
|
||||
|
||||
void wxAnyTestCase::As()
|
||||
{
|
||||
//
|
||||
// Test getting C++ data from wxAny without dynamic conversion
|
||||
signed char a = m_anySignedChar1.As<signed char>();
|
||||
CPPUNIT_ASSERT(a == (signed int)15);
|
||||
signed short b = m_anySignedShort1.As<signed short>();
|
||||
CPPUNIT_ASSERT(b == (signed int)15);
|
||||
signed int c = m_anySignedInt1.As<signed int>();
|
||||
CPPUNIT_ASSERT(c == (signed int)15);
|
||||
signed long d = m_anySignedLong1.As<signed long>();
|
||||
CPPUNIT_ASSERT(d == (signed int)15);
|
||||
wxLongLong_t e = m_anySignedLongLong1.As<wxLongLong_t>();
|
||||
CPPUNIT_ASSERT(e == (signed int)15);
|
||||
unsigned char f = m_anyUnsignedChar1.As<unsigned char>();
|
||||
CPPUNIT_ASSERT(f == (unsigned int)15);
|
||||
unsigned short g = m_anyUnsignedShort1.As<unsigned short>();
|
||||
CPPUNIT_ASSERT(g == (unsigned int)15);
|
||||
unsigned int h = m_anyUnsignedInt1.As<unsigned int>();
|
||||
CPPUNIT_ASSERT(h == (unsigned int)15);
|
||||
unsigned long i = m_anyUnsignedLong1.As<unsigned long>();
|
||||
CPPUNIT_ASSERT(i == (unsigned int)15);
|
||||
wxULongLong_t j = m_anyUnsignedLongLong1.As<wxULongLong_t>();
|
||||
CPPUNIT_ASSERT(j == (unsigned int)15);
|
||||
wxString k = m_anyStringString1.As<wxString>();
|
||||
CPPUNIT_ASSERT(k == "abc");
|
||||
wxString l = m_anyCharString1.As<wxString>();
|
||||
const char* cptr = m_anyCharString1.As<const char*>();
|
||||
CPPUNIT_ASSERT(l == "abc");
|
||||
CPPUNIT_ASSERT(cptr);
|
||||
wxString m = m_anyWcharString1.As<wxString>();
|
||||
const wchar_t* wcptr = m_anyWcharString1.As<const wchar_t*>();
|
||||
CPPUNIT_ASSERT(wcptr);
|
||||
CPPUNIT_ASSERT(m == "abc");
|
||||
bool n = m_anyBool1.As<bool>();
|
||||
CPPUNIT_ASSERT(n);
|
||||
|
||||
// Make sure the stored float that comes back is -identical-.
|
||||
// So do not use delta comparison here.
|
||||
float o = m_anyFloatDouble1.As<float>();
|
||||
CPPUNIT_ASSERT_EQUAL(o, TEST_FLOAT_CONST);
|
||||
|
||||
double p = m_anyDoubleDouble1.As<double>();
|
||||
CPPUNIT_ASSERT_EQUAL(p, TEST_DOUBLE_CONST);
|
||||
|
||||
wxUniChar chr = m_anyUniChar1.As<wxUniChar>();
|
||||
CPPUNIT_ASSERT(chr == 'A');
|
||||
wxDateTime q = m_anyDateTime1.As<wxDateTime>();
|
||||
CPPUNIT_ASSERT(q == m_testDateTime);
|
||||
wxObject* r = m_anyWxObjectPtr1.As<wxObject*>();
|
||||
CPPUNIT_ASSERT(r == dummyWxObjectPointer);
|
||||
void* s = m_anyVoidPtr1.As<void*>();
|
||||
CPPUNIT_ASSERT(s == dummyVoidPointer);
|
||||
}
|
||||
|
||||
void wxAnyTestCase::Null()
|
||||
{
|
||||
wxAny a;
|
||||
CPPUNIT_ASSERT(a.IsNull());
|
||||
a = -127;
|
||||
CPPUNIT_ASSERT(a == -127);
|
||||
a.MakeNull();
|
||||
CPPUNIT_ASSERT(a.IsNull());
|
||||
}
|
||||
|
||||
void wxAnyTestCase::GetAs()
|
||||
{
|
||||
//
|
||||
// Test dynamic conversion
|
||||
bool res;
|
||||
long l = 0;
|
||||
short int si = 0;
|
||||
unsigned long ul = 0;
|
||||
wxString s;
|
||||
// Let's test against float instead of double, since the former
|
||||
// is not the native underlying type the code converts to, but
|
||||
// should still work, all the same.
|
||||
float f = 0.0;
|
||||
bool b = false;
|
||||
|
||||
// Conversions from signed long type
|
||||
// The first check should be enough to make sure that the sub-type system
|
||||
// has not failed.
|
||||
res = m_anySignedLong1.GetAs(&si);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_EQUAL(si, 15);
|
||||
res = m_anySignedLong1.GetAs(&ul);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_EQUAL(ul, 15UL);
|
||||
res = m_anySignedLong1.GetAs(&s);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(s == "15");
|
||||
res = m_anySignedLong1.GetAs(&f);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(f, 15.0, FEQ_DELTA);
|
||||
res = m_anySignedLong1.GetAs(&b);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(b == true);
|
||||
|
||||
// Conversions from unsigned long type
|
||||
res = m_anyUnsignedLong1.GetAs(&l);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(l == static_cast<signed long>(15));
|
||||
res = m_anyUnsignedLong1.GetAs(&s);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(s == "15");
|
||||
res = m_anyUnsignedLong1.GetAs(&f);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(f, 15.0, FEQ_DELTA);
|
||||
res = m_anyUnsignedLong1.GetAs(&b);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(b == true);
|
||||
|
||||
// Conversions from default "abc" string to other types
|
||||
// should not work.
|
||||
CPPUNIT_ASSERT(!m_anyStringString1.GetAs(&l));
|
||||
CPPUNIT_ASSERT(!m_anyStringString1.GetAs(&ul));
|
||||
CPPUNIT_ASSERT(!m_anyStringString1.GetAs(&f));
|
||||
CPPUNIT_ASSERT(!m_anyStringString1.GetAs(&b));
|
||||
|
||||
// Let's test some other conversions from string that should work.
|
||||
wxAny anyString;
|
||||
|
||||
anyString = "15";
|
||||
res = anyString.GetAs(&l);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(l == static_cast<signed long>(15));
|
||||
res = anyString.GetAs(&ul);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_EQUAL(ul, static_cast<unsigned long>(15));
|
||||
res = anyString.GetAs(&f);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(f, 15.0, FEQ_DELTA);
|
||||
anyString = "TRUE";
|
||||
res = anyString.GetAs(&b);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(b == true);
|
||||
anyString = "0";
|
||||
res = anyString.GetAs(&b);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(b == false);
|
||||
|
||||
// Conversions from bool type
|
||||
res = m_anyBool1.GetAs(&l);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(l == static_cast<signed long>(1));
|
||||
res = m_anyBool1.GetAs(&ul);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_EQUAL(ul, static_cast<unsigned long>(1));
|
||||
res = m_anyBool1.GetAs(&s);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(s == "true");
|
||||
CPPUNIT_ASSERT(!m_anyBool1.GetAs(&f));
|
||||
|
||||
// Conversions from floating point type
|
||||
res = m_anyDoubleDouble1.GetAs(&l);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(l == static_cast<signed long>(123));
|
||||
res = m_anyDoubleDouble1.GetAs(&ul);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_EQUAL(ul, static_cast<unsigned long>(123));
|
||||
res = m_anyDoubleDouble1.GetAs(&s);
|
||||
CPPUNIT_ASSERT(res);
|
||||
double d2;
|
||||
res = s.ToCDouble(&d2);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(d2, TEST_FLOAT_CONST, FEQ_DELTA);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Test user data type for wxAnyValueTypeImpl specialization
|
||||
// any hand-built wxVariantData. Also for inplace allocation
|
||||
// sanity checks.
|
||||
//
|
||||
|
||||
class MyClass;
|
||||
|
||||
static wxVector<MyClass*> gs_myClassInstances;
|
||||
|
||||
class MyClass
|
||||
{
|
||||
public:
|
||||
MyClass( int someValue = 32768 )
|
||||
{
|
||||
Init();
|
||||
m_someValue = someValue;
|
||||
}
|
||||
MyClass( const MyClass& other )
|
||||
{
|
||||
Init();
|
||||
m_someValue = other.m_someValue;
|
||||
}
|
||||
virtual ~MyClass()
|
||||
{
|
||||
for ( size_t i=0; i<gs_myClassInstances.size(); i++ )
|
||||
{
|
||||
if ( gs_myClassInstances[i] == this )
|
||||
{
|
||||
gs_myClassInstances.erase(gs_myClassInstances.begin()+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GetValue() const
|
||||
{
|
||||
return m_someValue;
|
||||
}
|
||||
|
||||
wxString ToString()
|
||||
{
|
||||
return wxString::Format("%i", m_someValue);
|
||||
}
|
||||
|
||||
private:
|
||||
void Init()
|
||||
{
|
||||
// We use this for some sanity checking
|
||||
gs_myClassInstances.push_back(this);
|
||||
}
|
||||
|
||||
int m_someValue;
|
||||
};
|
||||
|
||||
|
||||
#if wxUSE_VARIANT
|
||||
|
||||
// For testing purposes, create dummy variant data implementation
|
||||
// that does not have wxAny conversion code
|
||||
class wxMyVariantData : public wxVariantData
|
||||
{
|
||||
public:
|
||||
wxMyVariantData(const MyClass& value)
|
||||
: m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Eq(wxVariantData& WXUNUSED(data)) const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// What type is it? Return a string name.
|
||||
virtual wxString GetType() const override { return "MyClass"; }
|
||||
|
||||
virtual wxVariantData* Clone() const override
|
||||
{
|
||||
return new wxMyVariantData(m_value);
|
||||
}
|
||||
|
||||
protected:
|
||||
MyClass m_value;
|
||||
};
|
||||
|
||||
#endif // wxUSE_VARIANT
|
||||
|
||||
|
||||
void wxAnyTestCase::wxVariantConversions()
|
||||
{
|
||||
#if wxUSE_VARIANT
|
||||
//
|
||||
// Test various conversions to and from wxVariant
|
||||
//
|
||||
bool res;
|
||||
|
||||
// Prepare wxVariants
|
||||
wxVariant vLong(123L);
|
||||
wxVariant vString("ABC");
|
||||
wxVariant vDouble(TEST_FLOAT_CONST);
|
||||
wxVariant vBool((bool)true);
|
||||
wxVariant vChar('A');
|
||||
wxVariant vLongLong(wxLongLong(wxLL(0xAABBBBCCCC)));
|
||||
wxVariant vULongLong(wxULongLong(wxULL(123456)));
|
||||
wxArrayString arrstr;
|
||||
arrstr.push_back("test string");
|
||||
wxVariant vArrayString(arrstr);
|
||||
wxVariant vDateTime(m_testDateTime);
|
||||
wxVariant vVoidPtr(dummyVoidPointer);
|
||||
wxVariant vCustomType(new wxMyVariantData(MyClass(101)));
|
||||
wxVariant vList;
|
||||
|
||||
vList.NullList();
|
||||
vList.Append(15);
|
||||
vList.Append("abc");
|
||||
|
||||
// Convert to wxAnys, and then back to wxVariants
|
||||
wxVariant variant;
|
||||
|
||||
wxAny any(vLong);
|
||||
CPPUNIT_ASSERT(any == 123L);
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant == 123L);
|
||||
|
||||
// Make sure integer variant has correct type information
|
||||
CPPUNIT_ASSERT(variant.GetLong() == 123);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "long");
|
||||
|
||||
// Unsigned long wxAny should convert to "ulonglong" wxVariant
|
||||
any = 1000UL;
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "ulonglong");
|
||||
CPPUNIT_ASSERT(variant.GetLong() == 1000);
|
||||
|
||||
any = vString;
|
||||
CPPUNIT_ASSERT(any == "ABC");
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetString() == "ABC");
|
||||
|
||||
// Must be able to build string wxVariant from wxAny built from
|
||||
// string literal
|
||||
any = "ABC";
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "string");
|
||||
CPPUNIT_ASSERT(variant.GetString() == "ABC");
|
||||
any = L"ABC";
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "string");
|
||||
CPPUNIT_ASSERT(variant.GetString() == L"ABC");
|
||||
|
||||
any = vDouble;
|
||||
double d = any.As<double>();
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(d, TEST_FLOAT_CONST, FEQ_DELTA);
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(variant.GetDouble(),
|
||||
TEST_FLOAT_CONST,
|
||||
FEQ_DELTA);
|
||||
|
||||
any = vBool;
|
||||
CPPUNIT_ASSERT(any.As<bool>() == true);
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetBool() == true);
|
||||
|
||||
any = wxAny(vChar);
|
||||
//CPPUNIT_ASSERT(any.As<wxUniChar>() == 'A');
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetChar() == 'A');
|
||||
|
||||
any = wxAny(vLongLong);
|
||||
CPPUNIT_ASSERT(any == wxLL(0xAABBBBCCCC));
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "longlong");
|
||||
CPPUNIT_ASSERT(variant.GetLongLong() == wxLongLong(wxLL(0xAABBBBCCCC)));
|
||||
|
||||
#if LONG_MAX == wxINT64_MAX
|
||||
// As a sanity check, test that wxVariant of type 'long' converts
|
||||
// seamlessly to 'longlong' (on some 64-bit systems)
|
||||
any = 0xAABBBBCCCCL;
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(variant.GetLongLong() == wxLongLong(wxLL(0xAABBBBCCCC)));
|
||||
#endif
|
||||
|
||||
any = wxAny(vULongLong);
|
||||
CPPUNIT_ASSERT(any == wxLL(123456));
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "ulonglong");
|
||||
CPPUNIT_ASSERT(variant.GetULongLong() == wxULongLong(wxULL(123456)));
|
||||
|
||||
any = (wxLongLong_t)-1;
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "long");
|
||||
CPPUNIT_ASSERT(variant.GetLong() == -1);
|
||||
|
||||
// Cannot test equality for the rest, just test that they convert
|
||||
// back correctly.
|
||||
any = wxAny(vArrayString);
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
wxArrayString arrstr2 = variant.GetArrayString();
|
||||
CPPUNIT_ASSERT(arrstr2 == arrstr);
|
||||
|
||||
any = m_testDateTime;
|
||||
CPPUNIT_ASSERT(any.As<wxDateTime>() == m_testDateTime);
|
||||
any = wxAny(vDateTime);
|
||||
CPPUNIT_ASSERT(any.As<wxDateTime>() == m_testDateTime);
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant == m_testDateTime);
|
||||
|
||||
any = wxAny(vVoidPtr);
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetVoidPtr() == dummyVoidPointer);
|
||||
|
||||
any = wxAny(vList);
|
||||
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxAnyList));
|
||||
wxAnyList anyList = any.As<wxAnyList>();
|
||||
CPPUNIT_ASSERT(anyList.GetCount() == 2);
|
||||
CPPUNIT_ASSERT((*anyList[0]).As<int>() == 15);
|
||||
CPPUNIT_ASSERT((*anyList[1]).As<wxString>() == "abc");
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "list");
|
||||
CPPUNIT_ASSERT(variant.GetCount() == 2);
|
||||
CPPUNIT_ASSERT(variant[0].GetLong() == 15);
|
||||
CPPUNIT_ASSERT(variant[1].GetString() == "abc");
|
||||
// Avoid the memory leak.
|
||||
wxClearList(anyList);
|
||||
|
||||
any = wxAny(vCustomType);
|
||||
CPPUNIT_ASSERT(wxANY_CHECK_TYPE(any, wxVariantData*));
|
||||
res = any.GetAs(&variant);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT(variant.GetType() == "MyClass");
|
||||
|
||||
#endif // wxUSE_VARIANT
|
||||
}
|
||||
|
||||
template<>
|
||||
class wxAnyValueTypeImpl<MyClass> :
|
||||
public wxAnyValueTypeImplBase<MyClass>
|
||||
{
|
||||
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
|
||||
public:
|
||||
wxAnyValueTypeImpl() :
|
||||
wxAnyValueTypeImplBase<MyClass>() { }
|
||||
virtual ~wxAnyValueTypeImpl() { }
|
||||
|
||||
virtual bool ConvertValue(const wxAnyValueBuffer& src,
|
||||
wxAnyValueType* dstType,
|
||||
wxAnyValueBuffer& dst) const override
|
||||
{
|
||||
MyClass value = GetValue(src);
|
||||
|
||||
if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )
|
||||
{
|
||||
wxString s = value.ToString();
|
||||
wxAnyValueTypeImpl<wxString>::SetValue(s, dst);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Following must be placed somewhere in your source code
|
||||
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<MyClass>)
|
||||
|
||||
void wxAnyTestCase::CustomTemplateSpecialization()
|
||||
{
|
||||
// Do only a minimal CheckType() test, as dynamic type conversion already
|
||||
// uses it a lot.
|
||||
bool res;
|
||||
MyClass myObject;
|
||||
wxAny any = myObject;
|
||||
|
||||
CPPUNIT_ASSERT( wxANY_CHECK_TYPE(any, MyClass) );
|
||||
MyClass myObject2 = any.As<MyClass>();
|
||||
wxUnusedVar(myObject2);
|
||||
|
||||
wxString str;
|
||||
res = any.GetAs(&str);
|
||||
CPPUNIT_ASSERT(res);
|
||||
CPPUNIT_ASSERT_EQUAL(str, myObject.ToString());
|
||||
}
|
||||
|
||||
void wxAnyTestCase::Misc()
|
||||
{
|
||||
// Do some (inplace) allocation sanity checks
|
||||
{
|
||||
|
||||
// Do it inside a scope so we can easily test instance count
|
||||
// afterwards
|
||||
MyClass myObject(15);
|
||||
wxAny any = myObject;
|
||||
|
||||
// There must be two instances - first in myObject,
|
||||
// and second copied in any.
|
||||
CPPUNIT_ASSERT_EQUAL(gs_myClassInstances.size(), 2);
|
||||
|
||||
// Check that it is allocated in-place, as supposed
|
||||
if ( sizeof(MyClass) <= WX_ANY_VALUE_BUFFER_SIZE )
|
||||
{
|
||||
// Memory block of the instance second must be inside the any
|
||||
size_t anyBegin = reinterpret_cast<size_t>(&any);
|
||||
size_t anyEnd = anyBegin + sizeof(wxAny);
|
||||
size_t pos = reinterpret_cast<size_t>(gs_myClassInstances[1]);
|
||||
CPPUNIT_ASSERT( pos >= anyBegin );
|
||||
CPPUNIT_ASSERT( pos < anyEnd );
|
||||
}
|
||||
|
||||
wxAny any2 = any;
|
||||
CPPUNIT_ASSERT( any2.As<MyClass>().GetValue() == 15 );
|
||||
}
|
||||
|
||||
// Make sure allocations and deallocations match
|
||||
CPPUNIT_ASSERT_EQUAL(gs_myClassInstances.size(), 0);
|
||||
}
|
||||
|
||||
#endif // wxUSE_ANY
|
||||
|
||||
1385
libs/wxWidgets-3.3.1/tests/archive/archivetest.cpp
Normal file
1385
libs/wxWidgets-3.3.1/tests/archive/archivetest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
281
libs/wxWidgets-3.3.1/tests/archive/archivetest.h
Normal file
281
libs/wxWidgets-3.3.1/tests/archive/archivetest.h
Normal file
@@ -0,0 +1,281 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/archive/archivetest.h
|
||||
// Purpose: Test the archive classes
|
||||
// Author: Mike Wetherell
|
||||
// Copyright: (c) 2004 Mike Wetherell
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef WX_ARCHIVETEST_INCLUDED
|
||||
#define WX_ARCHIVETEST_INCLUDED 1
|
||||
|
||||
#include "wx/archive.h"
|
||||
#include "wx/wfstream.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Bit flags for options for the tests
|
||||
|
||||
enum Options
|
||||
{
|
||||
PipeIn = 0x01, // input streams are non-seekable
|
||||
PipeOut = 0x02, // output streams are non-seekable
|
||||
Stub = 0x04, // the archive should be appended to a stub
|
||||
AllOptions = 0x07
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TestOutputStream and TestInputStream are memory streams which can be
|
||||
// seekable or non-seekable.
|
||||
|
||||
class TestOutputStream : public wxOutputStream
|
||||
{
|
||||
public:
|
||||
TestOutputStream(int options);
|
||||
|
||||
~TestOutputStream() { delete [] m_data; }
|
||||
|
||||
int GetOptions() const { return m_options; }
|
||||
wxFileOffset GetLength() const override { return m_size; }
|
||||
bool IsSeekable() const override { return (m_options & PipeOut) == 0; }
|
||||
|
||||
// gives away the data, this stream is then empty, and can be reused
|
||||
void GetData(char*& data, size_t& size);
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode) override;
|
||||
wxFileOffset OnSysTell() const override;
|
||||
size_t OnSysWrite(const void *buffer, size_t size) override;
|
||||
|
||||
int m_options;
|
||||
size_t m_pos;
|
||||
size_t m_capacity;
|
||||
size_t m_size;
|
||||
char *m_data;
|
||||
};
|
||||
|
||||
class TestInputStream : public wxInputStream
|
||||
{
|
||||
public:
|
||||
// various streams have implemented eof differently, so check the archive
|
||||
// stream works with all the possibilities (bit flags that can be ORed)
|
||||
enum EofTypes {
|
||||
AtLast = 0x01, // eof before an attempt to read past the last byte
|
||||
WithError = 0x02 // give an error instead of eof
|
||||
};
|
||||
|
||||
// ctor takes the data from the output stream, which is then empty
|
||||
TestInputStream(TestOutputStream& out, int eoftype)
|
||||
: m_data(nullptr), m_eoftype(eoftype) { SetData(out); }
|
||||
// this ctor 'dups'
|
||||
TestInputStream(const TestInputStream& in);
|
||||
~TestInputStream() { delete [] m_data; }
|
||||
|
||||
void Rewind();
|
||||
wxFileOffset GetLength() const override { return m_size; }
|
||||
bool IsSeekable() const override { return (m_options & PipeIn) == 0; }
|
||||
void SetData(TestOutputStream& out);
|
||||
|
||||
void Chop(size_t size) { m_size = size; }
|
||||
char& operator [](size_t pos) { return m_data[pos]; }
|
||||
|
||||
private:
|
||||
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode) override;
|
||||
wxFileOffset OnSysTell() const override;
|
||||
size_t OnSysRead(void *buffer, size_t size) override;
|
||||
|
||||
int m_options;
|
||||
size_t m_pos;
|
||||
size_t m_size;
|
||||
char *m_data;
|
||||
int m_eoftype;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// wxFFile streams for piping to/from an external program
|
||||
|
||||
class PFileInputStream : public wxFFileInputStream
|
||||
{
|
||||
public:
|
||||
PFileInputStream(const wxString& cmd);
|
||||
~PFileInputStream();
|
||||
};
|
||||
|
||||
class PFileOutputStream : public wxFFileOutputStream
|
||||
{
|
||||
public:
|
||||
PFileOutputStream(const wxString& cmd);
|
||||
~PFileOutputStream();
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// A class to hold a test entry
|
||||
|
||||
class TestEntry
|
||||
{
|
||||
public:
|
||||
TestEntry(const wxDateTime& dt, int len, const char *data);
|
||||
~TestEntry() { delete [] m_data; }
|
||||
|
||||
wxDateTime GetDateTime() const { return m_dt; }
|
||||
wxFileOffset GetLength() const { return m_len; }
|
||||
size_t GetSize() const { return m_len; }
|
||||
const char *GetData() const { return m_data; }
|
||||
wxString GetComment() const { return m_comment; }
|
||||
bool IsText() const { return m_isText; }
|
||||
|
||||
void SetComment(const wxString& comment) { m_comment = comment; }
|
||||
void SetDateTime(const wxDateTime& dt) { m_dt = dt; }
|
||||
|
||||
private:
|
||||
wxDateTime m_dt;
|
||||
size_t m_len;
|
||||
char *m_data;
|
||||
wxString m_comment;
|
||||
bool m_isText;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// The test case
|
||||
|
||||
template <class ClassFactoryT>
|
||||
class ArchiveTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ArchiveTestCase(std::string name,
|
||||
ClassFactoryT *factory,
|
||||
int options,
|
||||
const wxString& archiver = wxEmptyString,
|
||||
const wxString& unarchiver = wxEmptyString);
|
||||
|
||||
~ArchiveTestCase();
|
||||
|
||||
protected:
|
||||
// the classes to test
|
||||
typedef typename ClassFactoryT::entry_type EntryT;
|
||||
typedef typename ClassFactoryT::instream_type InputStreamT;
|
||||
typedef typename ClassFactoryT::outstream_type OutputStreamT;
|
||||
typedef typename ClassFactoryT::notifier_type NotifierT;
|
||||
typedef typename ClassFactoryT::iter_type IterT;
|
||||
typedef typename ClassFactoryT::pairiter_type PairIterT;
|
||||
|
||||
// the entry point for the test
|
||||
void runTest() override;
|
||||
|
||||
// create the test data
|
||||
void CreateTestData();
|
||||
TestEntry& Add(const char *name, const char *data, int len = -1);
|
||||
TestEntry& Add(const char *name, int len = 0, int value = EOF);
|
||||
|
||||
// 'archive up' the test data
|
||||
void CreateArchive(wxOutputStream& out);
|
||||
#ifndef __WXOSX_IPHONE__
|
||||
void CreateArchive(wxOutputStream& out, const wxString& archiver);
|
||||
#endif
|
||||
|
||||
// perform various modifications on the archive
|
||||
void ModifyArchive(wxInputStream& in, wxOutputStream& out);
|
||||
|
||||
// extract the archive and verify its contents
|
||||
void ExtractArchive(wxInputStream& in);
|
||||
#ifndef __WXOSX_IPHONE__
|
||||
void ExtractArchive(wxInputStream& in, const wxString& unarchiver);
|
||||
#endif
|
||||
void VerifyDir(wxString& path, size_t rootlen = 0);
|
||||
|
||||
// tests for the iterators
|
||||
void TestIterator(wxInputStream& in);
|
||||
void TestPairIterator(wxInputStream& in);
|
||||
void TestSmartIterator(wxInputStream& in);
|
||||
void TestSmartPairIterator(wxInputStream& in);
|
||||
|
||||
// try reading two entries at the same time
|
||||
void ReadSimultaneous(TestInputStream& in);
|
||||
|
||||
// overridables
|
||||
virtual void OnCreateArchive(OutputStreamT& WXUNUSED(arc)) { }
|
||||
virtual void OnSetNotifier(EntryT& entry);
|
||||
|
||||
virtual void OnArchiveExtracted(InputStreamT& WXUNUSED(arc),
|
||||
int WXUNUSED(expectedTotal)) { }
|
||||
|
||||
virtual void OnCreateEntry( OutputStreamT& WXUNUSED(arc),
|
||||
TestEntry& WXUNUSED(testEntry),
|
||||
EntryT *entry = nullptr) { (void)entry; }
|
||||
|
||||
virtual void OnEntryExtracted( EntryT& WXUNUSED(entry),
|
||||
const TestEntry& WXUNUSED(testEntry),
|
||||
InputStreamT *arc = nullptr) { (void)arc; }
|
||||
|
||||
typedef std::map<wxString, TestEntry*> TestEntries;
|
||||
TestEntries m_testEntries; // test data
|
||||
std::unique_ptr<ClassFactoryT> m_factory; // factory to make classes
|
||||
int m_options; // test options
|
||||
wxDateTime m_timeStamp; // timestamp to give test entries
|
||||
int m_id; // select between the possibilites
|
||||
wxString m_archiver; // external archiver
|
||||
wxString m_unarchiver; // external unarchiver
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Make ids
|
||||
|
||||
class TestId
|
||||
{
|
||||
public:
|
||||
// make a new id and return it as a string
|
||||
static std::string MakeId();
|
||||
// get the current id
|
||||
static int GetId() { return m_seed; }
|
||||
private:
|
||||
// seed for generating the ids
|
||||
static int m_seed;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Base class for the archive test suites
|
||||
|
||||
class ArchiveTestSuite : public CppUnit::TestSuite
|
||||
{
|
||||
public:
|
||||
ArchiveTestSuite(std::string name);
|
||||
|
||||
protected:
|
||||
void DoRunTest();
|
||||
|
||||
virtual CppUnit::Test *makeTest(std::string descr,
|
||||
int options,
|
||||
bool genericInterface,
|
||||
const wxString& archiver,
|
||||
const wxString& unarchiver);
|
||||
|
||||
void AddArchiver(const wxString& cmd) { AddCmd(m_archivers, cmd); }
|
||||
void AddUnArchiver(const wxString &cmd) { AddCmd(m_unarchivers, cmd); }
|
||||
bool IsInPath(const wxString& cmd);
|
||||
|
||||
std::string Description(const wxString& type,
|
||||
int options,
|
||||
bool genericInterface = false,
|
||||
const wxString& archiver = wxEmptyString,
|
||||
const wxString& unarchiver = wxEmptyString);
|
||||
|
||||
private:
|
||||
wxString m_name;
|
||||
wxPathList m_path;
|
||||
wxArrayString m_archivers;
|
||||
wxArrayString m_unarchivers;
|
||||
|
||||
void AddCmd(wxArrayString& cmdlist, const wxString& cmd);
|
||||
};
|
||||
|
||||
#endif
|
||||
72
libs/wxWidgets-3.3.1/tests/archive/tartest.cpp
Normal file
72
libs/wxWidgets-3.3.1/tests/archive/tartest.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/tartest.cpp
|
||||
// Purpose: Test the tar classes
|
||||
// Author: Mike Wetherell
|
||||
// Copyright: (c) 2004 Mike Wetherell
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
# include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
#include "archivetest.h"
|
||||
#include "wx/tarstrm.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Tar suite
|
||||
|
||||
class tartest : public ArchiveTestSuite
|
||||
{
|
||||
public:
|
||||
tartest();
|
||||
|
||||
void runTest() override { DoRunTest(); }
|
||||
|
||||
protected:
|
||||
CppUnit::Test *makeTest(string descr, int options,
|
||||
bool genericInterface,
|
||||
const wxString& archiver,
|
||||
const wxString& unarchiver) override;
|
||||
};
|
||||
|
||||
tartest::tartest()
|
||||
: ArchiveTestSuite("tar")
|
||||
{
|
||||
AddArchiver(wxT("tar cf %s *"));
|
||||
AddUnArchiver(wxT("tar xf %s"));
|
||||
}
|
||||
|
||||
CppUnit::Test *tartest::makeTest(
|
||||
string descr,
|
||||
int options,
|
||||
bool genericInterface,
|
||||
const wxString& archiver,
|
||||
const wxString& unarchiver)
|
||||
{
|
||||
if ((options & Stub) && (options & PipeIn) == 0)
|
||||
return nullptr;
|
||||
|
||||
if (genericInterface)
|
||||
{
|
||||
return new ArchiveTestCase<wxArchiveClassFactory>(
|
||||
descr, new wxTarClassFactory,
|
||||
options, archiver, unarchiver);
|
||||
}
|
||||
|
||||
return new ArchiveTestCase<wxTarClassFactory>(
|
||||
descr, new wxTarClassFactory,
|
||||
options, archiver, unarchiver);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(tartest);
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(tartest, "archive/tar");
|
||||
|
||||
#endif // wxUSE_STREAMS
|
||||
253
libs/wxWidgets-3.3.1/tests/archive/ziptest.cpp
Normal file
253
libs/wxWidgets-3.3.1/tests/archive/ziptest.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/archive/ziptest.cpp
|
||||
// Purpose: Test the zip classes
|
||||
// Author: Mike Wetherell
|
||||
// Copyright: (c) 2004 Mike Wetherell
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
# include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_STREAMS && wxUSE_ZIPSTREAM
|
||||
|
||||
#include "archivetest.h"
|
||||
#include "wx/zipstrm.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ArchiveTestCase<wxZipClassFactory> could be used directly, but instead this
|
||||
// derived class is used so that zip specific features can be tested.
|
||||
|
||||
class ZipTestCase : public ArchiveTestCase<wxZipClassFactory>
|
||||
{
|
||||
public:
|
||||
ZipTestCase(string name,
|
||||
int options,
|
||||
const wxString& archiver = wxEmptyString,
|
||||
const wxString& unarchiver = wxEmptyString)
|
||||
:
|
||||
ArchiveTestCase<wxZipClassFactory>(name, new wxZipClassFactory,
|
||||
options, archiver, unarchiver),
|
||||
m_count(0)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
void OnCreateArchive(wxZipOutputStream& zip) override;
|
||||
|
||||
void OnArchiveExtracted(wxZipInputStream& zip, int expectedTotal) override;
|
||||
|
||||
void OnCreateEntry(wxZipOutputStream& zip,
|
||||
TestEntry& testEntry,
|
||||
wxZipEntry *entry) override;
|
||||
|
||||
void OnEntryExtracted(wxZipEntry& entry,
|
||||
const TestEntry& testEntry,
|
||||
wxZipInputStream *arc) override;
|
||||
|
||||
void OnSetNotifier(EntryT& entry) override;
|
||||
|
||||
int m_count;
|
||||
wxString m_comment;
|
||||
};
|
||||
|
||||
void ZipTestCase::OnCreateArchive(wxZipOutputStream& zip)
|
||||
{
|
||||
m_comment << wxT("Comment for test ") << m_id;
|
||||
zip.SetComment(m_comment);
|
||||
}
|
||||
|
||||
void ZipTestCase::OnArchiveExtracted(wxZipInputStream& zip, int expectedTotal)
|
||||
{
|
||||
CPPUNIT_ASSERT(zip.GetComment() == m_comment);
|
||||
CPPUNIT_ASSERT(zip.GetTotalEntries() == expectedTotal);
|
||||
}
|
||||
|
||||
void ZipTestCase::OnCreateEntry(wxZipOutputStream& zip,
|
||||
TestEntry& testEntry,
|
||||
wxZipEntry *entry)
|
||||
{
|
||||
zip.SetLevel((m_id + m_count) % 10);
|
||||
|
||||
if (entry) {
|
||||
switch ((m_id + m_count) % 5) {
|
||||
case 0:
|
||||
{
|
||||
wxString comment = wxT("Comment for ") + entry->GetName();
|
||||
entry->SetComment(comment);
|
||||
// lowercase the expected result, and the notifier should do
|
||||
// the same for the zip entries when ModifyArchive() runs
|
||||
testEntry.SetComment(comment.Lower());
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
entry->SetMethod(wxZIP_METHOD_STORE);
|
||||
break;
|
||||
case 4:
|
||||
entry->SetMethod(wxZIP_METHOD_DEFLATE);
|
||||
break;
|
||||
}
|
||||
entry->SetIsText(testEntry.IsText());
|
||||
}
|
||||
|
||||
m_count++;
|
||||
}
|
||||
|
||||
void ZipTestCase::OnEntryExtracted(wxZipEntry& entry,
|
||||
const TestEntry& testEntry,
|
||||
wxZipInputStream *arc)
|
||||
{
|
||||
// provide some context for the error message so that we know which
|
||||
// iteration of the loop we were on
|
||||
wxString name = wxT(" '") + entry.GetName() + wxT("'");
|
||||
string error_entry(name.mb_str());
|
||||
string error_context(" failed for entry" + error_entry);
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("GetComment" + error_context,
|
||||
entry.GetComment() == testEntry.GetComment());
|
||||
|
||||
// for seekable streams, GetNextEntry() doesn't read the local header so
|
||||
// call OpenEntry() to do it
|
||||
if (arc && (m_options & PipeIn) == 0 && entry.IsDir())
|
||||
arc->OpenEntry(entry);
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("IsText" + error_context,
|
||||
entry.IsText() == testEntry.IsText());
|
||||
|
||||
INFO("Extra/LocalExtra mismatch for entry" + error_entry);
|
||||
if ( entry.GetExtraLen() )
|
||||
CHECK( entry.GetLocalExtraLen() != 0 );
|
||||
else
|
||||
CHECK( entry.GetLocalExtraLen() == 0 );
|
||||
}
|
||||
|
||||
// check the notifier mechanism by using it to fold the entry comments to
|
||||
// lowercase
|
||||
//
|
||||
class ZipNotifier : public wxZipNotifier
|
||||
{
|
||||
public:
|
||||
void OnEntryUpdated(wxZipEntry& entry) override;
|
||||
};
|
||||
|
||||
void ZipNotifier::OnEntryUpdated(wxZipEntry& entry)
|
||||
{
|
||||
entry.SetComment(entry.GetComment().Lower());
|
||||
}
|
||||
|
||||
void ZipTestCase::OnSetNotifier(EntryT& entry)
|
||||
{
|
||||
static ZipNotifier notifier;
|
||||
entry.SetNotifier(notifier);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 'zip - -' produces local headers without the size field set. This is a
|
||||
// case not covered by all the other tests, so this class tests it as a
|
||||
// special case
|
||||
|
||||
class ZipPipeTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ZipPipeTestCase(string name, int options) :
|
||||
CppUnit::TestCase(TestId::MakeId() + name),
|
||||
m_options(options),
|
||||
m_id(TestId::GetId())
|
||||
{ }
|
||||
|
||||
protected:
|
||||
void runTest() override;
|
||||
int m_options;
|
||||
int m_id;
|
||||
};
|
||||
|
||||
void ZipPipeTestCase::runTest()
|
||||
{
|
||||
TestOutputStream out(m_options);
|
||||
|
||||
wxString testdata = wxT("test data to pipe through zip");
|
||||
wxString cmd = wxT("echo ") + testdata + wxT(" | zip -q - -");
|
||||
|
||||
{
|
||||
PFileInputStream in(cmd);
|
||||
if (in.IsOk())
|
||||
out.Write(in);
|
||||
}
|
||||
|
||||
TestInputStream in(out, m_id % ((m_options & PipeIn) ? 4 : 3));
|
||||
wxZipInputStream zip(in);
|
||||
|
||||
std::unique_ptr<wxZipEntry> entry(zip.GetNextEntry());
|
||||
CPPUNIT_ASSERT(entry.get() != nullptr);
|
||||
|
||||
if ((m_options & PipeIn) == 0)
|
||||
CPPUNIT_ASSERT(entry->GetSize() != wxInvalidOffset);
|
||||
|
||||
char buf[64];
|
||||
size_t len = zip.Read(buf, sizeof(buf) - 1).LastRead();
|
||||
|
||||
while (len > 0 && buf[len - 1] <= 32)
|
||||
--len;
|
||||
buf[len] = 0;
|
||||
|
||||
CPPUNIT_ASSERT(zip.Eof());
|
||||
CPPUNIT_ASSERT(wxString(buf, *wxConvCurrent) == testdata);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Zip suite
|
||||
|
||||
class ziptest : public ArchiveTestSuite
|
||||
{
|
||||
public:
|
||||
ziptest();
|
||||
|
||||
void runTest() override { DoRunTest(); }
|
||||
|
||||
protected:
|
||||
CppUnit::Test *makeTest(string descr, int options,
|
||||
bool genericInterface, const wxString& archiver,
|
||||
const wxString& unarchiver) override;
|
||||
};
|
||||
|
||||
ziptest::ziptest()
|
||||
: ArchiveTestSuite("zip")
|
||||
{
|
||||
AddArchiver(wxT("zip -qr %s *"));
|
||||
AddUnArchiver(wxT("unzip -q %s"));
|
||||
}
|
||||
|
||||
CppUnit::Test *ziptest::makeTest(
|
||||
string descr,
|
||||
int options,
|
||||
bool genericInterface,
|
||||
const wxString& archiver,
|
||||
const wxString& unarchiver)
|
||||
{
|
||||
// unzip doesn't support piping in the zip
|
||||
if ((options & PipeIn) && !unarchiver.empty())
|
||||
return nullptr;
|
||||
|
||||
if (genericInterface)
|
||||
{
|
||||
return new ArchiveTestCase<wxArchiveClassFactory>(
|
||||
descr, new wxZipClassFactory,
|
||||
options, archiver, unarchiver);
|
||||
}
|
||||
|
||||
return new ZipTestCase(descr, options, archiver, unarchiver);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ziptest);
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ziptest, "archive/zip");
|
||||
|
||||
#endif // wxUSE_STREAMS && wxUSE_ZIPSTREAM
|
||||
921
libs/wxWidgets-3.3.1/tests/arrays/arrays.cpp
Normal file
921
libs/wxWidgets-3.3.1/tests/arrays/arrays.cpp
Normal file
@@ -0,0 +1,921 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/arrays/arrays.cpp
|
||||
// Purpose: wxArray unit test
|
||||
// Author: Vadim Zeitlin, Wlodzimierz ABX Skiba
|
||||
// Created: 2004-04-01
|
||||
// Copyright: (c) 2004 Vadim Zeitlin, Wlodzimierz Skiba
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/dynarray.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helpers for testing values and sizes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define COMPARE_VALUE( array , index , value ) ( array.Item( index ) == value )
|
||||
|
||||
#define COMPARE_2_VALUES( array , p0 , p1 ) \
|
||||
COMPARE_VALUE( array , 0 , p0 ) && \
|
||||
COMPARE_VALUE( array , 1 , p1 )
|
||||
|
||||
#define COMPARE_3_VALUES( array , p0 , p1 , p2 ) \
|
||||
COMPARE_2_VALUES( array , p0 , p1 ) && \
|
||||
COMPARE_VALUE( array , 2 , p2 )
|
||||
|
||||
#define COMPARE_4_VALUES( array , p0 , p1 , p2 , p3 ) \
|
||||
COMPARE_3_VALUES( array , p0 , p1 , p2 ) && \
|
||||
COMPARE_VALUE( array , 3 , p3 )
|
||||
|
||||
#define COMPARE_5_VALUES( array , p0 , p1 , p2 , p3 , p4 ) \
|
||||
COMPARE_4_VALUES( array , p0 , p1 , p2 , p3 ) && \
|
||||
COMPARE_VALUE( array , 4 , p4 )
|
||||
|
||||
#define COMPARE_6_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 ) \
|
||||
COMPARE_5_VALUES( array , p0 , p1 , p2 , p3 , p4 ) && \
|
||||
COMPARE_VALUE( array , 5 , p5 )
|
||||
|
||||
#define COMPARE_7_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 ) \
|
||||
COMPARE_6_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 ) && \
|
||||
COMPARE_VALUE( array , 6 , p6 )
|
||||
|
||||
#define COMPARE_8_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 ) \
|
||||
COMPARE_7_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 ) && \
|
||||
COMPARE_VALUE( array , 7 , p7 )
|
||||
|
||||
#define COMPARE_9_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 ) \
|
||||
COMPARE_8_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 ) && \
|
||||
COMPARE_VALUE( array , 8 , p8 )
|
||||
|
||||
#define COMPARE_10_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 , p9 ) \
|
||||
COMPARE_9_VALUES( array , p0 , p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 ) && \
|
||||
COMPARE_VALUE( array , 9 , p9 )
|
||||
|
||||
#define COMPARE_COUNT( array , n ) \
|
||||
(( array.GetCount() == n ) && \
|
||||
( array.Last() == array.Item( n - 1 ) ))
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helpers for testing wxObjArray
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class Bar
|
||||
{
|
||||
public:
|
||||
Bar(const wxString& name) : m_name(name) { ms_bars++; }
|
||||
Bar(const Bar& bar) : m_name(bar.m_name) { ms_bars++; }
|
||||
~Bar() { ms_bars--; }
|
||||
|
||||
static size_t GetNumber() { return ms_bars; }
|
||||
|
||||
const wxChar *GetName() const { return m_name.c_str(); }
|
||||
|
||||
private:
|
||||
wxString m_name;
|
||||
|
||||
static size_t ms_bars;
|
||||
};
|
||||
|
||||
size_t Bar::ms_bars = 0;
|
||||
|
||||
WX_DECLARE_OBJARRAY(Bar, ArrayBars);
|
||||
#include "wx/arrimpl.cpp"
|
||||
WX_DEFINE_OBJARRAY(ArrayBars)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// another object array test
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This code doesn't make any sense, as object arrays should be used with
|
||||
// objects, not pointers, but it used to work, so check that it continues to
|
||||
// compile.
|
||||
WX_DECLARE_OBJARRAY(Bar*, ArrayBarPtrs);
|
||||
#include "wx/arrimpl.cpp"
|
||||
WX_DEFINE_OBJARRAY(ArrayBarPtrs)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helpers for sorting arrays and comparing items
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxCMPFUNC_CONV StringLenCompare(const wxString& first,
|
||||
const wxString& second)
|
||||
{
|
||||
return first.length() - second.length();
|
||||
}
|
||||
|
||||
#define DEFINE_COMPARE(name, T) \
|
||||
\
|
||||
int wxCMPFUNC_CONV name ## CompareValues(T first, T second) \
|
||||
{ \
|
||||
return first - second; \
|
||||
} \
|
||||
\
|
||||
int wxCMPFUNC_CONV name ## Compare(T* first, T* second) \
|
||||
{ \
|
||||
return *first - *second; \
|
||||
} \
|
||||
\
|
||||
int wxCMPFUNC_CONV name ## RevCompare(T* first, T* second) \
|
||||
{ \
|
||||
return *second - *first; \
|
||||
} \
|
||||
|
||||
typedef unsigned short ushort;
|
||||
|
||||
DEFINE_COMPARE(Char, char)
|
||||
DEFINE_COMPARE(UShort, ushort)
|
||||
DEFINE_COMPARE(Int, int)
|
||||
|
||||
WX_DEFINE_ARRAY_CHAR(char, wxArrayChar);
|
||||
WX_DEFINE_SORTED_ARRAY_CHAR(char, wxSortedArrayCharNoCmp);
|
||||
WX_DEFINE_SORTED_ARRAY_CMP_CHAR(char, CharCompareValues, wxSortedArrayChar);
|
||||
|
||||
WX_DEFINE_ARRAY_SHORT(ushort, wxArrayUShort);
|
||||
WX_DEFINE_SORTED_ARRAY_SHORT(ushort, wxSortedArrayUShortNoCmp);
|
||||
WX_DEFINE_SORTED_ARRAY_CMP_SHORT(ushort, UShortCompareValues, wxSortedArrayUShort);
|
||||
|
||||
WX_DEFINE_SORTED_ARRAY_CMP_INT(int, IntCompareValues, wxSortedArrayInt);
|
||||
|
||||
struct Item
|
||||
{
|
||||
Item(int n_ = 0) : n(n_) { }
|
||||
|
||||
int n;
|
||||
};
|
||||
|
||||
WX_DEFINE_ARRAY_PTR(Item *, ItemPtrArray);
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const wxArrayString& arr)
|
||||
{
|
||||
os << "[ ";
|
||||
for ( size_t n = 0; n < arr.size(); ++n )
|
||||
{
|
||||
if ( n )
|
||||
os << ", ";
|
||||
os << '"' << arr[n] << '"';
|
||||
}
|
||||
os << " ] (size=" << arr.size() << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxArrayString", "[dynarray]")
|
||||
{
|
||||
wxArrayString a1;
|
||||
a1.Add(wxT("thermit"));
|
||||
a1.Add(wxT("condor"));
|
||||
a1.Add(wxT("lion"), 3);
|
||||
a1.Add(wxT("dog"));
|
||||
a1.Add(wxT("human"));
|
||||
a1.Add(wxT("alligator"));
|
||||
|
||||
CHECK((COMPARE_8_VALUES( a1 , wxT("thermit") ,
|
||||
wxT("condor") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("alligator") )));
|
||||
CHECK( COMPARE_COUNT( a1 , 8 ) );
|
||||
|
||||
wxArrayString a2(a1);
|
||||
|
||||
CHECK((COMPARE_8_VALUES( a2 , wxT("thermit") ,
|
||||
wxT("condor") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("alligator") )));
|
||||
CHECK( COMPARE_COUNT( a2 , 8 ) );
|
||||
|
||||
wxSortedArrayString a3(a1);
|
||||
|
||||
CHECK((COMPARE_8_VALUES( a3 , wxT("alligator") ,
|
||||
wxT("condor") ,
|
||||
wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("thermit") )));
|
||||
CHECK( COMPARE_COUNT( a3 , 8 ) );
|
||||
|
||||
wxSortedArrayString a4;
|
||||
for (wxArrayString::iterator it = a1.begin(), en = a1.end(); it != en; ++it)
|
||||
a4.Add(*it);
|
||||
|
||||
CHECK((COMPARE_8_VALUES( a4 , wxT("alligator") ,
|
||||
wxT("condor") ,
|
||||
wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("lion") ,
|
||||
wxT("thermit") )));
|
||||
CHECK( COMPARE_COUNT( a4 , 8 ) );
|
||||
|
||||
a1.RemoveAt(2,3);
|
||||
|
||||
CHECK((COMPARE_5_VALUES( a1 , wxT("thermit") ,
|
||||
wxT("condor") ,
|
||||
wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("alligator") )));
|
||||
CHECK( COMPARE_COUNT( a1 , 5 ) );
|
||||
|
||||
a2 = a1;
|
||||
|
||||
CHECK((COMPARE_5_VALUES( a2 , wxT("thermit") ,
|
||||
wxT("condor") ,
|
||||
wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("alligator") )));
|
||||
CHECK( COMPARE_COUNT( a2 , 5 ) );
|
||||
|
||||
a1.Sort(false);
|
||||
|
||||
CHECK((COMPARE_5_VALUES( a1 , wxT("alligator") ,
|
||||
wxT("condor") ,
|
||||
wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("thermit") )));
|
||||
CHECK( COMPARE_COUNT( a1 , 5 ) );
|
||||
|
||||
a1.Sort(true);
|
||||
|
||||
CHECK((COMPARE_5_VALUES( a1 , wxT("thermit") ,
|
||||
wxT("human") ,
|
||||
wxT("dog") ,
|
||||
wxT("condor") ,
|
||||
wxT("alligator") )));
|
||||
CHECK( COMPARE_COUNT( a1 , 5 ) );
|
||||
|
||||
a1.Sort(&StringLenCompare);
|
||||
|
||||
CHECK((COMPARE_5_VALUES( a1 , wxT("dog") ,
|
||||
wxT("human") ,
|
||||
wxT("condor") ,
|
||||
wxT("thermit") ,
|
||||
wxT("alligator") )));
|
||||
CHECK( COMPARE_COUNT( a1 , 5 ) );
|
||||
CHECK( a1.Index( wxT("dog") ) == 0 );
|
||||
CHECK( a1.Index( wxT("human") ) == 1 );
|
||||
CHECK( a1.Index( wxT("humann") ) == wxNOT_FOUND );
|
||||
CHECK( a1.Index( wxT("condor") ) == 2 );
|
||||
CHECK( a1.Index( wxT("thermit") ) == 3 );
|
||||
CHECK( a1.Index( wxT("alligator") ) == 4 );
|
||||
|
||||
CHECK( a1.Index( wxT("dog"), /*bCase=*/true, /*fromEnd=*/true ) == 0 );
|
||||
CHECK( a1.Index( wxT("human"), /*bCase=*/true, /*fromEnd=*/true ) == 1 );
|
||||
CHECK( a1.Index( wxT("humann"), /*bCase=*/true, /*fromEnd=*/true ) == wxNOT_FOUND );
|
||||
CHECK( a1.Index( wxT("condor"), /*bCase=*/true, /*fromEnd=*/true ) == 2 );
|
||||
CHECK( a1.Index( wxT("thermit"), /*bCase=*/true, /*fromEnd=*/true ) == 3 );
|
||||
CHECK( a1.Index( wxT("alligator"), /*bCase=*/true, /*fromEnd=*/true ) == 4 );
|
||||
|
||||
a1.push_back(wxT("alligator"));
|
||||
CHECK(a1.Index(wxT("alligator")) == 4);
|
||||
CHECK(a1.Index(wxT("alligator"), /*bCase=*/true, /*fromEnd=*/true) == 5);
|
||||
|
||||
wxArrayString a5;
|
||||
|
||||
CHECK( a5.Add( wxT("x"), 1 ) == 0 );
|
||||
CHECK( a5.Add( wxT("a"), 3 ) == 1 );
|
||||
|
||||
CHECK((COMPARE_4_VALUES( a5, wxT("x") ,
|
||||
wxT("a") ,
|
||||
wxT("a") ,
|
||||
wxT("a") )));
|
||||
|
||||
a5.assign(a1.end(), a1.end());
|
||||
CHECK( a5.empty() );
|
||||
|
||||
a5.assign(a1.begin(), a1.end());
|
||||
CHECK( a5 == a1 );
|
||||
|
||||
const wxString months[] = { "Jan", "Feb", "Mar" };
|
||||
a5.assign(months, months + WXSIZEOF(months));
|
||||
CHECK( a5.size() == WXSIZEOF(months) );
|
||||
CHECK((COMPARE_3_VALUES(a5, "Jan", "Feb", "Mar")));
|
||||
|
||||
a5.clear();
|
||||
CHECK( a5.size() == 0 );
|
||||
|
||||
a5.resize(7, "Foo");
|
||||
CHECK( a5.size() == 7 );
|
||||
CHECK( a5[3] == "Foo" );
|
||||
|
||||
a5.resize(3);
|
||||
CHECK( a5.size() == 3 );
|
||||
CHECK( a5[2] == "Foo" );
|
||||
|
||||
wxArrayString a6;
|
||||
a6.Add("Foo");
|
||||
a6.Insert(a6[0], 1, 100);
|
||||
|
||||
// The whole point of this code is to test self-assignment, so suppress
|
||||
// clang warning about it.
|
||||
wxCLANG_WARNING_SUPPRESS(self-assign-overloaded)
|
||||
|
||||
wxArrayString a7;
|
||||
a7 = a7;
|
||||
CHECK( a7.size() == 0 );
|
||||
a7.Add("Bar");
|
||||
a7 = a7;
|
||||
CHECK( a7.size() == 1 );
|
||||
|
||||
wxCLANG_WARNING_RESTORE(self-assign-overloaded)
|
||||
|
||||
wxArrayString a8( { wxT("dog"), wxT("human"), wxT("condor"), wxT("thermit"), wxT("alligator") } );
|
||||
CHECK( a8.size() == 5 );
|
||||
CHECK( a8[1] == "human" );
|
||||
CHECK( a8[4] == "alligator" );
|
||||
|
||||
a8 = { wxT("Foo") }; // Test operator=
|
||||
CHECK( a8.size() == 1 );
|
||||
CHECK( a8[0] == "Foo" );
|
||||
|
||||
// Same test with std::initializer_list<std::string>
|
||||
wxArrayString a9( { std::string("dog"), std::string("human"), std::string("condor"), std::string("thermit"), std::string("alligator") } );
|
||||
CHECK( a9.size() == 5 );
|
||||
}
|
||||
|
||||
TEST_CASE("wxArrayString::Vector", "[dynarray][vector]")
|
||||
{
|
||||
SECTION("wxString")
|
||||
{
|
||||
std::vector<wxString> vec{"first", "second"};
|
||||
wxArrayString a(vec);
|
||||
REQUIRE( a.size() == 2 );
|
||||
CHECK( a[1] == "second" );
|
||||
}
|
||||
|
||||
SECTION("string")
|
||||
{
|
||||
std::vector<std::string> vec{"third", "fourth"};
|
||||
wxArrayString a(vec);
|
||||
REQUIRE( a.size() == 2 );
|
||||
CHECK( a[1] == "fourth" );
|
||||
}
|
||||
|
||||
SECTION("AsVector")
|
||||
{
|
||||
wxArrayString a{"five", "six", "seven"};
|
||||
const std::vector<wxString>& vec = a.AsVector();
|
||||
REQUIRE( vec.size() == 3 );
|
||||
CHECK( vec.at(2) == "seven" );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("wxSortedArrayString", "[dynarray]")
|
||||
{
|
||||
wxSortedArrayString a;
|
||||
a.Add("d");
|
||||
a.Add("c");
|
||||
CHECK( a.Index("c") == 0 );
|
||||
|
||||
a.push_back("b");
|
||||
a.push_back("a");
|
||||
CHECK( a.Index("a") == 0 );
|
||||
|
||||
|
||||
wxSortedArrayString ar(wxStringSortDescending);
|
||||
ar.Add("a");
|
||||
ar.Add("b");
|
||||
CHECK( ar[0] == "b" );
|
||||
CHECK( ar[1] == "a" );
|
||||
|
||||
wxSortedArrayString ad(wxDictionaryStringSortAscending);
|
||||
ad.Add("AB");
|
||||
ad.Add("a");
|
||||
ad.Add("Aa");
|
||||
CHECK( ad[0] == "a" );
|
||||
CHECK( ad[1] == "Aa" );
|
||||
CHECK( ad.Index("a") == 0 );
|
||||
CHECK( ad.Index("Aa") == 1 );
|
||||
CHECK( ad.Index("AB") == 2 );
|
||||
CHECK( ad.Index("A") == wxNOT_FOUND );
|
||||
CHECK( ad.Index("z") == wxNOT_FOUND );
|
||||
}
|
||||
|
||||
TEST_CASE("Arrays::Split", "[dynarray]")
|
||||
{
|
||||
// test wxSplit:
|
||||
|
||||
{
|
||||
wxString str = wxT(",,,,first,second,third,,");
|
||||
const wxChar *expected[] =
|
||||
{ wxT(""), wxT(""), wxT(""), wxT(""), wxT("first"),
|
||||
wxT("second"), wxT("third"), wxT(""), wxT("") };
|
||||
|
||||
wxArrayString exparr(WXSIZEOF(expected), expected);
|
||||
wxArrayString realarr(wxSplit(str, wxT(',')));
|
||||
CHECK( exparr == realarr );
|
||||
}
|
||||
|
||||
{
|
||||
wxString str = wxT(",\\,first,second,third,");
|
||||
const wxChar *expected[] =
|
||||
{ wxT(""), wxT(",first"), wxT("second"), wxT("third"), wxT("") };
|
||||
const wxChar *expected2[] =
|
||||
{ wxT(""), wxT("\\"), wxT("first"), wxT("second"), wxT("third"), wxT("") };
|
||||
|
||||
// escaping on:
|
||||
wxArrayString exparr(WXSIZEOF(expected), expected);
|
||||
wxArrayString realarr(wxSplit(str, wxT(','), wxT('\\')));
|
||||
CHECK( exparr == realarr );
|
||||
|
||||
// escaping turned off:
|
||||
wxArrayString exparr2(WXSIZEOF(expected2), expected2);
|
||||
wxArrayString realarr2(wxSplit(str, wxT(','), wxT('\0')));
|
||||
CHECK( exparr2 == realarr2 );
|
||||
}
|
||||
|
||||
{
|
||||
// test is escape characters placed before non-separator character are
|
||||
// just ignored as they should:
|
||||
wxString str = wxT(",\\,,fir\\st,se\\cond\\,,\\third");
|
||||
const wxChar *expected[] =
|
||||
{ wxT(""), wxT(","), wxT("fir\\st"), wxT("se\\cond,"), wxT("\\third") };
|
||||
const wxChar *expected2[] =
|
||||
{ wxT(""), wxT("\\"), wxT(""), wxT("fir\\st"), wxT("se\\cond\\"),
|
||||
wxT(""), wxT("\\third") };
|
||||
|
||||
// escaping on:
|
||||
wxArrayString exparr(WXSIZEOF(expected), expected);
|
||||
wxArrayString realarr(wxSplit(str, wxT(','), wxT('\\')));
|
||||
CHECK( exparr == realarr );
|
||||
|
||||
// escaping turned off:
|
||||
wxArrayString exparr2(WXSIZEOF(expected2), expected2);
|
||||
wxArrayString realarr2(wxSplit(str, wxT(','), wxT('\0')));
|
||||
CHECK( exparr2 == realarr2 );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Arrays::Join", "[dynarray]")
|
||||
{
|
||||
// test wxJoin:
|
||||
|
||||
{
|
||||
const wxChar *arr[] = { wxT("first"), wxT(""), wxT("second"), wxT("third") };
|
||||
wxString expected = wxT("first,,second,third");
|
||||
|
||||
wxArrayString arrstr(WXSIZEOF(arr), arr);
|
||||
wxString result = wxJoin(arrstr, wxT(','));
|
||||
CHECK( expected == result );
|
||||
}
|
||||
|
||||
{
|
||||
const wxChar *arr[] = { wxT("first, word"), wxT(",,second"), wxT("third,,") };
|
||||
wxString expected = wxT("first\\, word,\\,\\,second,third\\,\\,");
|
||||
wxString expected2 = wxT("first, word,,,second,third,,");
|
||||
|
||||
// escaping on:
|
||||
wxArrayString arrstr(WXSIZEOF(arr), arr);
|
||||
wxString result = wxJoin(arrstr, wxT(','), wxT('\\'));
|
||||
CHECK( expected == result );
|
||||
|
||||
// escaping turned off:
|
||||
wxString result2 = wxJoin(arrstr, wxT(','), wxT('\0'));
|
||||
CHECK( expected2 == result2 );
|
||||
}
|
||||
|
||||
{
|
||||
// test is escape characters placed in the original array are just ignored as they should:
|
||||
const wxChar *arr[] = { wxT("first\\, wo\\rd"), wxT("seco\\nd"), wxT("\\third\\") };
|
||||
wxString expected = wxT("first\\\\, wo\\rd,seco\\nd,\\third\\");
|
||||
wxString expected2 = wxT("first\\, wo\\rd,seco\\nd,\\third\\");
|
||||
|
||||
// escaping on:
|
||||
wxArrayString arrstr(WXSIZEOF(arr), arr);
|
||||
wxString result = wxJoin(arrstr, wxT(','), wxT('\\'));
|
||||
CHECK( expected == result );
|
||||
|
||||
// escaping turned off:
|
||||
wxString result2 = wxJoin(arrstr, wxT(','), wxT('\0'));
|
||||
CHECK( expected2 == result2 );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Arrays::SplitJoin", "[dynarray]")
|
||||
{
|
||||
wxChar separators[] = { wxT('a'), wxT(','), wxT('_'), wxT(' '), wxT('\\'),
|
||||
wxT('&'), wxT('{'), wxT('A'), wxT('<'), wxT('>'),
|
||||
wxT('\''), wxT('\n'), wxT('!'), wxT('-') };
|
||||
|
||||
// test with a string: split it and then rejoin it:
|
||||
|
||||
wxString str = wxT("This is a long, long test; if wxSplit and wxJoin do work ")
|
||||
wxT("correctly, then splitting and joining this 'text' _multiple_ ")
|
||||
wxT("times shouldn't cause any loss of content.\n")
|
||||
wxT("This is some latex code: ")
|
||||
wxT("\\func{wxString}{wxJoin}{")
|
||||
wxT("\\param{const wxArray String\\&}{ arr}, ")
|
||||
wxT("\\param{const wxChar}{ sep}, ")
|
||||
wxT("\\param{const wxChar}{ escape = '\\'}}.\n")
|
||||
wxT("This is some HTML code: ")
|
||||
wxT("<html><head><meta http-equiv=\"content-type\">")
|
||||
wxT("<title>Initial page of Mozilla Firefox</title>")
|
||||
wxT("</meta></head></html>");
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < WXSIZEOF(separators); i++)
|
||||
{
|
||||
wxArrayString arr = wxSplit(str, separators[i]);
|
||||
|
||||
INFO("Using separator '" << static_cast<char>(separators[i]) << "' "
|
||||
"and split array \"" << arr << "\"");
|
||||
|
||||
CHECK( str == wxJoin(arr, separators[i]) );
|
||||
}
|
||||
|
||||
|
||||
// test with an array: join it and then resplit it:
|
||||
|
||||
const wxChar *arr[] =
|
||||
{
|
||||
wxT("first, second!"), wxT("this is the third!!"),
|
||||
wxT("\nThat's the fourth token\n\n"), wxT(" - fifth\ndummy\ntoken - "),
|
||||
wxT("_sixth__token__with_underscores"), wxT("The! Last! One!")
|
||||
};
|
||||
wxArrayString theArr(WXSIZEOF(arr), arr);
|
||||
|
||||
for (i = 0; i < WXSIZEOF(separators); i++)
|
||||
{
|
||||
wxString string = wxJoin(theArr, separators[i]);
|
||||
|
||||
INFO("Using separator '" << static_cast<char>(separators[i]) << "' "
|
||||
"and joined string \"" << string << "\"");
|
||||
|
||||
CHECK( theArr == wxSplit(string, separators[i]) );
|
||||
}
|
||||
|
||||
wxArrayString emptyArray;
|
||||
wxString string = wxJoin(emptyArray, wxT(';'));
|
||||
CHECK( string.empty() );
|
||||
|
||||
CHECK( wxSplit(string, wxT(';')).empty() );
|
||||
|
||||
CHECK( wxSplit(wxT(";"), wxT(';')).size() == 2 );
|
||||
|
||||
// Check for bug with escaping the escape character at the end (but not in
|
||||
// the middle).
|
||||
wxArrayString withBackslashes;
|
||||
withBackslashes.push_back("foo\\");
|
||||
withBackslashes.push_back("bar\\baz");
|
||||
|
||||
string = wxJoin(withBackslashes, ':');
|
||||
CHECK( string == "foo\\\\:bar\\baz" );
|
||||
|
||||
const wxArrayString withBackslashes2 = wxSplit(string, ':');
|
||||
REQUIRE( withBackslashes2.size() == 2 );
|
||||
CHECK( withBackslashes2[0] == withBackslashes[0] );
|
||||
CHECK( withBackslashes2[1] == withBackslashes[1] );
|
||||
}
|
||||
|
||||
TEST_CASE("wxObjArray", "[dynarray]")
|
||||
{
|
||||
{
|
||||
ArrayBars bars;
|
||||
Bar bar(wxT("first bar in general, second bar in array (two copies!)"));
|
||||
|
||||
CHECK( bars.GetCount() == 0 );
|
||||
CHECK( Bar::GetNumber() == 1 );
|
||||
|
||||
const wxString firstName(wxT("first bar in array"));
|
||||
bars.Add(new Bar(firstName));
|
||||
bars.Add(bar, 2);
|
||||
|
||||
// Test that range for works with wxObjArray.
|
||||
int count = 0;
|
||||
for ( const auto& b : bars )
|
||||
{
|
||||
if ( !count )
|
||||
CHECK( b.GetName() == firstName );
|
||||
|
||||
++count;
|
||||
}
|
||||
CHECK( count == 3 );
|
||||
|
||||
CHECK( bars.GetCount() == 3 );
|
||||
CHECK( Bar::GetNumber() == 4 );
|
||||
|
||||
ArrayBars tmp;
|
||||
bars.swap(tmp);
|
||||
CHECK( bars.size() == 0 );
|
||||
CHECK( Bar::GetNumber() == 4 );
|
||||
|
||||
bars.swap(tmp);
|
||||
CHECK( bars.size() == 3 );
|
||||
CHECK( Bar::GetNumber() == 4 );
|
||||
|
||||
bars.RemoveAt(1, bars.GetCount() - 1);
|
||||
|
||||
CHECK( bars.GetCount() == 1 );
|
||||
CHECK( Bar::GetNumber() == 2 );
|
||||
|
||||
bars.Empty();
|
||||
|
||||
CHECK( bars.GetCount() == 0 );
|
||||
CHECK( Bar::GetNumber() == 1 );
|
||||
}
|
||||
CHECK( Bar::GetNumber() == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE("wxObjArrayPtr", "[dynarray]")
|
||||
{
|
||||
// Just check that instantiating this class compiles.
|
||||
ArrayBarPtrs barptrs;
|
||||
CHECK( barptrs.size() == 0 );
|
||||
}
|
||||
|
||||
#define TestArrayOf(name) \
|
||||
\
|
||||
TEST_CASE("wxDynArray::" #name, "[dynarray]") \
|
||||
{ \
|
||||
wxArray##name a; \
|
||||
a.Add(1); \
|
||||
a.Add(17,2); \
|
||||
a.Add(5,3); \
|
||||
a.Add(3,4); \
|
||||
\
|
||||
CHECK((COMPARE_10_VALUES(a,1,17,17,5,5,5,3,3,3,3))); \
|
||||
CHECK( COMPARE_COUNT( a , 10 ) ); \
|
||||
\
|
||||
a.Sort(name ## Compare); \
|
||||
\
|
||||
CHECK((COMPARE_10_VALUES(a,1,3,3,3,3,5,5,5,17,17))); \
|
||||
CHECK( COMPARE_COUNT( a , 10 ) ); \
|
||||
\
|
||||
a.Sort(name ## RevCompare); \
|
||||
\
|
||||
CHECK((COMPARE_10_VALUES(a,17,17,5,5,5,3,3,3,3,1))); \
|
||||
CHECK( COMPARE_COUNT( a , 10 ) ); \
|
||||
\
|
||||
wxSortedArray##name b; \
|
||||
\
|
||||
b.Add(1); \
|
||||
b.Add(17); \
|
||||
b.Add(5); \
|
||||
b.Add(3); \
|
||||
\
|
||||
CHECK((COMPARE_4_VALUES(b,1,3,5,17))); \
|
||||
CHECK( COMPARE_COUNT( b , 4 ) ); \
|
||||
CHECK( b.Index( 0 ) == wxNOT_FOUND ); \
|
||||
CHECK( b.Index( 1 ) == 0 ); \
|
||||
CHECK( b.Index( 3 ) == 1 ); \
|
||||
CHECK( b.Index( 4 ) == wxNOT_FOUND ); \
|
||||
CHECK( b.Index( 5 ) == 2 ); \
|
||||
CHECK( b.Index( 6 ) == wxNOT_FOUND ); \
|
||||
CHECK( b.Index( 17 ) == 3 ); \
|
||||
\
|
||||
wxArray##name c({1,2,3}); \
|
||||
CHECK(c.size() == 3); \
|
||||
}
|
||||
|
||||
TestArrayOf(UShort)
|
||||
|
||||
TestArrayOf(Char)
|
||||
|
||||
TestArrayOf(Int)
|
||||
|
||||
TEST_CASE("wxDynArray::Alloc", "[dynarray]")
|
||||
{
|
||||
wxArrayInt a;
|
||||
a.Add(17);
|
||||
a.Add(9);
|
||||
CHECK( a.GetCount() == 2 );
|
||||
|
||||
a.Alloc(1000);
|
||||
|
||||
CHECK( a.GetCount() == 2 );
|
||||
CHECK( a[0] == 17 );
|
||||
CHECK( a[1] == 9 );
|
||||
}
|
||||
|
||||
TEST_CASE("wxDynArray::Clear", "[dynarray]")
|
||||
{
|
||||
ItemPtrArray items;
|
||||
|
||||
WX_CLEAR_ARRAY(items);
|
||||
CHECK( items.size() == 0 );
|
||||
|
||||
items.push_back(new Item(17));
|
||||
items.push_back(new Item(71));
|
||||
CHECK( items.size() == 2 );
|
||||
|
||||
WX_CLEAR_ARRAY(items);
|
||||
CHECK( items.size() == 0 );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
template <typename A, typename T>
|
||||
void DoTestSwap(T v1, T v2, T v3)
|
||||
{
|
||||
A a1, a2;
|
||||
a1.swap(a2);
|
||||
CHECK( a1.empty() );
|
||||
CHECK( a2.empty() );
|
||||
|
||||
a1.push_back(v1);
|
||||
a1.swap(a2);
|
||||
CHECK( a1.empty() );
|
||||
CHECK( a2.size() == 1 );
|
||||
|
||||
a1.push_back(v2);
|
||||
a1.push_back(v3);
|
||||
a2.swap(a1);
|
||||
CHECK( a1.size() == 1 );
|
||||
CHECK( a2.size() == 2 );
|
||||
CHECK( a1[0] == v1 );
|
||||
CHECK( a2[1] == v3 );
|
||||
|
||||
a1.swap(a2);
|
||||
CHECK( a1.size() == 2 );
|
||||
CHECK( a2.size() == 1 );
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_CASE("wxDynArray::Swap", "[dynarray]")
|
||||
{
|
||||
DoTestSwap<wxArrayString>("Foo", "Bar", "Baz");
|
||||
|
||||
DoTestSwap<wxArrayInt>(1, 10, 100);
|
||||
DoTestSwap<wxArrayLong>(6, 28, 496);
|
||||
}
|
||||
|
||||
TEST_CASE("wxDynArray::TestSTL", "[dynarray]")
|
||||
{
|
||||
wxArrayInt list1;
|
||||
wxArrayInt::iterator it, en;
|
||||
wxArrayInt::reverse_iterator rit, ren;
|
||||
int i;
|
||||
static const int COUNT = 5;
|
||||
|
||||
for ( i = 0; i < COUNT; ++i )
|
||||
list1.push_back(i);
|
||||
|
||||
CHECK( list1.capacity() >= (size_t)COUNT );
|
||||
CHECK( list1.size() == COUNT );
|
||||
|
||||
for ( it = list1.begin(), en = list1.end(), i = 0;
|
||||
it != en; ++it, ++i )
|
||||
{
|
||||
CHECK( *it == i );
|
||||
}
|
||||
|
||||
CHECK( i == COUNT );
|
||||
|
||||
for ( rit = list1.rbegin(), ren = list1.rend(), i = COUNT;
|
||||
rit != ren; ++rit, --i )
|
||||
{
|
||||
CHECK( *rit == i-1 );
|
||||
}
|
||||
|
||||
CHECK( i == 0 );
|
||||
|
||||
CHECK( *list1.rbegin() == *(list1.end()-1) );
|
||||
CHECK( *list1.begin() == *(list1.rend()-1) );
|
||||
|
||||
it = list1.begin()+1;
|
||||
rit = list1.rbegin()+1;
|
||||
CHECK( *list1.begin() == *(it-1) );
|
||||
CHECK( *list1.rbegin() == *(rit-1) );
|
||||
|
||||
CHECK( list1.front() == 0 );
|
||||
CHECK( list1.back() == COUNT - 1 );
|
||||
|
||||
list1.erase(list1.begin());
|
||||
list1.erase(list1.end()-1);
|
||||
|
||||
for ( it = list1.begin(), en = list1.end(), i = 1;
|
||||
it != en; ++it, ++i )
|
||||
{
|
||||
CHECK( *it == i );
|
||||
}
|
||||
|
||||
|
||||
ItemPtrArray items;
|
||||
items.push_back(new Item(17));
|
||||
CHECK( (*(items.rbegin()))->n == 17 );
|
||||
CHECK( (**items.begin()).n == 17 );
|
||||
WX_CLEAR_ARRAY(items);
|
||||
}
|
||||
|
||||
TEST_CASE("wxDynArray::IndexFromEnd", "[dynarray]")
|
||||
{
|
||||
wxArrayInt a;
|
||||
a.push_back(10);
|
||||
a.push_back(1);
|
||||
a.push_back(42);
|
||||
a.push_back(42);
|
||||
|
||||
CHECK( a.Index(10) == 0 );
|
||||
CHECK( a.Index(1) == 1 );
|
||||
CHECK( a.Index(42) == 2 );
|
||||
CHECK( a.Index(10, /*bFromEnd=*/true) == 0 );
|
||||
CHECK( a.Index( 1, /*bFromEnd=*/true) == 1 );
|
||||
CHECK( a.Index(42, /*bFromEnd=*/true) == 3 );
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("wxCmpNaturalGeneric", "[wxString][compare]")
|
||||
{
|
||||
// simple string comparison
|
||||
CHECK(wxCmpNaturalGeneric("a", "a") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("a", "z") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("z", "a") > 0);
|
||||
|
||||
// case insensitivity
|
||||
CHECK(wxCmpNaturalGeneric("a", "A") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("A", "a") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("AB", "a") > 0);
|
||||
CHECK(wxCmpNaturalGeneric("a", "AB") < 0);
|
||||
|
||||
// empty strings sort before whitespace and punctiation
|
||||
CHECK(wxCmpNaturalGeneric("", " ") < 0);
|
||||
CHECK(wxCmpNaturalGeneric(" ", "") > 0);
|
||||
CHECK(wxCmpNaturalGeneric("", ",") < 0);
|
||||
CHECK(wxCmpNaturalGeneric(",", "") > 0);
|
||||
|
||||
// empty strings sort before numbers
|
||||
CHECK(wxCmpNaturalGeneric("", "0") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("0", "") > 0);
|
||||
|
||||
// empty strings sort before letters and symbols
|
||||
CHECK(wxCmpNaturalGeneric("", "abc") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("abc", "") > 0);
|
||||
|
||||
// whitespace and punctiation sort before numbers
|
||||
CHECK(wxCmpNaturalGeneric(" ", "1") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("1", " ") > 0);
|
||||
CHECK(wxCmpNaturalGeneric(",", "1") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("1", ",") > 0);
|
||||
|
||||
// strings containing numbers sort before letters and symbols
|
||||
CHECK(wxCmpNaturalGeneric("00", "a") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("a", "00") > 0);
|
||||
|
||||
// strings containing numbers are compared by their value
|
||||
CHECK(wxCmpNaturalGeneric("01", "1") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("1", "01") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("1", "05") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("05", "1") > 0);
|
||||
CHECK(wxCmpNaturalGeneric("10", "5") > 0);
|
||||
CHECK(wxCmpNaturalGeneric("5", "10") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("1", "9999999999999999999") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("9999999999999999999", "1") > 0);
|
||||
|
||||
// comparing strings composed from whitespace,
|
||||
// punctuation, numbers, letters, and symbols
|
||||
CHECK(wxCmpNaturalGeneric("1st", " 1st") > 0);
|
||||
CHECK(wxCmpNaturalGeneric(" 1st", "1st") < 0);
|
||||
|
||||
CHECK(wxCmpNaturalGeneric("1st", ",1st") > 0);
|
||||
CHECK(wxCmpNaturalGeneric(",1st", "1st") < 0);
|
||||
|
||||
CHECK(wxCmpNaturalGeneric("1st", "01st") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("01st", "1st") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("10th", "5th") > 0);
|
||||
CHECK(wxCmpNaturalGeneric("5th", "10th") < 0);
|
||||
|
||||
CHECK(wxCmpNaturalGeneric("a1st", "a01st") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("a01st", "a1st") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("a10th", "a5th") > 0);
|
||||
CHECK(wxCmpNaturalGeneric("a5th", "a10th") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("a 10th", "a5th") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("a5th", "a 10th") > 0);
|
||||
|
||||
CHECK(wxCmpNaturalGeneric("a1st1", "a01st01") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("a01st01", "a1st1") == 0);
|
||||
CHECK(wxCmpNaturalGeneric("a10th10", "a5th5") > 0);
|
||||
CHECK(wxCmpNaturalGeneric("a5th5", "a10th10") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("a 10th 10", "a5th 5") < 0);
|
||||
CHECK(wxCmpNaturalGeneric("a5th 5", "a 10th 10") > 0);
|
||||
}
|
||||
|
||||
TEST_CASE("wxCmpNatural", "[wxString][compare]")
|
||||
{
|
||||
// We can't expect much from the native natural comparison function as it's
|
||||
// locale-dependent, so just run a simple sanity test
|
||||
CHECK(wxCmpNatural("same", "same") == 0);
|
||||
}
|
||||
48
libs/wxWidgets-3.3.1/tests/asserthelper.cpp
Normal file
48
libs/wxWidgets-3.3.1/tests/asserthelper.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/asserthelper.cpp
|
||||
// Purpose: Helper functions for cppunit
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-23
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#include "asserthelper.h"
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const wxColour& c)
|
||||
{
|
||||
os << c.GetAsString(wxC2S_HTML_SYNTAX);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const wxSize& s)
|
||||
{
|
||||
os << s.x << "*" << s.y;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const wxFont& f)
|
||||
{
|
||||
os << f.GetNativeFontInfoUserDesc();
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const wxPoint& p)
|
||||
{
|
||||
os << "(" << p.x << ", " << p.y << ")";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const wxRect& r)
|
||||
{
|
||||
os << "{"
|
||||
<< r.x << ", " << r.y << " " << r.width << "*" << r.height
|
||||
<< "}";
|
||||
return os;
|
||||
}
|
||||
25
libs/wxWidgets-3.3.1/tests/asserthelper.h
Normal file
25
libs/wxWidgets-3.3.1/tests/asserthelper.h
Normal file
@@ -0,0 +1,25 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/asserthelper.h
|
||||
// Purpose: Helper functions for cppunit
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-23
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_ASSERTHELPER_H_
|
||||
#define _WX_TESTS_ASSERTHELPER_H_
|
||||
|
||||
#include <ostream>
|
||||
#include "wx/colour.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/font.h"
|
||||
|
||||
// Operators used to show the values of the corresponding types when comparing
|
||||
// them in the unit tests fails.
|
||||
std::ostream& operator<<(std::ostream& os, const wxColour& c);
|
||||
std::ostream& operator<<(std::ostream& os, const wxSize& s);
|
||||
std::ostream& operator<<(std::ostream& os, const wxFont& f);
|
||||
std::ostream& operator<<(std::ostream& os, const wxPoint& p);
|
||||
std::ostream& operator<<(std::ostream& os, const wxRect& r);
|
||||
|
||||
#endif
|
||||
306
libs/wxWidgets-3.3.1/tests/base64/base64.cpp
Normal file
306
libs/wxWidgets-3.3.1/tests/base64/base64.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/base64/base64.cpp
|
||||
// Purpose: wxBase64Encode/Decode unit test
|
||||
// Author: Charles Reimers
|
||||
// Created: 2007-06-22
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#if wxUSE_BASE64
|
||||
|
||||
#include "wx/base64.h"
|
||||
|
||||
static const char encoded0to255[] =
|
||||
"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj"
|
||||
"JCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZH"
|
||||
"SElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWpr"
|
||||
"bG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6P"
|
||||
"kJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKz"
|
||||
"tLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX"
|
||||
"2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7"
|
||||
"/P3+/w==";
|
||||
|
||||
static void
|
||||
generatePatternedData(void* buff, size_t len, unsigned char startVal,
|
||||
unsigned char addVal, unsigned char multVal = 1,
|
||||
unsigned char xorMask = 0, unsigned char andMask = 255)
|
||||
{
|
||||
unsigned char *cbuff = (unsigned char *)buff;
|
||||
unsigned char curval = startVal;
|
||||
while(len--)
|
||||
{
|
||||
*(cbuff++) = curval;
|
||||
curval = (((curval + addVal) * multVal) ^ xorMask) & andMask;
|
||||
}
|
||||
}
|
||||
|
||||
static void generateRandomData(void* buff, size_t len)
|
||||
{
|
||||
unsigned char *cbuff = (unsigned char *)buff;
|
||||
while(len--)
|
||||
{
|
||||
*(cbuff++) = (unsigned char)((rand() / (float)RAND_MAX * 255.) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void generateGibberish(void* buff, size_t len)
|
||||
{
|
||||
static const unsigned char cb64[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
unsigned char *cbuff = (unsigned char *)buff;
|
||||
while(len--)
|
||||
{
|
||||
*(cbuff++) = cb64[(size_t)((rand() / (float)RAND_MAX * 64.) + 1)];
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// test class
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
class Base64TestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
Base64TestCase() { }
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( Base64TestCase );
|
||||
CPPUNIT_TEST( EncodeDecodeEmpty );
|
||||
CPPUNIT_TEST( EncodeDecodeA );
|
||||
CPPUNIT_TEST( EncodeDecodeAB );
|
||||
CPPUNIT_TEST( EncodeDecodeABC );
|
||||
CPPUNIT_TEST( EncodeDecodeABCD );
|
||||
CPPUNIT_TEST( EncodeDecode0to255 );
|
||||
CPPUNIT_TEST( EncodeDecodePatternA );
|
||||
CPPUNIT_TEST( EncodeDecodePatternB );
|
||||
CPPUNIT_TEST( EncodeDecodePatternC );
|
||||
CPPUNIT_TEST( EncodeDecodeRandom );
|
||||
CPPUNIT_TEST( DecodeInvalid );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void EncodeDecodeEmpty();
|
||||
void EncodeDecodeA();
|
||||
void EncodeDecodeAB();
|
||||
void EncodeDecodeABC();
|
||||
void EncodeDecodeABCD();
|
||||
void EncodeDecode0to255();
|
||||
void EncodeDecodePatternA();
|
||||
void EncodeDecodePatternB();
|
||||
void EncodeDecodePatternC();
|
||||
void EncodeDecodeRandom();
|
||||
void DecodeInvalid();
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(Base64TestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( Base64TestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( Base64TestCase, "Base64TestCase" );
|
||||
|
||||
void Base64TestCase::EncodeDecodeEmpty()
|
||||
{
|
||||
char shouldBeEmpty[10];
|
||||
shouldBeEmpty[0] = '\0';
|
||||
size_t len = 10;
|
||||
|
||||
CPPUNIT_ASSERT(wxBase64Encode(shouldBeEmpty, len, "", 0) != wxCONV_FAILED);
|
||||
CPPUNIT_ASSERT_EQUAL('\0', shouldBeEmpty[0]);
|
||||
|
||||
CPPUNIT_ASSERT(wxBase64Decode(shouldBeEmpty, len, "") != wxCONV_FAILED);
|
||||
CPPUNIT_ASSERT_EQUAL('\0', shouldBeEmpty[0]);
|
||||
|
||||
wxMemoryBuffer bufmt;
|
||||
wxString resultEmpty = wxBase64Encode(bufmt);
|
||||
CPPUNIT_ASSERT(resultEmpty.empty());
|
||||
|
||||
bufmt = wxBase64Decode(resultEmpty);
|
||||
CPPUNIT_ASSERT_EQUAL(0, bufmt.GetDataLen());
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodeA()
|
||||
{
|
||||
const wxString str = wxBase64Encode("A", 1);
|
||||
CPPUNIT_ASSERT_EQUAL(wxString("QQ=="), str);
|
||||
|
||||
wxMemoryBuffer buf = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT_EQUAL(1, buf.GetDataLen());
|
||||
CPPUNIT_ASSERT_EQUAL('A', *(char *)buf.GetData());
|
||||
|
||||
char cbuf[10];
|
||||
memset(cbuf, (char)-1, sizeof(cbuf));
|
||||
CPPUNIT_ASSERT_EQUAL( 1, wxBase64Decode(cbuf, 1, str) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'A', cbuf[0] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[1] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[2] );
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodeAB()
|
||||
{
|
||||
const wxString str = wxBase64Encode("AB", 2);
|
||||
CPPUNIT_ASSERT_EQUAL(wxString("QUI="), str);
|
||||
|
||||
wxMemoryBuffer buf = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT_EQUAL(2, buf.GetDataLen());
|
||||
CPPUNIT_ASSERT_EQUAL('A', buf[0]);
|
||||
CPPUNIT_ASSERT_EQUAL('B', buf[1]);
|
||||
|
||||
char cbuf[10];
|
||||
memset(cbuf, (char)-1, sizeof(cbuf));
|
||||
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, wxBase64Decode(cbuf, 1, str) );
|
||||
CPPUNIT_ASSERT_EQUAL( 2, wxBase64Decode(cbuf, 2, str) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'A', cbuf[0] );
|
||||
CPPUNIT_ASSERT_EQUAL( 'B', cbuf[1] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[2] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[3] );
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodeABC()
|
||||
{
|
||||
const wxString str = wxBase64Encode("ABC", 3);
|
||||
CPPUNIT_ASSERT_EQUAL(wxString("QUJD"), str);
|
||||
|
||||
wxMemoryBuffer buf = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT_EQUAL(3, buf.GetDataLen());
|
||||
CPPUNIT_ASSERT_EQUAL('A', buf[0]);
|
||||
CPPUNIT_ASSERT_EQUAL('B', buf[1]);
|
||||
CPPUNIT_ASSERT_EQUAL('C', buf[2]);
|
||||
|
||||
char cbuf[10];
|
||||
memset(cbuf, (char)-1, sizeof(cbuf));
|
||||
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, wxBase64Decode(cbuf, 2, str) );
|
||||
CPPUNIT_ASSERT_EQUAL( 3, wxBase64Decode(cbuf, 3, str) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'A', cbuf[0] );
|
||||
CPPUNIT_ASSERT_EQUAL( 'B', cbuf[1] );
|
||||
CPPUNIT_ASSERT_EQUAL( 'C', cbuf[2] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[3] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[4] );
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodeABCD()
|
||||
{
|
||||
const wxString str = wxBase64Encode("ABCD", 4);
|
||||
CPPUNIT_ASSERT_EQUAL(wxString("QUJDRA=="), str);
|
||||
|
||||
wxMemoryBuffer buf = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT_EQUAL(4, buf.GetDataLen());
|
||||
CPPUNIT_ASSERT_EQUAL('A', buf[0]);
|
||||
CPPUNIT_ASSERT_EQUAL('B', buf[1]);
|
||||
CPPUNIT_ASSERT_EQUAL('C', buf[2]);
|
||||
CPPUNIT_ASSERT_EQUAL('D', buf[3]);
|
||||
|
||||
char cbuf[10];
|
||||
memset(cbuf, (char)-1, sizeof(cbuf));
|
||||
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, wxBase64Decode(cbuf, 3, str) );
|
||||
CPPUNIT_ASSERT_EQUAL( 4, wxBase64Decode(cbuf, 4, str) );
|
||||
CPPUNIT_ASSERT_EQUAL( 'A', cbuf[0] );
|
||||
CPPUNIT_ASSERT_EQUAL( 'B', cbuf[1] );
|
||||
CPPUNIT_ASSERT_EQUAL( 'C', cbuf[2] );
|
||||
CPPUNIT_ASSERT_EQUAL( 'D', cbuf[3] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[4] );
|
||||
CPPUNIT_ASSERT_EQUAL( (char)-1, cbuf[5] );
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecode0to255()
|
||||
{
|
||||
unsigned char buff[256];
|
||||
generatePatternedData(buff, 256, 0, 1);
|
||||
wxString str = wxBase64Encode(buff, 256);
|
||||
wxMemoryBuffer mbuff = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT(memcmp(mbuff.GetData(), buff, mbuff.GetDataLen()) == 0);
|
||||
|
||||
mbuff = wxBase64Decode(encoded0to255);
|
||||
CPPUNIT_ASSERT(memcmp(mbuff.GetData(), buff, mbuff.GetDataLen()) == 0);
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodePatternA()
|
||||
{
|
||||
unsigned char buff[350];
|
||||
generatePatternedData(buff, 350, 24, 5, 3);
|
||||
wxString str = wxBase64Encode(buff, 350);
|
||||
wxMemoryBuffer mbuff = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT(memcmp(mbuff.GetData(), buff, mbuff.GetDataLen()) == 0);
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodePatternB()
|
||||
{
|
||||
unsigned char buff[350];
|
||||
generatePatternedData(buff, 350, 0, 1, 1, 0xAA);
|
||||
wxString str = wxBase64Encode(buff, 350);
|
||||
wxMemoryBuffer mbuff = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT(memcmp(mbuff.GetData(), buff, mbuff.GetDataLen()) == 0);
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodePatternC()
|
||||
{
|
||||
unsigned char buff[11];
|
||||
generatePatternedData(buff, 11, 1, 0, 2);
|
||||
wxString str = wxBase64Encode(buff, 11);
|
||||
wxMemoryBuffer mbuff = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT(memcmp(mbuff.GetData(), buff, mbuff.GetDataLen()) == 0);
|
||||
}
|
||||
|
||||
void Base64TestCase::EncodeDecodeRandom()
|
||||
{
|
||||
size_t size = (size_t)(rand() / (float)RAND_MAX * 3000. + 11);
|
||||
unsigned char *buff = new unsigned char[size];
|
||||
generateRandomData(buff, size);
|
||||
wxString str = wxBase64Encode(buff, size);
|
||||
wxMemoryBuffer mbuff = wxBase64Decode(str);
|
||||
CPPUNIT_ASSERT(memcmp(mbuff.GetData(), buff, mbuff.GetDataLen()) == 0);
|
||||
|
||||
generateGibberish(buff, size);
|
||||
char *buff2 = new char[size];
|
||||
size_t realsize = size;
|
||||
CPPUNIT_ASSERT(wxBase64Decode(buff2, realsize, (char *)buff, size));
|
||||
CPPUNIT_ASSERT(wxBase64Encode(buff2, size, buff2, realsize));
|
||||
delete[] buff2;
|
||||
delete[] buff;
|
||||
}
|
||||
|
||||
void Base64TestCase::DecodeInvalid()
|
||||
{
|
||||
size_t rc, posErr;
|
||||
rc = wxBase64Decode(nullptr, 0, "one two!", wxNO_LEN,
|
||||
wxBase64DecodeMode_Strict, &posErr);
|
||||
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, rc);
|
||||
CPPUNIT_ASSERT_EQUAL( 3, posErr );
|
||||
|
||||
rc = wxBase64Decode(nullptr, 0, "one two!", wxNO_LEN,
|
||||
wxBase64DecodeMode_SkipWS, &posErr);
|
||||
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, rc);
|
||||
CPPUNIT_ASSERT_EQUAL( 7, posErr );
|
||||
|
||||
rc = wxBase64Decode(nullptr, 0, "? QQ==", wxNO_LEN,
|
||||
wxBase64DecodeMode_SkipWS, &posErr);
|
||||
CPPUNIT_ASSERT_EQUAL( wxCONV_FAILED, rc);
|
||||
CPPUNIT_ASSERT_EQUAL( 0, posErr );
|
||||
|
||||
const size_t POS_INVALID = (size_t)-1;
|
||||
posErr = POS_INVALID;
|
||||
rc = wxBase64Decode(nullptr, 0, " QQ==", wxNO_LEN,
|
||||
wxBase64DecodeMode_SkipWS, &posErr);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, rc );
|
||||
CPPUNIT_ASSERT_EQUAL( POS_INVALID, posErr );
|
||||
|
||||
rc = wxBase64Decode(nullptr, 0, "? QQ==", wxNO_LEN,
|
||||
wxBase64DecodeMode_Relaxed, &posErr);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, rc );
|
||||
CPPUNIT_ASSERT_EQUAL( POS_INVALID, posErr );
|
||||
|
||||
CPPUNIT_ASSERT( !wxBase64Decode("wxGetApp()").GetDataLen() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_BASE64
|
||||
356
libs/wxWidgets-3.3.1/tests/benchmarks/Makefile.in
Normal file
356
libs/wxWidgets-3.3.1/tests/benchmarks/Makefile.in
Normal file
@@ -0,0 +1,356 @@
|
||||
# =========================================================================
|
||||
# This makefile was generated by
|
||||
# Bakefile 0.2.13 (http://www.bakefile.org)
|
||||
# Do not modify, all changes will be overwritten!
|
||||
# =========================================================================
|
||||
|
||||
|
||||
@MAKE_SET@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
datarootdir = @datarootdir@
|
||||
INSTALL = @INSTALL@
|
||||
EXEEXT = @EXEEXT@
|
||||
WINDRES = @WINDRES@
|
||||
BK_DEPS = @BK_DEPS@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
LIBS = @LIBS@
|
||||
CXX = @CXX@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
USE_DPI_AWARE_MANIFEST = @USE_DPI_AWARE_MANIFEST@
|
||||
WX_LIB_FLAVOUR = @WX_LIB_FLAVOUR@
|
||||
TOOLKIT = @TOOLKIT@
|
||||
TOOLKIT_LOWERCASE = @TOOLKIT_LOWERCASE@
|
||||
TOOLKIT_VERSION = @TOOLKIT_VERSION@
|
||||
TOOLCHAIN_FULLNAME = @TOOLCHAIN_FULLNAME@
|
||||
EXTRALIBS = @EXTRALIBS@
|
||||
EXTRALIBS_XML = @EXTRALIBS_XML@
|
||||
EXTRALIBS_GUI = @EXTRALIBS_GUI@
|
||||
EXTRALIBS_OPENGL = @EXTRALIBS_OPENGL@
|
||||
WX_CPPFLAGS = @WX_CPPFLAGS@
|
||||
WX_CXXFLAGS = @WX_CXXFLAGS@
|
||||
WX_LDFLAGS = @WX_LDFLAGS@
|
||||
HOST_SUFFIX = @HOST_SUFFIX@
|
||||
DYLIB_RPATH_FLAG = @DYLIB_RPATH_FLAG@
|
||||
SAMPLES_CXXFLAGS = @SAMPLES_CXXFLAGS@
|
||||
wx_top_builddir = @wx_top_builddir@
|
||||
|
||||
### Variables: ###
|
||||
|
||||
DESTDIR =
|
||||
WX_RELEASE = 3.3
|
||||
WX_VERSION = $(WX_RELEASE).1
|
||||
LIBDIRNAME = $(wx_top_builddir)/lib
|
||||
BENCH_CXXFLAGS = $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
$(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) -DwxUSE_GUI=0 $(WX_CXXFLAGS) \
|
||||
$(SAMPLES_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_OBJECTS = \
|
||||
bench_bench.o \
|
||||
bench_datetime.o \
|
||||
bench_htmlpars.o \
|
||||
bench_htmltag.o \
|
||||
bench_ipcclient.o \
|
||||
bench_log.o \
|
||||
bench_mbconv.o \
|
||||
bench_regex.o \
|
||||
bench_strings.o \
|
||||
bench_tls.o \
|
||||
bench_printfbench.o
|
||||
BENCH_GUI_CXXFLAGS = $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
$(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) -I$(srcdir)/../../samples \
|
||||
$(WX_CXXFLAGS) $(SAMPLES_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_GUI_OBJECTS = \
|
||||
$(__bench_gui___win32rc) \
|
||||
bench_gui_bench.o \
|
||||
bench_gui_display.o \
|
||||
bench_gui_image.o
|
||||
BENCH_GRAPHICS_CXXFLAGS = $(WX_CPPFLAGS) -D__WX$(TOOLKIT)__ \
|
||||
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \
|
||||
$(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) -I$(srcdir) $(__DLLFLAG_p) \
|
||||
-I$(srcdir)/../../samples $(WX_CXXFLAGS) $(SAMPLES_CXXFLAGS) $(CPPFLAGS) \
|
||||
$(CXXFLAGS)
|
||||
BENCH_GRAPHICS_OBJECTS = \
|
||||
$(__bench_graphics___win32rc) \
|
||||
bench_graphics_graphics.o
|
||||
|
||||
### Conditionally set variables: ###
|
||||
|
||||
@COND_DEPS_TRACKING_0@CXXC = $(CXX)
|
||||
@COND_DEPS_TRACKING_1@CXXC = $(BK_DEPS) $(CXX)
|
||||
@COND_USE_GUI_0@PORTNAME = base
|
||||
@COND_USE_GUI_1@PORTNAME = $(TOOLKIT_LOWERCASE)$(TOOLKIT_VERSION)
|
||||
@COND_TOOLKIT_MAC@WXBASEPORT = _carbon
|
||||
@COND_BUILD_debug@WXDEBUGFLAG = d
|
||||
@COND_WXUNIV_1@WXUNIVNAME = univ
|
||||
@COND_MONOLITHIC_0@EXTRALIBS_FOR_BASE = $(EXTRALIBS)
|
||||
@COND_MONOLITHIC_1@EXTRALIBS_FOR_BASE = $(EXTRALIBS) \
|
||||
@COND_MONOLITHIC_1@ $(EXTRALIBS_XML) $(EXTRALIBS_GUI)
|
||||
@COND_MONOLITHIC_0@EXTRALIBS_FOR_GUI = $(EXTRALIBS_GUI)
|
||||
@COND_MONOLITHIC_1@EXTRALIBS_FOR_GUI =
|
||||
COND_MONOLITHIC_0___WXLIB_NET_p = \
|
||||
-lwx_base$(WXBASEPORT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_MONOLITHIC_0@__WXLIB_NET_p = $(COND_MONOLITHIC_0___WXLIB_NET_p)
|
||||
@COND_MONOLITHIC_1@__LIB_PNG_IF_MONO_p = $(__LIB_PNG_p)
|
||||
@COND_USE_GUI_1@__bench_gui___depname = bench_gui$(EXEEXT)
|
||||
@COND_PLATFORM_WIN32_1@__bench_gui___win32rc = bench_gui_sample_rc.o
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_gui_app_Contents_PkgInfo___depname \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_gui.app/Contents/PkgInfo
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_gui_bundle___depname \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_gui_bundle
|
||||
@COND_TOOLKIT_COCOA@____bench_gui_BUNDLE_TGT_REF_DEP = \
|
||||
@COND_TOOLKIT_COCOA@ $(__bench_gui_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_MAC@____bench_gui_BUNDLE_TGT_REF_DEP = \
|
||||
@COND_TOOLKIT_MAC@ $(__bench_gui_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_OSX_CARBON@____bench_gui_BUNDLE_TGT_REF_DEP \
|
||||
@COND_TOOLKIT_OSX_CARBON@ = $(__bench_gui_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_OSX_COCOA@____bench_gui_BUNDLE_TGT_REF_DEP \
|
||||
@COND_TOOLKIT_OSX_COCOA@ = $(__bench_gui_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_OSX_IPHONE@____bench_gui_BUNDLE_TGT_REF_DEP \
|
||||
@COND_TOOLKIT_OSX_IPHONE@ = $(__bench_gui_app_Contents_PkgInfo___depname)
|
||||
@COND_MONOLITHIC_1_USE_STC_1@__LIB_SCINTILLA_IF_MONO_p \
|
||||
@COND_MONOLITHIC_1_USE_STC_1@ = $(__LIB_SCINTILLA_p)
|
||||
@COND_MONOLITHIC_1_USE_STC_1@__LIB_LEXILLA_IF_MONO_p = $(__LIB_LEXILLA_p)
|
||||
@COND_USE_GUI_1@__bench_graphics___depname = bench_graphics$(EXEEXT)
|
||||
@COND_PLATFORM_WIN32_1@__bench_graphics___win32rc = \
|
||||
@COND_PLATFORM_WIN32_1@ bench_graphics_sample_rc.o
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_graphics_app_Contents_PkgInfo___depname \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_graphics.app/Contents/PkgInfo
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@__bench_graphics_bundle___depname \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ = bench_graphics_bundle
|
||||
@COND_TOOLKIT_COCOA@____bench_graphics_BUNDLE_TGT_REF_DEP \
|
||||
@COND_TOOLKIT_COCOA@ = $(__bench_graphics_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_MAC@____bench_graphics_BUNDLE_TGT_REF_DEP = \
|
||||
@COND_TOOLKIT_MAC@ $(__bench_graphics_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_OSX_CARBON@____bench_graphics_BUNDLE_TGT_REF_DEP \
|
||||
@COND_TOOLKIT_OSX_CARBON@ = \
|
||||
@COND_TOOLKIT_OSX_CARBON@ $(__bench_graphics_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_OSX_COCOA@____bench_graphics_BUNDLE_TGT_REF_DEP \
|
||||
@COND_TOOLKIT_OSX_COCOA@ = \
|
||||
@COND_TOOLKIT_OSX_COCOA@ $(__bench_graphics_app_Contents_PkgInfo___depname)
|
||||
@COND_TOOLKIT_OSX_IPHONE@____bench_graphics_BUNDLE_TGT_REF_DEP \
|
||||
@COND_TOOLKIT_OSX_IPHONE@ = \
|
||||
@COND_TOOLKIT_OSX_IPHONE@ $(__bench_graphics_app_Contents_PkgInfo___depname)
|
||||
@COND_MONOLITHIC_1_USE_STC_1@__LIB_SCINTILLA_IF_MONO_p_1 \
|
||||
@COND_MONOLITHIC_1_USE_STC_1@ = $(__LIB_SCINTILLA_p)
|
||||
@COND_MONOLITHIC_1_USE_STC_1@__LIB_LEXILLA_IF_MONO_p_1 = $(__LIB_LEXILLA_p)
|
||||
@COND_WXUNIV_1@__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
|
||||
@COND_WXUNIV_1@__WXUNIV_DEFINE_p_0 = --define __WXUNIVERSAL__
|
||||
@COND_DEBUG_FLAG_0@__DEBUG_DEFINE_p = -DwxDEBUG_LEVEL=0
|
||||
@COND_DEBUG_FLAG_0@__DEBUG_DEFINE_p_0 = --define wxDEBUG_LEVEL=0
|
||||
@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS
|
||||
@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p_0 = --define wxNO_EXCEPTIONS
|
||||
@COND_USE_RTTI_0@__RTTI_DEFINE_p = -DwxNO_RTTI
|
||||
@COND_USE_RTTI_0@__RTTI_DEFINE_p_0 = --define wxNO_RTTI
|
||||
@COND_USE_THREADS_0@__THREAD_DEFINE_p = -DwxNO_THREADS
|
||||
@COND_USE_THREADS_0@__THREAD_DEFINE_p_0 = --define wxNO_THREADS
|
||||
@COND_SHARED_1@__DLLFLAG_p = -DWXUSINGDLL
|
||||
@COND_SHARED_1@__DLLFLAG_p_0 = --define WXUSINGDLL
|
||||
@COND_PLATFORM_WIN32_1@__WIN32_DPI_MANIFEST_p = \
|
||||
@COND_PLATFORM_WIN32_1@ --define \
|
||||
@COND_PLATFORM_WIN32_1@ wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST)
|
||||
@COND_TOOLKIT_MSW@__RCDEFDIR_p = --include-dir \
|
||||
@COND_TOOLKIT_MSW@ $(LIBDIRNAME)/wx/include/$(TOOLCHAIN_FULLNAME)
|
||||
COND_MONOLITHIC_0___WXLIB_CORE_p = \
|
||||
-lwx_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_MONOLITHIC_0@__WXLIB_CORE_p = $(COND_MONOLITHIC_0___WXLIB_CORE_p)
|
||||
COND_MONOLITHIC_0___WXLIB_BASE_p = \
|
||||
-lwx_base$(WXBASEPORT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_MONOLITHIC_0@__WXLIB_BASE_p = $(COND_MONOLITHIC_0___WXLIB_BASE_p)
|
||||
COND_MONOLITHIC_1___WXLIB_MONO_p = \
|
||||
-lwx_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_MONOLITHIC_1@__WXLIB_MONO_p = $(COND_MONOLITHIC_1___WXLIB_MONO_p)
|
||||
@COND_USE_STC_1@__LIB_SCINTILLA_p = \
|
||||
@COND_USE_STC_1@ -lwxscintilla$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_USE_STC_1@__LIB_LEXILLA_p = \
|
||||
@COND_USE_STC_1@ -lwxlexilla$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@__LIB_TIFF_p \
|
||||
@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@ = \
|
||||
@COND_USE_GUI_1_wxUSE_LIBTIFF_builtin@ -lwxtiff$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@__LIB_JPEG_p \
|
||||
@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@ = \
|
||||
@COND_USE_GUI_1_wxUSE_LIBJPEG_builtin@ -lwxjpeg$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@__LIB_PNG_p \
|
||||
@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@ = \
|
||||
@COND_USE_GUI_1_wxUSE_LIBPNG_builtin@ -lwxpng$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_USE_GUI_1_wxUSE_LIBWEBP_builtin@__LIB_WEBP_p \
|
||||
@COND_USE_GUI_1_wxUSE_LIBWEBP_builtin@ = \
|
||||
@COND_USE_GUI_1_wxUSE_LIBWEBP_builtin@ -lwxwebp$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_wxUSE_ZLIB_builtin@__LIB_ZLIB_p = \
|
||||
@COND_wxUSE_ZLIB_builtin@ -lwxzlib$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_wxUSE_REGEX_builtin@__LIB_REGEX_p = \
|
||||
@COND_wxUSE_REGEX_builtin@ -lwxregexu$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
@COND_wxUSE_EXPAT_builtin@__LIB_EXPAT_p = \
|
||||
@COND_wxUSE_EXPAT_builtin@ -lwxexpat$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX)
|
||||
|
||||
### Targets: ###
|
||||
|
||||
all: bench$(EXEEXT) data $(__bench_gui___depname) $(__bench_gui_bundle___depname) $(__bench_graphics___depname) $(__bench_graphics_bundle___depname) data-image
|
||||
|
||||
install:
|
||||
|
||||
uninstall:
|
||||
|
||||
install-strip: install
|
||||
|
||||
clean:
|
||||
rm -rf ./.deps ./.pch
|
||||
rm -f ./*.o
|
||||
rm -f bench$(EXEEXT)
|
||||
rm -f bench_gui$(EXEEXT)
|
||||
rm -rf bench_gui.app
|
||||
rm -f bench_graphics$(EXEEXT)
|
||||
rm -rf bench_graphics.app
|
||||
|
||||
distclean: clean
|
||||
rm -f config.cache config.log config.status bk-deps bk-make-pch Makefile
|
||||
|
||||
bench$(EXEEXT): $(BENCH_OBJECTS)
|
||||
$(CXX) -o $@ $(BENCH_OBJECTS) -L$(LIBDIRNAME) $(DYLIB_RPATH_FLAG) $(LDFLAGS) $(WX_LDFLAGS) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_PNG_IF_MONO_p) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS)
|
||||
|
||||
data:
|
||||
@mkdir -p .
|
||||
@for f in htmltest.html; do \
|
||||
if test ! -f ./$$f -a ! -d ./$$f ; \
|
||||
then x=yep ; \
|
||||
else x=`find $(srcdir)/$$f -newer ./$$f -print` ; \
|
||||
fi; \
|
||||
case "$$x" in ?*) \
|
||||
cp -pRf $(srcdir)/$$f . ;; \
|
||||
esac; \
|
||||
done
|
||||
|
||||
@COND_USE_GUI_1@bench_gui$(EXEEXT): $(BENCH_GUI_OBJECTS) $(__bench_gui___win32rc)
|
||||
@COND_USE_GUI_1@ $(CXX) -o $@ $(BENCH_GUI_OBJECTS) -L$(LIBDIRNAME) $(DYLIB_RPATH_FLAG) $(LDFLAGS) $(WX_LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS)
|
||||
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_gui.app/Contents/PkgInfo: $(__bench_gui___depname) $(top_srcdir)/src/osx/carbon/Info.plist.in $(top_srcdir)/src/osx/carbon/wxmac.icns
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_gui.app/Contents
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_gui.app/Contents/MacOS
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_gui.app/Contents/Resources
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ sed -e "s/\$${MACOSX_BUNDLE_GUI_IDENTIFIER}/org.wxwidgets.bench_gui/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_EXECUTABLE_NAME}/bench_gui/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_NAME}/bench_gui/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_COPYRIGHT}/Copyright 2002-2025 wxWidgets/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_VERSION}/$(WX_VERSION)/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_INFO_STRING}/bench_gui version $(WX_VERSION), (c) 2002-2025 wxWidgets/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_LONG_VERSION_STRING}/$(WX_VERSION), (c) 2002-2025 wxWidgets/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_SHORT_VERSION_STRING}/$(WX_RELEASE)/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ $(top_srcdir)/src/osx/carbon/Info.plist.in >bench_gui.app/Contents/Info.plist
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ /bin/echo "APPL????" >bench_gui.app/Contents/PkgInfo
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ ln -f bench_gui$(EXEEXT) bench_gui.app/Contents/MacOS/bench_gui
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ cp -f $(top_srcdir)/src/osx/carbon/wxmac.icns bench_gui.app/Contents/Resources/wxmac.icns
|
||||
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_gui_bundle: $(____bench_gui_BUNDLE_TGT_REF_DEP)
|
||||
|
||||
@COND_USE_GUI_1@bench_graphics$(EXEEXT): $(BENCH_GRAPHICS_OBJECTS) $(__bench_graphics___win32rc)
|
||||
@COND_USE_GUI_1@ $(CXX) -o $@ $(BENCH_GRAPHICS_OBJECTS) -L$(LIBDIRNAME) $(DYLIB_RPATH_FLAG) $(LDFLAGS) $(WX_LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) -lwx_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl-$(WX_RELEASE)$(HOST_SUFFIX) $(EXTRALIBS_OPENGL) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p_1) $(__LIB_LEXILLA_IF_MONO_p_1) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS)
|
||||
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_graphics.app/Contents/PkgInfo: $(__bench_graphics___depname) $(top_srcdir)/src/osx/carbon/Info.plist.in $(top_srcdir)/src/osx/carbon/wxmac.icns
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_graphics.app/Contents
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_graphics.app/Contents/MacOS
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p bench_graphics.app/Contents/Resources
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ sed -e "s/\$${MACOSX_BUNDLE_GUI_IDENTIFIER}/org.wxwidgets.bench_graphics/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_EXECUTABLE_NAME}/bench_graphics/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_NAME}/bench_graphics/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_COPYRIGHT}/Copyright 2002-2025 wxWidgets/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_BUNDLE_VERSION}/$(WX_VERSION)/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_INFO_STRING}/bench_graphics version $(WX_VERSION), (c) 2002-2025 wxWidgets/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_LONG_VERSION_STRING}/$(WX_VERSION), (c) 2002-2025 wxWidgets/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ -e "s/\$${MACOSX_BUNDLE_SHORT_VERSION_STRING}/$(WX_RELEASE)/" \
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ $(top_srcdir)/src/osx/carbon/Info.plist.in >bench_graphics.app/Contents/Info.plist
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ /bin/echo "APPL????" >bench_graphics.app/Contents/PkgInfo
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ ln -f bench_graphics$(EXEEXT) bench_graphics.app/Contents/MacOS/bench_graphics
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@ cp -f $(top_srcdir)/src/osx/carbon/wxmac.icns bench_graphics.app/Contents/Resources/wxmac.icns
|
||||
|
||||
@COND_PLATFORM_MACOSX_1_USE_GUI_1@bench_graphics_bundle: $(____bench_graphics_BUNDLE_TGT_REF_DEP)
|
||||
|
||||
data-image:
|
||||
@mkdir -p .
|
||||
@for f in ../../samples/image/horse.bmp ../../samples/image/horse.jpg ../../samples/image/horse.png ../../samples/image/horse.tif; do \
|
||||
if test ! -f ./$$f -a ! -d ./$$f ; \
|
||||
then x=yep ; \
|
||||
else x=`find $(srcdir)/$$f -newer ./$$f -print` ; \
|
||||
fi; \
|
||||
case "$$x" in ?*) \
|
||||
cp -pRf $(srcdir)/$$f . ;; \
|
||||
esac; \
|
||||
done
|
||||
|
||||
bench_bench.o: $(srcdir)/bench.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/bench.cpp
|
||||
|
||||
bench_datetime.o: $(srcdir)/datetime.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/datetime.cpp
|
||||
|
||||
bench_htmlpars.o: $(srcdir)/htmlparser/htmlpars.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/htmlparser/htmlpars.cpp
|
||||
|
||||
bench_htmltag.o: $(srcdir)/htmlparser/htmltag.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/htmlparser/htmltag.cpp
|
||||
|
||||
bench_ipcclient.o: $(srcdir)/ipcclient.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/ipcclient.cpp
|
||||
|
||||
bench_log.o: $(srcdir)/log.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/log.cpp
|
||||
|
||||
bench_mbconv.o: $(srcdir)/mbconv.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/mbconv.cpp
|
||||
|
||||
bench_regex.o: $(srcdir)/regex.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/regex.cpp
|
||||
|
||||
bench_strings.o: $(srcdir)/strings.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/strings.cpp
|
||||
|
||||
bench_tls.o: $(srcdir)/tls.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/tls.cpp
|
||||
|
||||
bench_printfbench.o: $(srcdir)/printfbench.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/printfbench.cpp
|
||||
|
||||
bench_gui_sample_rc.o: $(srcdir)/../../samples/sample.rc
|
||||
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(srcdir) $(__DLLFLAG_p_0) $(__WIN32_DPI_MANIFEST_p) --include-dir $(srcdir)/../../samples $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include
|
||||
|
||||
bench_gui_bench.o: $(srcdir)/bench.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/bench.cpp
|
||||
|
||||
bench_gui_display.o: $(srcdir)/display.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/display.cpp
|
||||
|
||||
bench_gui_image.o: $(srcdir)/image.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/image.cpp
|
||||
|
||||
bench_graphics_sample_rc.o: $(srcdir)/../../samples/sample.rc
|
||||
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(srcdir) $(__DLLFLAG_p_0) $(__WIN32_DPI_MANIFEST_p) --include-dir $(srcdir)/../../samples $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include
|
||||
|
||||
bench_graphics_graphics.o: $(srcdir)/graphics.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_GRAPHICS_CXXFLAGS) $(srcdir)/graphics.cpp
|
||||
|
||||
|
||||
# Include dependency info, if present:
|
||||
@IF_GNU_MAKE@-include ./.deps/*.d
|
||||
|
||||
.PHONY: all install uninstall clean distclean data bench_gui_bundle \
|
||||
bench_graphics_bundle data-image
|
||||
69
libs/wxWidgets-3.3.1/tests/benchmarks/bench.bkl
Normal file
69
libs/wxWidgets-3.3.1/tests/benchmarks/bench.bkl
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<makefile>
|
||||
<include file="../../build/bakefiles/common_samples.bkl"/>
|
||||
|
||||
<template id="wx_bench">
|
||||
</template>
|
||||
|
||||
<exe id="bench" template="wx_sample_console,wx_bench"
|
||||
template_append="wx_append_base">
|
||||
<sources>
|
||||
bench.cpp
|
||||
datetime.cpp
|
||||
htmlparser/htmlpars.cpp
|
||||
htmlparser/htmltag.cpp
|
||||
ipcclient.cpp
|
||||
log.cpp
|
||||
mbconv.cpp
|
||||
regex.cpp
|
||||
strings.cpp
|
||||
tls.cpp
|
||||
printfbench.cpp
|
||||
</sources>
|
||||
<wx-lib>net</wx-lib>
|
||||
<wx-lib>base</wx-lib>
|
||||
</exe>
|
||||
|
||||
<wx-data id="data">
|
||||
<files>htmltest.html</files>
|
||||
</wx-data>
|
||||
|
||||
<exe id="bench_gui" template="wx_sample,wx_bench"
|
||||
template_append="wx_append"
|
||||
cond="USE_GUI=='1'">
|
||||
|
||||
<app-type>console</app-type>
|
||||
|
||||
<sources>
|
||||
bench.cpp
|
||||
display.cpp
|
||||
image.cpp
|
||||
</sources>
|
||||
<wx-lib>core</wx-lib>
|
||||
<wx-lib>base</wx-lib>
|
||||
</exe>
|
||||
|
||||
<exe id="bench_graphics" template="wx_sample,wx_bench"
|
||||
template_append="wx_append"
|
||||
cond="USE_GUI=='1'">
|
||||
|
||||
<app-type>console</app-type>
|
||||
|
||||
<sources>
|
||||
graphics.cpp
|
||||
</sources>
|
||||
<wx-lib>core</wx-lib>
|
||||
<wx-lib>base</wx-lib>
|
||||
<wx-lib>gl</wx-lib>
|
||||
</exe>
|
||||
|
||||
<wx-data id="data-image">
|
||||
<files>
|
||||
../../samples/image/horse.bmp
|
||||
../../samples/image/horse.jpg
|
||||
../../samples/image/horse.png
|
||||
../../samples/image/horse.tif
|
||||
</files>
|
||||
</wx-data>
|
||||
</makefile>
|
||||
389
libs/wxWidgets-3.3.1/tests/benchmarks/bench.cpp
Normal file
389
libs/wxWidgets-3.3.1/tests/benchmarks/bench.cpp
Normal file
@@ -0,0 +1,389 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/bench.cpp
|
||||
// Purpose: Main file of the benchmarking suite
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-07-19
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/cmdline.h"
|
||||
#include "wx/stopwatch.h"
|
||||
#include "wx/uilocale.h"
|
||||
|
||||
#if wxUSE_GUI
|
||||
#include "wx/frame.h"
|
||||
#endif
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static const char OPTION_LIST = 'l';
|
||||
static const char OPTION_SINGLE = '1';
|
||||
|
||||
static const char OPTION_RUN_TIME = 't';
|
||||
static const char OPTION_NUM_RUNS = 'n';
|
||||
static const char OPTION_NUMERIC_PARAM = 'p';
|
||||
static const char OPTION_STRING_PARAM = 's';
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// BenchApp declaration
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_GUI
|
||||
typedef wxApp BenchAppBase;
|
||||
#else
|
||||
typedef wxAppConsole BenchAppBase;
|
||||
#endif
|
||||
|
||||
class BenchApp : public BenchAppBase
|
||||
{
|
||||
public:
|
||||
BenchApp();
|
||||
|
||||
// standard overrides
|
||||
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
||||
virtual bool OnInit();
|
||||
virtual int OnRun();
|
||||
virtual int OnExit();
|
||||
|
||||
// accessors
|
||||
int GetNumericParameter() const { return m_numParam; }
|
||||
const wxString& GetStringParameter() const { return m_strParam; }
|
||||
|
||||
private:
|
||||
// output the results of a single benchmark if successful or just return
|
||||
// false if anything went wrong
|
||||
bool RunSingleBenchmark(Bench::Function* func);
|
||||
|
||||
// list all registered benchmarks
|
||||
void ListBenchmarks();
|
||||
|
||||
// command lines options/parameters
|
||||
wxSortedArrayString m_toRun;
|
||||
long m_numRuns, // number of times to run a single benchmark or 0
|
||||
m_runTime, // minimum time to run a single benchmark if m_numRuns == 0
|
||||
m_numParam;
|
||||
wxString m_strParam;
|
||||
};
|
||||
|
||||
wxIMPLEMENT_APP_CONSOLE(BenchApp);
|
||||
|
||||
// ============================================================================
|
||||
// Bench namespace symbols implementation
|
||||
// ============================================================================
|
||||
|
||||
Bench::Function *Bench::Function::ms_head = nullptr;
|
||||
|
||||
long Bench::GetNumericParameter(long defVal)
|
||||
{
|
||||
const long val = wxGetApp().GetNumericParameter();
|
||||
return val ? val : defVal;
|
||||
}
|
||||
|
||||
wxString Bench::GetStringParameter(const wxString& defVal)
|
||||
{
|
||||
const wxString& val = wxGetApp().GetStringParameter();
|
||||
return !val.empty() ? val : defVal;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// BenchApp implementation
|
||||
// ============================================================================
|
||||
|
||||
BenchApp::BenchApp()
|
||||
{
|
||||
m_numRuns = 0; // this means to use m_runTime
|
||||
m_runTime = 500; // default minimum
|
||||
m_numParam = 0;
|
||||
}
|
||||
|
||||
bool BenchApp::OnInit()
|
||||
{
|
||||
if ( !BenchAppBase::OnInit() )
|
||||
return false;
|
||||
|
||||
// Some benchmarks are locale-sensitive, so use the current locale.
|
||||
wxUILocale::UseDefault();
|
||||
|
||||
wxPrintf("wxWidgets benchmarking program\n"
|
||||
"Build: %s\n", WX_BUILD_OPTIONS_SIGNATURE);
|
||||
|
||||
#if wxUSE_GUI
|
||||
// create a hidden parent window to be used as parent for the GUI controls
|
||||
new wxFrame(nullptr, wxID_ANY, "Hidden wx benchmark frame");
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BenchApp::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
{
|
||||
BenchAppBase::OnInitCmdLine(parser);
|
||||
|
||||
parser.AddSwitch(OPTION_LIST,
|
||||
"list",
|
||||
"list all the existing benchmarks");
|
||||
|
||||
parser.AddSwitch(OPTION_SINGLE,
|
||||
"single",
|
||||
"run the benchmark once only");
|
||||
|
||||
parser.AddOption(OPTION_RUN_TIME,
|
||||
"run-time",
|
||||
wxString::Format
|
||||
(
|
||||
"maximum time to run each benchmark in ms "
|
||||
"(default: %ld, set to 0 to disable)",
|
||||
m_runTime
|
||||
),
|
||||
wxCMD_LINE_VAL_NUMBER);
|
||||
parser.AddOption(OPTION_NUM_RUNS,
|
||||
"num-runs",
|
||||
wxString::Format
|
||||
(
|
||||
"number of times to run each benchmark in a loop "
|
||||
"(default: %ld, 0 means to run until max time passes)",
|
||||
m_numRuns
|
||||
),
|
||||
wxCMD_LINE_VAL_NUMBER);
|
||||
parser.AddOption(OPTION_NUMERIC_PARAM,
|
||||
"num-param",
|
||||
wxString::Format
|
||||
(
|
||||
"numeric parameter used by some benchmark functions "
|
||||
"(default: %ld)",
|
||||
m_numParam
|
||||
),
|
||||
wxCMD_LINE_VAL_NUMBER);
|
||||
parser.AddOption(OPTION_STRING_PARAM,
|
||||
"str-param",
|
||||
"string parameter used by some benchmark functions "
|
||||
"(default: empty)",
|
||||
wxCMD_LINE_VAL_STRING);
|
||||
|
||||
parser.AddParam("benchmark name",
|
||||
wxCMD_LINE_VAL_STRING,
|
||||
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE);
|
||||
}
|
||||
|
||||
bool BenchApp::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
{
|
||||
if ( parser.Found(OPTION_LIST) )
|
||||
{
|
||||
ListBenchmarks();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t count = parser.GetParamCount();
|
||||
if ( !count )
|
||||
{
|
||||
parser.Usage();
|
||||
|
||||
ListBenchmarks();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool runTimeSpecified = parser.Found(OPTION_RUN_TIME, &m_runTime);
|
||||
const bool numRunsSpecified = parser.Found(OPTION_NUM_RUNS, &m_numRuns);
|
||||
parser.Found(OPTION_NUMERIC_PARAM, &m_numParam);
|
||||
parser.Found(OPTION_STRING_PARAM, &m_strParam);
|
||||
if ( parser.Found(OPTION_SINGLE) )
|
||||
{
|
||||
if ( runTimeSpecified || numRunsSpecified )
|
||||
{
|
||||
wxFprintf(stderr, "Incompatible options specified.\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_numRuns = 1;
|
||||
}
|
||||
else if ( numRunsSpecified && !runTimeSpecified )
|
||||
{
|
||||
// If only the number of runs is specified, use it only.
|
||||
m_runTime = 0;
|
||||
}
|
||||
|
||||
// construct sorted array for quick verification of benchmark names
|
||||
wxSortedArrayString benchmarks;
|
||||
for ( Bench::Function *func = Bench::Function::GetFirst();
|
||||
func;
|
||||
func = func->GetNext() )
|
||||
{
|
||||
benchmarks.push_back(func->GetName());
|
||||
}
|
||||
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
const wxString name = parser.GetParam(n);
|
||||
if ( benchmarks.Index(name) == wxNOT_FOUND )
|
||||
{
|
||||
wxFprintf(stderr, "No benchmark named \"%s\".\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_toRun.push_back(name);
|
||||
}
|
||||
|
||||
return BenchAppBase::OnCmdLineParsed(parser);
|
||||
}
|
||||
|
||||
int BenchApp::OnRun()
|
||||
{
|
||||
int rc = EXIT_SUCCESS;
|
||||
|
||||
wxString params;
|
||||
if ( m_numParam )
|
||||
params += wxString::Format("N=%ld", m_numParam);
|
||||
if ( !m_strParam.empty() )
|
||||
{
|
||||
if ( !params.empty() )
|
||||
params += " and ";
|
||||
params += wxString::Format("s=\"%s\"", m_strParam);
|
||||
}
|
||||
|
||||
if ( !params.empty() )
|
||||
wxPrintf("Benchmarks are running with non-default %s\n", params);
|
||||
|
||||
for ( Bench::Function *func = Bench::Function::GetFirst();
|
||||
func;
|
||||
func = func->GetNext() )
|
||||
{
|
||||
if ( m_toRun.Index(func->GetName()) == wxNOT_FOUND )
|
||||
continue;
|
||||
|
||||
if ( !RunSingleBenchmark(func) )
|
||||
{
|
||||
wxFprintf(stderr, "ERROR running %s\n", func->GetName());
|
||||
rc = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool BenchApp::RunSingleBenchmark(Bench::Function* func)
|
||||
{
|
||||
if ( !func->Init() )
|
||||
return false;
|
||||
|
||||
wxPrintf("%-30s", wxString(func->GetName()) + ':');
|
||||
fflush(stdout);
|
||||
|
||||
// We use the algorithm for iteratively computing the mean and the
|
||||
// standard deviation of the sequence of values described in Knuth's
|
||||
// "The Art of Computer Programming, Volume 2: Seminumerical
|
||||
// Algorithms", section 4.2.2.
|
||||
//
|
||||
// The algorithm defines the sequences M(k) and S(k) as follows:
|
||||
//
|
||||
// M(1) = x(1), M(k) = M(k-1) + (x(k) - M(k-1)) / k
|
||||
// S(1) = 0, S(k) = S(k-1) + (x(k) - M(k-1))*(x(k) - M(k))
|
||||
//
|
||||
// where x(k) is the k-th value. Then the mean is simply the last value
|
||||
// of the first sequence M(N) and the standard deviation is
|
||||
// sqrt(S(N)/(N-1)).
|
||||
|
||||
wxStopWatch swTotal;
|
||||
if ( !func->Run() )
|
||||
return false;
|
||||
|
||||
double timeMin = DBL_MAX,
|
||||
timeMax = 0;
|
||||
|
||||
double m = swTotal.TimeInMicro().ToDouble();
|
||||
double s = 0;
|
||||
|
||||
long n = 0;
|
||||
for ( ;; )
|
||||
{
|
||||
// One termination condition is reaching the maximum number of runs.
|
||||
if ( ++n == m_numRuns )
|
||||
break;
|
||||
|
||||
double t;
|
||||
{
|
||||
wxStopWatch swThis;
|
||||
if ( !func->Run() )
|
||||
return false;
|
||||
|
||||
t = swThis.TimeInMicro().ToDouble();
|
||||
}
|
||||
|
||||
if ( t < timeMin )
|
||||
timeMin = t;
|
||||
if ( t > timeMax )
|
||||
timeMax = t;
|
||||
|
||||
const double lastM = m;
|
||||
m += (t - lastM) / n;
|
||||
s += (t - lastM)*(t - m);
|
||||
|
||||
// The other termination condition is that we are running for at least
|
||||
// m_runTime milliseconds.
|
||||
if ( m_runTime && swTotal.Time() >= m_runTime )
|
||||
break;
|
||||
}
|
||||
|
||||
func->Done();
|
||||
|
||||
// For a single run there is no standard deviation and min/max don't make
|
||||
// much sense.
|
||||
if ( n == 1 )
|
||||
{
|
||||
wxPrintf("single run took %.0fus\n", m);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = sqrt(s / (n - 1));
|
||||
|
||||
wxPrintf
|
||||
(
|
||||
"%12ld runs, %.0fus avg, %.0f std dev (%.0f/%.0f min/max)\n",
|
||||
n, m, s, timeMin, timeMax
|
||||
);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int BenchApp::OnExit()
|
||||
{
|
||||
#if wxUSE_GUI
|
||||
delete GetTopWindow();
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void BenchApp::ListBenchmarks()
|
||||
{
|
||||
wxPrintf("Available benchmarks:\n");
|
||||
for ( Bench::Function *func = Bench::Function::GetFirst();
|
||||
func;
|
||||
func = func->GetNext() )
|
||||
{
|
||||
wxPrintf("\t%s\n", func->GetName());
|
||||
}
|
||||
}
|
||||
126
libs/wxWidgets-3.3.1/tests/benchmarks/bench.h
Normal file
126
libs/wxWidgets-3.3.1/tests/benchmarks/bench.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/bench.h
|
||||
// Purpose: Main header of the benchmarking suite
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-07-19
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_BENCHMARKS_BENCH_H_
|
||||
#define _WX_TESTS_BENCHMARKS_BENCH_H_
|
||||
|
||||
#include "wx/cpp.h"
|
||||
#include "wx/crt.h"
|
||||
#include "wx/defs.h"
|
||||
|
||||
namespace Bench
|
||||
{
|
||||
|
||||
/**
|
||||
Utility object used to register the benchmark functions.
|
||||
|
||||
@see BENCHMARK_FUNC
|
||||
*/
|
||||
class Function
|
||||
{
|
||||
public:
|
||||
typedef bool (*InitType)();
|
||||
typedef bool (*FuncType)();
|
||||
typedef void (*DoneType)();
|
||||
|
||||
/// Ctor is used implicitly by BENCHMARK_FUNC().
|
||||
Function(const char *name,
|
||||
FuncType func,
|
||||
InitType init = nullptr,
|
||||
DoneType done = nullptr)
|
||||
: m_name(name),
|
||||
m_func(func),
|
||||
m_init(init),
|
||||
m_done(done),
|
||||
m_next(ms_head)
|
||||
{
|
||||
ms_head = this;
|
||||
}
|
||||
|
||||
/// Get the name of this function
|
||||
const char *GetName() const { return m_name; }
|
||||
|
||||
/// Perform once-only initialization prior to Run().
|
||||
bool Init() { return m_init ? (*m_init)() : true; }
|
||||
|
||||
/// Run the function, return its return value.
|
||||
bool Run() { return (*m_func)(); }
|
||||
|
||||
/// Clean up after performing the benchmark.
|
||||
void Done() { if ( m_done ) (*m_done)(); }
|
||||
|
||||
/// Get the head of the linked list of benchmark objects
|
||||
static Function *GetFirst() { return ms_head; }
|
||||
|
||||
/// Get the next object in the linked list or nullptr
|
||||
Function *GetNext() const { return m_next; }
|
||||
|
||||
private:
|
||||
// the head of the linked list of Bench::Function objects
|
||||
static Function *ms_head;
|
||||
|
||||
// name of and pointer to the function, as passed to the ctor
|
||||
const char * const m_name;
|
||||
const FuncType m_func;
|
||||
const InitType m_init;
|
||||
const DoneType m_done;
|
||||
|
||||
// pointer to the next object in the linked list or nullptr
|
||||
Function * const m_next;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(Function);
|
||||
};
|
||||
|
||||
/**
|
||||
Get the numeric parameter.
|
||||
|
||||
Tests may use this parameter in whatever way they see fit, by default it is
|
||||
1 but can be set to a different value by user from the command line.
|
||||
*/
|
||||
long GetNumericParameter(long defValue = 1);
|
||||
|
||||
/**
|
||||
Get the string parameter.
|
||||
|
||||
Tests may use this parameter in whatever way they see fit, by default it is
|
||||
empty but can be set to a different value by user from the command line.
|
||||
*/
|
||||
wxString GetStringParameter(const wxString& defValue = wxString());
|
||||
|
||||
} // namespace Bench
|
||||
|
||||
/**
|
||||
This macro defines a benchmark function.
|
||||
|
||||
All these functions return a boolean value and take no parameters. The
|
||||
return value is needed to prevent the compiler from optimizing the
|
||||
benchmark entirely away and so typically will be constructed using the
|
||||
results of the benchmark actions, even though normally benchmark should
|
||||
always return true.
|
||||
|
||||
Once benchmark is defined, it can be invoked from the command line of the
|
||||
main benchmarking program.
|
||||
*/
|
||||
#define BENCHMARK_FUNC(name) \
|
||||
static bool name(); \
|
||||
static Bench::Function wxMAKE_UNIQUE_NAME(name)(#name, name); \
|
||||
bool name()
|
||||
|
||||
/**
|
||||
Define a benchmark function requiring initialization and shutdown.
|
||||
|
||||
This macro is similar to BENCHMARK_FUNC() but ensures that @a init is
|
||||
called before the benchmark is ran and @a done afterwards.
|
||||
*/
|
||||
#define BENCHMARK_FUNC_WITH_INIT(name, init, done) \
|
||||
static bool name(); \
|
||||
static Bench::Function wxMAKE_UNIQUE_NAME(name)(#name, name, init, done); \
|
||||
bool name()
|
||||
|
||||
#endif // _WX_TESTS_BENCHMARKS_BENCH_H_
|
||||
19
libs/wxWidgets-3.3.1/tests/benchmarks/datetime.cpp
Normal file
19
libs/wxWidgets-3.3.1/tests/benchmarks/datetime.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/datetime.cpp
|
||||
// Purpose: wxDateTime benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-05-23
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/datetime.h"
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
BENCHMARK_FUNC(ParseDate)
|
||||
{
|
||||
wxDateTime dt;
|
||||
return dt.ParseDate("May 23, 2011") && dt.GetMonth() == wxDateTime::May;
|
||||
}
|
||||
|
||||
30
libs/wxWidgets-3.3.1/tests/benchmarks/display.cpp
Normal file
30
libs/wxWidgets-3.3.1/tests/benchmarks/display.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/display.cpp
|
||||
// Purpose: wxDisplay benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2018-09-30
|
||||
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/display.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
BENCHMARK_FUNC(DisplaySize)
|
||||
{
|
||||
int w, h;
|
||||
wxDisplaySize(&w, &h);
|
||||
return w > 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(GetDisplaySize)
|
||||
{
|
||||
return wxGetDisplaySize().x > 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(DisplayGetGeometry)
|
||||
{
|
||||
return wxDisplay().GetGeometry().GetSize().x > 0;
|
||||
}
|
||||
1058
libs/wxWidgets-3.3.1/tests/benchmarks/graphics.cpp
Normal file
1058
libs/wxWidgets-3.3.1/tests/benchmarks/graphics.cpp
Normal file
File diff suppressed because it is too large
Load Diff
4
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/README
Normal file
4
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/README
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
This is a copy of wxWidgets 2.8's wxHTML parser. Unlike the 2.9+ version, it
|
||||
uses wxString::operator[] during parsing and so is perfect for testing
|
||||
real-life performance of the new wxString class' operator[] caching.
|
||||
892
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmlpars.cpp
Normal file
892
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmlpars.cpp
Normal file
@@ -0,0 +1,892 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/html/htmlpars.cpp
|
||||
// Purpose: wx28HtmlParser class (generic parser)
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
|
||||
#include "htmlpars.h"
|
||||
|
||||
#ifndef WXPRECOMP
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/app.h"
|
||||
#endif
|
||||
|
||||
#include "wx/crt.h"
|
||||
#include "wx/tokenzr.h"
|
||||
#include "wx/wfstream.h"
|
||||
#include "wx/url.h"
|
||||
#include "wx/fontmap.h"
|
||||
#include "wx/html/htmldefs.h"
|
||||
#include "wx/arrimpl.cpp"
|
||||
|
||||
// DLL options compatibility check:
|
||||
WX_CHECK_BUILD_OPTIONS("wxHTML")
|
||||
|
||||
const wxChar *wxTRACE_HTML_DEBUG = wxT("htmldebug");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlParser helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wx28HtmlTextPiece
|
||||
{
|
||||
public:
|
||||
wx28HtmlTextPiece(int pos, int lng) : m_pos(pos), m_lng(lng) {}
|
||||
int m_pos, m_lng;
|
||||
};
|
||||
|
||||
WX_DECLARE_OBJARRAY(wx28HtmlTextPiece, wx28HtmlTextPieces);
|
||||
WX_DEFINE_OBJARRAY(wx28HtmlTextPieces)
|
||||
|
||||
class wx28HtmlParserState
|
||||
{
|
||||
public:
|
||||
wx28HtmlTag *m_curTag;
|
||||
wx28HtmlTag *m_tags;
|
||||
wx28HtmlTextPieces *m_textPieces;
|
||||
int m_curTextPiece;
|
||||
wxString m_source;
|
||||
wx28HtmlParserState *m_nextState;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlParser
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxIMPLEMENT_ABSTRACT_CLASS(wx28HtmlParser, wxObject);
|
||||
|
||||
wx28HtmlParser::wx28HtmlParser()
|
||||
: wxObject(), m_HandlersHash(wxKEY_STRING),
|
||||
m_FS(nullptr), m_HandlersStack(nullptr)
|
||||
{
|
||||
m_entitiesParser = new wx28HtmlEntitiesParser;
|
||||
m_Tags = nullptr;
|
||||
m_CurTag = nullptr;
|
||||
m_TextPieces = nullptr;
|
||||
m_CurTextPiece = 0;
|
||||
m_SavedStates = nullptr;
|
||||
}
|
||||
|
||||
wx28HtmlParser::~wx28HtmlParser()
|
||||
{
|
||||
while (RestoreState()) {}
|
||||
DestroyDOMTree();
|
||||
|
||||
if (m_HandlersStack)
|
||||
{
|
||||
wxList& tmp = *m_HandlersStack;
|
||||
wxList::iterator it, en;
|
||||
for( it = tmp.begin(), en = tmp.end(); it != en; ++it )
|
||||
delete (wxHashTable*)*it;
|
||||
tmp.clear();
|
||||
}
|
||||
delete m_HandlersStack;
|
||||
m_HandlersHash.Clear();
|
||||
wxClearList(m_HandlersList);
|
||||
delete m_entitiesParser;
|
||||
}
|
||||
|
||||
wxObject* wx28HtmlParser::Parse(const wxString& source)
|
||||
{
|
||||
InitParser(source);
|
||||
DoParsing();
|
||||
wxObject *result = GetProduct();
|
||||
DoneParser();
|
||||
return result;
|
||||
}
|
||||
|
||||
void wx28HtmlParser::InitParser(const wxString& source)
|
||||
{
|
||||
SetSource(source);
|
||||
m_stopParsing = false;
|
||||
}
|
||||
|
||||
void wx28HtmlParser::DoneParser()
|
||||
{
|
||||
DestroyDOMTree();
|
||||
}
|
||||
|
||||
void wx28HtmlParser::SetSource(const wxString& src)
|
||||
{
|
||||
DestroyDOMTree();
|
||||
m_Source = src;
|
||||
CreateDOMTree();
|
||||
m_CurTag = nullptr;
|
||||
m_CurTextPiece = 0;
|
||||
}
|
||||
|
||||
void wx28HtmlParser::CreateDOMTree()
|
||||
{
|
||||
wx28HtmlTagsCache cache(m_Source);
|
||||
m_TextPieces = new wx28HtmlTextPieces;
|
||||
CreateDOMSubTree(nullptr, 0, m_Source.length(), &cache);
|
||||
m_CurTextPiece = 0;
|
||||
}
|
||||
|
||||
extern bool wxIsCDATAElement(const wxChar *tag);
|
||||
|
||||
void wx28HtmlParser::CreateDOMSubTree(wx28HtmlTag *cur,
|
||||
int begin_pos, int end_pos,
|
||||
wx28HtmlTagsCache *cache)
|
||||
{
|
||||
if (end_pos <= begin_pos) return;
|
||||
|
||||
wxChar c;
|
||||
int i = begin_pos;
|
||||
int textBeginning = begin_pos;
|
||||
|
||||
// If the tag contains CDATA text, we include the text between beginning
|
||||
// and ending tag verbosely. Setting i=end_pos will skip to the very
|
||||
// end of this function where text piece is added, bypassing any child
|
||||
// tags parsing (CDATA element can't have child elements by definition):
|
||||
if (cur != nullptr && wxIsCDATAElement(cur->GetName().c_str()))
|
||||
{
|
||||
i = end_pos;
|
||||
}
|
||||
|
||||
while (i < end_pos)
|
||||
{
|
||||
c = m_Source.GetChar(i);
|
||||
|
||||
if (c == wxT('<'))
|
||||
{
|
||||
// add text to m_TextPieces:
|
||||
if (i - textBeginning > 0)
|
||||
m_TextPieces->Add(
|
||||
wx28HtmlTextPiece(textBeginning, i - textBeginning));
|
||||
|
||||
// if it is a comment, skip it:
|
||||
if (i < end_pos-6 && m_Source.GetChar(i+1) == wxT('!') &&
|
||||
m_Source.GetChar(i+2) == wxT('-') &&
|
||||
m_Source.GetChar(i+3) == wxT('-'))
|
||||
{
|
||||
// Comments begin with "<!--" and end with "--[ \t\r\n]*>"
|
||||
// according to HTML 4.0
|
||||
int dashes = 0;
|
||||
i += 4;
|
||||
while (i < end_pos)
|
||||
{
|
||||
c = m_Source.GetChar(i++);
|
||||
if ((c == wxT(' ') || c == wxT('\n') ||
|
||||
c == wxT('\r') || c == wxT('\t')) && dashes >= 2) {}
|
||||
else if (c == wxT('>') && dashes >= 2)
|
||||
{
|
||||
textBeginning = i;
|
||||
break;
|
||||
}
|
||||
else if (c == wxT('-'))
|
||||
dashes++;
|
||||
else
|
||||
dashes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// add another tag to the tree:
|
||||
else if (i < end_pos-1 && m_Source.GetChar(i+1) != wxT('/'))
|
||||
{
|
||||
wx28HtmlTag *chd;
|
||||
if (cur)
|
||||
chd = new wx28HtmlTag(cur, m_Source,
|
||||
i, end_pos, cache, m_entitiesParser);
|
||||
else
|
||||
{
|
||||
chd = new wx28HtmlTag(nullptr, m_Source,
|
||||
i, end_pos, cache, m_entitiesParser);
|
||||
if (!m_Tags)
|
||||
{
|
||||
// if this is the first tag to be created make the root
|
||||
// m_Tags point to it:
|
||||
m_Tags = chd;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there is already a root tag add this tag as
|
||||
// the last sibling:
|
||||
chd->m_Prev = m_Tags->GetLastSibling();
|
||||
chd->m_Prev->m_Next = chd;
|
||||
}
|
||||
}
|
||||
|
||||
if (chd->HasEnding())
|
||||
{
|
||||
CreateDOMSubTree(chd,
|
||||
chd->GetBeginPos(), chd->GetEndPos1(),
|
||||
cache);
|
||||
i = chd->GetEndPos2();
|
||||
}
|
||||
else
|
||||
i = chd->GetBeginPos();
|
||||
|
||||
textBeginning = i;
|
||||
}
|
||||
|
||||
// ... or skip ending tag:
|
||||
else
|
||||
{
|
||||
while (i < end_pos && m_Source.GetChar(i) != wxT('>')) i++;
|
||||
textBeginning = i+1;
|
||||
}
|
||||
}
|
||||
else i++;
|
||||
}
|
||||
|
||||
// add remaining text to m_TextPieces:
|
||||
if (end_pos - textBeginning > 0)
|
||||
m_TextPieces->Add(
|
||||
wx28HtmlTextPiece(textBeginning, end_pos - textBeginning));
|
||||
}
|
||||
|
||||
void wx28HtmlParser::DestroyDOMTree()
|
||||
{
|
||||
wx28HtmlTag *t1, *t2;
|
||||
t1 = m_Tags;
|
||||
while (t1)
|
||||
{
|
||||
t2 = t1->GetNextSibling();
|
||||
delete t1;
|
||||
t1 = t2;
|
||||
}
|
||||
m_Tags = m_CurTag = nullptr;
|
||||
|
||||
delete m_TextPieces;
|
||||
m_TextPieces = nullptr;
|
||||
}
|
||||
|
||||
void wx28HtmlParser::DoParsing()
|
||||
{
|
||||
m_CurTag = m_Tags;
|
||||
m_CurTextPiece = 0;
|
||||
DoParsing(0, m_Source.length());
|
||||
}
|
||||
|
||||
void wx28HtmlParser::DoParsing(int begin_pos, int end_pos)
|
||||
{
|
||||
if (end_pos <= begin_pos) return;
|
||||
|
||||
wx28HtmlTextPieces& pieces = *m_TextPieces;
|
||||
size_t piecesCnt = pieces.GetCount();
|
||||
|
||||
while (begin_pos < end_pos)
|
||||
{
|
||||
while (m_CurTag && m_CurTag->GetBeginPos() < begin_pos)
|
||||
m_CurTag = m_CurTag->GetNextTag();
|
||||
while (m_CurTextPiece < piecesCnt &&
|
||||
pieces[m_CurTextPiece].m_pos < begin_pos)
|
||||
m_CurTextPiece++;
|
||||
|
||||
if (m_CurTextPiece < piecesCnt &&
|
||||
(!m_CurTag ||
|
||||
pieces[m_CurTextPiece].m_pos < m_CurTag->GetBeginPos()))
|
||||
{
|
||||
// Add text:
|
||||
AddText(GetEntitiesParser()->Parse(
|
||||
m_Source.Mid(pieces[m_CurTextPiece].m_pos,
|
||||
pieces[m_CurTextPiece].m_lng)).t_str());
|
||||
begin_pos = pieces[m_CurTextPiece].m_pos +
|
||||
pieces[m_CurTextPiece].m_lng;
|
||||
m_CurTextPiece++;
|
||||
}
|
||||
else if (m_CurTag)
|
||||
{
|
||||
if (m_CurTag->HasEnding())
|
||||
begin_pos = m_CurTag->GetEndPos2();
|
||||
else
|
||||
begin_pos = m_CurTag->GetBeginPos();
|
||||
wx28HtmlTag *t = m_CurTag;
|
||||
m_CurTag = m_CurTag->GetNextTag();
|
||||
AddTag(*t);
|
||||
if (m_stopParsing)
|
||||
return;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
void wx28HtmlParser::AddTag(const wx28HtmlTag& tag)
|
||||
{
|
||||
wx28HtmlTagHandler *h;
|
||||
bool inner = false;
|
||||
|
||||
h = (wx28HtmlTagHandler*) m_HandlersHash.Get(tag.GetName());
|
||||
if (h)
|
||||
{
|
||||
inner = h->HandleTag(tag);
|
||||
if (m_stopParsing)
|
||||
return;
|
||||
}
|
||||
if (!inner)
|
||||
{
|
||||
if (tag.HasEnding())
|
||||
DoParsing(tag.GetBeginPos(), tag.GetEndPos1());
|
||||
}
|
||||
}
|
||||
|
||||
void wx28HtmlParser::AddTagHandler(wx28HtmlTagHandler *handler)
|
||||
{
|
||||
wxString s(handler->GetSupportedTags());
|
||||
wxStringTokenizer tokenizer(s, wxT(", "));
|
||||
|
||||
while (tokenizer.HasMoreTokens())
|
||||
m_HandlersHash.Put(tokenizer.GetNextToken(), handler);
|
||||
|
||||
if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND)
|
||||
m_HandlersList.Append(handler);
|
||||
|
||||
handler->SetParser(this);
|
||||
}
|
||||
|
||||
void wx28HtmlParser::PushTagHandler(wx28HtmlTagHandler *handler, const wxString& tags)
|
||||
{
|
||||
wxStringTokenizer tokenizer(tags, wxT(", "));
|
||||
wxString key;
|
||||
|
||||
if (m_HandlersStack == nullptr)
|
||||
{
|
||||
m_HandlersStack = new wxList;
|
||||
}
|
||||
|
||||
m_HandlersStack->Insert((wxObject*)new wxHashTable(m_HandlersHash));
|
||||
|
||||
while (tokenizer.HasMoreTokens())
|
||||
{
|
||||
key = tokenizer.GetNextToken();
|
||||
m_HandlersHash.Delete(key);
|
||||
m_HandlersHash.Put(key, handler);
|
||||
}
|
||||
}
|
||||
|
||||
void wx28HtmlParser::PopTagHandler()
|
||||
{
|
||||
wxList::compatibility_iterator first;
|
||||
|
||||
if ( !m_HandlersStack ||
|
||||
!(first = m_HandlersStack->GetFirst()) )
|
||||
{
|
||||
wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack."));
|
||||
return;
|
||||
}
|
||||
m_HandlersHash = *((wxHashTable*) first->GetData());
|
||||
delete (wxHashTable*) first->GetData();
|
||||
m_HandlersStack->Erase(first);
|
||||
}
|
||||
|
||||
void wx28HtmlParser::SetSourceAndSaveState(const wxString& src)
|
||||
{
|
||||
wx28HtmlParserState *s = new wx28HtmlParserState;
|
||||
|
||||
s->m_curTag = m_CurTag;
|
||||
s->m_tags = m_Tags;
|
||||
s->m_textPieces = m_TextPieces;
|
||||
s->m_curTextPiece = m_CurTextPiece;
|
||||
s->m_source = m_Source;
|
||||
|
||||
s->m_nextState = m_SavedStates;
|
||||
m_SavedStates = s;
|
||||
|
||||
m_CurTag = nullptr;
|
||||
m_Tags = nullptr;
|
||||
m_TextPieces = nullptr;
|
||||
m_CurTextPiece = 0;
|
||||
m_Source = wxEmptyString;
|
||||
|
||||
SetSource(src);
|
||||
}
|
||||
|
||||
bool wx28HtmlParser::RestoreState()
|
||||
{
|
||||
if (!m_SavedStates) return false;
|
||||
|
||||
DestroyDOMTree();
|
||||
|
||||
wx28HtmlParserState *s = m_SavedStates;
|
||||
m_SavedStates = s->m_nextState;
|
||||
|
||||
m_CurTag = s->m_curTag;
|
||||
m_Tags = s->m_tags;
|
||||
m_TextPieces = s->m_textPieces;
|
||||
m_CurTextPiece = s->m_curTextPiece;
|
||||
m_Source = s->m_source;
|
||||
|
||||
delete s;
|
||||
return true;
|
||||
}
|
||||
|
||||
wxString wx28HtmlParser::GetInnerSource(const wx28HtmlTag& tag)
|
||||
{
|
||||
return GetSource()->Mid(tag.GetBeginPos(),
|
||||
tag.GetEndPos1() - tag.GetBeginPos());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlTagHandler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxIMPLEMENT_ABSTRACT_CLASS(wx28HtmlTagHandler, wxObject);
|
||||
|
||||
void wx28HtmlTagHandler::ParseInnerSource(const wxString& source)
|
||||
{
|
||||
// It is safe to temporarily change the source being parsed,
|
||||
// provided we restore the state back after parsing
|
||||
m_Parser->SetSourceAndSaveState(source);
|
||||
m_Parser->DoParsing();
|
||||
m_Parser->RestoreState();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlEntitiesParser
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wx28HtmlEntitiesParser,wxObject);
|
||||
|
||||
wx28HtmlEntitiesParser::wx28HtmlEntitiesParser()
|
||||
{
|
||||
}
|
||||
|
||||
wx28HtmlEntitiesParser::~wx28HtmlEntitiesParser()
|
||||
{
|
||||
}
|
||||
|
||||
void wx28HtmlEntitiesParser::SetEncoding(wxFontEncoding encoding)
|
||||
{
|
||||
(void) encoding;
|
||||
}
|
||||
|
||||
wxString wx28HtmlEntitiesParser::Parse(const wxString& input)
|
||||
{
|
||||
const wxChar *c, *last;
|
||||
const wxChar *in_str = input.c_str();
|
||||
wxString output;
|
||||
|
||||
for (c = in_str, last = in_str; *c != wxT('\0'); c++)
|
||||
{
|
||||
if (*c == wxT('&'))
|
||||
{
|
||||
if ( output.empty() )
|
||||
output.reserve(input.length());
|
||||
|
||||
if (c - last > 0)
|
||||
output.append(last, c - last);
|
||||
if ( *++c == wxT('\0') )
|
||||
break;
|
||||
|
||||
wxString entity;
|
||||
const wxChar *ent_s = c;
|
||||
wxChar entity_char;
|
||||
|
||||
for (; (*c >= wxT('a') && *c <= wxT('z')) ||
|
||||
(*c >= wxT('A') && *c <= wxT('Z')) ||
|
||||
(*c >= wxT('0') && *c <= wxT('9')) ||
|
||||
*c == wxT('_') || *c == wxT('#'); c++) {}
|
||||
entity.append(ent_s, c - ent_s);
|
||||
if (*c != wxT(';')) c--;
|
||||
last = c+1;
|
||||
entity_char = GetEntityChar(entity);
|
||||
if (entity_char)
|
||||
output << entity_char;
|
||||
else
|
||||
{
|
||||
output.append(ent_s-1, c-ent_s+2);
|
||||
wxLogTrace(wxTRACE_HTML_DEBUG,
|
||||
wxT("Unrecognized HTML entity: '%s'"),
|
||||
entity.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (last == in_str) // common case: no entity
|
||||
return input;
|
||||
if (*last != wxT('\0'))
|
||||
output.append(last);
|
||||
return output;
|
||||
}
|
||||
|
||||
struct wx28HtmlEntityInfo
|
||||
{
|
||||
const wxChar *name;
|
||||
unsigned code;
|
||||
};
|
||||
|
||||
extern "C" int LINKAGEMODE wx28HtmlEntityCompare(const void *key, const void *item)
|
||||
{
|
||||
return wxStrcmp((wxChar*)key, ((wx28HtmlEntityInfo*)item)->name);
|
||||
}
|
||||
|
||||
wxChar wx28HtmlEntitiesParser::GetEntityChar(const wxString& entity)
|
||||
{
|
||||
unsigned code = 0;
|
||||
|
||||
if (entity[0] == wxT('#'))
|
||||
{
|
||||
const wxChar *ent_s = entity.c_str();
|
||||
const wxChar *format;
|
||||
|
||||
if (ent_s[1] == wxT('x') || ent_s[1] == wxT('X'))
|
||||
{
|
||||
format = wxT("%x");
|
||||
ent_s++;
|
||||
}
|
||||
else
|
||||
format = wxT("%u");
|
||||
ent_s++;
|
||||
|
||||
if (wxSscanf(ent_s, format, &code) != 1)
|
||||
code = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
static wx28HtmlEntityInfo substitutions[] = {
|
||||
{ wxT("AElig"),198 },
|
||||
{ wxT("Aacute"),193 },
|
||||
{ wxT("Acirc"),194 },
|
||||
{ wxT("Agrave"),192 },
|
||||
{ wxT("Alpha"),913 },
|
||||
{ wxT("Aring"),197 },
|
||||
{ wxT("Atilde"),195 },
|
||||
{ wxT("Auml"),196 },
|
||||
{ wxT("Beta"),914 },
|
||||
{ wxT("Ccedil"),199 },
|
||||
{ wxT("Chi"),935 },
|
||||
{ wxT("Dagger"),8225 },
|
||||
{ wxT("Delta"),916 },
|
||||
{ wxT("ETH"),208 },
|
||||
{ wxT("Eacute"),201 },
|
||||
{ wxT("Ecirc"),202 },
|
||||
{ wxT("Egrave"),200 },
|
||||
{ wxT("Epsilon"),917 },
|
||||
{ wxT("Eta"),919 },
|
||||
{ wxT("Euml"),203 },
|
||||
{ wxT("Gamma"),915 },
|
||||
{ wxT("Iacute"),205 },
|
||||
{ wxT("Icirc"),206 },
|
||||
{ wxT("Igrave"),204 },
|
||||
{ wxT("Iota"),921 },
|
||||
{ wxT("Iuml"),207 },
|
||||
{ wxT("Kappa"),922 },
|
||||
{ wxT("Lambda"),923 },
|
||||
{ wxT("Mu"),924 },
|
||||
{ wxT("Ntilde"),209 },
|
||||
{ wxT("Nu"),925 },
|
||||
{ wxT("OElig"),338 },
|
||||
{ wxT("Oacute"),211 },
|
||||
{ wxT("Ocirc"),212 },
|
||||
{ wxT("Ograve"),210 },
|
||||
{ wxT("Omega"),937 },
|
||||
{ wxT("Omicron"),927 },
|
||||
{ wxT("Oslash"),216 },
|
||||
{ wxT("Otilde"),213 },
|
||||
{ wxT("Ouml"),214 },
|
||||
{ wxT("Phi"),934 },
|
||||
{ wxT("Pi"),928 },
|
||||
{ wxT("Prime"),8243 },
|
||||
{ wxT("Psi"),936 },
|
||||
{ wxT("Rho"),929 },
|
||||
{ wxT("Scaron"),352 },
|
||||
{ wxT("Sigma"),931 },
|
||||
{ wxT("THORN"),222 },
|
||||
{ wxT("Tau"),932 },
|
||||
{ wxT("Theta"),920 },
|
||||
{ wxT("Uacute"),218 },
|
||||
{ wxT("Ucirc"),219 },
|
||||
{ wxT("Ugrave"),217 },
|
||||
{ wxT("Upsilon"),933 },
|
||||
{ wxT("Uuml"),220 },
|
||||
{ wxT("Xi"),926 },
|
||||
{ wxT("Yacute"),221 },
|
||||
{ wxT("Yuml"),376 },
|
||||
{ wxT("Zeta"),918 },
|
||||
{ wxT("aacute"),225 },
|
||||
{ wxT("acirc"),226 },
|
||||
{ wxT("acute"),180 },
|
||||
{ wxT("aelig"),230 },
|
||||
{ wxT("agrave"),224 },
|
||||
{ wxT("alefsym"),8501 },
|
||||
{ wxT("alpha"),945 },
|
||||
{ wxT("amp"),38 },
|
||||
{ wxT("and"),8743 },
|
||||
{ wxT("ang"),8736 },
|
||||
{ wxT("aring"),229 },
|
||||
{ wxT("asymp"),8776 },
|
||||
{ wxT("atilde"),227 },
|
||||
{ wxT("auml"),228 },
|
||||
{ wxT("bdquo"),8222 },
|
||||
{ wxT("beta"),946 },
|
||||
{ wxT("brvbar"),166 },
|
||||
{ wxT("bull"),8226 },
|
||||
{ wxT("cap"),8745 },
|
||||
{ wxT("ccedil"),231 },
|
||||
{ wxT("cedil"),184 },
|
||||
{ wxT("cent"),162 },
|
||||
{ wxT("chi"),967 },
|
||||
{ wxT("circ"),710 },
|
||||
{ wxT("clubs"),9827 },
|
||||
{ wxT("cong"),8773 },
|
||||
{ wxT("copy"),169 },
|
||||
{ wxT("crarr"),8629 },
|
||||
{ wxT("cup"),8746 },
|
||||
{ wxT("curren"),164 },
|
||||
{ wxT("dArr"),8659 },
|
||||
{ wxT("dagger"),8224 },
|
||||
{ wxT("darr"),8595 },
|
||||
{ wxT("deg"),176 },
|
||||
{ wxT("delta"),948 },
|
||||
{ wxT("diams"),9830 },
|
||||
{ wxT("divide"),247 },
|
||||
{ wxT("eacute"),233 },
|
||||
{ wxT("ecirc"),234 },
|
||||
{ wxT("egrave"),232 },
|
||||
{ wxT("empty"),8709 },
|
||||
{ wxT("emsp"),8195 },
|
||||
{ wxT("ensp"),8194 },
|
||||
{ wxT("epsilon"),949 },
|
||||
{ wxT("equiv"),8801 },
|
||||
{ wxT("eta"),951 },
|
||||
{ wxT("eth"),240 },
|
||||
{ wxT("euml"),235 },
|
||||
{ wxT("euro"),8364 },
|
||||
{ wxT("exist"),8707 },
|
||||
{ wxT("fnof"),402 },
|
||||
{ wxT("forall"),8704 },
|
||||
{ wxT("frac12"),189 },
|
||||
{ wxT("frac14"),188 },
|
||||
{ wxT("frac34"),190 },
|
||||
{ wxT("frasl"),8260 },
|
||||
{ wxT("gamma"),947 },
|
||||
{ wxT("ge"),8805 },
|
||||
{ wxT("gt"),62 },
|
||||
{ wxT("hArr"),8660 },
|
||||
{ wxT("harr"),8596 },
|
||||
{ wxT("hearts"),9829 },
|
||||
{ wxT("hellip"),8230 },
|
||||
{ wxT("iacute"),237 },
|
||||
{ wxT("icirc"),238 },
|
||||
{ wxT("iexcl"),161 },
|
||||
{ wxT("igrave"),236 },
|
||||
{ wxT("image"),8465 },
|
||||
{ wxT("infin"),8734 },
|
||||
{ wxT("int"),8747 },
|
||||
{ wxT("iota"),953 },
|
||||
{ wxT("iquest"),191 },
|
||||
{ wxT("isin"),8712 },
|
||||
{ wxT("iuml"),239 },
|
||||
{ wxT("kappa"),954 },
|
||||
{ wxT("lArr"),8656 },
|
||||
{ wxT("lambda"),955 },
|
||||
{ wxT("lang"),9001 },
|
||||
{ wxT("laquo"),171 },
|
||||
{ wxT("larr"),8592 },
|
||||
{ wxT("lceil"),8968 },
|
||||
{ wxT("ldquo"),8220 },
|
||||
{ wxT("le"),8804 },
|
||||
{ wxT("lfloor"),8970 },
|
||||
{ wxT("lowast"),8727 },
|
||||
{ wxT("loz"),9674 },
|
||||
{ wxT("lrm"),8206 },
|
||||
{ wxT("lsaquo"),8249 },
|
||||
{ wxT("lsquo"),8216 },
|
||||
{ wxT("lt"),60 },
|
||||
{ wxT("macr"),175 },
|
||||
{ wxT("mdash"),8212 },
|
||||
{ wxT("micro"),181 },
|
||||
{ wxT("middot"),183 },
|
||||
{ wxT("minus"),8722 },
|
||||
{ wxT("mu"),956 },
|
||||
{ wxT("nabla"),8711 },
|
||||
{ wxT("nbsp"),160 },
|
||||
{ wxT("ndash"),8211 },
|
||||
{ wxT("ne"),8800 },
|
||||
{ wxT("ni"),8715 },
|
||||
{ wxT("not"),172 },
|
||||
{ wxT("notin"),8713 },
|
||||
{ wxT("nsub"),8836 },
|
||||
{ wxT("ntilde"),241 },
|
||||
{ wxT("nu"),957 },
|
||||
{ wxT("oacute"),243 },
|
||||
{ wxT("ocirc"),244 },
|
||||
{ wxT("oelig"),339 },
|
||||
{ wxT("ograve"),242 },
|
||||
{ wxT("oline"),8254 },
|
||||
{ wxT("omega"),969 },
|
||||
{ wxT("omicron"),959 },
|
||||
{ wxT("oplus"),8853 },
|
||||
{ wxT("or"),8744 },
|
||||
{ wxT("ordf"),170 },
|
||||
{ wxT("ordm"),186 },
|
||||
{ wxT("oslash"),248 },
|
||||
{ wxT("otilde"),245 },
|
||||
{ wxT("otimes"),8855 },
|
||||
{ wxT("ouml"),246 },
|
||||
{ wxT("para"),182 },
|
||||
{ wxT("part"),8706 },
|
||||
{ wxT("permil"),8240 },
|
||||
{ wxT("perp"),8869 },
|
||||
{ wxT("phi"),966 },
|
||||
{ wxT("pi"),960 },
|
||||
{ wxT("piv"),982 },
|
||||
{ wxT("plusmn"),177 },
|
||||
{ wxT("pound"),163 },
|
||||
{ wxT("prime"),8242 },
|
||||
{ wxT("prod"),8719 },
|
||||
{ wxT("prop"),8733 },
|
||||
{ wxT("psi"),968 },
|
||||
{ wxT("quot"),34 },
|
||||
{ wxT("rArr"),8658 },
|
||||
{ wxT("radic"),8730 },
|
||||
{ wxT("rang"),9002 },
|
||||
{ wxT("raquo"),187 },
|
||||
{ wxT("rarr"),8594 },
|
||||
{ wxT("rceil"),8969 },
|
||||
{ wxT("rdquo"),8221 },
|
||||
{ wxT("real"),8476 },
|
||||
{ wxT("reg"),174 },
|
||||
{ wxT("rfloor"),8971 },
|
||||
{ wxT("rho"),961 },
|
||||
{ wxT("rlm"),8207 },
|
||||
{ wxT("rsaquo"),8250 },
|
||||
{ wxT("rsquo"),8217 },
|
||||
{ wxT("sbquo"),8218 },
|
||||
{ wxT("scaron"),353 },
|
||||
{ wxT("sdot"),8901 },
|
||||
{ wxT("sect"),167 },
|
||||
{ wxT("shy"),173 },
|
||||
{ wxT("sigma"),963 },
|
||||
{ wxT("sigmaf"),962 },
|
||||
{ wxT("sim"),8764 },
|
||||
{ wxT("spades"),9824 },
|
||||
{ wxT("sub"),8834 },
|
||||
{ wxT("sube"),8838 },
|
||||
{ wxT("sum"),8721 },
|
||||
{ wxT("sup"),8835 },
|
||||
{ wxT("sup1"),185 },
|
||||
{ wxT("sup2"),178 },
|
||||
{ wxT("sup3"),179 },
|
||||
{ wxT("supe"),8839 },
|
||||
{ wxT("szlig"),223 },
|
||||
{ wxT("tau"),964 },
|
||||
{ wxT("there4"),8756 },
|
||||
{ wxT("theta"),952 },
|
||||
{ wxT("thetasym"),977 },
|
||||
{ wxT("thinsp"),8201 },
|
||||
{ wxT("thorn"),254 },
|
||||
{ wxT("tilde"),732 },
|
||||
{ wxT("times"),215 },
|
||||
{ wxT("trade"),8482 },
|
||||
{ wxT("uArr"),8657 },
|
||||
{ wxT("uacute"),250 },
|
||||
{ wxT("uarr"),8593 },
|
||||
{ wxT("ucirc"),251 },
|
||||
{ wxT("ugrave"),249 },
|
||||
{ wxT("uml"),168 },
|
||||
{ wxT("upsih"),978 },
|
||||
{ wxT("upsilon"),965 },
|
||||
{ wxT("uuml"),252 },
|
||||
{ wxT("weierp"),8472 },
|
||||
{ wxT("xi"),958 },
|
||||
{ wxT("yacute"),253 },
|
||||
{ wxT("yen"),165 },
|
||||
{ wxT("yuml"),255 },
|
||||
{ wxT("zeta"),950 },
|
||||
{ wxT("zwj"),8205 },
|
||||
{ wxT("zwnj"),8204 },
|
||||
{nullptr, 0}};
|
||||
static size_t substitutions_cnt = 0;
|
||||
|
||||
if (substitutions_cnt == 0)
|
||||
while (substitutions[substitutions_cnt].code != 0)
|
||||
substitutions_cnt++;
|
||||
|
||||
wx28HtmlEntityInfo *info = nullptr;
|
||||
info = (wx28HtmlEntityInfo*) bsearch(entity.c_str(), substitutions,
|
||||
substitutions_cnt,
|
||||
sizeof(wx28HtmlEntityInfo),
|
||||
wx28HtmlEntityCompare);
|
||||
if (info)
|
||||
code = info->code;
|
||||
}
|
||||
|
||||
if (code == 0)
|
||||
return 0;
|
||||
else
|
||||
return GetCharForCode(code);
|
||||
}
|
||||
|
||||
wxFSFile *wx28HtmlParser::OpenURL(wx28HtmlURLType WXUNUSED(type),
|
||||
const wxString& url) const
|
||||
{
|
||||
return m_FS ? m_FS->OpenFile(url) : nullptr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlParser::ExtractCharsetInformation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxMetaTagParser : public wx28HtmlParser
|
||||
{
|
||||
public:
|
||||
wxMetaTagParser() { }
|
||||
|
||||
wxObject* GetProduct() { return nullptr; }
|
||||
|
||||
protected:
|
||||
virtual void AddText(const wxChar* WXUNUSED(txt)) {}
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxMetaTagParser);
|
||||
};
|
||||
|
||||
class wxMetaTagHandler : public wx28HtmlTagHandler
|
||||
{
|
||||
public:
|
||||
wxMetaTagHandler(wxString *retval) : wx28HtmlTagHandler(), m_retval(retval) {}
|
||||
wxString GetSupportedTags() { return wxT("META,BODY"); }
|
||||
bool HandleTag(const wx28HtmlTag& tag);
|
||||
|
||||
private:
|
||||
wxString *m_retval;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxMetaTagHandler);
|
||||
};
|
||||
|
||||
bool wxMetaTagHandler::HandleTag(const wx28HtmlTag& tag)
|
||||
{
|
||||
if (tag.GetName() == wxT("BODY"))
|
||||
{
|
||||
m_Parser->StopParsing();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tag.HasParam(wxT("HTTP-EQUIV")) &&
|
||||
tag.GetParam(wxT("HTTP-EQUIV")).IsSameAs(wxT("Content-Type"), false) &&
|
||||
tag.HasParam(wxT("CONTENT")))
|
||||
{
|
||||
wxString content = tag.GetParam(wxT("CONTENT")).Lower();
|
||||
if (content.Left(19) == wxT("text/html; charset="))
|
||||
{
|
||||
*m_retval = content.Mid(19);
|
||||
m_Parser->StopParsing();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
wxString wx28HtmlParser::ExtractCharsetInformation(const wxString& markup)
|
||||
{
|
||||
wxString charset;
|
||||
wxMetaTagParser *parser = new wxMetaTagParser();
|
||||
if(parser)
|
||||
{
|
||||
parser->AddTagHandler(new wxMetaTagHandler(&charset));
|
||||
parser->Parse(markup);
|
||||
delete parser;
|
||||
}
|
||||
return charset;
|
||||
}
|
||||
270
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmlpars.h
Normal file
270
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmlpars.h
Normal file
@@ -0,0 +1,270 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: htmlpars.h
|
||||
// Purpose: wx28HtmlParser class (generic parser)
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_HTMLPARS_H_
|
||||
#define _WX_HTMLPARS_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/filesys.h"
|
||||
#include "wx/hash.h"
|
||||
#include "wx/fontenc.h"
|
||||
|
||||
#include "htmltag.h"
|
||||
|
||||
class wxMBConv;
|
||||
class wx28HtmlParser;
|
||||
class wx28HtmlTagHandler;
|
||||
class wx28HtmlEntitiesParser;
|
||||
|
||||
class wx28HtmlTextPieces;
|
||||
class wx28HtmlParserState;
|
||||
|
||||
|
||||
enum wx28HtmlURLType
|
||||
{
|
||||
wxHTML_URL_PAGE,
|
||||
wxHTML_URL_IMAGE,
|
||||
wxHTML_URL_OTHER
|
||||
};
|
||||
|
||||
// This class handles generic parsing of HTML document : it scans
|
||||
// the document and divides it into blocks of tags (where one block
|
||||
// consists of starting and ending tag and of text between these
|
||||
// 2 tags.
|
||||
class wx28HtmlParser : public wxObject
|
||||
{
|
||||
wxDECLARE_ABSTRACT_CLASS(wx28HtmlParser);
|
||||
|
||||
public:
|
||||
wx28HtmlParser();
|
||||
virtual ~wx28HtmlParser();
|
||||
|
||||
// Sets the class which will be used for opening files
|
||||
void SetFS(wxFileSystem *fs) { m_FS = fs; }
|
||||
|
||||
wxFileSystem* GetFS() const { return m_FS; }
|
||||
|
||||
// Opens file if the parser is allowed to open given URL (may be forbidden
|
||||
// for security reasons)
|
||||
virtual wxFSFile *OpenURL(wx28HtmlURLType type, const wxString& url) const;
|
||||
|
||||
// You can simply call this method when you need parsed output.
|
||||
// This method does these things:
|
||||
// 1. call InitParser(source);
|
||||
// 2. call DoParsing();
|
||||
// 3. call GetProduct(); (its return value is then returned)
|
||||
// 4. call DoneParser();
|
||||
wxObject* Parse(const wxString& source);
|
||||
|
||||
// Sets the source. This must be called before running Parse() method.
|
||||
virtual void InitParser(const wxString& source);
|
||||
// This must be called after Parse().
|
||||
virtual void DoneParser();
|
||||
|
||||
// May be called during parsing to immediately return from Parse().
|
||||
virtual void StopParsing() { m_stopParsing = true; }
|
||||
|
||||
// Parses the m_Source from begin_pos to end_pos-1.
|
||||
// (in noparams version it parses whole m_Source)
|
||||
void DoParsing(int begin_pos, int end_pos);
|
||||
void DoParsing();
|
||||
|
||||
// Returns pointer to the tag at parser's current position
|
||||
wx28HtmlTag *GetCurrentTag() const { return m_CurTag; }
|
||||
|
||||
// Returns product of parsing
|
||||
// Returned value is result of parsing of the part. The type of this result
|
||||
// depends on internal representation in derived parser
|
||||
// (see wx28HtmlWinParser for details).
|
||||
virtual wxObject* GetProduct() = 0;
|
||||
|
||||
// adds handler to the list & hash table of handlers.
|
||||
virtual void AddTagHandler(wx28HtmlTagHandler *handler);
|
||||
|
||||
// Forces the handler to handle additional tags (not returned by GetSupportedTags).
|
||||
// The handler should already be in use by this parser.
|
||||
// Example: you want to parse following pseudo-html structure:
|
||||
// <myitems>
|
||||
// <it name="one" value="1">
|
||||
// <it name="two" value="2">
|
||||
// </myitems>
|
||||
// <it> This last it has different meaning, we don't want it to be parsed by myitems handler!
|
||||
// handler can handle only 'myitems' (e.g. its GetSupportedTags returns "MYITEMS")
|
||||
// you can call PushTagHandler(handler, "IT") when you find <myitems>
|
||||
// and call PopTagHandler() when you find </myitems>
|
||||
void PushTagHandler(wx28HtmlTagHandler *handler, const wxString& tags);
|
||||
|
||||
// Restores state before last call to PushTagHandler
|
||||
void PopTagHandler();
|
||||
|
||||
wxString* GetSource() {return &m_Source;}
|
||||
void SetSource(const wxString& src);
|
||||
|
||||
// Sets HTML source and remembers current parser's state so that it can
|
||||
// later be restored. This is useful for on-line modifications of
|
||||
// HTML source (for example, <pre> handler replaces spaces with
|
||||
// and newlines with <br>)
|
||||
virtual void SetSourceAndSaveState(const wxString& src);
|
||||
// Restores parser's state from stack or returns false if the stack is
|
||||
// empty
|
||||
virtual bool RestoreState();
|
||||
|
||||
// Returns HTML source inside the element (i.e. between the starting
|
||||
// and ending tag)
|
||||
wxString GetInnerSource(const wx28HtmlTag& tag);
|
||||
|
||||
// Parses HTML string 'markup' and extracts charset info from <meta> tag
|
||||
// if present. Returns empty string if the tag is missing.
|
||||
// For wxHTML's internal use.
|
||||
static wxString ExtractCharsetInformation(const wxString& markup);
|
||||
|
||||
// Returns entity parser object, used to substitute HTML &entities;
|
||||
wx28HtmlEntitiesParser *GetEntitiesParser() const { return m_entitiesParser; }
|
||||
|
||||
protected:
|
||||
// DOM structure
|
||||
void CreateDOMTree();
|
||||
void DestroyDOMTree();
|
||||
void CreateDOMSubTree(wx28HtmlTag *cur,
|
||||
int begin_pos, int end_pos,
|
||||
wx28HtmlTagsCache *cache);
|
||||
|
||||
// Adds text to the output.
|
||||
// This is called from Parse() and must be overridden in derived classes.
|
||||
// txt is not guaranteed to be only one word. It is largest continuous part of text
|
||||
// (= not broken by tags)
|
||||
// NOTE : using char* because of speed improvements
|
||||
virtual void AddText(const wxChar* txt) = 0;
|
||||
|
||||
// Adds tag and proceeds it. Parse() may (and usually is) called from this method.
|
||||
// This is called from Parse() and may be overridden.
|
||||
// Default behaviour is that it looks for proper handler in m_Handlers. The tag is
|
||||
// ignored if no hander is found.
|
||||
// Derived class is *responsible* for filling in m_Handlers table.
|
||||
virtual void AddTag(const wx28HtmlTag& tag);
|
||||
|
||||
protected:
|
||||
// DOM tree:
|
||||
wx28HtmlTag *m_CurTag;
|
||||
wx28HtmlTag *m_Tags;
|
||||
wx28HtmlTextPieces *m_TextPieces;
|
||||
size_t m_CurTextPiece;
|
||||
|
||||
wxString m_Source;
|
||||
|
||||
wx28HtmlParserState *m_SavedStates;
|
||||
|
||||
// handlers that handle particular tags. The table is accessed by
|
||||
// key = tag's name.
|
||||
// This attribute MUST be filled by derived class otherwise it would
|
||||
// be empty and no tags would be recognized
|
||||
// (see wx28HtmlWinParser for details about filling it)
|
||||
// m_HandlersHash is for random access based on knowledge of tag name (BR, P, etc.)
|
||||
// it may (and often does) contain more references to one object
|
||||
// m_HandlersList is list of all handlers and it is guaranteed to contain
|
||||
// only one reference to each handler instance.
|
||||
wxList m_HandlersList;
|
||||
wxHashTable m_HandlersHash;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wx28HtmlParser);
|
||||
|
||||
// class for opening files (file system)
|
||||
wxFileSystem *m_FS;
|
||||
// handlers stack used by PushTagHandler and PopTagHandler
|
||||
wxList *m_HandlersStack;
|
||||
|
||||
// entity parse
|
||||
wx28HtmlEntitiesParser *m_entitiesParser;
|
||||
|
||||
// flag indicating that the parser should stop
|
||||
bool m_stopParsing;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// This class (and derived classes) cooperates with wx28HtmlParser.
|
||||
// Each recognized tag is passed to handler which is capable
|
||||
// of handling it. Each tag is handled in 3 steps:
|
||||
// 1. Handler will modifies state of parser
|
||||
// (using its public methods)
|
||||
// 2. Parser parses source between starting and ending tag
|
||||
// 3. Handler restores original state of the parser
|
||||
class wx28HtmlTagHandler : public wxObject
|
||||
{
|
||||
wxDECLARE_ABSTRACT_CLASS(wx28HtmlTagHandler);
|
||||
|
||||
public:
|
||||
wx28HtmlTagHandler() : wxObject () { m_Parser = nullptr; }
|
||||
|
||||
// Sets the parser.
|
||||
// NOTE : each _instance_ of handler is guaranteed to be called
|
||||
// only by one parser. This means you don't have to care about
|
||||
// reentrancy.
|
||||
virtual void SetParser(wx28HtmlParser *parser)
|
||||
{ m_Parser = parser; }
|
||||
|
||||
// Returns list of supported tags. The list is in uppercase and
|
||||
// tags are delimited by ','.
|
||||
// Example : "I,B,FONT,P"
|
||||
// is capable of handling italic, bold, font and paragraph tags
|
||||
virtual wxString GetSupportedTags() = 0;
|
||||
|
||||
// This is hadling core method. It does all the Steps 1-3.
|
||||
// To process step 2, you can call ParseInner()
|
||||
// returned value : true if it called ParseInner(),
|
||||
// false etherwise
|
||||
virtual bool HandleTag(const wx28HtmlTag& tag) = 0;
|
||||
|
||||
protected:
|
||||
// parses input between beginning and ending tag.
|
||||
// m_Parser must be set.
|
||||
void ParseInner(const wx28HtmlTag& tag)
|
||||
{ m_Parser->DoParsing(tag.GetBeginPos(), tag.GetEndPos1()); }
|
||||
|
||||
// Parses given source as if it was tag's inner code (see
|
||||
// wx28HtmlParser::GetInnerSource). Unlike ParseInner(), this method lets
|
||||
// you specify the source code to parse. This is useful when you need to
|
||||
// modify the inner text before parsing.
|
||||
void ParseInnerSource(const wxString& source);
|
||||
|
||||
wx28HtmlParser *m_Parser;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wx28HtmlTagHandler);
|
||||
};
|
||||
|
||||
|
||||
// This class is used to parse HTML entities in strings. It can handle
|
||||
// both named entities and &#xxxx entries where xxxx is Unicode code.
|
||||
class wx28HtmlEntitiesParser : public wxObject
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wx28HtmlEntitiesParser);
|
||||
|
||||
public:
|
||||
wx28HtmlEntitiesParser();
|
||||
virtual ~wx28HtmlEntitiesParser();
|
||||
|
||||
// Sets encoding of output string.
|
||||
// Has no effect any more.
|
||||
void SetEncoding(wxFontEncoding encoding);
|
||||
|
||||
// Parses entities in input and replaces them with respective characters
|
||||
// (with respect to output encoding)
|
||||
wxString Parse(const wxString& input);
|
||||
|
||||
// Returns character for given entity or 0 if the enity is unknown
|
||||
wxChar GetEntityChar(const wxString& entity);
|
||||
|
||||
// Returns character that represents given Unicode code
|
||||
wxChar GetCharForCode(unsigned code) { return (wxChar)code; }
|
||||
|
||||
protected:
|
||||
wxDECLARE_NO_COPY_CLASS(wx28HtmlEntitiesParser);
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_HTMLPARS_H_
|
||||
467
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmltag.cpp
Normal file
467
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmltag.cpp
Normal file
@@ -0,0 +1,467 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/html/htmltag.cpp
|
||||
// Purpose: wx28HtmlTag class (represents single tag)
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
|
||||
#include "htmltag.h"
|
||||
|
||||
#include "htmlpars.h"
|
||||
|
||||
#include "wx/crt.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlTagsCache
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct wx28HtmlCacheItem
|
||||
{
|
||||
// this is "pos" value passed to wx28HtmlTag's constructor.
|
||||
// it is position of '<' character of the tag
|
||||
int Key;
|
||||
|
||||
// end positions for the tag:
|
||||
// end1 is '<' of ending tag,
|
||||
// end2 is '>' or both are
|
||||
// -1 if there is no ending tag for this one...
|
||||
// or -2 if this is ending tag </...>
|
||||
int End1, End2;
|
||||
|
||||
// name of this tag
|
||||
wxChar *Name;
|
||||
};
|
||||
|
||||
|
||||
wxIMPLEMENT_CLASS(wx28HtmlTagsCache,wxObject);
|
||||
|
||||
#define CACHE_INCREMENT 64
|
||||
|
||||
bool wxIsCDATAElement(const wxChar *tag)
|
||||
{
|
||||
return (wxStrcmp(tag, wxT("SCRIPT")) == 0) ||
|
||||
(wxStrcmp(tag, wxT("STYLE")) == 0);
|
||||
}
|
||||
|
||||
wx28HtmlTagsCache::wx28HtmlTagsCache(const wxString& source)
|
||||
{
|
||||
const wxChar *src = source.c_str();
|
||||
int lng = source.length();
|
||||
wxChar tagBuffer[256];
|
||||
|
||||
m_Cache = nullptr;
|
||||
m_CacheSize = 0;
|
||||
m_CachePos = 0;
|
||||
|
||||
int pos = 0;
|
||||
while (pos < lng)
|
||||
{
|
||||
if (src[pos] == wxT('<')) // tag found:
|
||||
{
|
||||
if (m_CacheSize % CACHE_INCREMENT == 0)
|
||||
m_Cache = (wx28HtmlCacheItem*) realloc(m_Cache, (m_CacheSize + CACHE_INCREMENT) * sizeof(wx28HtmlCacheItem));
|
||||
int tg = m_CacheSize++;
|
||||
int stpos = pos++;
|
||||
m_Cache[tg].Key = stpos;
|
||||
|
||||
int i;
|
||||
for ( i = 0;
|
||||
pos < lng && i < (int)WXSIZEOF(tagBuffer) - 1 &&
|
||||
src[pos] != wxT('>') && !wxIsspace(src[pos]);
|
||||
i++, pos++ )
|
||||
{
|
||||
tagBuffer[i] = (wxChar)wxToupper(src[pos]);
|
||||
}
|
||||
tagBuffer[i] = wxT('\0');
|
||||
|
||||
m_Cache[tg].Name = new wxChar[i+1];
|
||||
memcpy(m_Cache[tg].Name, tagBuffer, (i+1)*sizeof(wxChar));
|
||||
|
||||
while (pos < lng && src[pos] != wxT('>')) pos++;
|
||||
|
||||
if (src[stpos+1] == wxT('/')) // ending tag:
|
||||
{
|
||||
m_Cache[tg].End1 = m_Cache[tg].End2 = -2;
|
||||
// find matching begin tag:
|
||||
for (i = tg; i >= 0; i--)
|
||||
if ((m_Cache[i].End1 == -1) && (wxStrcmp(m_Cache[i].Name, tagBuffer+1) == 0))
|
||||
{
|
||||
m_Cache[i].End1 = stpos;
|
||||
m_Cache[i].End2 = pos + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Cache[tg].End1 = m_Cache[tg].End2 = -1;
|
||||
|
||||
if (wxIsCDATAElement(tagBuffer))
|
||||
{
|
||||
// store the orig pos in case we are missing the closing
|
||||
// tag (see below)
|
||||
wxInt32 old_pos = pos;
|
||||
bool foundCloseTag = false;
|
||||
|
||||
// find next matching tag
|
||||
int tag_len = wxStrlen(tagBuffer);
|
||||
while (pos < lng)
|
||||
{
|
||||
// find the ending tag
|
||||
while (pos + 1 < lng &&
|
||||
(src[pos] != '<' || src[pos+1] != '/'))
|
||||
++pos;
|
||||
if (src[pos] == '<')
|
||||
++pos;
|
||||
|
||||
// see if it matches
|
||||
int match_pos = 0;
|
||||
while (pos < lng && match_pos < tag_len && src[pos] != '>' && src[pos] != '<') {
|
||||
// cast to wxChar needed to suppress warning in
|
||||
// Unicode build
|
||||
if ((wxChar)wxToupper(src[pos]) == tagBuffer[match_pos]) {
|
||||
++match_pos;
|
||||
}
|
||||
else if (src[pos] == wxT(' ') || src[pos] == wxT('\n') ||
|
||||
src[pos] == wxT('\r') || src[pos] == wxT('\t')) {
|
||||
// need to skip over these
|
||||
}
|
||||
else {
|
||||
match_pos = 0;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
|
||||
// found a match
|
||||
if (match_pos == tag_len)
|
||||
{
|
||||
pos = pos - tag_len - 3;
|
||||
foundCloseTag = true;
|
||||
break;
|
||||
}
|
||||
else // keep looking for the closing tag
|
||||
{
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
if (!foundCloseTag)
|
||||
{
|
||||
// we didn't find closing tag; this means the markup
|
||||
// is incorrect and the best thing we can do is to
|
||||
// ignore the unclosed tag and continue parsing as if
|
||||
// it didn't exist:
|
||||
pos = old_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
// ok, we're done, now we'll free .Name members of cache - we don't need it anymore:
|
||||
for (int i = 0; i < m_CacheSize; i++)
|
||||
{
|
||||
delete[] m_Cache[i].Name;
|
||||
m_Cache[i].Name = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void wx28HtmlTagsCache::QueryTag(int at, int* end1, int* end2)
|
||||
{
|
||||
if (m_Cache == nullptr) return;
|
||||
if (m_Cache[m_CachePos].Key != at)
|
||||
{
|
||||
int delta = (at < m_Cache[m_CachePos].Key) ? -1 : 1;
|
||||
do
|
||||
{
|
||||
if ( m_CachePos < 0 || m_CachePos == m_CacheSize )
|
||||
{
|
||||
// something is very wrong with HTML, give up by returning an
|
||||
// impossibly large value which is going to be ignored by the
|
||||
// caller
|
||||
*end1 =
|
||||
*end2 = INT_MAX;
|
||||
return;
|
||||
}
|
||||
|
||||
m_CachePos += delta;
|
||||
}
|
||||
while (m_Cache[m_CachePos].Key != at);
|
||||
}
|
||||
*end1 = m_Cache[m_CachePos].End1;
|
||||
*end2 = m_Cache[m_CachePos].End2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlTag
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxIMPLEMENT_CLASS(wx28HtmlTag,wxObject);
|
||||
|
||||
wx28HtmlTag::wx28HtmlTag(wx28HtmlTag *parent,
|
||||
const wxString& source, int pos, int end_pos,
|
||||
wx28HtmlTagsCache *cache,
|
||||
wx28HtmlEntitiesParser *entParser) : wxObject()
|
||||
{
|
||||
/* Setup DOM relations */
|
||||
|
||||
m_Next = nullptr;
|
||||
m_FirstChild = m_LastChild = nullptr;
|
||||
m_Parent = parent;
|
||||
if (parent)
|
||||
{
|
||||
m_Prev = m_Parent->m_LastChild;
|
||||
if (m_Prev == nullptr)
|
||||
m_Parent->m_FirstChild = this;
|
||||
else
|
||||
m_Prev->m_Next = this;
|
||||
m_Parent->m_LastChild = this;
|
||||
}
|
||||
else
|
||||
m_Prev = nullptr;
|
||||
|
||||
/* Find parameters and their values: */
|
||||
|
||||
int i;
|
||||
wxChar c;
|
||||
|
||||
// fill-in name, params and begin pos:
|
||||
i = pos+1;
|
||||
|
||||
// find tag's name and convert it to uppercase:
|
||||
while ((i < end_pos) &&
|
||||
((c = source[i++]) != wxT(' ') && c != wxT('\r') &&
|
||||
c != wxT('\n') && c != wxT('\t') &&
|
||||
c != wxT('>')))
|
||||
{
|
||||
if ((c >= wxT('a')) && (c <= wxT('z')))
|
||||
c -= (wxT('a') - wxT('A'));
|
||||
m_Name << c;
|
||||
}
|
||||
|
||||
// if the tag has parameters, read them and "normalize" them,
|
||||
// i.e. convert to uppercase, replace whitespaces by spaces and
|
||||
// remove whitespaces around '=':
|
||||
if (source[i-1] != wxT('>'))
|
||||
{
|
||||
#define IS_WHITE(c) (c == wxT(' ') || c == wxT('\r') || \
|
||||
c == wxT('\n') || c == wxT('\t'))
|
||||
wxString pname, pvalue;
|
||||
wxChar quote;
|
||||
enum
|
||||
{
|
||||
ST_BEFORE_NAME = 1,
|
||||
ST_NAME,
|
||||
ST_BEFORE_EQ,
|
||||
ST_BEFORE_VALUE,
|
||||
ST_VALUE
|
||||
} state;
|
||||
|
||||
quote = 0;
|
||||
state = ST_BEFORE_NAME;
|
||||
while (i < end_pos)
|
||||
{
|
||||
c = source[i++];
|
||||
|
||||
if (c == wxT('>') && !(state == ST_VALUE && quote != 0))
|
||||
{
|
||||
if (state == ST_BEFORE_EQ || state == ST_NAME)
|
||||
{
|
||||
m_ParamNames.Add(pname);
|
||||
m_ParamValues.Add(wxEmptyString);
|
||||
}
|
||||
else if (state == ST_VALUE && quote == 0)
|
||||
{
|
||||
m_ParamNames.Add(pname);
|
||||
if (entParser)
|
||||
m_ParamValues.Add(entParser->Parse(pvalue));
|
||||
else
|
||||
m_ParamValues.Add(pvalue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case ST_BEFORE_NAME:
|
||||
if (!IS_WHITE(c))
|
||||
{
|
||||
pname = c;
|
||||
state = ST_NAME;
|
||||
}
|
||||
break;
|
||||
case ST_NAME:
|
||||
if (IS_WHITE(c))
|
||||
state = ST_BEFORE_EQ;
|
||||
else if (c == wxT('='))
|
||||
state = ST_BEFORE_VALUE;
|
||||
else
|
||||
pname << c;
|
||||
break;
|
||||
case ST_BEFORE_EQ:
|
||||
if (c == wxT('='))
|
||||
state = ST_BEFORE_VALUE;
|
||||
else if (!IS_WHITE(c))
|
||||
{
|
||||
m_ParamNames.Add(pname);
|
||||
m_ParamValues.Add(wxEmptyString);
|
||||
pname = c;
|
||||
state = ST_NAME;
|
||||
}
|
||||
break;
|
||||
case ST_BEFORE_VALUE:
|
||||
if (!IS_WHITE(c))
|
||||
{
|
||||
if (c == wxT('"') || c == wxT('\''))
|
||||
quote = c, pvalue = wxEmptyString;
|
||||
else
|
||||
quote = 0, pvalue = c;
|
||||
state = ST_VALUE;
|
||||
}
|
||||
break;
|
||||
case ST_VALUE:
|
||||
if ((quote != 0 && c == quote) ||
|
||||
(quote == 0 && IS_WHITE(c)))
|
||||
{
|
||||
m_ParamNames.Add(pname);
|
||||
if (quote == 0)
|
||||
{
|
||||
// VS: backward compatibility, no real reason,
|
||||
// but wxHTML code relies on this... :(
|
||||
pvalue.MakeUpper();
|
||||
}
|
||||
if (entParser)
|
||||
m_ParamValues.Add(entParser->Parse(pvalue));
|
||||
else
|
||||
m_ParamValues.Add(pvalue);
|
||||
state = ST_BEFORE_NAME;
|
||||
}
|
||||
else
|
||||
pvalue << c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#undef IS_WHITE
|
||||
}
|
||||
m_Begin = i;
|
||||
|
||||
cache->QueryTag(pos, &m_End1, &m_End2);
|
||||
if (m_End1 > end_pos) m_End1 = end_pos;
|
||||
if (m_End2 > end_pos) m_End2 = end_pos;
|
||||
}
|
||||
|
||||
wx28HtmlTag::~wx28HtmlTag()
|
||||
{
|
||||
wx28HtmlTag *t1, *t2;
|
||||
t1 = m_FirstChild;
|
||||
while (t1)
|
||||
{
|
||||
t2 = t1->GetNextSibling();
|
||||
delete t1;
|
||||
t1 = t2;
|
||||
}
|
||||
}
|
||||
|
||||
bool wx28HtmlTag::HasParam(const wxString& par) const
|
||||
{
|
||||
return (m_ParamNames.Index(par, false) != wxNOT_FOUND);
|
||||
}
|
||||
|
||||
wxString wx28HtmlTag::GetParam(const wxString& par, bool with_commas) const
|
||||
{
|
||||
int index = m_ParamNames.Index(par, false);
|
||||
if (index == wxNOT_FOUND)
|
||||
return wxEmptyString;
|
||||
if (with_commas)
|
||||
{
|
||||
// VS: backward compatibility, seems to be never used by wxHTML...
|
||||
wxString s;
|
||||
s << wxT('"') << m_ParamValues[index] << wxT('"');
|
||||
return s;
|
||||
}
|
||||
else
|
||||
return m_ParamValues[index];
|
||||
}
|
||||
|
||||
int wx28HtmlTag::ScanParam(const wxString& par,
|
||||
const wxChar *format,
|
||||
void *param) const
|
||||
{
|
||||
wxString parval = GetParam(par);
|
||||
return wxSscanf(parval, format, param);
|
||||
}
|
||||
|
||||
bool wx28HtmlTag::GetParamAsInt(const wxString& par, int *clr) const
|
||||
{
|
||||
if ( !HasParam(par) )
|
||||
return false;
|
||||
|
||||
long i;
|
||||
if ( !GetParam(par).ToLong(&i) )
|
||||
return false;
|
||||
|
||||
*clr = (int)i;
|
||||
return true;
|
||||
}
|
||||
|
||||
wxString wx28HtmlTag::GetAllParams() const
|
||||
{
|
||||
// VS: this function is for backward compatibility only,
|
||||
// never used by wxHTML
|
||||
wxString s;
|
||||
size_t cnt = m_ParamNames.GetCount();
|
||||
for (size_t i = 0; i < cnt; i++)
|
||||
{
|
||||
s << m_ParamNames[i];
|
||||
s << wxT('=');
|
||||
if (m_ParamValues[i].Find(wxT('"')) != wxNOT_FOUND)
|
||||
s << wxT('\'') << m_ParamValues[i] << wxT('\'');
|
||||
else
|
||||
s << wxT('"') << m_ParamValues[i] << wxT('"');
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
wx28HtmlTag *wx28HtmlTag::GetFirstSibling() const
|
||||
{
|
||||
if (m_Parent)
|
||||
return m_Parent->m_FirstChild;
|
||||
else
|
||||
{
|
||||
wx28HtmlTag *cur = (wx28HtmlTag*)this;
|
||||
while (cur->m_Prev)
|
||||
cur = cur->m_Prev;
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
wx28HtmlTag *wx28HtmlTag::GetLastSibling() const
|
||||
{
|
||||
if (m_Parent)
|
||||
return m_Parent->m_LastChild;
|
||||
else
|
||||
{
|
||||
wx28HtmlTag *cur = (wx28HtmlTag*)this;
|
||||
while (cur->m_Next)
|
||||
cur = cur->m_Next;
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
wx28HtmlTag *wx28HtmlTag::GetNextTag() const
|
||||
{
|
||||
if (m_FirstChild) return m_FirstChild;
|
||||
if (m_Next) return m_Next;
|
||||
wx28HtmlTag *cur = m_Parent;
|
||||
if (!cur) return nullptr;
|
||||
while (cur->m_Parent && !cur->m_Next)
|
||||
cur = cur->m_Parent;
|
||||
return cur->m_Next;
|
||||
}
|
||||
138
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmltag.h
Normal file
138
libs/wxWidgets-3.3.1/tests/benchmarks/htmlparser/htmltag.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: htmltag.h
|
||||
// Purpose: wx28HtmlTag class (represents single tag)
|
||||
// Author: Vaclav Slavik
|
||||
// Copyright: (c) 1999 Vaclav Slavik
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_HTMLTAG_H_
|
||||
#define _WX_HTMLTAG_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/arrstr.h"
|
||||
|
||||
class wx28HtmlEntitiesParser;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wx28HtmlTagsCache
|
||||
// - internal wxHTML class, do not use!
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct wx28HtmlCacheItem;
|
||||
|
||||
class wx28HtmlTagsCache : public wxObject
|
||||
{
|
||||
wxDECLARE_DYNAMIC_CLASS(wx28HtmlTagsCache);
|
||||
|
||||
private:
|
||||
wx28HtmlCacheItem *m_Cache;
|
||||
int m_CacheSize;
|
||||
int m_CachePos;
|
||||
|
||||
public:
|
||||
wx28HtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = nullptr;}
|
||||
wx28HtmlTagsCache(const wxString& source);
|
||||
virtual ~wx28HtmlTagsCache() {free(m_Cache);}
|
||||
|
||||
// Finds parameters for tag starting at at and fills the variables
|
||||
void QueryTag(int at, int* end1, int* end2);
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wx28HtmlTagsCache);
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wx28HtmlTag
|
||||
// This represents single tag. It is used as internal structure
|
||||
// by wx28HtmlParser.
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
class wx28HtmlTag : public wxObject
|
||||
{
|
||||
wxDECLARE_CLASS(wx28HtmlTag);
|
||||
|
||||
protected:
|
||||
// constructs wx28HtmlTag object based on HTML tag.
|
||||
// The tag begins (with '<' character) at position pos in source
|
||||
// end_pos is position where parsing ends (usually end of document)
|
||||
wx28HtmlTag(wx28HtmlTag *parent,
|
||||
const wxString& source, int pos, int end_pos,
|
||||
wx28HtmlTagsCache *cache,
|
||||
wx28HtmlEntitiesParser *entParser);
|
||||
friend class wx28HtmlParser;
|
||||
public:
|
||||
virtual ~wx28HtmlTag();
|
||||
|
||||
wx28HtmlTag *GetParent() const {return m_Parent;}
|
||||
wx28HtmlTag *GetFirstSibling() const;
|
||||
wx28HtmlTag *GetLastSibling() const;
|
||||
wx28HtmlTag *GetChildren() const { return m_FirstChild; }
|
||||
wx28HtmlTag *GetPreviousSibling() const { return m_Prev; }
|
||||
wx28HtmlTag *GetNextSibling() const {return m_Next; }
|
||||
// Return next tag, as if tree had been flattened
|
||||
wx28HtmlTag *GetNextTag() const;
|
||||
|
||||
// Returns tag's name in uppercase.
|
||||
inline wxString GetName() const {return m_Name;}
|
||||
|
||||
// Returns true if the tag has given parameter. Parameter
|
||||
// should always be in uppercase.
|
||||
// Example : <IMG SRC="test.jpg"> HasParam("SRC") returns true
|
||||
bool HasParam(const wxString& par) const;
|
||||
|
||||
// Returns value of the param. Value is in uppercase unless it is
|
||||
// enclosed with "
|
||||
// Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
|
||||
// <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
|
||||
// (or ("WhaT.jpg") if with_commas == true)
|
||||
wxString GetParam(const wxString& par, bool with_commas = false) const;
|
||||
|
||||
bool GetParamAsInt(const wxString& par, int *clr) const;
|
||||
|
||||
// Scans param like scanf() functions family does.
|
||||
// Example : ScanParam("COLOR", "\"#%X\"", &clr);
|
||||
// This is always with with_commas=false
|
||||
// Returns number of scanned values
|
||||
// (like sscanf() does)
|
||||
// NOTE: unlike scanf family, this function only accepts
|
||||
// *one* parameter !
|
||||
int ScanParam(const wxString& par, const wxChar *format, void *param) const;
|
||||
|
||||
// Returns string containing all params.
|
||||
wxString GetAllParams() const;
|
||||
|
||||
// return true if this there is matching ending tag
|
||||
inline bool HasEnding() const {return m_End1 >= 0;}
|
||||
|
||||
// returns beginning position of _internal_ block of text
|
||||
// See explanation (returned value is marked with *):
|
||||
// bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
|
||||
inline int GetBeginPos() const {return m_Begin;}
|
||||
// returns ending position of _internal_ block of text.
|
||||
// bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
|
||||
inline int GetEndPos1() const {return m_End1;}
|
||||
// returns end position 2 :
|
||||
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
|
||||
inline int GetEndPos2() const {return m_End2;}
|
||||
|
||||
private:
|
||||
wxString m_Name;
|
||||
int m_Begin, m_End1, m_End2;
|
||||
wxArrayString m_ParamNames, m_ParamValues;
|
||||
|
||||
// DOM tree relations:
|
||||
wx28HtmlTag *m_Next;
|
||||
wx28HtmlTag *m_Prev;
|
||||
wx28HtmlTag *m_FirstChild, *m_LastChild;
|
||||
wx28HtmlTag *m_Parent;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wx28HtmlTag);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _WX_HTMLTAG_H_
|
||||
|
||||
192
libs/wxWidgets-3.3.1/tests/benchmarks/htmltest.html
Normal file
192
libs/wxWidgets-3.3.1/tests/benchmarks/htmltest.html
Normal file
@@ -0,0 +1,192 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i686) [Netscape]">
|
||||
</HEAD>
|
||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
|
||||
|
||||
<H3>
|
||||
This is TABLES
|
||||
tests page...</H3>
|
||||
|
||||
|
||||
(yes, really, see below:)
|
||||
<BR>Click <a href="test.htm">here</a> to go to original testing page...
|
||||
<BR>Click <a href="../../docs/html/man.htm">here</a> to go to manuals...
|
||||
<BR>
|
||||
<CENTER><TABLE CELLSPACING=5 BORDER COLS=2 WIDTH="40%" NOSAVE >
|
||||
<TR ALIGN=CENTER NOSAVE>
|
||||
<TD WIDTH="40%" NOSAVE>Top left
|
||||
<BR>(two lines expression)
|
||||
<P>paragraph done</TD>
|
||||
|
||||
<TD NOSAVE>Top right</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD>Bottom left</TD>
|
||||
|
||||
<TD>Bottom right</TD>
|
||||
</TR>
|
||||
</TABLE></CENTER>
|
||||
|
||||
<P>Subsampling is shown there:
|
||||
<BR>
|
||||
<TABLE BORDER COLS=2 WIDTH="100%" NOSAVE >
|
||||
<TR NOSAVE>
|
||||
<TD VALIGN=BOTTOM NOSAVE>
|
||||
<TABLE BORDER COLS=2 WIDTH="50%" NOSAVE >
|
||||
<TR ALIGN=CENTER BGCOLOR="#3366FF" NOSAVE>
|
||||
<TD>a</TD>
|
||||
|
||||
<TD WIDTH="10%" NOSAVE>b</TD>
|
||||
</TR>
|
||||
|
||||
<TR NOSAVE>
|
||||
<TD>c</TD>
|
||||
|
||||
<TD NOSAVE>d</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
</TD>
|
||||
|
||||
<TD VALIGN=BOTTOM NOSAVE>2</TD>
|
||||
</TR>
|
||||
|
||||
<TR NOSAVE>
|
||||
<TD>3 dflkj lkjfl dkjldkfjl flk jflkf lkjflkj ljlf ajlfj alff h khg hgj
|
||||
gjg jg gjhfg fg gjh gjf jgf jgj f gjfgj kfajg </TD>
|
||||
|
||||
<TD ALIGN=CENTER VALIGN=BOTTOM BGCOLOR="#FFFF99" NOSAVE>4
|
||||
<BR>gh
|
||||
<BR>gfh
|
||||
<BR>gh
|
||||
<BR>hg
|
||||
<BR>5</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<P>This is "default" table - with no sizes givev:
|
||||
<BR>
|
||||
<TABLE BORDER COLS=4 WIDTH="100%" NOSAVE >
|
||||
<TR NOSAVE>
|
||||
<TD>Hello</TD>
|
||||
|
||||
<TD NOSAVE>lkfdsjlk fj dlfj lkfj lkjflk jlfk lk fjlk elwkf lkejflek f jlekjflkj
|
||||
ljlk lk jlkf lefjl j flkj ljl lf lfj lfjl lj lwe lekf;eh kfejh lkh kjh
|
||||
kjhkj hkj hkj lkh kjh kjlh kj</TD>
|
||||
|
||||
<TD>shortebn formo lr lk</TD>
|
||||
|
||||
<TD>djsf lkjlf poer oi pjr po kpk </TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD>a</TD>
|
||||
|
||||
<TD>b</TD>
|
||||
|
||||
<TD>c</TD>
|
||||
|
||||
<TD>d</TD>
|
||||
</TR>
|
||||
|
||||
<TR NOSAVE>
|
||||
<TD>1</TD>
|
||||
|
||||
<TD>2</TD>
|
||||
|
||||
<TD COLSPAN="2" ROWSPAN="2" NOSAVE>3</TD>
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD>A</TD>
|
||||
|
||||
<TD>B</Td>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<hr size="8"/>
|
||||
|
||||
|
||||
|
||||
<table cellspacing='0' cellpadding='0'>
|
||||
<tr align='left'>
|
||||
<td width="30%" valign='top'>Error:</td>
|
||||
<td width='5'></td>
|
||||
<td>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
|
||||
</tr>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Command:</td>
|
||||
<td width='5'></td>
|
||||
<td>Go out and spread the word, <b>we shall prevail!</b></td><td>X</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<table cellspacing='0' cellpadding='0'>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Error:</td>
|
||||
<td width='5'></td>
|
||||
<td>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
|
||||
</tr>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Command:</td>
|
||||
<td width='5'></td>
|
||||
<td>Go out and spread the word, <b>we shall prevail!</b></td><td>X</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<table width="200" cellspacing='0' cellpadding='0'>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Error:</td>
|
||||
<td width='5'></td>
|
||||
<td nowrap>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
|
||||
</tr>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Command:</td>
|
||||
<td width='5'></td>
|
||||
<td>Go out and spread the word, <b>we shall prevail!</b></td><td>X</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<table cellspacing='0' cellpadding='0'>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Error:</td>
|
||||
<td width='5'></td>
|
||||
<td>
|
||||
<table cellspacing='0' cellpadding='0'>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Error:</td>
|
||||
<td width='5'></td>
|
||||
<td>Sex sells better than <b>truth and honour</b></td><td align='right'>X For President is my agenda!</td>
|
||||
</tr>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Command:</td>
|
||||
<td width='5'></td>
|
||||
<td>Go out and spread the word, <b>we shall prevail!</b></td>
|
||||
<td>X</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td align='right'>X For President is my agenda!</td>
|
||||
</tr>
|
||||
<tr align='left'>
|
||||
<td valign='top'>Command:</td>
|
||||
<td width='5'></td>
|
||||
<td>Go out and spread the word, <b>we shall prevail!</b></td>
|
||||
<td>X</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<table cellspacing='0' cellpadding='0'>
|
||||
<tr>
|
||||
<td><ul><li>Just a small test</li></ul></td>
|
||||
<td>Really, a test!</td>
|
||||
</tr>
|
||||
</table>
|
||||
120
libs/wxWidgets-3.3.1/tests/benchmarks/image.cpp
Normal file
120
libs/wxWidgets-3.3.1/tests/benchmarks/image.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/image.cpp
|
||||
// Purpose: wxImage benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2013-06-30
|
||||
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/image.h"
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
BENCHMARK_FUNC(LoadBMP)
|
||||
{
|
||||
wxImage image;
|
||||
return image.LoadFile("horse.bmp");
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(LoadJPEG)
|
||||
{
|
||||
static bool s_handlerAdded = false;
|
||||
if ( !s_handlerAdded )
|
||||
{
|
||||
s_handlerAdded = true;
|
||||
wxImage::AddHandler(new wxJPEGHandler);
|
||||
}
|
||||
|
||||
wxImage image;
|
||||
return image.LoadFile("horse.jpg");
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(LoadPNG)
|
||||
{
|
||||
static bool s_handlerAdded = false;
|
||||
if ( !s_handlerAdded )
|
||||
{
|
||||
s_handlerAdded = true;
|
||||
wxImage::AddHandler(new wxPNGHandler);
|
||||
}
|
||||
|
||||
wxImage image;
|
||||
return image.LoadFile("horse.png");
|
||||
}
|
||||
|
||||
#if wxUSE_LIBTIFF
|
||||
BENCHMARK_FUNC(LoadTIFF)
|
||||
{
|
||||
static bool s_handlerAdded = false;
|
||||
if ( !s_handlerAdded )
|
||||
{
|
||||
s_handlerAdded = true;
|
||||
wxImage::AddHandler(new wxTIFFHandler);
|
||||
}
|
||||
|
||||
wxImage image;
|
||||
return image.LoadFile("horse.tif");
|
||||
}
|
||||
#endif // wxUSE_LIBTIFF
|
||||
|
||||
static const wxImage& GetTestImage()
|
||||
{
|
||||
static wxImage s_image;
|
||||
static bool s_triedToLoad = false;
|
||||
if ( !s_triedToLoad )
|
||||
{
|
||||
s_triedToLoad = true;
|
||||
s_image.LoadFile(Bench::GetStringParameter("horse.bmp"));
|
||||
}
|
||||
|
||||
return s_image;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(EnlargeNormal)
|
||||
{
|
||||
const wxImage& image = GetTestImage();
|
||||
const double factor = Bench::GetNumericParameter(150) / 100.;
|
||||
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
|
||||
wxIMAGE_QUALITY_NORMAL).IsOk();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(EnlargeBoxAverage)
|
||||
{
|
||||
const wxImage& image = GetTestImage();
|
||||
const double factor = Bench::GetNumericParameter(150) / 100.;
|
||||
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
|
||||
wxIMAGE_QUALITY_BOX_AVERAGE).IsOk();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(EnlargeHighQuality)
|
||||
{
|
||||
const wxImage& image = GetTestImage();
|
||||
const double factor = Bench::GetNumericParameter(150) / 100.;
|
||||
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
|
||||
wxIMAGE_QUALITY_HIGH).IsOk();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ShrinkNormal)
|
||||
{
|
||||
const wxImage& image = GetTestImage();
|
||||
const double factor = Bench::GetNumericParameter(50) / 100.;
|
||||
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
|
||||
wxIMAGE_QUALITY_NORMAL).IsOk();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ShrinkBoxAverage)
|
||||
{
|
||||
const wxImage& image = GetTestImage();
|
||||
const double factor = Bench::GetNumericParameter(50) / 100.;
|
||||
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
|
||||
wxIMAGE_QUALITY_BOX_AVERAGE).IsOk();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ShrinkHighQuality)
|
||||
{
|
||||
const wxImage& image = GetTestImage();
|
||||
const double factor = Bench::GetNumericParameter(50) / 100.;
|
||||
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
|
||||
wxIMAGE_QUALITY_HIGH).IsOk();
|
||||
}
|
||||
169
libs/wxWidgets-3.3.1/tests/benchmarks/ipcclient.cpp
Normal file
169
libs/wxWidgets-3.3.1/tests/benchmarks/ipcclient.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/ipcclient.cpp
|
||||
// Purpose: wxIPC client side benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-10-13
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
// do this before including wx/ipc.h under Windows to use TCP even there
|
||||
#define wxUSE_DDE_FOR_IPC 0
|
||||
#include "wx/ipc.h"
|
||||
#include "../../samples/ipc/ipcsetup.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class PokeAdviseConn : public wxConnection
|
||||
{
|
||||
public:
|
||||
PokeAdviseConn() { m_gotAdvised = false; }
|
||||
|
||||
bool GotAdvised()
|
||||
{
|
||||
if ( !m_gotAdvised )
|
||||
return false;
|
||||
|
||||
m_gotAdvised = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const wxString& GetItem() const { return m_item; }
|
||||
|
||||
virtual bool OnAdvise(const wxString& topic,
|
||||
const wxString& item,
|
||||
const void *data,
|
||||
size_t size,
|
||||
wxIPCFormat format)
|
||||
{
|
||||
m_gotAdvised = true;
|
||||
|
||||
if ( topic != IPC_BENCHMARK_TOPIC ||
|
||||
item != IPC_BENCHMARK_ITEM ||
|
||||
!IsTextFormat(format) )
|
||||
{
|
||||
m_item = "ERROR";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_item = GetTextFromData(data, size, format);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
wxString m_item;
|
||||
bool m_gotAdvised;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(PokeAdviseConn);
|
||||
};
|
||||
|
||||
class PokeAdviseClient : public wxClient
|
||||
{
|
||||
public:
|
||||
// provide a convenient helper taking care of connecting to the right
|
||||
// server/service/topic and returning the connection of the derived type
|
||||
// (or nullptr if we failed to connect)
|
||||
PokeAdviseConn *Connect()
|
||||
{
|
||||
wxString host = Bench::GetStringParameter();
|
||||
if ( host.empty() )
|
||||
host = IPC_HOST;
|
||||
|
||||
wxString service;
|
||||
int port = Bench::GetNumericParameter();
|
||||
if ( !port )
|
||||
service = IPC_SERVICE;
|
||||
else
|
||||
service.Printf("%d", port);
|
||||
|
||||
return static_cast<PokeAdviseConn *>(
|
||||
MakeConnection(host, service, IPC_BENCHMARK_TOPIC));
|
||||
}
|
||||
|
||||
|
||||
// override base class virtual to use a custom connection class
|
||||
virtual wxConnectionBase *OnMakeConnection()
|
||||
{
|
||||
return new PokeAdviseConn;
|
||||
}
|
||||
};
|
||||
|
||||
class PokeAdvisePersistentConnection
|
||||
{
|
||||
public:
|
||||
PokeAdvisePersistentConnection()
|
||||
{
|
||||
m_client = new PokeAdviseClient;
|
||||
m_conn = m_client->Connect();
|
||||
if ( m_conn )
|
||||
m_conn->StartAdvise(IPC_BENCHMARK_ITEM);
|
||||
}
|
||||
|
||||
~PokeAdvisePersistentConnection()
|
||||
{
|
||||
if ( m_conn )
|
||||
{
|
||||
m_conn->StopAdvise(IPC_BENCHMARK_ITEM);
|
||||
m_conn->Disconnect();
|
||||
}
|
||||
|
||||
delete m_client;
|
||||
}
|
||||
|
||||
PokeAdviseConn *Get() const { return m_conn; }
|
||||
|
||||
private:
|
||||
PokeAdviseClient *m_client;
|
||||
PokeAdviseConn *m_conn;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(PokeAdvisePersistentConnection);
|
||||
};
|
||||
|
||||
PokeAdvisePersistentConnection *theConnection = nullptr;
|
||||
|
||||
bool ConnInit()
|
||||
{
|
||||
theConnection = new PokeAdvisePersistentConnection;
|
||||
if ( !theConnection->Get() )
|
||||
{
|
||||
delete theConnection;
|
||||
theConnection = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConnDone()
|
||||
{
|
||||
delete theConnection;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
BENCHMARK_FUNC_WITH_INIT(IPCPokeAdvise, ConnInit, ConnDone)
|
||||
{
|
||||
wxEventLoop loop;
|
||||
|
||||
PokeAdviseConn * const conn = theConnection->Get();
|
||||
|
||||
const wxString s(1024, '@');
|
||||
|
||||
if ( !conn->Poke(IPC_BENCHMARK_ITEM, s) )
|
||||
return false;
|
||||
|
||||
while ( !conn->GotAdvised() )
|
||||
loop.Dispatch();
|
||||
|
||||
if ( conn->GetItem() != s )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
108
libs/wxWidgets-3.3.1/tests/benchmarks/log.cpp
Normal file
108
libs/wxWidgets-3.3.1/tests/benchmarks/log.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/log.cpp
|
||||
// Purpose: Log-related benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2012-01-21
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
#include "wx/log.h"
|
||||
|
||||
// This class is used to check that the arguments of log functions are not
|
||||
// evaluated.
|
||||
struct NotCreated
|
||||
{
|
||||
NotCreated() { wxAbort(); }
|
||||
|
||||
const char* AsStr() const { return "unreachable"; }
|
||||
};
|
||||
|
||||
// Temporarily change the log level to the given one.
|
||||
class LogLevelSetter
|
||||
{
|
||||
public:
|
||||
LogLevelSetter(wxLogLevel levelNew)
|
||||
: m_levelOld(wxLog::GetLogLevel())
|
||||
{
|
||||
wxLog::SetLogLevel(levelNew);
|
||||
}
|
||||
|
||||
~LogLevelSetter()
|
||||
{
|
||||
wxLog::SetLogLevel(m_levelOld);
|
||||
}
|
||||
|
||||
private:
|
||||
const wxLogLevel m_levelOld;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(LogLevelSetter);
|
||||
};
|
||||
|
||||
BENCHMARK_FUNC(LogDebugDisabled)
|
||||
{
|
||||
LogLevelSetter level(wxLOG_Info);
|
||||
|
||||
wxLogDebug("Ignored debug message: %s", NotCreated().AsStr());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(LogTraceDisabled)
|
||||
{
|
||||
LogLevelSetter level(wxLOG_Info);
|
||||
|
||||
wxLogTrace("", NotCreated().AsStr());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(LogTraceActive)
|
||||
{
|
||||
static bool s_added = false;
|
||||
if ( !s_added )
|
||||
{
|
||||
s_added = true;
|
||||
wxLog::AddTraceMask("logbench");
|
||||
}
|
||||
|
||||
// Remove the actual logging overhead by simply throwing away the log
|
||||
// messages.
|
||||
class NulLog : public wxLog
|
||||
{
|
||||
public:
|
||||
NulLog()
|
||||
: m_logOld(wxLog::SetActiveTarget(this))
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~NulLog()
|
||||
{
|
||||
wxLog::SetActiveTarget(m_logOld);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void DoLogRecord(wxLogLevel,
|
||||
const wxString&,
|
||||
const wxLogRecordInfo&)
|
||||
{
|
||||
}
|
||||
|
||||
wxLog* m_logOld;
|
||||
};
|
||||
|
||||
NulLog nulLog;
|
||||
|
||||
wxLogTrace("logbench", "Trace message");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(LogTraceInactive)
|
||||
{
|
||||
wxLogTrace("bloordyblop", "Trace message");
|
||||
|
||||
return true;
|
||||
}
|
||||
346
libs/wxWidgets-3.3.1/tests/benchmarks/makefile.gcc
Normal file
346
libs/wxWidgets-3.3.1/tests/benchmarks/makefile.gcc
Normal file
@@ -0,0 +1,346 @@
|
||||
# =========================================================================
|
||||
# This makefile was generated by
|
||||
# Bakefile 0.2.13 (http://www.bakefile.org)
|
||||
# Do not modify, all changes will be overwritten!
|
||||
# =========================================================================
|
||||
|
||||
include ../../build/msw/config.gcc
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Do not modify the rest of this file!
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
### Variables: ###
|
||||
|
||||
CPPDEPS = -MT$@ -MF$@.d -MD -MP
|
||||
WX_RELEASE_NODOT = 33
|
||||
COMPILER_PREFIX = gcc
|
||||
OBJS = \
|
||||
$(COMPILER_PREFIX)$(COMPILER_VERSION)_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WXDLLFLAG)$(CFG)
|
||||
LIBDIRNAME = \
|
||||
.\..\..\lib\$(COMPILER_PREFIX)$(COMPILER_VERSION)_$(LIBTYPE_SUFFIX)$(CFG)
|
||||
SETUPHDIR = $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)
|
||||
BENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) -D__WXMSW__ \
|
||||
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
|
||||
-I$(SETUPHDIR) -I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -W -Wall \
|
||||
-I. $(__DLLFLAG_p) -DwxUSE_GUI=0 $(__RTTIFLAG) $(__EXCEPTIONSFLAG) \
|
||||
-Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_OBJECTS = \
|
||||
$(OBJS)\bench_bench.o \
|
||||
$(OBJS)\bench_datetime.o \
|
||||
$(OBJS)\bench_htmlpars.o \
|
||||
$(OBJS)\bench_htmltag.o \
|
||||
$(OBJS)\bench_ipcclient.o \
|
||||
$(OBJS)\bench_log.o \
|
||||
$(OBJS)\bench_mbconv.o \
|
||||
$(OBJS)\bench_regex.o \
|
||||
$(OBJS)\bench_strings.o \
|
||||
$(OBJS)\bench_tls.o \
|
||||
$(OBJS)\bench_printfbench.o
|
||||
BENCH_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
|
||||
-D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
|
||||
-I$(SETUPHDIR) -I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -W -Wall \
|
||||
-I. $(__DLLFLAG_p) -I.\..\..\samples -DNOPCH $(__RTTIFLAG) \
|
||||
$(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_GUI_OBJECTS = \
|
||||
$(OBJS)\bench_gui_sample_rc.o \
|
||||
$(OBJS)\bench_gui_bench.o \
|
||||
$(OBJS)\bench_gui_display.o \
|
||||
$(OBJS)\bench_gui_image.o
|
||||
BENCH_GRAPHICS_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
|
||||
-D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
|
||||
-I$(SETUPHDIR) -I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -W -Wall \
|
||||
-I. $(__DLLFLAG_p) -I.\..\..\samples -DNOPCH $(__RTTIFLAG) \
|
||||
$(__EXCEPTIONSFLAG) -Wno-ctor-dtor-privacy $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_GRAPHICS_OBJECTS = \
|
||||
$(OBJS)\bench_graphics_sample_rc.o \
|
||||
$(OBJS)\bench_graphics_graphics.o
|
||||
|
||||
### Conditionally set variables: ###
|
||||
|
||||
ifeq ($(USE_GUI),0)
|
||||
PORTNAME = base
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
PORTNAME = msw$(TOOLKIT_VERSION)
|
||||
endif
|
||||
ifeq ($(OFFICIAL_BUILD),1)
|
||||
COMPILER_VERSION = ERROR-COMPILER-VERSION-MUST-BE-SET-FOR-OFFICIAL-BUILD
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
WXDEBUGFLAG = d
|
||||
endif
|
||||
ifeq ($(WXUNIV),1)
|
||||
WXUNIVNAME = univ
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
WXDLLFLAG = dll
|
||||
endif
|
||||
ifeq ($(SHARED),0)
|
||||
LIBTYPE_SUFFIX = lib
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
LIBTYPE_SUFFIX = dll
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),0)
|
||||
EXTRALIBS_FOR_BASE =
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
EXTRALIBS_FOR_BASE =
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),0)
|
||||
__WXLIB_NET_p = \
|
||||
-lwxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
__LIB_PNG_IF_MONO_p = $(__LIB_PNG_p)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__bench_gui___depname = $(OBJS)\bench_gui.exe
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
ifeq ($(USE_STC),1)
|
||||
__LIB_LEXILLA_IF_MONO_p = $(__LIB_LEXILLA_p)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__bench_graphics___depname = $(OBJS)\bench_graphics.exe
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
ifeq ($(USE_STC),1)
|
||||
__LIB_LEXILLA_IF_MONO_p_1 = $(__LIB_LEXILLA_p)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
__OPTIMIZEFLAG = -O0
|
||||
endif
|
||||
ifeq ($(BUILD),release)
|
||||
__OPTIMIZEFLAG = -O2
|
||||
endif
|
||||
ifeq ($(USE_RTTI),0)
|
||||
__RTTIFLAG = -fno-rtti
|
||||
endif
|
||||
ifeq ($(USE_RTTI),1)
|
||||
__RTTIFLAG =
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),0)
|
||||
__EXCEPTIONSFLAG = -fno-exceptions
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),1)
|
||||
__EXCEPTIONSFLAG =
|
||||
endif
|
||||
ifeq ($(WXUNIV),1)
|
||||
__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__
|
||||
endif
|
||||
ifeq ($(WXUNIV),1)
|
||||
__WXUNIV_DEFINE_p_0 = --define __WXUNIVERSAL__
|
||||
endif
|
||||
ifeq ($(DEBUG_FLAG),0)
|
||||
__DEBUG_DEFINE_p = -DwxDEBUG_LEVEL=0
|
||||
endif
|
||||
ifeq ($(DEBUG_FLAG),0)
|
||||
__DEBUG_DEFINE_p_0 = --define wxDEBUG_LEVEL=0
|
||||
endif
|
||||
ifeq ($(BUILD),release)
|
||||
__NDEBUG_DEFINE_p = -DNDEBUG
|
||||
endif
|
||||
ifeq ($(BUILD),release)
|
||||
__NDEBUG_DEFINE_p_0 = --define NDEBUG
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),0)
|
||||
__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS
|
||||
endif
|
||||
ifeq ($(USE_EXCEPTIONS),0)
|
||||
__EXCEPTIONS_DEFINE_p_0 = --define wxNO_EXCEPTIONS
|
||||
endif
|
||||
ifeq ($(USE_RTTI),0)
|
||||
__RTTI_DEFINE_p = -DwxNO_RTTI
|
||||
endif
|
||||
ifeq ($(USE_RTTI),0)
|
||||
__RTTI_DEFINE_p_0 = --define wxNO_RTTI
|
||||
endif
|
||||
ifeq ($(USE_THREADS),0)
|
||||
__THREAD_DEFINE_p = -DwxNO_THREADS
|
||||
endif
|
||||
ifeq ($(USE_THREADS),0)
|
||||
__THREAD_DEFINE_p_0 = --define wxNO_THREADS
|
||||
endif
|
||||
ifeq ($(USE_CAIRO),1)
|
||||
____CAIRO_INCLUDEDIR_FILENAMES = -I$(CAIRO_ROOT)\include\cairo
|
||||
endif
|
||||
ifeq ($(USE_CAIRO),1)
|
||||
__CAIRO_INCLUDEDIR_p = --include-dir $(CAIRO_ROOT)/include/cairo
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
__DLLFLAG_p = -DWXUSINGDLL
|
||||
endif
|
||||
ifeq ($(SHARED),1)
|
||||
__DLLFLAG_p_0 = --define WXUSINGDLL
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),0)
|
||||
__WXLIB_CORE_p = \
|
||||
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),0)
|
||||
__WXLIB_BASE_p = -lwxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
__WXLIB_MONO_p = \
|
||||
-lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)
|
||||
endif
|
||||
ifeq ($(MONOLITHIC),1)
|
||||
ifeq ($(USE_STC),1)
|
||||
__LIB_SCINTILLA_IF_MONO_p = -lwxscintilla$(WXDEBUGFLAG)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(USE_STC),1)
|
||||
__LIB_LEXILLA_p = -lwxlexilla$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__LIB_TIFF_p = -lwxtiff$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__LIB_JPEG_p = -lwxjpeg$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__LIB_PNG_p = -lwxpng$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(USE_GUI),1)
|
||||
__LIB_WEBP_p = -lwxwebp$(WXDEBUGFLAG)
|
||||
endif
|
||||
ifeq ($(USE_CAIRO),1)
|
||||
__CAIRO_LIB_p = -lcairo
|
||||
endif
|
||||
ifeq ($(USE_CAIRO),1)
|
||||
____CAIRO_LIBDIR_FILENAMES = -L$(CAIRO_ROOT)\lib
|
||||
endif
|
||||
ifeq ($(BUILD),debug)
|
||||
ifeq ($(DEBUG_INFO),default)
|
||||
__DEBUGINFO = -g
|
||||
endif
|
||||
endif
|
||||
ifeq ($(BUILD),release)
|
||||
ifeq ($(DEBUG_INFO),default)
|
||||
__DEBUGINFO =
|
||||
endif
|
||||
endif
|
||||
ifeq ($(DEBUG_INFO),0)
|
||||
__DEBUGINFO =
|
||||
endif
|
||||
ifeq ($(DEBUG_INFO),1)
|
||||
__DEBUGINFO = -g
|
||||
endif
|
||||
ifeq ($(USE_THREADS),0)
|
||||
__THREADSFLAG =
|
||||
endif
|
||||
ifeq ($(USE_THREADS),1)
|
||||
__THREADSFLAG = -mthreads
|
||||
endif
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
$(OBJS):
|
||||
-if not exist $(OBJS) mkdir $(OBJS)
|
||||
|
||||
### Targets: ###
|
||||
|
||||
all: $(OBJS)\bench.exe data $(__bench_gui___depname) $(__bench_graphics___depname) data-image
|
||||
|
||||
clean:
|
||||
-if exist $(OBJS)\*.o del $(OBJS)\*.o
|
||||
-if exist $(OBJS)\*.d del $(OBJS)\*.d
|
||||
-if exist $(OBJS)\bench.exe del $(OBJS)\bench.exe
|
||||
-if exist $(OBJS)\bench_gui.exe del $(OBJS)\bench_gui.exe
|
||||
-if exist $(OBJS)\bench_graphics.exe del $(OBJS)\bench_graphics.exe
|
||||
|
||||
$(OBJS)\bench.exe: $(BENCH_OBJECTS)
|
||||
$(foreach f,$(subst \,/,$(BENCH_OBJECTS)),$(shell echo $f >> $(subst \,/,$@).rsp.tmp))
|
||||
@move /y $@.rsp.tmp $@.rsp >nul
|
||||
$(CXX) -o $@ @$@.rsp $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_PNG_IF_MONO_p) -lwxzlib$(WXDEBUGFLAG) -lwxregexu$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lgdiplus -lmsimg32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lws2_32 -lwininet -loleacc -luxtheme
|
||||
@-del $@.rsp
|
||||
|
||||
data:
|
||||
if not exist $(OBJS) mkdir $(OBJS)
|
||||
for %%f in (htmltest.html) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS)
|
||||
|
||||
ifeq ($(USE_GUI),1)
|
||||
$(OBJS)\bench_gui.exe: $(BENCH_GUI_OBJECTS) $(OBJS)\bench_gui_sample_rc.o
|
||||
$(foreach f,$(subst \,/,$(BENCH_GUI_OBJECTS)),$(shell echo $f >> $(subst \,/,$@).rsp.tmp))
|
||||
@move /y $@.rsp.tmp $@.rsp >nul
|
||||
$(CXX) -o $@ @$@.rsp $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) -lwxzlib$(WXDEBUGFLAG) -lwxregexu$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lgdiplus -lmsimg32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lws2_32 -lwininet -loleacc -luxtheme
|
||||
@-del $@.rsp
|
||||
endif
|
||||
|
||||
ifeq ($(USE_GUI),1)
|
||||
$(OBJS)\bench_graphics.exe: $(BENCH_GRAPHICS_OBJECTS) $(OBJS)\bench_graphics_sample_rc.o
|
||||
$(foreach f,$(subst \,/,$(BENCH_GRAPHICS_OBJECTS)),$(shell echo $f >> $(subst \,/,$@).rsp.tmp))
|
||||
@move /y $@.rsp.tmp $@.rsp >nul
|
||||
$(CXX) -o $@ @$@.rsp $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) -lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl -lopengl32 $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p_1) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) -lwxzlib$(WXDEBUGFLAG) -lwxregexu$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lgdiplus -lmsimg32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lws2_32 -lwininet -loleacc -luxtheme
|
||||
@-del $@.rsp
|
||||
endif
|
||||
|
||||
data-image:
|
||||
if not exist $(OBJS) mkdir $(OBJS)
|
||||
for %%f in (../../samples/image/horse.bmp ../../samples/image/horse.jpg ../../samples/image/horse.png ../../samples/image/horse.tif) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS)
|
||||
|
||||
$(OBJS)\bench_bench.o: ./bench.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_datetime.o: ./datetime.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_htmlpars.o: ./htmlparser/htmlpars.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_htmltag.o: ./htmlparser/htmltag.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_ipcclient.o: ./ipcclient.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_log.o: ./log.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_mbconv.o: ./mbconv.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_regex.o: ./regex.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_strings.o: ./strings.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_tls.o: ./tls.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_printfbench.o: ./printfbench.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_gui_sample_rc.o: ./../../samples/sample.rc
|
||||
$(WINDRES) -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(SETUPHDIR) --include-dir ./../../include $(__CAIRO_INCLUDEDIR_p) --include-dir . $(__DLLFLAG_p_0) --define wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST) --include-dir ./../../samples --define NOPCH
|
||||
|
||||
$(OBJS)\bench_gui_bench.o: ./bench.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_gui_display.o: ./display.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_gui_image.o: ./image.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_graphics_sample_rc.o: ./../../samples/sample.rc
|
||||
$(WINDRES) -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --include-dir $(SETUPHDIR) --include-dir ./../../include $(__CAIRO_INCLUDEDIR_p) --include-dir . $(__DLLFLAG_p_0) --define wxUSE_DPI_AWARE_MANIFEST=$(USE_DPI_AWARE_MANIFEST) --include-dir ./../../samples --define NOPCH
|
||||
|
||||
$(OBJS)\bench_graphics_graphics.o: ./graphics.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_GRAPHICS_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
.PHONY: all clean data data-image
|
||||
|
||||
|
||||
SHELL := $(COMSPEC)
|
||||
|
||||
# Dependencies tracking:
|
||||
-include $(OBJS)/*.d
|
||||
603
libs/wxWidgets-3.3.1/tests/benchmarks/makefile.vc
Normal file
603
libs/wxWidgets-3.3.1/tests/benchmarks/makefile.vc
Normal file
@@ -0,0 +1,603 @@
|
||||
# =========================================================================
|
||||
# This makefile was generated by
|
||||
# Bakefile 0.2.13 (http://www.bakefile.org)
|
||||
# Do not modify, all changes will be overwritten!
|
||||
# =========================================================================
|
||||
|
||||
!include <../../build/msw/config.vc>
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Do not modify the rest of this file!
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
### Variables: ###
|
||||
|
||||
WX_RELEASE_NODOT = 33
|
||||
COMPILER_PREFIX = vc
|
||||
OBJS = \
|
||||
$(COMPILER_PREFIX)$(COMPILER_VERSION)$(ARCH_SUFFIX)_$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)$(WXDLLFLAG)$(CFG)
|
||||
LIBDIRNAME = \
|
||||
.\..\..\lib\$(COMPILER_PREFIX)$(COMPILER_VERSION)$(ARCH_SUFFIX)_$(LIBTYPE_SUFFIX)$(CFG)
|
||||
SETUPHDIR = $(LIBDIRNAME)\$(PORTNAME)$(WXUNIVNAME)u$(WXDEBUGFLAG)
|
||||
BENCH_CXXFLAGS = /M$(__RUNTIME_LIBS_10)$(__DEBUGRUNTIME) /DWIN32 \
|
||||
$(__DEBUGINFO) /Fd$(OBJS)\bench.pdb $(____DEBUGRUNTIME) $(__OPTIMIZEFLAG) \
|
||||
/D_CRT_SECURE_NO_DEPRECATE=1 /D_CRT_NON_CONFORMING_SWPRINTFS=1 \
|
||||
/D_SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p) $(__TARGET_CPU_COMPFLAG_p) \
|
||||
/D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
|
||||
/I$(SETUPHDIR) /I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) /W4 /I. \
|
||||
$(__DLLFLAG_p) /D_CONSOLE /DwxUSE_GUI=0 $(__RTTIFLAG) $(__EXCEPTIONSFLAG) \
|
||||
$(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_OBJECTS = \
|
||||
$(OBJS)\bench_bench.obj \
|
||||
$(OBJS)\bench_datetime.obj \
|
||||
$(OBJS)\bench_htmlpars.obj \
|
||||
$(OBJS)\bench_htmltag.obj \
|
||||
$(OBJS)\bench_ipcclient.obj \
|
||||
$(OBJS)\bench_log.obj \
|
||||
$(OBJS)\bench_mbconv.obj \
|
||||
$(OBJS)\bench_regex.obj \
|
||||
$(OBJS)\bench_strings.obj \
|
||||
$(OBJS)\bench_tls.obj \
|
||||
$(OBJS)\bench_printfbench.obj
|
||||
BENCH_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_26)$(__DEBUGRUNTIME) /DWIN32 \
|
||||
$(__DEBUGINFO) /Fd$(OBJS)\bench_gui.pdb $(____DEBUGRUNTIME) \
|
||||
$(__OPTIMIZEFLAG) /D_CRT_SECURE_NO_DEPRECATE=1 \
|
||||
/D_CRT_NON_CONFORMING_SWPRINTFS=1 /D_SCL_SECURE_NO_WARNINGS=1 \
|
||||
$(__NO_VC_CRTDBG_p) $(__TARGET_CPU_COMPFLAG_p) /D__WXMSW__ \
|
||||
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
|
||||
/I$(SETUPHDIR) /I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) /W4 /I. \
|
||||
$(__DLLFLAG_p) /I.\..\..\samples /DNOPCH /D_CONSOLE $(__RTTIFLAG) \
|
||||
$(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_GUI_OBJECTS = \
|
||||
$(OBJS)\bench_gui_bench.obj \
|
||||
$(OBJS)\bench_gui_display.obj \
|
||||
$(OBJS)\bench_gui_image.obj
|
||||
BENCH_GUI_RESOURCES = \
|
||||
$(OBJS)\bench_gui_sample.res
|
||||
BENCH_GRAPHICS_CXXFLAGS = /M$(__RUNTIME_LIBS_42)$(__DEBUGRUNTIME) /DWIN32 \
|
||||
$(__DEBUGINFO) /Fd$(OBJS)\bench_graphics.pdb $(____DEBUGRUNTIME) \
|
||||
$(__OPTIMIZEFLAG) /D_CRT_SECURE_NO_DEPRECATE=1 \
|
||||
/D_CRT_NON_CONFORMING_SWPRINTFS=1 /D_SCL_SECURE_NO_WARNINGS=1 \
|
||||
$(__NO_VC_CRTDBG_p) $(__TARGET_CPU_COMPFLAG_p) /D__WXMSW__ \
|
||||
$(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) \
|
||||
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
|
||||
/I$(SETUPHDIR) /I.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) /W4 /I. \
|
||||
$(__DLLFLAG_p) /I.\..\..\samples /DNOPCH /D_CONSOLE $(__RTTIFLAG) \
|
||||
$(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_GRAPHICS_OBJECTS = \
|
||||
$(OBJS)\bench_graphics_graphics.obj
|
||||
BENCH_GRAPHICS_RESOURCES = \
|
||||
$(OBJS)\bench_graphics_sample.res
|
||||
|
||||
### Conditionally set variables: ###
|
||||
|
||||
!if "$(TARGET_CPU)" == "AMD64"
|
||||
ARCH_SUFFIX = _x64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ARM"
|
||||
ARCH_SUFFIX = _arm
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ARM64"
|
||||
ARCH_SUFFIX = _arm64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "IA64"
|
||||
ARCH_SUFFIX = _ia64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "X64"
|
||||
ARCH_SUFFIX = _x64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
|
||||
ARCH_SUFFIX = _x64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
|
||||
ARCH_SUFFIX = _x64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "amd64"
|
||||
ARCH_SUFFIX = _x64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "arm"
|
||||
ARCH_SUFFIX = _arm
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "arm64"
|
||||
ARCH_SUFFIX = _arm64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ia64"
|
||||
ARCH_SUFFIX = _ia64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "x64"
|
||||
ARCH_SUFFIX = _x64
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "0"
|
||||
PORTNAME = base
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
PORTNAME = msw$(TOOLKIT_VERSION)
|
||||
!endif
|
||||
!if "$(OFFICIAL_BUILD)" == "1"
|
||||
COMPILER_VERSION = ERROR-COMPILER-VERSION-MUST-BE-SET-FOR-OFFICIAL-BUILD
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
WXDEBUGFLAG = d
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
WXDEBUGFLAG = d
|
||||
!endif
|
||||
!if "$(WXUNIV)" == "1"
|
||||
WXUNIVNAME = univ
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
WXDLLFLAG = dll
|
||||
!endif
|
||||
!if "$(SHARED)" == "0"
|
||||
LIBTYPE_SUFFIX = lib
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
LIBTYPE_SUFFIX = dll
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "AMD64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ARM"
|
||||
LINK_TARGET_CPU = /MACHINE:ARM
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ARM64"
|
||||
LINK_TARGET_CPU = /MACHINE:ARM64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "IA64"
|
||||
LINK_TARGET_CPU = /MACHINE:IA64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "X64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "amd64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "arm"
|
||||
LINK_TARGET_CPU = /MACHINE:ARM
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "arm64"
|
||||
LINK_TARGET_CPU = /MACHINE:ARM64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "ia64"
|
||||
LINK_TARGET_CPU = /MACHINE:IA64
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "x64"
|
||||
LINK_TARGET_CPU = /MACHINE:X64
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "14.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "15.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "16.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "1" && "$(VISUALSTUDIOVERSION)" == "17.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware.manifest
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "14.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "15.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "16.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
|
||||
!endif
|
||||
!if "$(USE_DPI_AWARE_MANIFEST)" == "2" && "$(VISUALSTUDIOVERSION)" == "17.0"
|
||||
WIN32_DPI_LINKFLAG = /MANIFEST:EMBED \
|
||||
/MANIFESTINPUT:./../../include/wx/msw/wx_dpi_aware_pmv2.manifest
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "0"
|
||||
EXTRALIBS_FOR_BASE =
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1"
|
||||
EXTRALIBS_FOR_BASE =
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_2 = $(__DEBUGRUNTIME_1)
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_2 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO_2 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO_2 = $(__DEBUGRUNTIME_1)
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "dynamic"
|
||||
__RUNTIME_LIBS_10 = D
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "static"
|
||||
__RUNTIME_LIBS_10 = $(__THREADSFLAG)
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "0"
|
||||
__WXLIB_NET_p = \
|
||||
wxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net.lib
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1"
|
||||
__LIB_PNG_IF_MONO_p = $(__LIB_PNG_p)
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__bench_gui___depname = $(OBJS)\bench_gui.exe
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_18 = $(__DEBUGRUNTIME_1)
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_18 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO_18 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO_18 = $(__DEBUGRUNTIME_1)
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "dynamic"
|
||||
__RUNTIME_LIBS_26 = D
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "static"
|
||||
__RUNTIME_LIBS_26 = $(__THREADSFLAG)
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1" && "$(USE_STC)" == "1"
|
||||
__LIB_LEXILLA_IF_MONO_p = $(__LIB_LEXILLA_p)
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__bench_graphics___depname = $(OBJS)\bench_graphics.exe
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_34 = $(__DEBUGRUNTIME_1)
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_34 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO_34 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO_34 = $(__DEBUGRUNTIME_1)
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "dynamic"
|
||||
__RUNTIME_LIBS_42 = D
|
||||
!endif
|
||||
!if "$(RUNTIME_LIBS)" == "static"
|
||||
__RUNTIME_LIBS_42 = $(__THREADSFLAG)
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1" && "$(USE_STC)" == "1"
|
||||
__LIB_LEXILLA_IF_MONO_p_1 = $(__LIB_LEXILLA_p)
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO = /Zi
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO = /Zi
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_3 = /DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_INFO)" == "default"
|
||||
__DEBUGINFO_3 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "0"
|
||||
__DEBUGINFO_3 =
|
||||
!endif
|
||||
!if "$(DEBUG_INFO)" == "1"
|
||||
__DEBUGINFO_3 = /DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME = /D_DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
____DEBUGRUNTIME =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
____DEBUGRUNTIME = /D_DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME_0 = /d _DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
____DEBUGRUNTIME_0 =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
____DEBUGRUNTIME_0 =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
____DEBUGRUNTIME_0 = /d _DEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME = d
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__DEBUGRUNTIME =
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
__DEBUGRUNTIME = d
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME_1 =
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__DEBUGRUNTIME_1 = /opt:ref /opt:icf
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__DEBUGRUNTIME_1 = /opt:ref /opt:icf
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "1"
|
||||
__DEBUGRUNTIME_1 =
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug"
|
||||
__OPTIMIZEFLAG = /Od
|
||||
!endif
|
||||
!if "$(BUILD)" == "release"
|
||||
__OPTIMIZEFLAG = /O2
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "0"
|
||||
__THREADSFLAG = L
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "1"
|
||||
__THREADSFLAG = T
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "0"
|
||||
__RTTIFLAG = /GR-
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "1"
|
||||
__RTTIFLAG = /GR
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "0"
|
||||
__EXCEPTIONSFLAG =
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "1"
|
||||
__EXCEPTIONSFLAG = /EHsc
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
|
||||
__NO_VC_CRTDBG_p = /D__NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(BUILD)" == "debug" && "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NO_VC_CRTDBG_p_0 = /d __NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_FLAG)" == "1"
|
||||
__NO_VC_CRTDBG_p_0 = /d __NO_VC_CRTDBG__
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == ""
|
||||
__TARGET_CPU_COMPFLAG_p = /DTARGET_CPU_COMPFLAG=0
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
|
||||
__TARGET_CPU_COMPFLAG_p =
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
|
||||
__TARGET_CPU_COMPFLAG_p =
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == ""
|
||||
__TARGET_CPU_COMPFLAG_p_0 = /d TARGET_CPU_COMPFLAG=0
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "X64"
|
||||
__TARGET_CPU_COMPFLAG_p_0 =
|
||||
!endif
|
||||
!if "$(TARGET_CPU)" == "" && "$(VISUALSTUDIOPLATFORM)" == "x64"
|
||||
__TARGET_CPU_COMPFLAG_p_0 =
|
||||
!endif
|
||||
!if "$(WXUNIV)" == "1"
|
||||
__WXUNIV_DEFINE_p = /D__WXUNIVERSAL__
|
||||
!endif
|
||||
!if "$(WXUNIV)" == "1"
|
||||
__WXUNIV_DEFINE_p_0 = /d __WXUNIVERSAL__
|
||||
!endif
|
||||
!if "$(DEBUG_FLAG)" == "0"
|
||||
__DEBUG_DEFINE_p = /DwxDEBUG_LEVEL=0
|
||||
!endif
|
||||
!if "$(DEBUG_FLAG)" == "0"
|
||||
__DEBUG_DEFINE_p_0 = /d wxDEBUG_LEVEL=0
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__NDEBUG_DEFINE_p = /DNDEBUG
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NDEBUG_DEFINE_p = /DNDEBUG
|
||||
!endif
|
||||
!if "$(BUILD)" == "release" && "$(DEBUG_RUNTIME_LIBS)" == "default"
|
||||
__NDEBUG_DEFINE_p_0 = /d NDEBUG
|
||||
!endif
|
||||
!if "$(DEBUG_RUNTIME_LIBS)" == "0"
|
||||
__NDEBUG_DEFINE_p_0 = /d NDEBUG
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "0"
|
||||
__EXCEPTIONS_DEFINE_p = /DwxNO_EXCEPTIONS
|
||||
!endif
|
||||
!if "$(USE_EXCEPTIONS)" == "0"
|
||||
__EXCEPTIONS_DEFINE_p_0 = /d wxNO_EXCEPTIONS
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "0"
|
||||
__RTTI_DEFINE_p = /DwxNO_RTTI
|
||||
!endif
|
||||
!if "$(USE_RTTI)" == "0"
|
||||
__RTTI_DEFINE_p_0 = /d wxNO_RTTI
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "0"
|
||||
__THREAD_DEFINE_p = /DwxNO_THREADS
|
||||
!endif
|
||||
!if "$(USE_THREADS)" == "0"
|
||||
__THREAD_DEFINE_p_0 = /d wxNO_THREADS
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
____CAIRO_INCLUDEDIR_FILENAMES = /I$(CAIRO_ROOT)\include\cairo
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
____CAIRO_INCLUDEDIR_FILENAMES_0 = /i $(CAIRO_ROOT)\include\cairo
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
__DLLFLAG_p = /DWXUSINGDLL
|
||||
!endif
|
||||
!if "$(SHARED)" == "1"
|
||||
__DLLFLAG_p_0 = /d WXUSINGDLL
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "0"
|
||||
__WXLIB_CORE_p = \
|
||||
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core.lib
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "0"
|
||||
__WXLIB_BASE_p = \
|
||||
wxbase$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1"
|
||||
__WXLIB_MONO_p = \
|
||||
wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR).lib
|
||||
!endif
|
||||
!if "$(MONOLITHIC)" == "1" && "$(USE_STC)" == "1"
|
||||
__LIB_SCINTILLA_IF_MONO_p = wxscintilla$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_STC)" == "1"
|
||||
__LIB_LEXILLA_p = wxlexilla$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__LIB_TIFF_p = wxtiff$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__LIB_JPEG_p = wxjpeg$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__LIB_PNG_p = wxpng$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_GUI)" == "1"
|
||||
__LIB_WEBP_p = wxwebp$(WXDEBUGFLAG).lib
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
__CAIRO_LIB_p = cairo.lib
|
||||
!endif
|
||||
!if "$(USE_CAIRO)" == "1"
|
||||
____CAIRO_LIBDIR_FILENAMES = /LIBPATH:$(CAIRO_ROOT)\lib
|
||||
!endif
|
||||
|
||||
|
||||
all: $(OBJS)
|
||||
$(OBJS):
|
||||
-if not exist $(OBJS) mkdir $(OBJS)
|
||||
|
||||
### Targets: ###
|
||||
|
||||
all: $(OBJS)\bench.exe data $(__bench_gui___depname) $(__bench_graphics___depname) data-image
|
||||
|
||||
clean:
|
||||
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
|
||||
-if exist $(OBJS)\*.res del $(OBJS)\*.res
|
||||
-if exist $(OBJS)\*.pch del $(OBJS)\*.pch
|
||||
-if exist $(OBJS)\bench.exe del $(OBJS)\bench.exe
|
||||
-if exist $(OBJS)\bench.ilk del $(OBJS)\bench.ilk
|
||||
-if exist $(OBJS)\bench.pdb del $(OBJS)\bench.pdb
|
||||
-if exist $(OBJS)\bench_gui.exe del $(OBJS)\bench_gui.exe
|
||||
-if exist $(OBJS)\bench_gui.ilk del $(OBJS)\bench_gui.ilk
|
||||
-if exist $(OBJS)\bench_gui.pdb del $(OBJS)\bench_gui.pdb
|
||||
-if exist $(OBJS)\bench_graphics.exe del $(OBJS)\bench_graphics.exe
|
||||
-if exist $(OBJS)\bench_graphics.ilk del $(OBJS)\bench_graphics.ilk
|
||||
-if exist $(OBJS)\bench_graphics.pdb del $(OBJS)\bench_graphics.pdb
|
||||
|
||||
$(OBJS)\bench.exe: $(BENCH_OBJECTS)
|
||||
link /NOLOGO /OUT:$@ $(__DEBUGINFO_3) /pdb:"$(OBJS)\bench.pdb" $(__DEBUGINFO_2) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<<
|
||||
$(BENCH_OBJECTS) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_PNG_IF_MONO_p) wxzlib$(WXDEBUGFLAG).lib wxregexu$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib gdiplus.lib msimg32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib ws2_32.lib wininet.lib
|
||||
<<
|
||||
|
||||
data:
|
||||
if not exist $(OBJS) mkdir $(OBJS)
|
||||
for %f in (htmltest.html) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
|
||||
|
||||
!if "$(USE_GUI)" == "1"
|
||||
$(OBJS)\bench_gui.exe: $(BENCH_GUI_OBJECTS) $(OBJS)\bench_gui_sample.res
|
||||
link /NOLOGO /OUT:$@ $(__DEBUGINFO_3) /pdb:"$(OBJS)\bench_gui.pdb" $(__DEBUGINFO_18) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) $(WIN32_DPI_LINKFLAG) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<<
|
||||
$(BENCH_GUI_OBJECTS) $(BENCH_GUI_RESOURCES) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) wxzlib$(WXDEBUGFLAG).lib wxregexu$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib gdiplus.lib msimg32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib ws2_32.lib wininet.lib
|
||||
<<
|
||||
!endif
|
||||
|
||||
!if "$(USE_GUI)" == "1"
|
||||
$(OBJS)\bench_graphics.exe: $(BENCH_GRAPHICS_OBJECTS) $(OBJS)\bench_graphics_sample.res
|
||||
link /NOLOGO /OUT:$@ $(__DEBUGINFO_3) /pdb:"$(OBJS)\bench_graphics.pdb" $(__DEBUGINFO_34) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) $(WIN32_DPI_LINKFLAG) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<<
|
||||
$(BENCH_GRAPHICS_OBJECTS) $(BENCH_GRAPHICS_RESOURCES) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)u$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib opengl32.lib $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_LEXILLA_IF_MONO_p_1) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(__LIB_WEBP_p) wxzlib$(WXDEBUGFLAG).lib wxregexu$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib gdiplus.lib msimg32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib ws2_32.lib wininet.lib
|
||||
<<
|
||||
!endif
|
||||
|
||||
data-image:
|
||||
if not exist $(OBJS) mkdir $(OBJS)
|
||||
for %f in (../../samples/image/horse.bmp ../../samples/image/horse.jpg ../../samples/image/horse.png ../../samples/image/horse.tif) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
|
||||
|
||||
$(OBJS)\bench_bench.obj: .\bench.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\bench.cpp
|
||||
|
||||
$(OBJS)\bench_datetime.obj: .\datetime.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\datetime.cpp
|
||||
|
||||
$(OBJS)\bench_htmlpars.obj: .\htmlparser\htmlpars.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\htmlparser\htmlpars.cpp
|
||||
|
||||
$(OBJS)\bench_htmltag.obj: .\htmlparser\htmltag.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\htmlparser\htmltag.cpp
|
||||
|
||||
$(OBJS)\bench_ipcclient.obj: .\ipcclient.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\ipcclient.cpp
|
||||
|
||||
$(OBJS)\bench_log.obj: .\log.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\log.cpp
|
||||
|
||||
$(OBJS)\bench_mbconv.obj: .\mbconv.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\mbconv.cpp
|
||||
|
||||
$(OBJS)\bench_regex.obj: .\regex.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\regex.cpp
|
||||
|
||||
$(OBJS)\bench_strings.obj: .\strings.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\strings.cpp
|
||||
|
||||
$(OBJS)\bench_tls.obj: .\tls.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\tls.cpp
|
||||
|
||||
$(OBJS)\bench_printfbench.obj: .\printfbench.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\printfbench.cpp
|
||||
|
||||
$(OBJS)\bench_gui_sample.res: .\..\..\samples\sample.rc
|
||||
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_0) /d _CRT_SECURE_NO_DEPRECATE=1 /d _CRT_NON_CONFORMING_SWPRINTFS=1 /d _SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p_0) $(__TARGET_CPU_COMPFLAG_p_0) /d __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) /i $(SETUPHDIR) /i .\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_0) /i . $(__DLLFLAG_p_0) /i .\..\..\samples /d NOPCH /d _CONSOLE .\..\..\samples\sample.rc
|
||||
|
||||
$(OBJS)\bench_gui_bench.obj: .\bench.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\bench.cpp
|
||||
|
||||
$(OBJS)\bench_gui_display.obj: .\display.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\display.cpp
|
||||
|
||||
$(OBJS)\bench_gui_image.obj: .\image.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\image.cpp
|
||||
|
||||
$(OBJS)\bench_graphics_sample.res: .\..\..\samples\sample.rc
|
||||
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_0) /d _CRT_SECURE_NO_DEPRECATE=1 /d _CRT_NON_CONFORMING_SWPRINTFS=1 /d _SCL_SECURE_NO_WARNINGS=1 $(__NO_VC_CRTDBG_p_0) $(__TARGET_CPU_COMPFLAG_p_0) /d __WXMSW__ $(__WXUNIV_DEFINE_p_0) $(__DEBUG_DEFINE_p_0) $(__NDEBUG_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) /i $(SETUPHDIR) /i .\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_0) /i . $(__DLLFLAG_p_0) /i .\..\..\samples /d NOPCH /d _CONSOLE .\..\..\samples\sample.rc
|
||||
|
||||
$(OBJS)\bench_graphics_graphics.obj: .\graphics.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GRAPHICS_CXXFLAGS) .\graphics.cpp
|
||||
|
||||
78
libs/wxWidgets-3.3.1/tests/benchmarks/mbconv.cpp
Normal file
78
libs/wxWidgets-3.3.1/tests/benchmarks/mbconv.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/mbconv.cpp
|
||||
// Purpose: MB<->WC conversion benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-10-17
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/strconv.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const wchar_t *TEST_STRING =
|
||||
L"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod"
|
||||
L"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim"
|
||||
L"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea"
|
||||
L"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate"
|
||||
L"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint"
|
||||
L"occaecat cupidatat non proident, sunt in culpa qui officia deserunt"
|
||||
L"mollit anim id est laborum."
|
||||
;
|
||||
|
||||
// just compute the length of the resulting multibyte string
|
||||
bool ComputeMBLength(const wxMBConv& conv)
|
||||
{
|
||||
// we suppose a fixed length encoding here (which happens to cover UTF-8
|
||||
// too as long as the test string is ASCII)
|
||||
return conv.FromWChar(nullptr, 0, TEST_STRING)
|
||||
== (wcslen(TEST_STRING) + 1)*conv.GetMBNulLen();
|
||||
}
|
||||
|
||||
// perform the conversion
|
||||
bool ConvertToMB(const wxMBConv& conv)
|
||||
{
|
||||
const size_t outlen = (wcslen(TEST_STRING) + 1)*conv.GetMBNulLen();
|
||||
wxCharBuffer buf(outlen - 1); // it adds 1 internally
|
||||
return conv.FromWChar(buf.data(), outlen, TEST_STRING) == outlen;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
BENCHMARK_FUNC(UTF16InitWX)
|
||||
{
|
||||
wxMBConvUTF16 conv;
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(UTF16InitSys)
|
||||
{
|
||||
wxCSConv conv("UTF-16LE");
|
||||
return conv.IsOk();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(UTF16LenWX)
|
||||
{
|
||||
return ComputeMBLength(wxMBConvUTF16());
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(UTF16LenSys)
|
||||
{
|
||||
return ComputeMBLength(wxCSConv("UTF-16LE"));
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(UTF16WX)
|
||||
{
|
||||
return ConvertToMB(wxMBConvUTF16());
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(UTF16Sys)
|
||||
{
|
||||
return ConvertToMB(wxCSConv("UTF-16LE"));
|
||||
}
|
||||
|
||||
134
libs/wxWidgets-3.3.1/tests/benchmarks/printfbench.cpp
Normal file
134
libs/wxWidgets-3.3.1/tests/benchmarks/printfbench.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: printfbench.cpp
|
||||
// Purpose: benchmarks for wx*Printf*() functions
|
||||
// Author: Francesco Montorsi
|
||||
// Created: 27/3/2006
|
||||
// Copyright: (c) 2006-2009 Francesco Montorsi
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
TODO: revise the benchmarking functions below to allow valid comparisons
|
||||
between the wx implementation and the system's implementation of
|
||||
the tested functions (e.g. adding tests which use the wxS macro to
|
||||
avoid runtime encoding conversions, etc etc).
|
||||
*/
|
||||
|
||||
//
|
||||
// Profiling under Linux:
|
||||
// =====================
|
||||
//
|
||||
// 1) configure wxWidgets in release mode
|
||||
// 2) make sure that HAVE_UNIX98_PRINTF is undefined (just #defining it to zero
|
||||
// does not work; you must comment out the entire #define) in your setup.h;
|
||||
// and also that wxUSE_PRINTF_POS_PARAMS is set to 1; this will force the
|
||||
// use of wx's own implementation of wxVsnprintf()
|
||||
// 3) compile wx
|
||||
// 4) set wxTEST_WX_ONLY to 1 and compile tests as well
|
||||
//
|
||||
// Now you have two main choices:
|
||||
//
|
||||
// - using gprof:
|
||||
// 5) add to the Makefile of this test program the -pg option both to
|
||||
// CXXFLAGS and to LDFLAGS
|
||||
// 6) run the test
|
||||
// 7) look at the gmon.out file with gprof utility
|
||||
//
|
||||
// - using valgrind:
|
||||
// 4) run "valgrind --tool=callgrind ./printfbench"
|
||||
// 5) run "kcachegrind dump_file_generated_by_callgrind"
|
||||
//
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "bench.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define BUFSIZE 10000
|
||||
|
||||
const wxString g_verylongString =
|
||||
"very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very "
|
||||
"very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long string!\n\n\n";
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// benchmarking helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define DO_LONG_BENCHMARK(fnc, prefix) \
|
||||
fnc(buffer, BUFSIZE, \
|
||||
prefix##"This is a reasonably long string with various %s arguments, exactly %d, " \
|
||||
prefix##"and is used as benchmark for %s - %% %.2f %d %s", \
|
||||
prefix##"(many!!)", 6, "this program", 23.342f, 999, \
|
||||
(const char*)g_verylongString.c_str());
|
||||
|
||||
#define DO_LONG_POSITIONAL_BENCHMARK(fnc, prefix) \
|
||||
fnc(buffer, BUFSIZE, \
|
||||
prefix##"This is a %2$s and thus is harder to parse... let's %1$s " \
|
||||
prefix##"for our benchmarking aims - %% %3$f %5$d %4$s", \
|
||||
prefix##"test it", "string with positional arguments", 23.342f, \
|
||||
(const char*)g_verylongString.c_str(), 999);
|
||||
|
||||
#define DO_BENCHMARK(fnc, prefix) \
|
||||
fnc(buffer, BUFSIZE, prefix##"This is a short %s string with very few words", "test");
|
||||
|
||||
#define DO_POSITIONAL_BENCHMARK(fnc, prefix) \
|
||||
fnc(buffer, BUFSIZE, \
|
||||
prefix##"This is a %2$s and thus is harder to parse... nonetheless, %1$s !", \
|
||||
"test it", "string with positional arguments");
|
||||
|
||||
// the configure script of wxWidgets will define HAVE_UNIX98_PRINTF on those
|
||||
// system with a *printf() family of functions conformant to Unix 98 standard;
|
||||
// systems without the configure script as build system (e.g. Windows) do not
|
||||
// have positional support anyway
|
||||
#ifdef HAVE_UNIX98_PRINTF
|
||||
#define wxSYSTEM_HAS_POSPARAM_SUPPORT 1
|
||||
#else
|
||||
#define wxSYSTEM_HAS_POSPARAM_SUPPORT 1
|
||||
#endif
|
||||
|
||||
// we need to avoid the use of wxPrintf() here since it could have been mapped
|
||||
// to wxWidgets' implementation of wxVsnPrintf() !
|
||||
#define sys_printf swprintf
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// main
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(SnprintfWithPositionals)
|
||||
{
|
||||
wxChar buffer[BUFSIZE];
|
||||
#if wxUSE_PRINTF_POS_PARAMS
|
||||
DO_LONG_POSITIONAL_BENCHMARK(wxSnprintf, )
|
||||
DO_POSITIONAL_BENCHMARK(wxSnprintf, )
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(Snprintf)
|
||||
{
|
||||
wxChar buffer[BUFSIZE];
|
||||
DO_LONG_BENCHMARK(wxSnprintf, )
|
||||
DO_BENCHMARK(wxSnprintf, )
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(SystemSnprintfWithPositionals)
|
||||
{
|
||||
wxChar buffer[BUFSIZE];
|
||||
DO_LONG_POSITIONAL_BENCHMARK(sys_printf, L)
|
||||
DO_POSITIONAL_BENCHMARK(sys_printf, L)
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(SystemSnprintf)
|
||||
{
|
||||
wxChar buffer[BUFSIZE];
|
||||
DO_LONG_BENCHMARK(sys_printf, L)
|
||||
DO_BENCHMARK(sys_printf, L)
|
||||
return true;
|
||||
}
|
||||
|
||||
74
libs/wxWidgets-3.3.1/tests/benchmarks/regex.cpp
Normal file
74
libs/wxWidgets-3.3.1/tests/benchmarks/regex.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/regex.cpp
|
||||
// Purpose: wxRegEx benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2018-11-15
|
||||
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/ffile.h"
|
||||
#include "wx/regex.h"
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Benchmark relative costs of compiling and matching for a simple regex
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static const char* const RE_SIMPLE = ".";
|
||||
|
||||
BENCHMARK_FUNC(RECompile)
|
||||
{
|
||||
return wxRegEx(RE_SIMPLE).IsValid();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(REMatch)
|
||||
{
|
||||
static wxRegEx re(RE_SIMPLE);
|
||||
return re.Matches("foo");
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(RECompileAndMatch)
|
||||
{
|
||||
return wxRegEx(RE_SIMPLE).Matches("foo");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Benchmark the cost of using a more complicated regex
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Use the contents of an already existing test file.
|
||||
const wxString& GetTestText()
|
||||
{
|
||||
static wxString text;
|
||||
if ( text.empty() )
|
||||
{
|
||||
wxFFile("htmltest.html").ReadAll(&text);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
BENCHMARK_FUNC(REFindTD)
|
||||
{
|
||||
// This is too simplistic, but good enough for benchmarking.
|
||||
static wxRegEx re("<td>[^<]*</td>", wxRE_ICASE | wxRE_NEWLINE);
|
||||
|
||||
int matches = 0;
|
||||
for ( const wxChar* p = GetTestText().c_str(); re.Matches(p); ++matches )
|
||||
{
|
||||
size_t start, len;
|
||||
if ( !re.GetMatch(&start, &len) )
|
||||
return false;
|
||||
|
||||
p += start + len;
|
||||
}
|
||||
|
||||
return matches == 21; // result of "grep -c"
|
||||
}
|
||||
770
libs/wxWidgets-3.3.1/tests/benchmarks/strings.cpp
Normal file
770
libs/wxWidgets-3.3.1/tests/benchmarks/strings.cpp
Normal file
@@ -0,0 +1,770 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/strings.cpp
|
||||
// Purpose: String-related benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-07-19
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/ffile.h"
|
||||
#include "wx/arrstr.h"
|
||||
|
||||
#include "bench.h"
|
||||
#include "htmlparser/htmlpars.h"
|
||||
|
||||
static const char asciistr[] =
|
||||
"This is just the first line of a very long 7 bit ASCII string"
|
||||
"This is just the second line of a very long 7 bit ASCII string"
|
||||
"This is just the third line of a very long 7 bit ASCII string"
|
||||
"This is just the fourth line of a very long 7 bit ASCII string"
|
||||
"This is just the fifth line of a very long 7 bit ASCII string"
|
||||
"This is just the sixth line of a very long 7 bit ASCII string"
|
||||
"This is just the seventh line of a very long 7 bit ASCII string"
|
||||
"This is just the eighth line of a very long 7 bit ASCII string"
|
||||
"This is just the ninth line of a very long 7 bit ASCII string"
|
||||
"This is just the tenth line of a very long 7 bit ASCII string"
|
||||
;
|
||||
|
||||
static const char utf8str[] =
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 0"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 1"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 2"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 3"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 4"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 5"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 6"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 7"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 8"
|
||||
"\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5 \xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE 9"
|
||||
;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const wxString& GetTestAsciiString()
|
||||
{
|
||||
static wxString testString;
|
||||
if ( testString.empty() )
|
||||
{
|
||||
long num = Bench::GetNumericParameter();
|
||||
if ( !num )
|
||||
num = 1;
|
||||
|
||||
for ( long n = 0; n < num; n++ )
|
||||
testString += wxString::FromAscii(asciistr);
|
||||
}
|
||||
|
||||
return testString;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// this is just a baseline
|
||||
BENCHMARK_FUNC(Strlen)
|
||||
{
|
||||
if ( strlen(utf8str) != WXSIZEOF(utf8str) - 1 )
|
||||
return false;
|
||||
|
||||
if ( strlen(asciistr) != WXSIZEOF(asciistr) - 1 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// FromUTF8() benchmarks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(FromUTF8)
|
||||
{
|
||||
wxString s = wxString::FromUTF8(utf8str);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
s = wxString::FromUTF8(asciistr);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(FromUTF8WithNpos)
|
||||
{
|
||||
wxString s = wxString::FromUTF8(utf8str, wxString::npos);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
s = wxString::FromUTF8(asciistr, wxString::npos);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(FromUTF8WithLen)
|
||||
{
|
||||
wxString s = wxString::FromUTF8(utf8str, WXSIZEOF(utf8str));
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
s = wxString::FromUTF8(asciistr, WXSIZEOF(asciistr));
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// FromUTF8Unchecked() benchmarks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(FromUTF8Unchecked)
|
||||
{
|
||||
wxString s = wxString::FromUTF8Unchecked(utf8str);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
s = wxString::FromUTF8Unchecked(asciistr);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(FromUTF8UncheckedWithNpos)
|
||||
{
|
||||
wxString s = wxString::FromUTF8Unchecked(utf8str, wxString::npos);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
s = wxString::FromUTF8Unchecked(asciistr, wxString::npos);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(FromUTF8UncheckedWithLen)
|
||||
{
|
||||
wxString s = wxString::FromUTF8Unchecked(utf8str, WXSIZEOF(utf8str));
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
s = wxString::FromUTF8Unchecked(asciistr, WXSIZEOF(asciistr));
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// FromAscii() benchmarks
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(FromAscii)
|
||||
{
|
||||
wxString s = wxString::FromAscii(asciistr);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(FromAsciiWithNpos)
|
||||
{
|
||||
wxString s = wxString::FromAscii(asciistr);
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(FromAsciiWithLen)
|
||||
{
|
||||
wxString s = wxString::FromAscii(asciistr, WXSIZEOF(asciistr));
|
||||
if ( s.empty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// simple string iteration
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// baseline
|
||||
BENCHMARK_FUNC(ForCString)
|
||||
{
|
||||
for ( size_t n = 0; n < WXSIZEOF(asciistr); n++ )
|
||||
{
|
||||
if ( asciistr[n] == '~' )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ForStringIndex)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
const size_t len = s.length();
|
||||
for ( size_t n = 0; n < len; n++ )
|
||||
{
|
||||
if ( s[n] == '~' )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ForStringIter)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
const wxString::const_iterator end = s.end();
|
||||
for ( wxString::const_iterator i = s.begin(); i != end; ++i )
|
||||
{
|
||||
if ( *i == '~' )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ForStringRIter)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
const wxString::const_reverse_iterator rend = s.rend();
|
||||
for ( wxString::const_reverse_iterator i = s.rbegin(); i != rend; ++i )
|
||||
{
|
||||
if ( *i == '~' )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxString::Replace()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
const size_t ASCIISTR_LEN = strlen(asciistr);
|
||||
|
||||
BENCHMARK_FUNC(ReplaceLoop)
|
||||
{
|
||||
wxString str('x', ASCIISTR_LEN);
|
||||
for ( size_t n = 0; n < ASCIISTR_LEN; n++ )
|
||||
{
|
||||
if ( str[n] == 'a' )
|
||||
str[n] = 'z';
|
||||
}
|
||||
|
||||
return str.length() != 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ReplaceNone)
|
||||
{
|
||||
wxString str('x', ASCIISTR_LEN);
|
||||
return str.Replace("a", "z") == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ReplaceSome)
|
||||
{
|
||||
wxString str(asciistr);
|
||||
return str.Replace("7", "8") != 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ReplaceAll)
|
||||
{
|
||||
wxString str('x', ASCIISTR_LEN);
|
||||
return str.Replace("x", "y") != 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ReplaceLonger)
|
||||
{
|
||||
wxString str('x', ASCIISTR_LEN);
|
||||
return str.Replace("x", "yy") != 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ReplaceShorter)
|
||||
{
|
||||
wxString str('x', ASCIISTR_LEN);
|
||||
return str.Replace("xx", "y") != 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string arrays
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(ArrStrPushBack)
|
||||
{
|
||||
wxArrayString a;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
a.push_back(wxString(asciistr));
|
||||
a.push_back(wxString(utf8str));
|
||||
}
|
||||
return !a.empty();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ArrStrInsert)
|
||||
{
|
||||
wxArrayString a;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
a.insert(a.begin(), wxString(asciistr));
|
||||
a.insert(a.begin(), wxString(utf8str));
|
||||
}
|
||||
return !a.empty();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(ArrStrSort)
|
||||
{
|
||||
wxArrayString a;
|
||||
a.reserve(100);
|
||||
for (int i = 0; i < 100; ++i)
|
||||
a.push_back(wxString(asciistr + i));
|
||||
a.Sort();
|
||||
return !a.empty();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(VectorStrPushBack)
|
||||
{
|
||||
std::vector<wxString> v;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
v.push_back(wxString(asciistr));
|
||||
v.push_back(wxString(utf8str));
|
||||
}
|
||||
return !v.empty();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(VectorStrInsert)
|
||||
{
|
||||
std::vector<wxString> v;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
v.insert(v.begin(), wxString(asciistr));
|
||||
v.insert(v.begin(), wxString(utf8str));
|
||||
}
|
||||
return !v.empty();
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(VectorStrSort)
|
||||
{
|
||||
std::vector<wxString> v;
|
||||
v.reserve(100);
|
||||
for (int i = 0; i < 100; ++i)
|
||||
v.push_back(wxString(asciistr + i));
|
||||
std::sort(v.begin(), v.end());
|
||||
return !v.empty();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string case conversion
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(Lower)
|
||||
{
|
||||
return GetTestAsciiString().Lower().length() > 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(Upper)
|
||||
{
|
||||
return GetTestAsciiString().Upper().length() > 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string comparison
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(StrcmpA)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return wxCRT_StrcmpA(s.c_str(), s.c_str()) == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StrcmpW)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return wxCRT_StrcmpW(s.wc_str(), s.wc_str()) == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StricmpA)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return wxCRT_StricmpA(s.c_str(), s.c_str()) == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StricmpW)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return wxCRT_StricmpW(s.wc_str(), s.wc_str()) == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StringCmp)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return s.Cmp(s) == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StringCmpNoCase)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return s.CmpNoCase(s) == 0;
|
||||
}
|
||||
|
||||
// Also benchmark various native functions under MSW. Surprisingly/annoyingly
|
||||
// they sometimes have vastly better performance than alternatives, especially
|
||||
// for case-sensitive comparison (see #10375).
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
#include "wx/msw/wrapwin.h"
|
||||
|
||||
BENCHMARK_FUNC(MSWlstrcmp)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return lstrcmp(s.t_str(), s.t_str()) == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(MSWlstrcmpi)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return lstrcmpi(s.t_str(), s.t_str()) == 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(MSWCompareString)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return ::CompareString
|
||||
(
|
||||
LOCALE_USER_DEFAULT,
|
||||
0,
|
||||
s.t_str(), s.length(),
|
||||
s.t_str(), s.length()
|
||||
) == CSTR_EQUAL;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(MSWCompareStringIgnoreCase)
|
||||
{
|
||||
const wxString& s = GetTestAsciiString();
|
||||
|
||||
return ::CompareString
|
||||
(
|
||||
LOCALE_USER_DEFAULT,
|
||||
NORM_IGNORECASE,
|
||||
s.t_str(), s.length(),
|
||||
s.t_str(), s.length()
|
||||
) == CSTR_EQUAL;
|
||||
}
|
||||
|
||||
#endif // __WINDOWS__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string buffers: wx[W]CharBuffer
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BENCHMARK_FUNC(CharBuffer)
|
||||
{
|
||||
wxString str(asciistr);
|
||||
|
||||
// NB: wxStrlen() is here to simulate some use of the returned buffer.
|
||||
// Both mb_str() and wc_str() are used so that this code does something
|
||||
// nontrivial in any build.
|
||||
return wxStrlen(str.mb_str()) == ASCIISTR_LEN &&
|
||||
wxStrlen(str.wc_str()) == ASCIISTR_LEN;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxString::operator[] - parse large HTML page
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class DummyParser : public wx28HtmlParser
|
||||
{
|
||||
public:
|
||||
virtual wxObject* GetProduct() { return nullptr; }
|
||||
virtual void AddText(const wxChar*) {}
|
||||
};
|
||||
|
||||
|
||||
BENCHMARK_FUNC(ParseHTML)
|
||||
{
|
||||
// static so that construction time is not counted
|
||||
static DummyParser parser;
|
||||
static wxString html;
|
||||
if ( html.empty() )
|
||||
{
|
||||
wxString html1;
|
||||
wxFFile("htmltest.html").ReadAll(&html1, wxConvUTF8);
|
||||
|
||||
// this is going to make for some invalid HTML, of course, but it
|
||||
// doesn't really matter
|
||||
long num = Bench::GetNumericParameter();
|
||||
if ( !num )
|
||||
num = 1;
|
||||
|
||||
for ( long n = 0; n < num; n++ )
|
||||
html += html1;
|
||||
}
|
||||
|
||||
parser.Parse(html);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// conversions between strings and numbers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const struct ToDoubleData
|
||||
{
|
||||
const char *str;
|
||||
double value;
|
||||
bool ok;
|
||||
} toDoubleData[] =
|
||||
{
|
||||
{ "1", 1, true },
|
||||
{ "1.23", 1.23, true },
|
||||
{ ".1", .1, true },
|
||||
{ "1.", 1, true },
|
||||
{ "1..", 0, false },
|
||||
{ "0", 0, true },
|
||||
{ "a", 0, false },
|
||||
{ "12345", 12345, true },
|
||||
{ "-1", -1, true },
|
||||
{ "--1", 0, false },
|
||||
{ "-3E-5", -3E-5, true },
|
||||
{ "-3E-abcde5", 0, false },
|
||||
};
|
||||
|
||||
const struct FromDoubleData
|
||||
{
|
||||
double value;
|
||||
int prec;
|
||||
const char *str;
|
||||
} fromDoubleData[] =
|
||||
{
|
||||
{ 1.23, -1, "1.23" },
|
||||
{ -0.45678, -1, "-0.45678" },
|
||||
{ 1.2345678, 0, "1" },
|
||||
{ 1.2345678, 1, "1.2" },
|
||||
{ 1.2345678, 2, "1.23" },
|
||||
{ 1.2345678, 3, "1.235" },
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
BENCHMARK_FUNC(StringToDouble)
|
||||
{
|
||||
double d = 0.;
|
||||
for ( const auto& data : toDoubleData )
|
||||
{
|
||||
if ( wxString(data.str).ToDouble(&d) != data.ok )
|
||||
return false;
|
||||
|
||||
if ( data.ok && d != data.value )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StringToCDouble)
|
||||
{
|
||||
double d = 0.;
|
||||
for ( const auto& data : toDoubleData )
|
||||
{
|
||||
if ( wxString(data.str).ToCDouble(&d) != data.ok )
|
||||
return false;
|
||||
|
||||
if ( data.ok && d != data.value )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StringFromDouble)
|
||||
{
|
||||
for ( const auto& data : fromDoubleData )
|
||||
{
|
||||
const wxString& s = wxString::FromDouble(data.value, data.prec);
|
||||
if ( wxStrcmp(s.utf8_str(), data.str) != 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StringFromCDouble)
|
||||
{
|
||||
for ( const auto& data : fromDoubleData )
|
||||
{
|
||||
const wxString& s = wxString::FromCDouble(data.value, data.prec);
|
||||
if ( wxStrcmp(s.utf8_str(), data.str) != 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(Strtod)
|
||||
{
|
||||
double d = 0.;
|
||||
char* end = nullptr;
|
||||
for ( const auto& data : toDoubleData )
|
||||
{
|
||||
d = strtod(data.str, &end);
|
||||
|
||||
if ( (end && *end == '\0') != data.ok )
|
||||
return false;
|
||||
|
||||
if ( data.ok && d != data.value )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(PrintfDouble)
|
||||
{
|
||||
char buf[64];
|
||||
for ( const auto& data : fromDoubleData )
|
||||
{
|
||||
if ( data.prec == -1 )
|
||||
{
|
||||
if ( !snprintf(buf, sizeof(buf), "%g", data.value) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !snprintf(buf, sizeof(buf), "%.*f", data.prec, data.value) )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( strcmp(buf, data.str) != 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(AppendString)
|
||||
{
|
||||
static wxString s;
|
||||
long num = Bench::GetNumericParameter();
|
||||
if ( !num )
|
||||
num = 1;
|
||||
|
||||
s.clear();
|
||||
for ( int n = 0; n < num; n++ )
|
||||
{
|
||||
s << wxS("123");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(AppendIntDirect)
|
||||
{
|
||||
static wxString s;
|
||||
long num = Bench::GetNumericParameter();
|
||||
if ( !num )
|
||||
num = 1;
|
||||
|
||||
s.clear();
|
||||
for ( int n = 0; n < num; n++ )
|
||||
{
|
||||
s << n;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(AppendIntViaString)
|
||||
{
|
||||
static wxString s;
|
||||
long num = Bench::GetNumericParameter();
|
||||
if ( !num )
|
||||
num = 1;
|
||||
|
||||
s.clear();
|
||||
for ( int n = 0; n < num; n++ )
|
||||
{
|
||||
#if wxUSE_UNICODE_WCHAR
|
||||
s << std::to_wstring(n);
|
||||
#else
|
||||
s << std::to_string(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxHAS_CXX17_INCLUDE(<charconv>)
|
||||
|
||||
#include <charconv>
|
||||
|
||||
#ifdef __cpp_lib_to_chars
|
||||
BENCHMARK_FUNC(StdFromChars)
|
||||
{
|
||||
double d = 0.;
|
||||
for ( const auto& data : toDoubleData )
|
||||
{
|
||||
const auto end = data.str + strlen(data.str);
|
||||
const auto res = std::from_chars(data.str, end, d);
|
||||
|
||||
if ( (res.ptr == end && res.ec == std::errc{}) != data.ok )
|
||||
return false;
|
||||
|
||||
if ( data.ok && d != data.value )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(StdToChars)
|
||||
{
|
||||
char buf[64];
|
||||
std::to_chars_result res;
|
||||
for ( const auto& data : fromDoubleData )
|
||||
{
|
||||
if ( data.prec == -1 )
|
||||
{
|
||||
res = std::to_chars(buf, buf + sizeof(buf), data.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = std::to_chars(buf, buf + sizeof(buf), data.value,
|
||||
std::chars_format::fixed, data.prec);
|
||||
}
|
||||
|
||||
if ( res.ec != std::errc{} )
|
||||
return false;
|
||||
|
||||
*res.ptr = '\0';
|
||||
|
||||
if ( strcmp(buf, data.str) != 0 )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // __cpp_lib_to_chars
|
||||
|
||||
#endif // wxHAS_CXX17_INCLUDE(<charconv>)
|
||||
189
libs/wxWidgets-3.3.1/tests/benchmarks/tls.cpp
Normal file
189
libs/wxWidgets-3.3.1/tests/benchmarks/tls.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/strings.cpp
|
||||
// Purpose: String-related benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-07-19
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
#include "wx/tls.h"
|
||||
|
||||
#if defined(__UNIX__)
|
||||
#define HAVE_PTHREAD
|
||||
#include <pthread.h>
|
||||
#elif defined(__WIN32__)
|
||||
#define HAVE_WIN32_THREAD
|
||||
#include "wx/msw/wrapwin.h"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define HAVE_COMPILER_THREAD
|
||||
#define wxTHREAD_SPECIFIC __thread
|
||||
#elif defined(__VISUALC__)
|
||||
#define HAVE_COMPILER_THREAD
|
||||
#define wxTHREAD_SPECIFIC __declspec(thread)
|
||||
#endif
|
||||
|
||||
// uncomment this to also test Boost version (you will also need to link with
|
||||
// libboost_threads)
|
||||
//#define HAVE_BOOST_THREAD
|
||||
#ifdef HAVE_BOOST_THREAD
|
||||
#include <boost/thread/tss.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
static const int NUM_ITER = 1000;
|
||||
|
||||
// this is just a baseline
|
||||
BENCHMARK_FUNC(DummyTLS)
|
||||
{
|
||||
static int s_global = 0;
|
||||
|
||||
for ( int n = 0; n < NUM_ITER; n++ )
|
||||
{
|
||||
if ( n % 2 )
|
||||
s_global = 0;
|
||||
else
|
||||
s_global = n;
|
||||
}
|
||||
|
||||
return !s_global;
|
||||
}
|
||||
|
||||
#ifdef HAVE_COMPILER_THREAD
|
||||
|
||||
BENCHMARK_FUNC(CompilerTLS)
|
||||
{
|
||||
static wxTHREAD_SPECIFIC int s_global = 0;
|
||||
|
||||
for ( int n = 0; n < NUM_ITER; n++ )
|
||||
{
|
||||
if ( n % 2 )
|
||||
s_global = 0;
|
||||
else
|
||||
s_global = n;
|
||||
}
|
||||
|
||||
return !s_global;
|
||||
}
|
||||
|
||||
#endif // HAVE_COMPILER_THREAD
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
|
||||
class PthreadKey
|
||||
{
|
||||
public:
|
||||
PthreadKey()
|
||||
{
|
||||
pthread_key_create(&m_key, nullptr);
|
||||
}
|
||||
|
||||
~PthreadKey()
|
||||
{
|
||||
pthread_key_delete(m_key);
|
||||
}
|
||||
|
||||
operator pthread_key_t() const { return m_key; }
|
||||
|
||||
private:
|
||||
pthread_key_t m_key;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(PthreadKey);
|
||||
};
|
||||
|
||||
BENCHMARK_FUNC(PosixTLS)
|
||||
{
|
||||
static PthreadKey s_key;
|
||||
|
||||
for ( int n = 0; n < NUM_ITER; n++ )
|
||||
{
|
||||
if ( n % 2 )
|
||||
pthread_setspecific(s_key, 0);
|
||||
else
|
||||
pthread_setspecific(s_key, &n);
|
||||
}
|
||||
|
||||
return !pthread_getspecific(s_key);
|
||||
}
|
||||
|
||||
#endif // HAVE_PTHREAD
|
||||
|
||||
#ifdef HAVE_WIN32_THREAD
|
||||
|
||||
class TlsSlot
|
||||
{
|
||||
public:
|
||||
TlsSlot()
|
||||
{
|
||||
m_slot = ::TlsAlloc();
|
||||
}
|
||||
|
||||
~TlsSlot()
|
||||
{
|
||||
::TlsFree(m_slot);
|
||||
}
|
||||
|
||||
operator DWORD() const { return m_slot; }
|
||||
|
||||
private:
|
||||
DWORD m_slot;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TlsSlot);
|
||||
};
|
||||
|
||||
BENCHMARK_FUNC(Win32TLS)
|
||||
{
|
||||
static TlsSlot s_slot;
|
||||
|
||||
for ( int n = 0; n < NUM_ITER; n++ )
|
||||
{
|
||||
if ( n % 2 )
|
||||
::TlsSetValue(s_slot, 0);
|
||||
else
|
||||
::TlsSetValue(s_slot, &n);
|
||||
}
|
||||
|
||||
return !::TlsGetValue(s_slot);
|
||||
}
|
||||
|
||||
#endif // HAVE_WIN32_THREAD
|
||||
|
||||
#ifdef HAVE_BOOST_THREAD
|
||||
|
||||
BENCHMARK_FUNC(BoostTLS)
|
||||
{
|
||||
static boost::thread_specific_ptr<int> s_ptr;
|
||||
if ( !s_ptr.get() )
|
||||
s_ptr.reset(new int(0));
|
||||
|
||||
for ( int n = 0; n < NUM_ITER; n++ )
|
||||
{
|
||||
if ( n % 2 )
|
||||
*s_ptr = 0;
|
||||
else
|
||||
*s_ptr = n;
|
||||
}
|
||||
|
||||
return !*s_ptr;
|
||||
}
|
||||
|
||||
#endif // HAVE_BOOST_THREAD
|
||||
|
||||
BENCHMARK_FUNC(wxTLS)
|
||||
{
|
||||
static wxTHREAD_SPECIFIC_DECL int s_global;
|
||||
|
||||
for ( int n = 0; n < NUM_ITER; n++ )
|
||||
{
|
||||
if ( n % 2 )
|
||||
s_global = 0;
|
||||
else
|
||||
s_global = n;
|
||||
}
|
||||
|
||||
return !s_global;
|
||||
}
|
||||
411
libs/wxWidgets-3.3.1/tests/cmdline/cmdlinetest.cpp
Normal file
411
libs/wxWidgets-3.3.1/tests/cmdline/cmdlinetest.cpp
Normal file
@@ -0,0 +1,411 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/cmdline/cmdlinetest.cpp
|
||||
// Purpose: wxCmdLineParser unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-04-12
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/cmdline.h"
|
||||
#include "wx/msgout.h"
|
||||
#include "wx/scopeguard.h"
|
||||
|
||||
#include "testdate.h"
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// test class
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
class CmdLineTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
CmdLineTestCase() {}
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( CmdLineTestCase );
|
||||
CPPUNIT_TEST( ConvertStringTestCase );
|
||||
CPPUNIT_TEST( ParseSwitches );
|
||||
CPPUNIT_TEST( ArgumentsCollection );
|
||||
CPPUNIT_TEST( Usage );
|
||||
CPPUNIT_TEST( Found );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void ConvertStringTestCase();
|
||||
void ParseSwitches();
|
||||
void ArgumentsCollection();
|
||||
void Usage();
|
||||
void Found();
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(CmdLineTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( CmdLineTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CmdLineTestCase, "CmdLineTestCase" );
|
||||
|
||||
// Use this macro to compare a wxArrayString with the pipe-separated elements
|
||||
// of the given string
|
||||
//
|
||||
// NB: it's a macro and not a function to have the correct line numbers in the
|
||||
// test failure messages
|
||||
#define WX_ASSERT_STRARRAY_EQUAL(s, a) \
|
||||
{ \
|
||||
wxArrayString expected(wxSplit(s, '|', '\0')); \
|
||||
\
|
||||
CPPUNIT_ASSERT_EQUAL( expected.size(), a.size() ); \
|
||||
\
|
||||
for ( size_t n = 0; n < a.size(); n++ ) \
|
||||
{ \
|
||||
CPPUNIT_ASSERT_EQUAL( expected[n], a[n] ); \
|
||||
} \
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
void CmdLineTestCase::ConvertStringTestCase()
|
||||
{
|
||||
#define WX_ASSERT_DOS_ARGS_EQUAL(s, args) \
|
||||
{ \
|
||||
const wxArrayString \
|
||||
argsDOS(wxCmdLineParser::ConvertStringToArgs(args, \
|
||||
wxCMD_LINE_SPLIT_DOS)); \
|
||||
WX_ASSERT_STRARRAY_EQUAL(s, argsDOS); \
|
||||
}
|
||||
|
||||
#define WX_ASSERT_UNIX_ARGS_EQUAL(s, args) \
|
||||
{ \
|
||||
const wxArrayString \
|
||||
argsUnix(wxCmdLineParser::ConvertStringToArgs(args, \
|
||||
wxCMD_LINE_SPLIT_UNIX)); \
|
||||
WX_ASSERT_STRARRAY_EQUAL(s, argsUnix); \
|
||||
}
|
||||
|
||||
#define WX_ASSERT_ARGS_EQUAL(s, args) \
|
||||
WX_ASSERT_DOS_ARGS_EQUAL(s, args) \
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL(s, args)
|
||||
|
||||
// normal cases
|
||||
WX_ASSERT_ARGS_EQUAL( "foo", "foo" )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo bar", "\"foo bar\"" )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo|bar", "foo bar" )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo|bar|baz", "foo bar baz" )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo|bar baz", "foo \"bar baz\"" )
|
||||
|
||||
// special cases
|
||||
WX_ASSERT_ARGS_EQUAL( "", "" )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo", "foo " )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo", "foo \t " )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo|bar", "foo bar " )
|
||||
WX_ASSERT_ARGS_EQUAL( "foo|bar|", "foo bar \"" )
|
||||
WX_ASSERT_DOS_ARGS_EQUAL( "foo|bar|\\", "foo bar \\" )
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "foo|bar|", "foo bar \\" )
|
||||
|
||||
WX_ASSERT_ARGS_EQUAL( "12 34", "1\"2 3\"4" );
|
||||
WX_ASSERT_ARGS_EQUAL( "1|2 34", "1 \"2 3\"4" );
|
||||
WX_ASSERT_ARGS_EQUAL( "1|2 3|4", "1 \"2 3\" 4" );
|
||||
|
||||
// check for (broken) Windows semantics: backslash doesn't escape spaces
|
||||
WX_ASSERT_DOS_ARGS_EQUAL( "\\\\foo\\\\|/bar", "\"\\\\foo\\\\\" /bar" );
|
||||
WX_ASSERT_DOS_ARGS_EQUAL( "foo|bar\\|baz", "foo bar\\ baz" );
|
||||
WX_ASSERT_DOS_ARGS_EQUAL( "foo|bar\\\"baz", "foo \"bar\\\"baz\"" );
|
||||
|
||||
// check for more sane Unix semantics: backslash does escape spaces and
|
||||
// quotes
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "foo|bar baz", "foo bar\\ baz" );
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "foo|bar\"baz", "foo \"bar\\\"baz\"" );
|
||||
|
||||
// check that single quotes work too with Unix semantics
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "foo bar", "'foo bar'" )
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "foo|bar baz", "foo 'bar baz'" )
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "foo|bar baz", "foo 'bar baz'" )
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "O'Henry", "\"O'Henry\"" )
|
||||
WX_ASSERT_UNIX_ARGS_EQUAL( "O'Henry", "O\\'Henry" )
|
||||
|
||||
#undef WX_ASSERT_DOS_ARGS_EQUAL
|
||||
#undef WX_ASSERT_UNIX_ARGS_EQUAL
|
||||
#undef WX_ASSERT_ARGS_EQUAL
|
||||
}
|
||||
|
||||
void CmdLineTestCase::ParseSwitches()
|
||||
{
|
||||
// install a dummy message output object just suppress error messages from
|
||||
// wxCmdLineParser::Parse()
|
||||
class NoMessageOutput : public wxMessageOutput
|
||||
{
|
||||
public:
|
||||
virtual void Output(const wxString& WXUNUSED(str)) override { }
|
||||
} noMessages;
|
||||
|
||||
wxMessageOutput * const old = wxMessageOutput::Set(&noMessages);
|
||||
wxON_BLOCK_EXIT1( wxMessageOutput::Set, old );
|
||||
|
||||
wxCmdLineParser p;
|
||||
p.AddSwitch("a");
|
||||
p.AddSwitch("b");
|
||||
p.AddSwitch("c");
|
||||
p.AddSwitch("d");
|
||||
p.AddSwitch("n", "neg", "Switch that can be negated",
|
||||
wxCMD_LINE_SWITCH_NEGATABLE);
|
||||
|
||||
p.SetCmdLine("");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT( !p.Found("a") );
|
||||
|
||||
p.SetCmdLine("-z");
|
||||
CPPUNIT_ASSERT( p.Parse(false) != 0 );
|
||||
|
||||
p.SetCmdLine("-a");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT( p.Found("a") );
|
||||
CPPUNIT_ASSERT( !p.Found("b") );
|
||||
|
||||
p.SetCmdLine("-a -d");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT( p.Found("a") );
|
||||
CPPUNIT_ASSERT( !p.Found("b") );
|
||||
CPPUNIT_ASSERT( !p.Found("c") );
|
||||
CPPUNIT_ASSERT( p.Found("d") );
|
||||
|
||||
p.SetCmdLine("-abd");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT( p.Found("a") );
|
||||
CPPUNIT_ASSERT( p.Found("b") );
|
||||
CPPUNIT_ASSERT( !p.Found("c") );
|
||||
CPPUNIT_ASSERT( p.Found("d") );
|
||||
|
||||
p.SetCmdLine("-abdz");
|
||||
CPPUNIT_ASSERT( p.Parse(false) != 0 );
|
||||
|
||||
p.SetCmdLine("-ab -cd");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT( p.Found("a") );
|
||||
CPPUNIT_ASSERT( p.Found("b") );
|
||||
CPPUNIT_ASSERT( p.Found("c") );
|
||||
CPPUNIT_ASSERT( p.Found("d") );
|
||||
|
||||
p.SetCmdLine("-da");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT( p.Found("a") );
|
||||
CPPUNIT_ASSERT( !p.Found("b") );
|
||||
CPPUNIT_ASSERT( !p.Found("c") );
|
||||
CPPUNIT_ASSERT( p.Found("d") );
|
||||
|
||||
p.SetCmdLine("-n");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_NOT_FOUND, p.FoundSwitch("a") );
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_ON, p.FoundSwitch("n") );
|
||||
|
||||
p.SetCmdLine("-n-");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_OFF, p.FoundSwitch("neg") );
|
||||
|
||||
p.SetCmdLine("--neg");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_ON, p.FoundSwitch("neg") );
|
||||
|
||||
p.SetCmdLine("--neg-");
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_SWITCH_OFF, p.FoundSwitch("n") );
|
||||
}
|
||||
|
||||
void CmdLineTestCase::ArgumentsCollection()
|
||||
{
|
||||
wxCmdLineParser p;
|
||||
|
||||
p.AddLongSwitch ("verbose");
|
||||
p.AddOption ("l", "long", wxEmptyString, wxCMD_LINE_VAL_NUMBER);
|
||||
p.AddOption ("d", "date", wxEmptyString, wxCMD_LINE_VAL_DATE);
|
||||
p.AddOption ("f", "double", wxEmptyString, wxCMD_LINE_VAL_DOUBLE);
|
||||
p.AddOption ("s", "string", wxEmptyString, wxCMD_LINE_VAL_STRING);
|
||||
p.AddParam (wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE);
|
||||
|
||||
wxDateTime wasNow = wxDateTime::Now().GetDateOnly();
|
||||
p.SetCmdLine (wxString::Format ("--verbose param1 -l 22 -d \"%s\" -f 50.12e-1 param2 --string \"some string\"",
|
||||
wasNow.FormatISODate()));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, p.Parse(false) );
|
||||
|
||||
wxCmdLineArgs::const_iterator itargs = p.GetArguments().begin();
|
||||
|
||||
// --verbose
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_SWITCH, itargs->GetKind());
|
||||
CPPUNIT_ASSERT_EQUAL("verbose", itargs->GetLongName());
|
||||
CPPUNIT_ASSERT_EQUAL(false, itargs->IsNegated());
|
||||
|
||||
// param1
|
||||
++itargs; // pre incrementation test
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_PARAM, itargs->GetKind());
|
||||
CPPUNIT_ASSERT_EQUAL("param1", itargs->GetStrVal());
|
||||
|
||||
// -l 22
|
||||
itargs++; // post incrementation test
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_OPTION, itargs->GetKind());
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_VAL_NUMBER, itargs->GetType());
|
||||
CPPUNIT_ASSERT_EQUAL("l", itargs->GetShortName());
|
||||
CPPUNIT_ASSERT_EQUAL(22, itargs->GetLongVal());
|
||||
|
||||
// -d (some date)
|
||||
++itargs;
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_OPTION, itargs->GetKind());
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_VAL_DATE, itargs->GetType());
|
||||
CPPUNIT_ASSERT_EQUAL("d", itargs->GetShortName());
|
||||
CPPUNIT_ASSERT_EQUAL(wasNow, itargs->GetDateVal());
|
||||
|
||||
// -f 50.12e-1
|
||||
++itargs;
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_OPTION, itargs->GetKind());
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_VAL_DOUBLE, itargs->GetType());
|
||||
CPPUNIT_ASSERT_EQUAL("f", itargs->GetShortName());
|
||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(50.12e-1, itargs->GetDoubleVal(), 0.000001);
|
||||
|
||||
// param2
|
||||
++itargs;
|
||||
CPPUNIT_ASSERT_EQUAL (wxCMD_LINE_PARAM, itargs->GetKind());
|
||||
CPPUNIT_ASSERT_EQUAL ("param2", itargs->GetStrVal());
|
||||
|
||||
// --string "some string"
|
||||
++itargs;
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_OPTION, itargs->GetKind());
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_VAL_STRING, itargs->GetType());
|
||||
CPPUNIT_ASSERT_EQUAL("s", itargs->GetShortName());
|
||||
CPPUNIT_ASSERT_EQUAL("string", itargs->GetLongName());
|
||||
CPPUNIT_ASSERT_EQUAL("some string", itargs->GetStrVal());
|
||||
|
||||
// testing pre and post-increment
|
||||
--itargs;
|
||||
itargs--;
|
||||
CPPUNIT_ASSERT_EQUAL(wxCMD_LINE_VAL_DOUBLE, itargs->GetType());
|
||||
|
||||
++itargs;++itargs;++itargs;
|
||||
CPPUNIT_ASSERT(itargs == p.GetArguments().end());
|
||||
}
|
||||
|
||||
void CmdLineTestCase::Usage()
|
||||
{
|
||||
wxGCC_WARNING_SUPPRESS(missing-field-initializers)
|
||||
|
||||
// check that Usage() returns roughly what we expect (don't check all the
|
||||
// details, its format can change in the future)
|
||||
static const wxCmdLineEntryDesc desc[] =
|
||||
{
|
||||
{ wxCMD_LINE_USAGE_TEXT, nullptr, nullptr, "Verbosity options" },
|
||||
{ wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },
|
||||
{ wxCMD_LINE_SWITCH, "q", "quiet", "be quiet" },
|
||||
|
||||
{ wxCMD_LINE_USAGE_TEXT, nullptr, nullptr, "Output options" },
|
||||
{ wxCMD_LINE_OPTION, "o", "output", "output file" },
|
||||
{ wxCMD_LINE_OPTION, "s", "size", "output block size", wxCMD_LINE_VAL_NUMBER },
|
||||
{ wxCMD_LINE_OPTION, "d", "date", "output file date", wxCMD_LINE_VAL_DATE },
|
||||
{ wxCMD_LINE_OPTION, "f", "double", "output double", wxCMD_LINE_VAL_DOUBLE },
|
||||
|
||||
{ wxCMD_LINE_PARAM, nullptr, nullptr, "input file", },
|
||||
|
||||
{ wxCMD_LINE_USAGE_TEXT, nullptr, nullptr, "\nEven more usage text" },
|
||||
{ wxCMD_LINE_NONE }
|
||||
};
|
||||
|
||||
wxGCC_WARNING_RESTORE(missing-field-initializers)
|
||||
|
||||
wxCmdLineParser p(desc);
|
||||
const wxArrayString usageLines = wxSplit(p.GetUsageString(), '\n');
|
||||
|
||||
enum
|
||||
{
|
||||
Line_Synopsis,
|
||||
Line_Text_Verbosity,
|
||||
Line_Verbose,
|
||||
Line_Quiet,
|
||||
Line_Text_Output,
|
||||
Line_Output_File,
|
||||
Line_Output_Size,
|
||||
Line_Output_Date,
|
||||
Line_Output_Double,
|
||||
Line_Text_Dummy1,
|
||||
Line_Text_Dummy2,
|
||||
Line_Last,
|
||||
Line_Max
|
||||
};
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)Line_Max, usageLines.size());
|
||||
CPPUNIT_ASSERT_EQUAL("Verbosity options", usageLines[Line_Text_Verbosity]);
|
||||
CPPUNIT_ASSERT_EQUAL("", usageLines[Line_Text_Dummy1]);
|
||||
CPPUNIT_ASSERT_EQUAL("Even more usage text", usageLines[Line_Text_Dummy2]);
|
||||
CPPUNIT_ASSERT_EQUAL("", usageLines[Line_Last]);
|
||||
}
|
||||
|
||||
void CmdLineTestCase::Found()
|
||||
{
|
||||
wxGCC_WARNING_SUPPRESS(missing-field-initializers)
|
||||
|
||||
static const wxCmdLineEntryDesc desc[] =
|
||||
{
|
||||
{ wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },
|
||||
{ wxCMD_LINE_OPTION, "o", "output", "output file" },
|
||||
{ wxCMD_LINE_OPTION, "s", "size", "output block size", wxCMD_LINE_VAL_NUMBER },
|
||||
{ wxCMD_LINE_OPTION, "d", "date", "output file date", wxCMD_LINE_VAL_DATE },
|
||||
{ wxCMD_LINE_OPTION, "f", "double", "output double", wxCMD_LINE_VAL_DOUBLE },
|
||||
{ wxCMD_LINE_PARAM, nullptr, nullptr, "input file", },
|
||||
{ wxCMD_LINE_NONE }
|
||||
};
|
||||
|
||||
wxGCC_WARNING_RESTORE(missing-field-initializers)
|
||||
|
||||
wxCmdLineParser p(desc);
|
||||
p.SetCmdLine ("-v --output hello -s 2 --date=2014-02-17 -f 0.2 input-file.txt");
|
||||
|
||||
CPPUNIT_ASSERT(p.Parse() == 0);
|
||||
|
||||
wxString dummys;
|
||||
wxDateTime dummydate;
|
||||
long dummyl;
|
||||
double dummyd;
|
||||
// now verify that any option/switch badly queried actually generates an exception
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("v", &dummyd));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("v", &dummydate));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("v", &dummyl));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("v", &dummys));
|
||||
CPPUNIT_ASSERT(p.FoundSwitch("v") != wxCMD_SWITCH_NOT_FOUND);
|
||||
CPPUNIT_ASSERT(p.Found("v"));
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("o", &dummyd));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("o", &dummydate));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("o", &dummyl));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.FoundSwitch("o"));
|
||||
CPPUNIT_ASSERT(p.Found("o", &dummys));
|
||||
CPPUNIT_ASSERT(p.Found("o"));
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("s", &dummyd));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("s", &dummydate));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("s", &dummys));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.FoundSwitch("s"));
|
||||
CPPUNIT_ASSERT(p.Found("s", &dummyl));
|
||||
CPPUNIT_ASSERT(p.Found("s"));
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("d", &dummyd));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("d", &dummyl));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("d", &dummys));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.FoundSwitch("d"));
|
||||
CPPUNIT_ASSERT(p.Found("d", &dummydate));
|
||||
CPPUNIT_ASSERT(p.Found("d"));
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("f", &dummydate));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("f", &dummyl));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.Found("f", &dummys));
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(p.FoundSwitch("f"));
|
||||
CPPUNIT_ASSERT(p.Found("f", &dummyd));
|
||||
CPPUNIT_ASSERT(p.Found("f"));
|
||||
}
|
||||
215
libs/wxWidgets-3.3.1/tests/config/config.cpp
Normal file
215
libs/wxWidgets-3.3.1/tests/config/config.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/config/config.cpp
|
||||
// Purpose: wxConfig unit test
|
||||
// Author: Marcin Wojdyr
|
||||
// Created: 2007-07-07
|
||||
// Copyright: (c) 2007 Marcin Wojdyr
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// NOTE: this test is compiled both as part of the non-GUI test and test_gui
|
||||
// because it can only use wxColour in the latter.
|
||||
//
|
||||
// See also tests/config/fileconf.cpp for wxFileConfig specific tests and
|
||||
// tests/config/regconf.cpp for wxRegConfig specific tests.
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_CONFIG
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/config.h"
|
||||
|
||||
// Tests using wxColour can only be done when using GUI library and they
|
||||
// require template functions that are not supported by some ancient compilers.
|
||||
#if wxUSE_GUI && defined(wxHAS_CONFIG_TEMPLATE_RW)
|
||||
#define TEST_WXCOLOUR
|
||||
#endif
|
||||
|
||||
#ifdef TEST_WXCOLOUR
|
||||
#include "wx/colour.h"
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// the tests
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxConfig::ReadWriteLocal", "[config]")
|
||||
{
|
||||
wxString app = "wxConfigTestCase";
|
||||
wxString vendor = "wxWidgets";
|
||||
|
||||
// See comment in regconf.cpp.
|
||||
const wxLongLong_t val64 = wxLL(0x8000000000000008);
|
||||
const wxULongLong_t uval64 = wxULL(0x9000000000000009);
|
||||
|
||||
{
|
||||
wxConfig config(app, vendor, "", "", wxCONFIG_USE_LOCAL_FILE);
|
||||
config.DeleteAll();
|
||||
config.Write("string1", "abc");
|
||||
config.Write("string2", wxString("def"));
|
||||
config.Write("int1", 123);
|
||||
config.Write(wxString("long1"), 234L);
|
||||
config.Write("double1", 345.67);
|
||||
config.Write("bool1", true);
|
||||
|
||||
config.Write("ll", val64);
|
||||
|
||||
config.Write("ull", uval64);
|
||||
|
||||
config.Write("size", size_t(UINT_MAX));
|
||||
#ifdef TEST_WXCOLOUR
|
||||
config.Write("color1", wxColour(11,22,33,44));
|
||||
#endif // TEST_WXCOLOUR
|
||||
config.Flush();
|
||||
}
|
||||
|
||||
wxConfig config(app, vendor, "", "", wxCONFIG_USE_LOCAL_FILE);
|
||||
wxString string1 = config.Read("string1");
|
||||
CHECK( string1 == "abc" );
|
||||
string1 = config.Read("string1", "defaultvalue");
|
||||
CHECK( string1 == "abc" );
|
||||
|
||||
wxString string2;
|
||||
bool r = config.Read("string2", &string2);
|
||||
CHECK( r );
|
||||
CHECK( string2 == "def" );
|
||||
|
||||
r = config.Read("string2", &string2, "defaultvalue");
|
||||
CHECK( r );
|
||||
CHECK( string2 == "def" );
|
||||
|
||||
int int1 = config.Read("int1", 5);
|
||||
CHECK( int1 == 123 );
|
||||
|
||||
long long1;
|
||||
r = config.Read("long1", &long1);
|
||||
CHECK( r );
|
||||
CHECK( long1 == 234L );
|
||||
|
||||
CHECK( config.ReadLong("long1", 0) == 234 );
|
||||
|
||||
double double1;
|
||||
r = config.Read("double1", &double1);
|
||||
CHECK( r );
|
||||
CHECK( double1 == 345.67 );
|
||||
|
||||
CHECK( config.ReadDouble("double1", 0) == double1 );
|
||||
|
||||
bool bool1;
|
||||
r = config.Read("foo", &bool1); // there is no "foo" key
|
||||
CHECK( !r );
|
||||
|
||||
r = config.Read("bool1", &bool1);
|
||||
CHECK( r );
|
||||
CHECK( bool1 == true );
|
||||
|
||||
CHECK( config.ReadBool("bool1", false) == bool1 );
|
||||
|
||||
wxLongLong_t ll;
|
||||
CHECK( config.Read("ll", &ll) );
|
||||
CHECK( ll == val64 );
|
||||
CHECK( config.ReadLongLong("ll", 0) == val64 );
|
||||
|
||||
CHECK( config.Read("ull", &ll) );
|
||||
CHECK( ll == static_cast<wxLongLong_t>(uval64) );
|
||||
CHECK( config.ReadLongLong("ull", 0) == static_cast<wxLongLong_t>(uval64) );
|
||||
|
||||
size_t size;
|
||||
CHECK( config.Read("size", &size) );
|
||||
CHECK( size == UINT_MAX );
|
||||
|
||||
#ifdef TEST_WXCOLOUR
|
||||
wxColour color1;
|
||||
r = config.Read("color1", &color1);
|
||||
CHECK( r );
|
||||
CHECK( color1 == wxColour(11,22,33,44) );
|
||||
|
||||
CHECK( config.ReadObject("color1", wxNullColour) == color1 );
|
||||
#endif // TEST_WXCOLOUR
|
||||
|
||||
config.DeleteAll();
|
||||
}
|
||||
|
||||
// Helper of RecordingDefaultsTest() test.
|
||||
static
|
||||
size_t ReadValues(const wxConfig& config, bool has_values)
|
||||
{
|
||||
size_t read = 0;
|
||||
bool r;
|
||||
|
||||
config.Read("string1", "abc");
|
||||
read++;
|
||||
|
||||
config.Read("string2", wxString("def"));
|
||||
read++;
|
||||
|
||||
wxString string3;
|
||||
r = config.Read("string3", &string3, "abc");
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
wxString string4;
|
||||
r = config.Read("string4", &string4, wxString("def"));
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
int int1;
|
||||
r = config.Read("int1", &int1, 123);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
int int2 = config.Read("int2", 1234);
|
||||
CHECK( 1234 == int2 );
|
||||
read++;
|
||||
|
||||
long long1;
|
||||
r = config.Read(wxString("long1"), &long1, 234L);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
double double1;
|
||||
r = config.Read("double1", &double1, 345.67);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
bool bool1;
|
||||
r = config.Read("bool1", &bool1, true);
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
|
||||
#ifdef TEST_WXCOLOUR
|
||||
wxColour color1;
|
||||
r = config.Read("color1", &color1, wxColour(11,22,33,44));
|
||||
CHECK( r == has_values );
|
||||
read++;
|
||||
#endif // TEST_WXCOLOUR
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("wxConfig::RecordingDefaults", "[config]")
|
||||
{
|
||||
wxString app = "wxConfigTestCaseRD";
|
||||
wxString vendor = "wxWidgets";
|
||||
wxConfig config(app, vendor, "", "", wxCONFIG_USE_LOCAL_FILE);
|
||||
config.DeleteAll();
|
||||
config.SetRecordDefaults(false); // by default it is false
|
||||
ReadValues(config, false);
|
||||
CHECK( config.GetNumberOfEntries() == 0 );
|
||||
config.SetRecordDefaults(true);
|
||||
size_t read = ReadValues(config, false);
|
||||
CHECK( config.GetNumberOfEntries() == read );
|
||||
ReadValues(config, true);
|
||||
config.DeleteAll();
|
||||
}
|
||||
|
||||
#endif //wxUSE_CONFIG
|
||||
664
libs/wxWidgets-3.3.1/tests/config/fileconf.cpp
Normal file
664
libs/wxWidgets-3.3.1/tests/config/fileconf.cpp
Normal file
@@ -0,0 +1,664 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/fileconf/fileconf.cpp
|
||||
// Purpose: wxFileConf unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2004-09-19
|
||||
// Copyright: (c) 2004 Vadim Zeitlin
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#if wxUSE_FILECONFIG
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/fileconf.h"
|
||||
#include "wx/sstream.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#include "testlog.h"
|
||||
|
||||
static const char *testconfig =
|
||||
"[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[root/group2]\n"
|
||||
;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// local functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static wxString Dump(wxFileConfig& fc)
|
||||
{
|
||||
wxStringOutputStream sos;
|
||||
fc.Save(sos);
|
||||
return wxTextFile::Translate(sos.GetString(), wxTextFileType_Unix);
|
||||
}
|
||||
|
||||
// helper macro to test wxFileConfig contents
|
||||
#define wxVERIFY_FILECONFIG(t, fc) CHECK(Dump(fc) == t)
|
||||
|
||||
static wxString ChangePath(wxFileConfig& fc, const char *path)
|
||||
{
|
||||
fc.SetPath(path);
|
||||
|
||||
return fc.GetPath();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxFileConfig::Path", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( ChangePath(fc, "") == "" );
|
||||
CHECK( ChangePath(fc, "/") == "" );
|
||||
CHECK( ChangePath(fc, "root") == "/root" );
|
||||
CHECK( ChangePath(fc, "/root") == "/root" );
|
||||
CHECK( ChangePath(fc, "/root/group1/subgroup") == "/root/group1/subgroup" );
|
||||
CHECK( ChangePath(fc, "/root/group2") == "/root/group2" );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::AddEntries", "[fileconfig][config]")
|
||||
{
|
||||
wxFileConfig fc;
|
||||
|
||||
wxVERIFY_FILECONFIG( "", fc );
|
||||
|
||||
fc.Write("/Foo", "foo");
|
||||
wxVERIFY_FILECONFIG( "Foo=foo\n", fc );
|
||||
|
||||
fc.Write("/Bar/Baz", "baz");
|
||||
wxVERIFY_FILECONFIG( "Foo=foo\n[Bar]\nBaz=baz\n", fc );
|
||||
|
||||
fc.DeleteAll();
|
||||
wxVERIFY_FILECONFIG( "", fc );
|
||||
|
||||
fc.Write("/Bar/Baz", "baz");
|
||||
wxVERIFY_FILECONFIG( "[Bar]\nBaz=baz\n", fc );
|
||||
|
||||
fc.Write("/Foo", "foo");
|
||||
wxVERIFY_FILECONFIG( "Foo=foo\n[Bar]\nBaz=baz\n", fc );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void
|
||||
CheckGroupEntries(const wxFileConfig& fc,
|
||||
const char *path,
|
||||
size_t nEntries,
|
||||
...)
|
||||
{
|
||||
wxConfigPathChanger change(&fc, wxString(path) + "/");
|
||||
|
||||
CHECK( fc.GetNumberOfEntries() == nEntries );
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, nEntries);
|
||||
|
||||
long cookie;
|
||||
wxString name;
|
||||
for ( bool cont = fc.GetFirstEntry(name, cookie);
|
||||
cont;
|
||||
cont = fc.GetNextEntry(name, cookie), nEntries-- )
|
||||
{
|
||||
CHECK( name == va_arg(ap, char *) );
|
||||
}
|
||||
|
||||
CHECK( nEntries == 0 );
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
CheckGroupSubgroups(const wxFileConfig& fc,
|
||||
const char *path,
|
||||
size_t nGroups,
|
||||
...)
|
||||
{
|
||||
wxConfigPathChanger change(&fc, wxString(path) + "/");
|
||||
|
||||
CHECK( fc.GetNumberOfGroups() == nGroups );
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, nGroups);
|
||||
|
||||
long cookie;
|
||||
wxString name;
|
||||
for ( bool cont = fc.GetFirstGroup(name, cookie);
|
||||
cont;
|
||||
cont = fc.GetNextGroup(name, cookie), nGroups-- )
|
||||
{
|
||||
CHECK( name == va_arg(ap, char *) );
|
||||
}
|
||||
|
||||
CHECK( nGroups == 0 );
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_CASE("wxFileConfig::GetEntries", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CheckGroupEntries(fc, "", 0);
|
||||
CheckGroupEntries(fc, "/root", 1, "entry");
|
||||
CheckGroupEntries(fc, "/root/group1", 0);
|
||||
CheckGroupEntries(fc, "/root/group1/subgroup",
|
||||
2, "subentry", "subentry2");
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::GetGroups", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CheckGroupSubgroups(fc, "", 1, "root");
|
||||
CheckGroupSubgroups(fc, "/root", 2, "group1", "group2");
|
||||
CheckGroupSubgroups(fc, "/root/group1", 1, "subgroup");
|
||||
CheckGroupSubgroups(fc, "/root/group2", 0);
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::HasEntry", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( !fc.HasEntry("root") );
|
||||
CHECK( fc.HasEntry("root/entry") );
|
||||
CHECK( fc.HasEntry("/root/entry") );
|
||||
CHECK( fc.HasEntry("root/group1/subgroup/subentry") );
|
||||
CHECK( !fc.HasEntry("") );
|
||||
CHECK( !fc.HasEntry("root/group1") );
|
||||
CHECK( !fc.HasEntry("subgroup/subentry") );
|
||||
CHECK( !fc.HasEntry("/root/no_such_group/entry") );
|
||||
CHECK( !fc.HasGroup("/root/no_such_group") );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::HasGroup", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( fc.HasGroup("root") );
|
||||
CHECK( fc.HasGroup("root/group1") );
|
||||
CHECK( fc.HasGroup("root/group1/subgroup") );
|
||||
CHECK( fc.HasGroup("root/group2") );
|
||||
CHECK( !fc.HasGroup("") );
|
||||
CHECK( !fc.HasGroup("root/group") );
|
||||
CHECK( !fc.HasGroup("root//subgroup") );
|
||||
CHECK( !fc.HasGroup("foot/subgroup") );
|
||||
CHECK( !fc.HasGroup("foot") );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::Binary", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(
|
||||
"[root]\n"
|
||||
"binary=Zm9vCg==\n"
|
||||
);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
wxMemoryBuffer buf;
|
||||
fc.Read("/root/binary", &buf);
|
||||
|
||||
CHECK( memcmp("foo\n", buf.GetData(), buf.GetDataLen()) == 0 );
|
||||
|
||||
buf.SetDataLen(0);
|
||||
buf.AppendData("\0\1\2", 3);
|
||||
fc.Write("/root/012", buf);
|
||||
wxVERIFY_FILECONFIG(
|
||||
"[root]\n"
|
||||
"binary=Zm9vCg==\n"
|
||||
"012=AAEC\n",
|
||||
fc
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::Save", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
wxVERIFY_FILECONFIG( testconfig, fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteEntry", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( !fc.DeleteEntry("foo") );
|
||||
|
||||
CHECK( fc.DeleteEntry("root/group1/subgroup/subentry") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
|
||||
// group should be deleted now as well as it became empty
|
||||
wxConfigPathChanger change(&fc, "root/group1/subgroup/subentry2");
|
||||
CHECK( fc.DeleteEntry("subentry2") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteAndWriteEntry", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(
|
||||
"[root/group1]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"subentry3=subvalue3\n"
|
||||
);
|
||||
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.DeleteEntry("/root/group1/subentry2");
|
||||
fc.Write("/root/group1/subentry2", "testvalue");
|
||||
fc.DeleteEntry("/root/group2/subentry2");
|
||||
fc.Write("/root/group2/subentry2", "testvalue2");
|
||||
fc.DeleteEntry("/root/group1/subentry2");
|
||||
fc.Write("/root/group1/subentry2", "testvalue");
|
||||
fc.DeleteEntry("/root/group2/subentry2");
|
||||
fc.Write("/root/group2/subentry2", "testvalue2");
|
||||
|
||||
wxVERIFY_FILECONFIG( "[root/group1]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry3=subvalue3\n"
|
||||
"subentry2=testvalue\n"
|
||||
"[root/group2]\n"
|
||||
"subentry2=testvalue2\n",
|
||||
fc );
|
||||
|
||||
fc.DeleteEntry("/root/group2/subentry2");
|
||||
wxVERIFY_FILECONFIG( "[root/group1]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry3=subvalue3\n"
|
||||
"subentry2=testvalue\n",
|
||||
fc );
|
||||
|
||||
fc.DeleteEntry("/root/group1/subentry2");
|
||||
fc.DeleteEntry("/root/group1/subentry");
|
||||
fc.DeleteEntry("/root/group1/subentry3");
|
||||
wxVERIFY_FILECONFIG( "", fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteLastRootEntry", "[fileconfig][config]")
|
||||
{
|
||||
// This tests for the bug which occurred when the last entry of the root
|
||||
// group was deleted: this corrupted internal state and resulted in a crash
|
||||
// after trying to write the just deleted entry again.
|
||||
wxStringInputStream sis("");
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.Write("key", "value");
|
||||
wxVERIFY_FILECONFIG( "key=value\n", fc );
|
||||
|
||||
fc.DeleteEntry("key");
|
||||
wxVERIFY_FILECONFIG( "", fc );
|
||||
|
||||
fc.Write("key", "value");
|
||||
wxVERIFY_FILECONFIG( "key=value\n", fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteGroup", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( !fc.DeleteGroup("foo") );
|
||||
|
||||
CHECK( fc.DeleteGroup("root/group1") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
|
||||
// notice trailing slash: it should be ignored
|
||||
CHECK( fc.DeleteGroup("root/group2/") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"entry=value\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.DeleteGroup("root") );
|
||||
CHECK( Dump(fc).empty() );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteAll", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( fc.DeleteAll() );
|
||||
CHECK( Dump(fc).empty() );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::RenameEntry", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.SetPath("root");
|
||||
CHECK( fc.RenameEntry("entry", "newname") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"newname=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
|
||||
fc.SetPath("group1/subgroup");
|
||||
CHECK( !fc.RenameEntry("entry", "newname") );
|
||||
CHECK( !fc.RenameEntry("subentry", "subentry2") );
|
||||
|
||||
CHECK( fc.RenameEntry("subentry", "subentry1") );
|
||||
wxVERIFY_FILECONFIG( "[root]\n"
|
||||
"newname=value\n"
|
||||
"[root/group1]\n"
|
||||
"[root/group1/subgroup]\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"subentry1=subvalue\n"
|
||||
"[root/group2]\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::RenameGroup", "[fileconfig][config]")
|
||||
{
|
||||
wxStringInputStream sis(testconfig);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK( fc.RenameGroup("root", "foot") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group1]\n"
|
||||
"[foot/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group2]\n",
|
||||
fc );
|
||||
|
||||
// renaming a path doesn't work, it must be the immediate group
|
||||
CHECK( !fc.RenameGroup("foot/group1", "group2") );
|
||||
|
||||
|
||||
fc.SetPath("foot");
|
||||
|
||||
// renaming to a name of existing group doesn't work
|
||||
CHECK( !fc.RenameGroup("group1", "group2") );
|
||||
|
||||
// try exchanging the groups names and then restore them back
|
||||
CHECK( fc.RenameGroup("group1", "groupTmp") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/groupTmp]\n"
|
||||
"[foot/groupTmp/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group2]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup("group2", "group1") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/groupTmp]\n"
|
||||
"[foot/groupTmp/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group1]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup("groupTmp", "group2") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group2]\n"
|
||||
"[foot/group2/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group1]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup("group1", "groupTmp") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group2]\n"
|
||||
"[foot/group2/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/groupTmp]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup("group2", "group1") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group1]\n"
|
||||
"[foot/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/groupTmp]\n",
|
||||
fc );
|
||||
|
||||
CHECK( fc.RenameGroup("groupTmp", "group2") );
|
||||
wxVERIFY_FILECONFIG( "[foot]\n"
|
||||
"entry=value\n"
|
||||
"[foot/group1]\n"
|
||||
"[foot/group1/subgroup]\n"
|
||||
"subentry=subvalue\n"
|
||||
"subentry2=subvalue2\n"
|
||||
"[foot/group2]\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::CreateSubgroupAndEntries", "[fileconfig][config]")
|
||||
{
|
||||
wxFileConfig fc;
|
||||
fc.Write("sub/sub_first", "sub_one");
|
||||
fc.Write("first", "one");
|
||||
|
||||
wxVERIFY_FILECONFIG( "first=one\n"
|
||||
"[sub]\n"
|
||||
"sub_first=sub_one\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::CreateEntriesAndSubgroup", "[fileconfig][config]")
|
||||
{
|
||||
wxFileConfig fc;
|
||||
fc.Write("first", "one");
|
||||
fc.Write("second", "two");
|
||||
fc.Write("sub/sub_first", "sub_one");
|
||||
|
||||
wxVERIFY_FILECONFIG( "first=one\n"
|
||||
"second=two\n"
|
||||
"[sub]\n"
|
||||
"sub_first=sub_one\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
static void EmptyConfigAndWriteKey()
|
||||
{
|
||||
wxFileConfig fc("deleteconftest");
|
||||
|
||||
const wxString groupPath = "/root";
|
||||
|
||||
if ( fc.Exists(groupPath) )
|
||||
{
|
||||
// using DeleteGroup exposes the problem, using DeleteAll doesn't
|
||||
CHECK( fc.DeleteGroup(groupPath) );
|
||||
}
|
||||
|
||||
// the config must be empty for the problem to arise
|
||||
CHECK( !fc.GetNumberOfEntries(true) );
|
||||
CHECK( !fc.GetNumberOfGroups(true) );
|
||||
|
||||
|
||||
// this crashes on second call of this function
|
||||
CHECK( fc.Write(groupPath + "/entry", "value") );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteLastGroup", "[fileconfig][config]")
|
||||
{
|
||||
/*
|
||||
We make 2 of the same calls, first to create a file config with a single
|
||||
group and key...
|
||||
*/
|
||||
::EmptyConfigAndWriteKey();
|
||||
|
||||
/*
|
||||
... then the same but this time the key's group is deleted before the
|
||||
key is written again. This causes a crash.
|
||||
*/
|
||||
::EmptyConfigAndWriteKey();
|
||||
|
||||
|
||||
// clean up
|
||||
wxLogNull noLogging;
|
||||
(void) ::wxRemoveFile(wxFileConfig::GetLocalFileName("deleteconftest"));
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::DeleteAndRecreateGroup", "[fileconfig][config]")
|
||||
{
|
||||
static const char *confInitial =
|
||||
"[First]\n"
|
||||
"Value1=Foo\n"
|
||||
"[Second]\n"
|
||||
"Value2=Bar\n";
|
||||
|
||||
wxStringInputStream sis(confInitial);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.DeleteGroup("Second");
|
||||
wxVERIFY_FILECONFIG( "[First]\n"
|
||||
"Value1=Foo\n",
|
||||
fc );
|
||||
|
||||
fc.Write("Second/Value2", "New");
|
||||
wxVERIFY_FILECONFIG( "[First]\n"
|
||||
"Value1=Foo\n"
|
||||
"[Second]\n"
|
||||
"Value2=New\n",
|
||||
fc );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::AddToExistingRoot", "[fileconfig][config]")
|
||||
{
|
||||
static const char *confInitial =
|
||||
"[Group]\n"
|
||||
"value1=foo\n";
|
||||
|
||||
wxStringInputStream sis(confInitial);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
fc.Write("/value1", "bar");
|
||||
wxVERIFY_FILECONFIG(
|
||||
"value1=bar\n"
|
||||
"[Group]\n"
|
||||
"value1=foo\n",
|
||||
fc
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::ReadNonExistent", "[fileconfig][config]")
|
||||
{
|
||||
static const char *confTest =
|
||||
"community=censored\n"
|
||||
"[City1]\n"
|
||||
"URL=www.fake1.na\n"
|
||||
"[City1/A1]\n"
|
||||
"[City1/A1/1]\n"
|
||||
"IP=192.168.1.66\n"
|
||||
"URL=www.fake2.na\n"
|
||||
;
|
||||
|
||||
wxStringInputStream sis(confTest);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
wxString url;
|
||||
CHECK( !fc.Read("URL", &url) );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::ReadEmpty", "[fileconfig][config]")
|
||||
{
|
||||
static const char *confTest = "";
|
||||
|
||||
wxStringInputStream sis(confTest);
|
||||
wxFileConfig fc(sis);
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::ReadFloat", "[fileconfig][config]")
|
||||
{
|
||||
static const char *confTest =
|
||||
"x=1.234\n"
|
||||
"y=-9876.5432\n"
|
||||
"z=2e+308\n"
|
||||
;
|
||||
|
||||
wxStringInputStream sis(confTest);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
float f;
|
||||
CHECK( fc.Read("x", &f) );
|
||||
CHECK( f == 1.234f );
|
||||
|
||||
CHECK( fc.Read("y", &f) );
|
||||
CHECK( f == -9876.5432f );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFileConfig::LongLong", "[fileconfig][config][longlong]")
|
||||
{
|
||||
wxFileConfig fc("", "", "", "", 0); // Don't use any files.
|
||||
|
||||
// See comment near val64 definition in regconf.cpp.
|
||||
const wxLongLong_t val = wxLL(0x8000000000000008);
|
||||
REQUIRE( fc.Write("ll", val) );
|
||||
|
||||
wxLongLong_t ll;
|
||||
REQUIRE( fc.Read("ll", &ll) );
|
||||
CHECK( ll == val );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(LogTestCase, "wxFileConfig::Error", "[fileconfig][error]")
|
||||
{
|
||||
const auto checkWarning = [this](const char* contents, const char* expected)
|
||||
{
|
||||
wxStringInputStream sis(contents);
|
||||
wxFileConfig fc(sis);
|
||||
|
||||
CHECK_THAT( m_log->GetLog(wxLOG_Warning).utf8_string(),
|
||||
Catch::Contains(expected) );
|
||||
m_log->Clear();
|
||||
};
|
||||
|
||||
// Check that the expected warning is logged.
|
||||
checkWarning("foo=\\", "trailing backslash");
|
||||
|
||||
// Check that it's the second quote which is unexpected, not the first one.
|
||||
checkWarning(R"(foo="x"y)", R"(unexpected " at position 3)");
|
||||
}
|
||||
|
||||
#endif // wxUSE_FILECONFIG
|
||||
|
||||
91
libs/wxWidgets-3.3.1/tests/config/regconf.cpp
Normal file
91
libs/wxWidgets-3.3.1/tests/config/regconf.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/config/regconf.cpp
|
||||
// Purpose: wxRegConfig unit test
|
||||
// Author: Francesco Montorsi (extracted from console sample)
|
||||
// Created: 2010-06-02
|
||||
// Copyright: (c) 2010 wxWidgets team
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#if wxUSE_CONFIG && wxUSE_REGKEY
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/msw/regconf.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxRegConfig::ReadWrite", "[regconfig][config][registry]")
|
||||
{
|
||||
wxString app = "wxRegConfigTestCase";
|
||||
wxString vendor = "wxWidgets";
|
||||
|
||||
// NOTE: we use wxCONFIG_USE_LOCAL_FILE explicitly to test wxRegConfig
|
||||
// with something different from the default value wxCONFIG_USE_GLOBAL_FILE
|
||||
wxRegConfig config(app, vendor, "", "", wxCONFIG_USE_LOCAL_FILE);
|
||||
|
||||
// test writing
|
||||
config.SetPath("/group1");
|
||||
CHECK( config.Write("entry1", "foo") );
|
||||
config.SetPath("/group2");
|
||||
CHECK( config.Write("entry1", "bar") );
|
||||
|
||||
CHECK( config.Write("int32", 1234567) );
|
||||
|
||||
// Note that type of wxLL(0x8000000000000008) literal is somehow unsigned
|
||||
// long long with MinGW, not sure if it's a bug or not, but work around it
|
||||
// by specifying the type explicitly.
|
||||
const wxLongLong_t val64 = wxLL(0x8000000000000008);
|
||||
CHECK( config.Write("int64", val64) );
|
||||
|
||||
// test reading
|
||||
wxString str;
|
||||
long dummy;
|
||||
|
||||
config.SetPath("/");
|
||||
CHECK( config.GetFirstGroup(str, dummy) );
|
||||
CHECK( str == "group1" );
|
||||
CHECK( config.Read("group1/entry1", "INVALID DEFAULT") == "foo" );
|
||||
CHECK( config.GetNextGroup(str, dummy) );
|
||||
CHECK( str == "group2" );
|
||||
CHECK( config.Read("group2/entry1", "INVALID DEFAULT") == "bar" );
|
||||
|
||||
CHECK( config.ReadLong("group2/int32", 0) == 1234567 );
|
||||
CHECK( config.ReadLongLong("group2/int64", 0) == val64 );
|
||||
|
||||
config.DeleteAll();
|
||||
}
|
||||
|
||||
TEST_CASE("wxRegKey::DeleteFromRedirectedView", "[registry][64bits]")
|
||||
{
|
||||
if ( !wxIsPlatform64Bit() )
|
||||
{
|
||||
// Test needs WoW64.
|
||||
return;
|
||||
}
|
||||
|
||||
// Test inside a key that's known to be redirected and is in HKCU so that
|
||||
// admin rights are not required (unlike with HKLM).
|
||||
wxRegKey key(wxRegKey::HKCU, "SOFTWARE\\Classes\\CLSID\\wxWidgetsTestKey",
|
||||
sizeof(void *) == 4
|
||||
? wxRegKey::WOW64ViewMode_64
|
||||
: wxRegKey::WOW64ViewMode_32);
|
||||
|
||||
REQUIRE( key.Create() );
|
||||
CHECK( key.DeleteSelf() );
|
||||
CHECK( !key.Exists() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_CONFIG && wxUSE_REGKEY
|
||||
|
||||
360
libs/wxWidgets-3.3.1/tests/controls/auitest.cpp
Normal file
360
libs/wxWidgets-3.3.1/tests/controls/auitest.cpp
Normal file
@@ -0,0 +1,360 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/auitest.cpp
|
||||
// Purpose: wxAui control tests
|
||||
// Author: Sebastian Walderich
|
||||
// Created: 2018-12-19
|
||||
// Copyright: (c) 2018 Sebastian Walderich
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_AUI
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/panel.h"
|
||||
|
||||
#include "wx/aui/auibar.h"
|
||||
#include "wx/aui/auibook.h"
|
||||
#include "wx/aui/serializer.h"
|
||||
|
||||
#include "asserthelper.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test fixtures
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class AuiNotebookTestCase
|
||||
{
|
||||
public:
|
||||
AuiNotebookTestCase()
|
||||
: nb(new wxAuiNotebook(wxTheApp->GetTopWindow()))
|
||||
{
|
||||
}
|
||||
|
||||
~AuiNotebookTestCase()
|
||||
{
|
||||
delete nb;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxAuiNotebook* const nb;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::DoGetBestSize", "[aui]")
|
||||
{
|
||||
wxPanel *p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(100, 100));
|
||||
REQUIRE( nb->AddPage(p, "Center Pane") );
|
||||
|
||||
const int tabHeight = nb->GetTabCtrlHeight();
|
||||
|
||||
SECTION( "Single pane with multiple tabs" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(300, 100));
|
||||
nb->AddPage(p, "Center Tab 2");
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(100, 200));
|
||||
nb->AddPage(p, "Center Tab 3");
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(300, 200 + tabHeight) );
|
||||
}
|
||||
|
||||
SECTION( "Horizontal split" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(25, 0));
|
||||
nb->AddPage(p, "Left Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxLEFT);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(125, 100 + tabHeight) );
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(50, 0));
|
||||
nb->AddPage(p, "Right Pane 1");
|
||||
nb->Split(nb->GetPageCount()-1, wxRIGHT);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(175, 100 + tabHeight) );
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(100, 0));
|
||||
nb->AddPage(p, "Right Pane 2");
|
||||
nb->Split(nb->GetPageCount()-1, wxRIGHT);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(275, 100 + tabHeight) );
|
||||
}
|
||||
|
||||
SECTION( "Vertical split" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(0, 100));
|
||||
nb->AddPage(p, "Top Pane 1");
|
||||
nb->Split(nb->GetPageCount()-1, wxTOP);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(0, 50));
|
||||
nb->AddPage(p, "Top Pane 2");
|
||||
nb->Split(nb->GetPageCount()-1, wxTOP);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(100, 250 + 3*tabHeight) );
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(0, 25));
|
||||
nb->AddPage(p, "Bottom Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxBOTTOM);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(100, 275 + 4*tabHeight) );
|
||||
}
|
||||
|
||||
SECTION( "Surrounding panes" )
|
||||
{
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(50, 25));
|
||||
nb->AddPage(p, "Bottom Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxBOTTOM);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(50, 120));
|
||||
nb->AddPage(p, "Right Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxRIGHT);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(225, 50));
|
||||
nb->AddPage(p, "Top Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxTOP);
|
||||
|
||||
p = new wxPanel(nb);
|
||||
p->SetMinSize(wxSize(25, 105));
|
||||
nb->AddPage(p, "Left Pane");
|
||||
nb->Split(nb->GetPageCount()-1, wxLEFT);
|
||||
|
||||
CHECK( nb->GetBestSize() == wxSize(250, 175 + 3*tabHeight) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::RTTI", "[aui][rtti]")
|
||||
{
|
||||
wxBookCtrlBase* const book = nb;
|
||||
CHECK( wxDynamicCast(book, wxAuiNotebook) == nb );
|
||||
|
||||
CHECK( wxDynamicCast(nb, wxBookCtrlBase) == book );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::FindPage", "[aui]")
|
||||
{
|
||||
wxPanel *p1 = new wxPanel(nb);
|
||||
wxPanel *p2 = new wxPanel(nb);
|
||||
wxPanel *p3 = new wxPanel(nb);
|
||||
REQUIRE( nb->AddPage(p1, "Page 1") );
|
||||
REQUIRE( nb->AddPage(p2, "Page 2") );
|
||||
|
||||
CHECK( nb->FindPage(nullptr) == wxNOT_FOUND );
|
||||
CHECK( nb->FindPage(p1) == 0 );
|
||||
CHECK( nb->FindPage(p2) == 1 );
|
||||
CHECK( nb->FindPage(p3) == wxNOT_FOUND );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(AuiNotebookTestCase, "wxAuiNotebook::Layout", "[aui]")
|
||||
{
|
||||
const auto addPage = [this](int n)
|
||||
{
|
||||
return nb->AddPage(new wxPanel(nb), wxString::Format("Page %d", n + 1));
|
||||
};
|
||||
|
||||
for ( int n = 0; n < 5; n++ )
|
||||
{
|
||||
REQUIRE( addPage(n) );
|
||||
}
|
||||
|
||||
using Ints = std::vector<int>;
|
||||
using Indices = std::vector<size_t>;
|
||||
|
||||
// This serializer allows the code below to tweak its data before using it
|
||||
// as deserializer.
|
||||
class TestSerializer : public wxAuiBookSerializer,
|
||||
public wxAuiBookDeserializer
|
||||
{
|
||||
public:
|
||||
virtual void BeforeSaveNotebook(const wxString& name) override
|
||||
{
|
||||
m_name = name;
|
||||
m_afterSaveCalled = false;
|
||||
m_tabsLayoutInfo.clear();
|
||||
}
|
||||
|
||||
virtual void
|
||||
SaveNotebookTabControl(const wxAuiTabLayoutInfo& tab) override
|
||||
{
|
||||
m_tabsLayoutInfo.push_back(tab);
|
||||
}
|
||||
|
||||
virtual void AfterSaveNotebook() override
|
||||
{
|
||||
m_afterSaveCalled = true;
|
||||
}
|
||||
|
||||
virtual std::vector<wxAuiTabLayoutInfo>
|
||||
LoadNotebookTabs(const wxString& name) override
|
||||
{
|
||||
CHECK( name == m_name );
|
||||
|
||||
m_orphanedPages.clear();
|
||||
|
||||
return m_tabsLayoutInfo;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
HandleOrphanedPage(wxAuiNotebook& WXUNUSED(book),
|
||||
int page,
|
||||
wxAuiTabCtrl** WXUNUSED(tabCtrl),
|
||||
int* tabIndex) override
|
||||
{
|
||||
m_orphanedPages.push_back(page);
|
||||
|
||||
*tabIndex = m_orphanedPageReturnIndex;
|
||||
|
||||
return m_orphanedPageReturnValue;
|
||||
}
|
||||
|
||||
wxString m_name;
|
||||
std::vector<wxAuiTabLayoutInfo> m_tabsLayoutInfo;
|
||||
bool m_afterSaveCalled = false;
|
||||
|
||||
Ints m_orphanedPages;
|
||||
bool m_orphanedPageReturnValue = true;
|
||||
int m_orphanedPageReturnIndex = wxNOT_FOUND;
|
||||
} ser;
|
||||
|
||||
// Just for convenience.
|
||||
auto& info = ser.m_tabsLayoutInfo;
|
||||
|
||||
// Check the default layout has expected representation.
|
||||
nb->SaveLayout("layout", ser);
|
||||
CHECK( ser.m_name == "layout" );
|
||||
CHECK( ser.m_afterSaveCalled );
|
||||
REQUIRE( info.size() == 1 );
|
||||
|
||||
CHECK( info[0].pages == Ints{} );
|
||||
CHECK( info[0].pinned == Ints{} );
|
||||
CHECK( info[0].active == 0 );
|
||||
|
||||
|
||||
// Check that the active page is restored correctly.
|
||||
info[0].active = 1;
|
||||
nb->LoadLayout("layout", ser);
|
||||
|
||||
CHECK( nb->GetSelection() == 1 );
|
||||
|
||||
|
||||
// Check that page order is serialized as expected.
|
||||
auto* mainTabCtrl = nb->GetMainTabCtrl();
|
||||
REQUIRE( mainTabCtrl );
|
||||
CHECK( mainTabCtrl->MovePage(1, 4) );
|
||||
|
||||
nb->SaveLayout("layout", ser);
|
||||
REQUIRE( info.size() == 1 );
|
||||
CHECK( info[0].pages == Ints{0, 2, 3, 4, 1} );
|
||||
|
||||
|
||||
// Check that pinned pages are serialized as expected.
|
||||
REQUIRE( nb->SetPageKind(2, wxAuiTabKind::Pinned) );
|
||||
|
||||
nb->SaveLayout("layout", ser);
|
||||
REQUIRE( info.size() == 1 );
|
||||
|
||||
// Note that pinning a page moves it in front of all other pages.
|
||||
CHECK( info[0].pages == Ints{2, 0, 3, 4, 1} );
|
||||
CHECK( info[0].pinned == Ints{2} );
|
||||
|
||||
|
||||
// Check a more complicated case with both locked and pinned pages.
|
||||
REQUIRE( nb->SetPageKind(4, wxAuiTabKind::Locked) );
|
||||
REQUIRE( nb->SetPageKind(3, wxAuiTabKind::Pinned) );
|
||||
|
||||
nb->SaveLayout("layout", ser);
|
||||
REQUIRE( info.size() == 1 );
|
||||
|
||||
// Note that pinning a page moves it in front of all other pages.
|
||||
CHECK( info[0].pages == Ints{4, 2, 3, 0, 1} );
|
||||
CHECK( info[0].pinned == Ints{2, 3} );
|
||||
|
||||
|
||||
// Check that restoring existing layout after adding some pages works.
|
||||
addPage(5);
|
||||
addPage(6);
|
||||
nb->LoadLayout("layout", ser);
|
||||
CHECK( ser.m_orphanedPages == Ints{5, 6} );
|
||||
|
||||
// By default, orphaned pages should have been appended.
|
||||
CHECK( nb->GetPagesInDisplayOrder(mainTabCtrl) ==
|
||||
Indices{4, 2, 3, 0, 1, 5, 6} );
|
||||
|
||||
// But we can change this by telling deserializer to insert them in front.
|
||||
ser.m_orphanedPageReturnIndex = 0;
|
||||
|
||||
nb->LoadLayout("layout", ser);
|
||||
CHECK( ser.m_orphanedPages == Ints{5, 6} );
|
||||
|
||||
CHECK( nb->GetPagesInDisplayOrder(mainTabCtrl) ==
|
||||
Indices{6, 5, 4, 2, 3, 0, 1} );
|
||||
|
||||
// Or drop them entirely.
|
||||
ser.m_orphanedPageReturnValue = false;
|
||||
|
||||
nb->LoadLayout("layout", ser);
|
||||
CHECK( ser.m_orphanedPages == Ints{5, 6} );
|
||||
|
||||
CHECK( nb->GetPagesInDisplayOrder(mainTabCtrl) ==
|
||||
Indices{4, 2, 3, 0, 1} );
|
||||
|
||||
|
||||
// Finally, check that invalid data is handled gracefully.
|
||||
info[0].active = 100;
|
||||
info[0].pages = Ints{10, 0, 1, 2, 3, 4};
|
||||
info[0].pinned = Ints{2, 99, 0};
|
||||
|
||||
nb->LoadLayout("layout", ser);
|
||||
CHECK( ser.m_orphanedPages == Ints{} );
|
||||
|
||||
// Locked tab should have remained first.
|
||||
CHECK( nb->GetPagesInDisplayOrder(mainTabCtrl) == Indices{4, 0, 1, 2, 3} );
|
||||
|
||||
// And selection should have been set to it because the specified value was
|
||||
// invalid.
|
||||
CHECK( nb->GetSelection() == 4 );
|
||||
|
||||
// And only tabs appearing before the normal ones can be pinned.
|
||||
CHECK( nb->GetPageKind(0) == wxAuiTabKind::Pinned );
|
||||
CHECK( nb->GetPageKind(1) == wxAuiTabKind::Normal );
|
||||
CHECK( nb->GetPageKind(2) == wxAuiTabKind::Normal );
|
||||
CHECK( nb->GetPageKind(3) == wxAuiTabKind::Normal );
|
||||
CHECK( nb->GetPageKind(4) == wxAuiTabKind::Locked );
|
||||
}
|
||||
|
||||
TEST_CASE("wxAuiToolBar::Items", "[aui][toolbar]")
|
||||
{
|
||||
std::unique_ptr<wxAuiToolBar> tbar{new wxAuiToolBar(wxTheApp->GetTopWindow())};
|
||||
|
||||
// Check that adding more toolbar elements doesn't invalidate the existing
|
||||
// pointers.
|
||||
auto first = tbar->AddLabel(wxID_ANY, "first");
|
||||
tbar->AddLabel(wxID_ANY, "second");
|
||||
CHECK( first->GetLabel() == "first" );
|
||||
}
|
||||
|
||||
#endif
|
||||
107
libs/wxWidgets-3.3.1/tests/controls/bitmapcomboboxtest.cpp
Normal file
107
libs/wxWidgets-3.3.1/tests/controls/bitmapcomboboxtest.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/bitmapcomboboxtest.cpp
|
||||
// Purpose: wxBitmapComboBox unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-15
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_BITMAPCOMBOBOX
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/bmpcbox.h"
|
||||
#include "wx/artprov.h"
|
||||
#include "textentrytest.h"
|
||||
#include "itemcontainertest.h"
|
||||
#include "asserthelper.h"
|
||||
|
||||
class BitmapComboBoxTestCase : public TextEntryTestCase,
|
||||
public ItemContainerTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
BitmapComboBoxTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_combo; }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo; }
|
||||
|
||||
virtual wxItemContainer *GetContainer() const override { return m_combo; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_combo; }
|
||||
|
||||
virtual void CheckStringSelection(const char * WXUNUSED(sel)) override
|
||||
{
|
||||
// do nothing here, as explained in TextEntryTestCase comment, our
|
||||
// GetStringSelection() is the wxChoice, not wxTextEntry, one and there
|
||||
// is no way to return the selection contents directly
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE( BitmapComboBoxTestCase );
|
||||
wxTEXT_ENTRY_TESTS();
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST( Bitmap );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Bitmap();
|
||||
|
||||
wxBitmapComboBox *m_combo;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(BitmapComboBoxTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(BitmapComboBoxTestCase,
|
||||
"[BitmapComboBoxTestCase][item-container]");
|
||||
|
||||
void BitmapComboBoxTestCase::setUp()
|
||||
{
|
||||
m_combo = new wxBitmapComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
void BitmapComboBoxTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_combo);
|
||||
}
|
||||
|
||||
void BitmapComboBoxTestCase::Bitmap()
|
||||
{
|
||||
wxArrayString items;
|
||||
items.push_back("item 0");
|
||||
items.push_back("item 1");
|
||||
// TODO: Add wxBitmapComboBoxBase::Append(wxArrayString )
|
||||
for( unsigned int i = 0; i < items.size(); ++i )
|
||||
m_combo->Append(items[i]);
|
||||
|
||||
CPPUNIT_ASSERT(!m_combo->GetItemBitmap(0).IsOk());
|
||||
|
||||
wxBitmap bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER,
|
||||
m_combo->FromDIP(wxSize(16, 16)));
|
||||
|
||||
m_combo->Append("item with bitmap", bitmap);
|
||||
|
||||
CPPUNIT_ASSERT(m_combo->GetItemBitmap(2).IsOk());
|
||||
|
||||
m_combo->Insert("item with bitmap", bitmap, 1);
|
||||
|
||||
CPPUNIT_ASSERT(m_combo->GetItemBitmap(1).IsOk());
|
||||
|
||||
m_combo->SetItemBitmap(0, bitmap);
|
||||
|
||||
CPPUNIT_ASSERT(m_combo->GetItemBitmap(0).IsOk());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(m_combo->FromDIP(wxSize(16, 16)), m_combo->GetBitmapSize());
|
||||
|
||||
m_combo->SetSelection( 1 );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( m_combo->GetStringSelection(), "item with bitmap" );
|
||||
}
|
||||
|
||||
#endif //wxUSE_BITMAPCOMBOBOX
|
||||
121
libs/wxWidgets-3.3.1/tests/controls/bitmaptogglebuttontest.cpp
Normal file
121
libs/wxWidgets-3.3.1/tests/controls/bitmaptogglebuttontest.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/bitmaptogglebuttontest.cpp
|
||||
// Purpose: wxBitmapToggleButton unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-17
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_TOGGLEBTN
|
||||
|
||||
|
||||
#include "wx/tglbtn.h"
|
||||
|
||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/artprov.h"
|
||||
|
||||
class BitmapToggleButtonTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
BitmapToggleButtonTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( BitmapToggleButtonTestCase );
|
||||
WXUISIM_TEST( Click );
|
||||
CPPUNIT_TEST( Value );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Click();
|
||||
void Value();
|
||||
|
||||
wxBitmapToggleButton* m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(BitmapToggleButtonTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( BitmapToggleButtonTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapToggleButtonTestCase,
|
||||
"BitmapToggleButtonTestCase" );
|
||||
|
||||
void BitmapToggleButtonTestCase::setUp()
|
||||
{
|
||||
m_button = new wxBitmapToggleButton(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxArtProvider::GetIcon(wxART_INFORMATION,
|
||||
wxART_OTHER,
|
||||
wxSize(32, 32)));
|
||||
m_button->Update();
|
||||
m_button->Refresh();
|
||||
}
|
||||
|
||||
void BitmapToggleButtonTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_button);
|
||||
}
|
||||
|
||||
void BitmapToggleButtonTestCase::Click()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter clicked(m_button, wxEVT_TOGGLEBUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
const wxPoint pos = m_button->GetScreenPosition();
|
||||
|
||||
//We move in slightly to account for window decorations
|
||||
sim.MouseMove(pos + wxPoint(10, 10));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(m_button->GetValue());
|
||||
|
||||
clicked.Clear();
|
||||
|
||||
// Change the mouse position to prevent the second click from being
|
||||
// recognized as double click.
|
||||
sim.MouseMove(pos + wxPoint(20, 20));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
}
|
||||
|
||||
void BitmapToggleButtonTestCase::Value()
|
||||
{
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
|
||||
m_button->SetValue(true);
|
||||
|
||||
CPPUNIT_ASSERT(m_button->GetValue());
|
||||
|
||||
m_button->SetValue(false);
|
||||
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, clicked.GetCount() );
|
||||
}
|
||||
|
||||
#endif // wxHAS_BITMAPTOGGLEBUTTON
|
||||
|
||||
#endif // wxUSE_TOGGLEBTN
|
||||
176
libs/wxWidgets-3.3.1/tests/controls/bookctrlbasetest.cpp
Normal file
176
libs/wxWidgets-3.3.1/tests/controls/bookctrlbasetest.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/bookctrlbasetest.cpp
|
||||
// Purpose: wxBookCtrlBase unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-02
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_BOOKCTRL
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/panel.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/artprov.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/bookctrl.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
void BookCtrlBaseTestCase::AddPanels()
|
||||
{
|
||||
wxBookCtrlBase * const base = GetBase();
|
||||
|
||||
wxSize size(32, 32);
|
||||
|
||||
m_list = new wxImageList(size.x, size.y);
|
||||
m_list->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size));
|
||||
m_list->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size));
|
||||
m_list->Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size));
|
||||
|
||||
base->AssignImageList(m_list);
|
||||
|
||||
Realize();
|
||||
|
||||
m_panel1 = new wxPanel(base);
|
||||
m_panel2 = new wxPanel(base);
|
||||
m_panel3 = new wxPanel(base);
|
||||
|
||||
base->AddPage(m_panel1, "Panel &1", false, 0);
|
||||
base->AddPage(m_panel2, "Panel 2", false, 1);
|
||||
base->AddPage(m_panel3, "Panel 3", false, 2);
|
||||
}
|
||||
|
||||
void BookCtrlBaseTestCase::Selection()
|
||||
{
|
||||
wxBookCtrlBase * const base = GetBase();
|
||||
|
||||
base->SetSelection(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, base->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel1, wxWindow), base->GetCurrentPage());
|
||||
|
||||
base->AdvanceSelection(false);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, base->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel3, wxWindow), base->GetCurrentPage());
|
||||
|
||||
base->AdvanceSelection();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, base->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel1, wxWindow), base->GetCurrentPage());
|
||||
|
||||
base->ChangeSelection(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, base->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel2, wxWindow), base->GetCurrentPage());
|
||||
}
|
||||
|
||||
void BookCtrlBaseTestCase::Text()
|
||||
{
|
||||
wxBookCtrlBase * const base = GetBase();
|
||||
|
||||
const wxString expected(HasBrokenMnemonics() ? "Panel 1" : "Panel &1");
|
||||
CPPUNIT_ASSERT_EQUAL(expected, base->GetPageText(0));
|
||||
|
||||
base->SetPageText(1, "Some other string");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("Some other string", base->GetPageText(1));
|
||||
|
||||
base->SetPageText(2, "string with\nline break");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("string with\nline break", base->GetPageText(2));
|
||||
|
||||
if ( !HasBrokenMnemonics() )
|
||||
{
|
||||
base->SetPageText(0, "With &mnemonic");
|
||||
CPPUNIT_ASSERT_EQUAL("With &mnemonic", base->GetPageText(0));
|
||||
}
|
||||
}
|
||||
|
||||
void BookCtrlBaseTestCase::PageManagement()
|
||||
{
|
||||
wxBookCtrlBase * const base = GetBase();
|
||||
|
||||
base->InsertPage(0, new wxPanel(base), "New Panel", true, 0);
|
||||
|
||||
Realize();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, base->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL(4, base->GetPageCount());
|
||||
|
||||
// Change the selection to verify that deleting a page before the currently
|
||||
// selected one correctly updates the selection.
|
||||
base->SetSelection(2);
|
||||
CPPUNIT_ASSERT_EQUAL(2, base->GetSelection());
|
||||
|
||||
base->DeletePage(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(3, base->GetPageCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, base->GetSelection());
|
||||
|
||||
base->RemovePage(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, base->GetPageCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, base->GetSelection());
|
||||
|
||||
base->DeleteAllPages();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, base->GetPageCount());
|
||||
CPPUNIT_ASSERT_EQUAL(-1, base->GetSelection());
|
||||
}
|
||||
|
||||
void BookCtrlBaseTestCase::ChangeEvents()
|
||||
{
|
||||
wxBookCtrlBase * const base = GetBase();
|
||||
|
||||
base->SetSelection(0);
|
||||
|
||||
EventCounter changing(base, GetChangingEvent());
|
||||
EventCounter changed(base, GetChangedEvent());
|
||||
|
||||
base->SetSelection(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
|
||||
changed.Clear();
|
||||
changing.Clear();
|
||||
base->ChangeSelection(2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, changed.GetCount());
|
||||
|
||||
base->AdvanceSelection();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
|
||||
changed.Clear();
|
||||
changing.Clear();
|
||||
base->AdvanceSelection(false);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, changing.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
}
|
||||
|
||||
void BookCtrlBaseTestCase::Image()
|
||||
{
|
||||
wxBookCtrlBase * const base = GetBase();
|
||||
|
||||
//Check AddPanels() set things correctly
|
||||
CPPUNIT_ASSERT_EQUAL(m_list, base->GetImageList());
|
||||
CPPUNIT_ASSERT_EQUAL(0, base->GetPageImage(0));
|
||||
CPPUNIT_ASSERT_EQUAL(1, base->GetPageImage(1));
|
||||
CPPUNIT_ASSERT_EQUAL(2, base->GetPageImage(2));
|
||||
|
||||
base->SetPageImage(0, 2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, base->GetPageImage(2));
|
||||
}
|
||||
|
||||
#endif
|
||||
67
libs/wxWidgets-3.3.1/tests/controls/bookctrlbasetest.h
Normal file
67
libs/wxWidgets-3.3.1/tests/controls/bookctrlbasetest.h
Normal file
@@ -0,0 +1,67 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/bookctrlbasetest.cpp
|
||||
// Purpose: wxBookCtrlBase unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-02
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_CONTROLS_BOOKCTRLBASETEST_H_
|
||||
#define _WX_TESTS_CONTROLS_BOOKCTRLBASETEST_H_
|
||||
|
||||
class BookCtrlBaseTestCase
|
||||
{
|
||||
public:
|
||||
BookCtrlBaseTestCase() { }
|
||||
virtual ~BookCtrlBaseTestCase() { }
|
||||
|
||||
protected:
|
||||
// this function must be overridden by the derived classes to return the
|
||||
// text entry object we're testing, typically this is done by creating a
|
||||
// control implementing wxBookCtrlBase interface in setUp() virtual method and
|
||||
// just returning it from here
|
||||
virtual wxBookCtrlBase *GetBase() const = 0;
|
||||
|
||||
virtual wxEventType GetChangedEvent() const = 0;
|
||||
|
||||
virtual wxEventType GetChangingEvent() const = 0;
|
||||
|
||||
// Some wxBookCtrlBase-derived classes strip mnemonics and don't return
|
||||
// them from their GetPageText(), allow them to just return true from here.
|
||||
virtual bool HasBrokenMnemonics() const { return false; }
|
||||
|
||||
// this should be inserted in the derived class CPPUNIT_TEST_SUITE
|
||||
// definition to run all wxBookCtrlBase tests as part of it
|
||||
#define wxBOOK_CTRL_BASE_TESTS() \
|
||||
CPPUNIT_TEST( Selection ); \
|
||||
CPPUNIT_TEST( Text ); \
|
||||
CPPUNIT_TEST( PageManagement ); \
|
||||
CPPUNIT_TEST( ChangeEvents )
|
||||
|
||||
void Selection();
|
||||
void Text();
|
||||
void PageManagement();
|
||||
void ChangeEvents();
|
||||
|
||||
//You need to add CPPUNIT_TEST( Image ) specifically if you want it to be
|
||||
//tested as only wxNotebook and wxTreebook support images correctly
|
||||
void Image();
|
||||
|
||||
//Call this from the setUp function of a specific test to add panels to
|
||||
//the ctrl.
|
||||
void AddPanels();
|
||||
|
||||
// Override this to call Realize() on the toolbar in the wxToolbook test.
|
||||
virtual void Realize() { }
|
||||
|
||||
wxPanel* m_panel1;
|
||||
wxPanel* m_panel2;
|
||||
wxPanel* m_panel3;
|
||||
|
||||
wxImageList* m_list;
|
||||
|
||||
private:
|
||||
wxDECLARE_NO_COPY_CLASS(BookCtrlBaseTestCase);
|
||||
};
|
||||
|
||||
#endif // _WX_TESTS_CONTROLS_BOOKCTRLBASETEST_H_
|
||||
190
libs/wxWidgets-3.3.1/tests/controls/buttontest.cpp
Normal file
190
libs/wxWidgets-3.3.1/tests/controls/buttontest.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/buttontest.cpp
|
||||
// Purpose: wxButton unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-06-21
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_BUTTON
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/button.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/artprov.h"
|
||||
|
||||
// Get operator<<(wxSize) so that wxSize values are shown correctly in case of
|
||||
// a failure of a CHECK() involving them.
|
||||
#include "asserthelper.h"
|
||||
#include "waitfor.h"
|
||||
|
||||
class ButtonTestCase
|
||||
{
|
||||
public:
|
||||
ButtonTestCase();
|
||||
~ButtonTestCase();
|
||||
|
||||
protected:
|
||||
wxButton* m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ButtonTestCase);
|
||||
};
|
||||
|
||||
ButtonTestCase::ButtonTestCase()
|
||||
{
|
||||
//We use wxTheApp->GetTopWindow() as there is only a single testable frame
|
||||
//so it will always be returned
|
||||
m_button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY, "wxButton");
|
||||
}
|
||||
|
||||
ButtonTestCase::~ButtonTestCase()
|
||||
{
|
||||
delete m_button;
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(ButtonTestCase, "Button::Click", "[button]")
|
||||
{
|
||||
//We use the internal class EventCounter which handles connecting and
|
||||
//disconnecting the control to the wxTestableFrame
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
//We move in slightly to account for window decorations, we need to yield
|
||||
//after every wxUIActionSimulator action to keep everything working in GTK
|
||||
sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
|
||||
// At least under wxMSW calling wxYield() just once doesn't always work, so
|
||||
// try for a while.
|
||||
WaitFor("button to be clicked", [&]() { return clicked.GetCount() != 0; });
|
||||
|
||||
CHECK( clicked.GetCount() == 1 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ButtonTestCase, "Button::Disabled", "[button]")
|
||||
{
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
// In this test we disable the button and check events are not sent and we
|
||||
// do it once by disabling the previously enabled button and once by
|
||||
// creating the button in the disabled state.
|
||||
SECTION("Disable after creation")
|
||||
{
|
||||
m_button->Disable();
|
||||
}
|
||||
|
||||
SECTION("Create disabled")
|
||||
{
|
||||
delete m_button;
|
||||
m_button = new wxButton();
|
||||
m_button->Disable();
|
||||
m_button->Create(wxTheApp->GetTopWindow(), wxID_ANY, "wxButton");
|
||||
}
|
||||
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
|
||||
sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CHECK( clicked.GetCount() == 0 );
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(ButtonTestCase, "Button::Auth", "[button]")
|
||||
{
|
||||
//Some functions only work on specific operating system versions, for
|
||||
//this we need a runtime check
|
||||
int major = 0;
|
||||
|
||||
if(wxGetOsVersion(&major) != wxOS_WINDOWS_NT || major < 6)
|
||||
return;
|
||||
|
||||
//We are running Windows Vista or newer
|
||||
CHECK(!m_button->GetAuthNeeded());
|
||||
|
||||
m_button->SetAuthNeeded();
|
||||
|
||||
CHECK(m_button->GetAuthNeeded());
|
||||
|
||||
//We test both states
|
||||
m_button->SetAuthNeeded(false);
|
||||
|
||||
CHECK(!m_button->GetAuthNeeded());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ButtonTestCase, "Button::BitmapMargins", "[button]")
|
||||
{
|
||||
//Some functions only work on specific platforms in which case we can use
|
||||
//a preprocessor check
|
||||
#ifdef __WXMSW__
|
||||
//We must set a bitmap before we can set its margins, when writing unit
|
||||
//tests it is easiest to use an image from wxArtProvider
|
||||
m_button->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER,
|
||||
wxSize(32, 32)));
|
||||
|
||||
m_button->SetBitmapMargins(15, 15);
|
||||
|
||||
CHECK( m_button->GetBitmapMargins() == wxSize(15, 15) );
|
||||
|
||||
m_button->SetBitmapMargins(wxSize(20, 20));
|
||||
|
||||
CHECK( m_button->GetBitmapMargins() == wxSize(20, 20) );
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ButtonTestCase, "Button::Bitmap", "[button]")
|
||||
{
|
||||
//We start with no bitmaps
|
||||
CHECK(!m_button->GetBitmap().IsOk());
|
||||
|
||||
// Some bitmap, doesn't really matter which.
|
||||
const wxBitmap bmp = wxArtProvider::GetBitmap(wxART_INFORMATION);
|
||||
|
||||
m_button->SetBitmap(bmp);
|
||||
|
||||
CHECK(m_button->GetBitmap().IsOk());
|
||||
|
||||
// The call above shouldn't affect any other bitmaps as returned by the API
|
||||
// even though the same (normal) bitmap does appear for all the states.
|
||||
CHECK( !m_button->GetBitmapCurrent().IsOk() );
|
||||
CHECK( !m_button->GetBitmapDisabled().IsOk() );
|
||||
CHECK( !m_button->GetBitmapFocus().IsOk() );
|
||||
CHECK( !m_button->GetBitmapPressed().IsOk() );
|
||||
|
||||
// Do set one of the bitmaps now.
|
||||
m_button->SetBitmapPressed(wxArtProvider::GetBitmap(wxART_ERROR));
|
||||
CHECK( m_button->GetBitmapPressed().IsOk() );
|
||||
|
||||
// Check that resetting the button label doesn't result in problems when
|
||||
// updating the bitmap later, as it used to be the case in wxGTK (#18898).
|
||||
m_button->SetLabel(wxString());
|
||||
CHECK_NOTHROW( m_button->Disable() );
|
||||
|
||||
wxButton* button = new wxButton(m_button->GetParent(), wxID_ANY, "a");
|
||||
button->SetLabel("");
|
||||
CHECK_NOTHROW(button->SetBitmap(bmp));
|
||||
delete button;
|
||||
|
||||
// Also check that setting an invalid bitmap doesn't do anything untoward,
|
||||
// such as crashing, as it used to do in wxOSX (#19257).
|
||||
CHECK_NOTHROW( m_button->SetBitmapPressed(wxNullBitmap) );
|
||||
CHECK( !m_button->GetBitmapPressed().IsOk() );
|
||||
}
|
||||
|
||||
#endif //wxUSE_BUTTON
|
||||
168
libs/wxWidgets-3.3.1/tests/controls/checkboxtest.cpp
Normal file
168
libs/wxWidgets-3.3.1/tests/controls/checkboxtest.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/checkboxtest.cpp
|
||||
// Purpose: wCheckBox unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-14
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_CHECKBOX
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/checkbox.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
|
||||
class CheckBoxTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
CheckBoxTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( CheckBoxTestCase );
|
||||
CPPUNIT_TEST( Check );
|
||||
#ifdef wxHAS_3STATE_CHECKBOX
|
||||
CPPUNIT_TEST( ThirdState );
|
||||
CPPUNIT_TEST( ThirdStateUser );
|
||||
CPPUNIT_TEST( InvalidStyles );
|
||||
#endif // wxHAS_3STATE_CHECKBOX
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Check();
|
||||
#ifdef wxHAS_3STATE_CHECKBOX
|
||||
void ThirdState();
|
||||
void ThirdStateUser();
|
||||
void InvalidStyles();
|
||||
#endif // wxHAS_3STATE_CHECKBOX
|
||||
|
||||
// Initialize m_check with a new checkbox with the specified style
|
||||
//
|
||||
// This function always returns false just to make it more convenient to
|
||||
// use inside WX_ASSERT_FAILS_WITH_ASSERT(), its return value doesn't have
|
||||
// any meaning otherwise.
|
||||
bool CreateCheckBox(long style)
|
||||
{
|
||||
wxDELETE( m_check );
|
||||
m_check = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, "Check box",
|
||||
wxDefaultPosition, wxDefaultSize, style);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
wxCheckBox* m_check;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(CheckBoxTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( CheckBoxTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CheckBoxTestCase, "CheckBoxTestCase" );
|
||||
|
||||
void CheckBoxTestCase::setUp()
|
||||
{
|
||||
m_check = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, "Check box");
|
||||
}
|
||||
|
||||
void CheckBoxTestCase::tearDown()
|
||||
{
|
||||
delete m_check;
|
||||
}
|
||||
|
||||
void CheckBoxTestCase::Check()
|
||||
{
|
||||
EventCounter clicked(m_check, wxEVT_CHECKBOX);
|
||||
|
||||
//We should be unchecked by default
|
||||
CPPUNIT_ASSERT(!m_check->IsChecked());
|
||||
|
||||
m_check->SetValue(true);
|
||||
|
||||
CPPUNIT_ASSERT(m_check->IsChecked());
|
||||
|
||||
m_check->SetValue(false);
|
||||
|
||||
CPPUNIT_ASSERT(!m_check->IsChecked());
|
||||
|
||||
m_check->Set3StateValue(wxCHK_CHECKED);
|
||||
|
||||
CPPUNIT_ASSERT(m_check->IsChecked());
|
||||
|
||||
m_check->Set3StateValue(wxCHK_UNCHECKED);
|
||||
|
||||
CPPUNIT_ASSERT(!m_check->IsChecked());
|
||||
|
||||
//None of these should send events
|
||||
CPPUNIT_ASSERT_EQUAL(0, clicked.GetCount());
|
||||
}
|
||||
|
||||
#ifdef wxHAS_3STATE_CHECKBOX
|
||||
void CheckBoxTestCase::ThirdState()
|
||||
{
|
||||
CreateCheckBox(wxCHK_3STATE);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(wxCHK_UNCHECKED, m_check->Get3StateValue());
|
||||
CPPUNIT_ASSERT(m_check->Is3State());
|
||||
CPPUNIT_ASSERT(!m_check->Is3rdStateAllowedForUser());
|
||||
|
||||
m_check->SetValue(true);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(wxCHK_CHECKED, m_check->Get3StateValue());
|
||||
|
||||
m_check->Set3StateValue(wxCHK_UNDETERMINED);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(wxCHK_UNDETERMINED, m_check->Get3StateValue());
|
||||
}
|
||||
|
||||
void CheckBoxTestCase::ThirdStateUser()
|
||||
{
|
||||
CreateCheckBox(wxCHK_3STATE | wxCHK_ALLOW_3RD_STATE_FOR_USER);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(wxCHK_UNCHECKED, m_check->Get3StateValue());
|
||||
CPPUNIT_ASSERT(m_check->Is3State());
|
||||
CPPUNIT_ASSERT(m_check->Is3rdStateAllowedForUser());
|
||||
|
||||
m_check->SetValue(true);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(wxCHK_CHECKED, m_check->Get3StateValue());
|
||||
|
||||
m_check->Set3StateValue(wxCHK_UNDETERMINED);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(wxCHK_UNDETERMINED, m_check->Get3StateValue());
|
||||
|
||||
m_check->SetValue(true);
|
||||
CPPUNIT_ASSERT_EQUAL(wxCHK_CHECKED, m_check->Get3StateValue());
|
||||
}
|
||||
|
||||
void CheckBoxTestCase::InvalidStyles()
|
||||
{
|
||||
// Check that using incompatible styles doesn't work.
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( CreateCheckBox(wxCHK_2STATE | wxCHK_3STATE) );
|
||||
#if !wxDEBUG_LEVEL
|
||||
CPPUNIT_ASSERT( !m_check->Is3State() );
|
||||
CPPUNIT_ASSERT( !m_check->Is3rdStateAllowedForUser() );
|
||||
#endif
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(
|
||||
CreateCheckBox(wxCHK_2STATE | wxCHK_ALLOW_3RD_STATE_FOR_USER) );
|
||||
#if !wxDEBUG_LEVEL
|
||||
CPPUNIT_ASSERT( !m_check->Is3State() );
|
||||
CPPUNIT_ASSERT( !m_check->Is3rdStateAllowedForUser() );
|
||||
#endif
|
||||
|
||||
// wxCHK_ALLOW_3RD_STATE_FOR_USER without wxCHK_3STATE doesn't work.
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( CreateCheckBox(wxCHK_ALLOW_3RD_STATE_FOR_USER) );
|
||||
}
|
||||
|
||||
#endif // wxHAS_3STATE_CHECKBOX
|
||||
|
||||
#endif // wxUSE_CHECKBOX
|
||||
90
libs/wxWidgets-3.3.1/tests/controls/checklistboxtest.cpp
Normal file
90
libs/wxWidgets-3.3.1/tests/controls/checklistboxtest.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/checklistlistbox.cpp
|
||||
// Purpose: wxCheckListBox unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-06-30
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/checklst.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
class CheckListBoxTestCase : public ItemContainerTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
CheckListBoxTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_check; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_check; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( CheckListBoxTestCase );
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST( Check );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Check();
|
||||
|
||||
wxCheckListBox* m_check;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(CheckListBoxTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(CheckListBoxTestCase,
|
||||
"[CheckListBoxTestCase][item-container]");
|
||||
|
||||
void CheckListBoxTestCase::setUp()
|
||||
{
|
||||
m_check = new wxCheckListBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
void CheckListBoxTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_check);
|
||||
}
|
||||
|
||||
void CheckListBoxTestCase::Check()
|
||||
{
|
||||
EventCounter toggled(m_check, wxEVT_CHECKLISTBOX);
|
||||
|
||||
wxArrayInt checkedItems;
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
testitems.Add("item 3");
|
||||
|
||||
m_check->Append(testitems);
|
||||
|
||||
m_check->Check(0);
|
||||
m_check->Check(1);
|
||||
m_check->Check(1, false);
|
||||
|
||||
//We should not get any events when changing this from code
|
||||
CPPUNIT_ASSERT_EQUAL(0, toggled.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(true, m_check->IsChecked(0));
|
||||
CPPUNIT_ASSERT_EQUAL(false, m_check->IsChecked(1));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, m_check->GetCheckedItems(checkedItems));
|
||||
CPPUNIT_ASSERT_EQUAL(0, checkedItems[0]);
|
||||
|
||||
//Make sure a double check of an items doesn't deselect it
|
||||
m_check->Check(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(true, m_check->IsChecked(0));
|
||||
}
|
||||
|
||||
#endif // wxUSE_CHECKLISTBOX
|
||||
79
libs/wxWidgets-3.3.1/tests/controls/choicebooktest.cpp
Normal file
79
libs/wxWidgets-3.3.1/tests/controls/choicebooktest.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/choicebooktest.cpp
|
||||
// Purpose: wxChoicebook unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-02
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_CHOICEBOOK
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/panel.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/choicebk.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
class ChoicebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ChoicebookTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_choicebook; }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_CHOICEBOOK_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_CHOICEBOOK_PAGE_CHANGING; }
|
||||
|
||||
virtual bool HasBrokenMnemonics() const override { return true; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( ChoicebookTestCase );
|
||||
wxBOOK_CTRL_BASE_TESTS();
|
||||
CPPUNIT_TEST( Choice );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Choice();
|
||||
|
||||
wxChoicebook *m_choicebook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ChoicebookTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ChoicebookTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoicebookTestCase, "ChoicebookTestCase" );
|
||||
|
||||
void ChoicebookTestCase::setUp()
|
||||
{
|
||||
m_choicebook = new wxChoicebook(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
void ChoicebookTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_choicebook);
|
||||
}
|
||||
|
||||
void ChoicebookTestCase::Choice()
|
||||
{
|
||||
wxChoice* choice = m_choicebook->GetChoiceCtrl();
|
||||
|
||||
CPPUNIT_ASSERT(choice);
|
||||
CPPUNIT_ASSERT_EQUAL(3, choice->GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL("Panel 1", choice->GetString(0));
|
||||
}
|
||||
|
||||
#endif //wxUSE_CHOICEBOOK
|
||||
120
libs/wxWidgets-3.3.1/tests/controls/choicetest.cpp
Normal file
120
libs/wxWidgets-3.3.1/tests/controls/choicetest.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/choice.cpp
|
||||
// Purpose: wxChoice unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-06-29
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_CHOICE
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/choice.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "itemcontainertest.h"
|
||||
|
||||
class ChoiceTestCase : public ItemContainerTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ChoiceTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_choice; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_choice; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( ChoiceTestCase );
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST( Sort );
|
||||
CPPUNIT_TEST( GetBestSize );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Sort();
|
||||
void GetBestSize();
|
||||
|
||||
wxChoice* m_choice;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ChoiceTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(ChoiceTestCase,
|
||||
"[ChoiceTestCase][item-container]");
|
||||
|
||||
void ChoiceTestCase::setUp()
|
||||
{
|
||||
m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
void ChoiceTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_choice);
|
||||
}
|
||||
|
||||
void ChoiceTestCase::Sort()
|
||||
{
|
||||
#if !defined(__WXOSX__)
|
||||
wxDELETE(m_choice);
|
||||
m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxCB_SORT);
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("aaa");
|
||||
testitems.Add("Aaa");
|
||||
testitems.Add("aba");
|
||||
testitems.Add("aaab");
|
||||
testitems.Add("aab");
|
||||
testitems.Add("AAA");
|
||||
|
||||
m_choice->Append(testitems);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("AAA", m_choice->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("Aaa", m_choice->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("aaa", m_choice->GetString(2));
|
||||
CPPUNIT_ASSERT_EQUAL("aaab", m_choice->GetString(3));
|
||||
CPPUNIT_ASSERT_EQUAL("aab", m_choice->GetString(4));
|
||||
CPPUNIT_ASSERT_EQUAL("aba", m_choice->GetString(5));
|
||||
|
||||
m_choice->Append("a");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("a", m_choice->GetString(0));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChoiceTestCase::GetBestSize()
|
||||
{
|
||||
wxArrayString testitems;
|
||||
testitems.Add("1");
|
||||
testitems.Add("11");
|
||||
m_choice->Append(testitems);
|
||||
|
||||
SECTION("Normal best size")
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// Ensure that the hidden control return a valid best size too.
|
||||
SECTION("Hidden best size")
|
||||
{
|
||||
m_choice->Hide();
|
||||
}
|
||||
|
||||
wxYield();
|
||||
|
||||
m_choice->InvalidateBestSize();
|
||||
const wxSize bestSize = m_choice->GetBestSize();
|
||||
|
||||
CHECK(bestSize.GetWidth() > m_choice->FromDIP(30));
|
||||
CHECK(bestSize.GetWidth() < m_choice->FromDIP(120));
|
||||
CHECK(bestSize.GetHeight() > m_choice->FromDIP(15));
|
||||
CHECK(bestSize.GetHeight() < m_choice->FromDIP(35));
|
||||
}
|
||||
|
||||
#endif //wxUSE_CHOICE
|
||||
273
libs/wxWidgets-3.3.1/tests/controls/comboboxtest.cpp
Normal file
273
libs/wxWidgets-3.3.1/tests/controls/comboboxtest.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/comboboxtest.cpp
|
||||
// Purpose: wxComboBox unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2007-09-25
|
||||
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_COMBOBOX
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/combobox.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "textentrytest.h"
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class ComboBoxTestCase : public TextEntryTestCase, public ItemContainerTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ComboBoxTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_combo; }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo; }
|
||||
|
||||
virtual wxItemContainer *GetContainer() const override { return m_combo; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_combo; }
|
||||
|
||||
virtual void CheckStringSelection(const char * WXUNUSED(sel)) override
|
||||
{
|
||||
// do nothing here, as explained in TextEntryTestCase comment, our
|
||||
// GetStringSelection() is the wxChoice, not wxTextEntry, one and there
|
||||
// is no way to return the selection contents directly
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE( ComboBoxTestCase );
|
||||
#ifdef __WXOSX__
|
||||
CPPUNIT_TEST( SetValue );
|
||||
CPPUNIT_TEST( TextChangeEvents );
|
||||
CPPUNIT_TEST( Selection );
|
||||
CPPUNIT_TEST( InsertionPoint );
|
||||
CPPUNIT_TEST( Replace );
|
||||
// TODO on OS X only works interactively
|
||||
// WXUISIM_TEST( Editable );
|
||||
CPPUNIT_TEST( Hint );
|
||||
CPPUNIT_TEST( CopyPaste );
|
||||
CPPUNIT_TEST( UndoRedo );
|
||||
#else
|
||||
wxTEXT_ENTRY_TESTS();
|
||||
#endif
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST( Size );
|
||||
CPPUNIT_TEST( PopDismiss );
|
||||
CPPUNIT_TEST( Sort );
|
||||
CPPUNIT_TEST( ReadOnly );
|
||||
CPPUNIT_TEST( IsEmpty );
|
||||
CPPUNIT_TEST( SetStringSelection );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Size();
|
||||
void PopDismiss();
|
||||
void Sort();
|
||||
void ReadOnly();
|
||||
void IsEmpty();
|
||||
void SetStringSelection();
|
||||
|
||||
wxComboBox *m_combo;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ComboBoxTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(ComboBoxTestCase,
|
||||
"[ComboBoxTestCase][item-container]");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void ComboBoxTestCase::setUp()
|
||||
{
|
||||
m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
void ComboBoxTestCase::tearDown()
|
||||
{
|
||||
delete m_combo;
|
||||
m_combo = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void ComboBoxTestCase::Size()
|
||||
{
|
||||
// under MSW changing combobox size is a non-trivial operation because of
|
||||
// confusion between the size of the control with and without dropdown, so
|
||||
// check that it does work as expected
|
||||
|
||||
const int heightOrig = m_combo->GetSize().y;
|
||||
|
||||
// check that the height doesn't change if we don't touch it
|
||||
m_combo->SetSize(100, -1);
|
||||
CPPUNIT_ASSERT_EQUAL( heightOrig, m_combo->GetSize().y );
|
||||
|
||||
// check that setting both big and small (but not too small, there is a
|
||||
// limit on how small the control can become under MSW) heights works
|
||||
m_combo->SetSize(-1, 50);
|
||||
CPPUNIT_ASSERT_EQUAL( 50, m_combo->GetSize().y );
|
||||
|
||||
m_combo->SetSize(-1, 10);
|
||||
CPPUNIT_ASSERT_EQUAL( 10, m_combo->GetSize().y );
|
||||
|
||||
// and also that restoring it works (this used to be broken before 2.9.1)
|
||||
m_combo->SetSize(-1, heightOrig);
|
||||
CPPUNIT_ASSERT_EQUAL( heightOrig, m_combo->GetSize().y );
|
||||
}
|
||||
|
||||
void ComboBoxTestCase::PopDismiss()
|
||||
{
|
||||
#if defined(__WXMSW__) || defined(__WXGTK210__) || defined(__WXQT__)
|
||||
EventCounter drop(m_combo, wxEVT_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo, wxEVT_COMBOBOX_CLOSEUP);
|
||||
|
||||
m_combo->Popup();
|
||||
CPPUNIT_ASSERT_EQUAL(1, drop.GetCount());
|
||||
|
||||
m_combo->Dismiss();
|
||||
|
||||
#if defined(__WXGTK__) && !defined(__WXGTK3__)
|
||||
// Under wxGTK2, the event is sent only during idle time and not
|
||||
// immediately, so we need this yield to get it.
|
||||
wxYield();
|
||||
#endif // wxGTK2
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ComboBoxTestCase::Sort()
|
||||
{
|
||||
#if !defined(__WXOSX__)
|
||||
delete m_combo;
|
||||
m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxCB_SORT);
|
||||
|
||||
m_combo->Append("aaa");
|
||||
m_combo->Append("Aaa");
|
||||
m_combo->Append("aba");
|
||||
m_combo->Append("aaab");
|
||||
m_combo->Append("aab");
|
||||
m_combo->Append("AAA");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("AAA", m_combo->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("Aaa", m_combo->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("aaa", m_combo->GetString(2));
|
||||
CPPUNIT_ASSERT_EQUAL("aaab", m_combo->GetString(3));
|
||||
CPPUNIT_ASSERT_EQUAL("aab", m_combo->GetString(4));
|
||||
CPPUNIT_ASSERT_EQUAL("aba", m_combo->GetString(5));
|
||||
|
||||
m_combo->Append("a");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("a", m_combo->GetString(0));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ComboBoxTestCase::ReadOnly()
|
||||
{
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
delete m_combo;
|
||||
m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, testitems,
|
||||
wxCB_READONLY);
|
||||
|
||||
m_combo->SetValue("item 1");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue());
|
||||
|
||||
m_combo->SetValue("not an item");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue());
|
||||
|
||||
// Since this uses FindString it is case insensitive
|
||||
m_combo->SetValue("ITEM 2");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", m_combo->GetValue());
|
||||
}
|
||||
|
||||
void ComboBoxTestCase::IsEmpty()
|
||||
{
|
||||
CPPUNIT_ASSERT( m_combo->IsListEmpty() );
|
||||
CPPUNIT_ASSERT( m_combo->IsTextEmpty() );
|
||||
|
||||
m_combo->Append("foo");
|
||||
CPPUNIT_ASSERT( !m_combo->IsListEmpty() );
|
||||
CPPUNIT_ASSERT( m_combo->IsTextEmpty() );
|
||||
|
||||
m_combo->SetValue("bar");
|
||||
CPPUNIT_ASSERT( !m_combo->IsListEmpty() );
|
||||
CPPUNIT_ASSERT( !m_combo->IsTextEmpty() );
|
||||
|
||||
m_combo->Clear();
|
||||
CPPUNIT_ASSERT( m_combo->IsListEmpty() );
|
||||
CPPUNIT_ASSERT( m_combo->IsTextEmpty() );
|
||||
|
||||
#ifdef TEST_INVALID_COMBOBOX_ISEMPTY
|
||||
// Compiling this should fail, see failtest target definition in test.bkl.
|
||||
m_combo->IsEmpty();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ComboBoxTestCase::SetStringSelection()
|
||||
{
|
||||
m_combo->Append("foo");
|
||||
m_combo->Append("bar");
|
||||
m_combo->Append("baz");
|
||||
|
||||
EventCounter events(m_combo, wxEVT_COMBOBOX);
|
||||
m_combo->SetStringSelection("bar");
|
||||
CPPUNIT_ASSERT_EQUAL( 0, events.GetCount() );
|
||||
|
||||
m_combo->SetStringSelection("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( 0, events.GetCount() );
|
||||
}
|
||||
|
||||
TEST_CASE("wxComboBox::ProcessEnter", "[wxComboBox][enter]")
|
||||
{
|
||||
class ComboBoxCreator : public TextLikeControlCreator
|
||||
{
|
||||
public:
|
||||
virtual wxControl* Create(wxWindow* parent, int style) const override
|
||||
{
|
||||
const wxString choices[] = { "foo", "bar", "baz" };
|
||||
|
||||
return new wxComboBox(parent, wxID_ANY, wxString(),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
WXSIZEOF(choices), choices,
|
||||
style);
|
||||
}
|
||||
};
|
||||
|
||||
TestProcessEnter(ComboBoxCreator());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef TEST_INVALID_COMBOBOX_ISEMPTY
|
||||
#error provoke failing here
|
||||
#endif
|
||||
|
||||
#endif //wxUSE_COMBOBOX
|
||||
887
libs/wxWidgets-3.3.1/tests/controls/dataviewctrltest.cpp
Normal file
887
libs/wxWidgets-3.3.1/tests/controls/dataviewctrltest.cpp
Normal file
@@ -0,0 +1,887 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/dataviewctrltest.cpp
|
||||
// Purpose: wxDataViewCtrl unit test
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2011-08-08
|
||||
// Copyright: (c) 2011 Vaclav Slavik <vslavik@gmail.com>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_DATAVIEWCTRL
|
||||
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/dataview.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#include "waitfor.h"
|
||||
#endif // __WXGTK__
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "asserthelper.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class DataViewCtrlTestCase
|
||||
{
|
||||
public:
|
||||
explicit DataViewCtrlTestCase(long style);
|
||||
~DataViewCtrlTestCase();
|
||||
|
||||
protected:
|
||||
void TestSelectionFor0and1();
|
||||
|
||||
// the dataview control itself
|
||||
wxDataViewTreeCtrl *m_dvc;
|
||||
|
||||
// and some of its items
|
||||
wxDataViewItem m_root,
|
||||
m_child1,
|
||||
m_child2,
|
||||
m_grandchild;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(DataViewCtrlTestCase);
|
||||
};
|
||||
|
||||
class SingleSelectDataViewCtrlTestCase : public DataViewCtrlTestCase
|
||||
{
|
||||
public:
|
||||
SingleSelectDataViewCtrlTestCase()
|
||||
: DataViewCtrlTestCase(wxDV_SINGLE)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class MultiSelectDataViewCtrlTestCase : public DataViewCtrlTestCase
|
||||
{
|
||||
public:
|
||||
MultiSelectDataViewCtrlTestCase()
|
||||
: DataViewCtrlTestCase(wxDV_MULTIPLE)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class MultiColumnsDataViewCtrlTestCase
|
||||
{
|
||||
public:
|
||||
MultiColumnsDataViewCtrlTestCase();
|
||||
~MultiColumnsDataViewCtrlTestCase();
|
||||
|
||||
protected:
|
||||
// the dataview control itself
|
||||
wxDataViewListCtrl *m_dvc;
|
||||
|
||||
// constants
|
||||
const wxSize m_size;
|
||||
const int m_firstColumnWidth;
|
||||
|
||||
// and the columns
|
||||
wxDataViewColumn* m_firstColumn;
|
||||
wxDataViewColumn* m_lastColumn;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(MultiColumnsDataViewCtrlTestCase);
|
||||
};
|
||||
|
||||
class DataViewCtrlTestModel: public wxDataViewModel
|
||||
{
|
||||
public:
|
||||
// Items of the model.
|
||||
//
|
||||
// wxTEST_ITEM_NULL
|
||||
// |
|
||||
// |-- wxTEST_ITEM_ROOT
|
||||
// |
|
||||
// |-- wxTEST_ITEM_CHILD
|
||||
// |
|
||||
// |-- wxTEST_ITEM_GRANDCHILD
|
||||
// | |
|
||||
// | |-- wxTEST_ITEM_LEAF
|
||||
// | |
|
||||
// | |-- wxTEST_ITEM_LEAF_HIDDEN
|
||||
// |
|
||||
// |-- wxTEST_ITEM_GRANDCHILD_HIDDEN
|
||||
//
|
||||
enum wxTestItem
|
||||
{
|
||||
wxTEST_ITEM_NULL,
|
||||
wxTEST_ITEM_ROOT,
|
||||
wxTEST_ITEM_CHILD,
|
||||
wxTEST_ITEM_GRANDCHILD,
|
||||
wxTEST_ITEM_LEAF,
|
||||
wxTEST_ITEM_LEAF_HIDDEN,
|
||||
wxTEST_ITEM_GRANDCHILD_HIDDEN
|
||||
};
|
||||
|
||||
DataViewCtrlTestModel()
|
||||
: m_root(wxTEST_ITEM_ROOT),
|
||||
m_child(wxTEST_ITEM_CHILD),
|
||||
m_grandChild(wxTEST_ITEM_GRANDCHILD),
|
||||
m_leaf(wxTEST_ITEM_LEAF),
|
||||
m_leafHidden(wxTEST_ITEM_LEAF_HIDDEN),
|
||||
m_grandchildHidden(wxTEST_ITEM_GRANDCHILD_HIDDEN),
|
||||
m_allItemsVisible(false)
|
||||
{
|
||||
}
|
||||
|
||||
wxDataViewItem GetDataViewItem(wxTestItem item) const
|
||||
{
|
||||
switch( item )
|
||||
{
|
||||
case wxTEST_ITEM_NULL:
|
||||
return wxDataViewItem();
|
||||
|
||||
case wxTEST_ITEM_ROOT:
|
||||
return wxDataViewItem(const_cast<wxTestItem*>(&m_root));
|
||||
|
||||
case wxTEST_ITEM_CHILD:
|
||||
return wxDataViewItem(const_cast<wxTestItem*>(&m_child));
|
||||
|
||||
case wxTEST_ITEM_GRANDCHILD:
|
||||
return wxDataViewItem(const_cast<wxTestItem*>(&m_grandChild));
|
||||
|
||||
case wxTEST_ITEM_LEAF:
|
||||
return wxDataViewItem(const_cast<wxTestItem*>(&m_leaf));
|
||||
|
||||
case wxTEST_ITEM_LEAF_HIDDEN:
|
||||
return wxDataViewItem(const_cast<wxTestItem*>(&m_leafHidden));
|
||||
|
||||
case wxTEST_ITEM_GRANDCHILD_HIDDEN:
|
||||
return wxDataViewItem(const_cast<wxTestItem*>(&m_grandchildHidden));
|
||||
}
|
||||
return wxDataViewItem();
|
||||
}
|
||||
|
||||
// Overridden wxDataViewModel methods.
|
||||
|
||||
void GetValue(wxVariant &variant, const wxDataViewItem &item,
|
||||
unsigned int WXUNUSED(col)) const override
|
||||
{
|
||||
switch( GetItemID(item) )
|
||||
{
|
||||
case wxTEST_ITEM_NULL:
|
||||
break;
|
||||
|
||||
case wxTEST_ITEM_ROOT:
|
||||
variant = "root";
|
||||
break;
|
||||
|
||||
case wxTEST_ITEM_CHILD:
|
||||
variant = "child";
|
||||
break;
|
||||
|
||||
case wxTEST_ITEM_GRANDCHILD:
|
||||
variant = "grand child";
|
||||
break;
|
||||
|
||||
case wxTEST_ITEM_LEAF:
|
||||
variant = "leaf";
|
||||
break;
|
||||
|
||||
case wxTEST_ITEM_LEAF_HIDDEN:
|
||||
variant = "initially hidden leaf";
|
||||
break;
|
||||
|
||||
case wxTEST_ITEM_GRANDCHILD_HIDDEN:
|
||||
variant = "initially hidden";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool SetValue(const wxVariant &WXUNUSED(variant),
|
||||
const wxDataViewItem &WXUNUSED(item),
|
||||
unsigned int WXUNUSED(col)) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HasContainerColumns(const wxDataViewItem &WXUNUSED(item)) const override
|
||||
{
|
||||
// Always display all the columns, even for the containers.
|
||||
return true;
|
||||
}
|
||||
|
||||
wxDataViewItem GetParent(const wxDataViewItem &item) const override
|
||||
{
|
||||
switch( GetItemID(item) )
|
||||
{
|
||||
case wxTEST_ITEM_NULL:
|
||||
FAIL( "The item is the top most container" );
|
||||
return wxDataViewItem();
|
||||
|
||||
case wxTEST_ITEM_ROOT:
|
||||
return wxDataViewItem();
|
||||
|
||||
case wxTEST_ITEM_CHILD:
|
||||
return GetDataViewItem(m_root);
|
||||
|
||||
case wxTEST_ITEM_GRANDCHILD:
|
||||
case wxTEST_ITEM_GRANDCHILD_HIDDEN:
|
||||
return GetDataViewItem(m_child);
|
||||
|
||||
case wxTEST_ITEM_LEAF:
|
||||
case wxTEST_ITEM_LEAF_HIDDEN:
|
||||
return GetDataViewItem(m_grandChild);
|
||||
}
|
||||
return wxDataViewItem();
|
||||
}
|
||||
|
||||
bool IsContainer(const wxDataViewItem &item) const override
|
||||
{
|
||||
switch( GetItemID(item) )
|
||||
{
|
||||
case wxTEST_ITEM_NULL:
|
||||
case wxTEST_ITEM_ROOT:
|
||||
case wxTEST_ITEM_CHILD:
|
||||
case wxTEST_ITEM_GRANDCHILD:
|
||||
return true;
|
||||
|
||||
case wxTEST_ITEM_LEAF:
|
||||
case wxTEST_ITEM_LEAF_HIDDEN:
|
||||
case wxTEST_ITEM_GRANDCHILD_HIDDEN:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int GetChildren(const wxDataViewItem &item,
|
||||
wxDataViewItemArray &children) const override
|
||||
{
|
||||
switch( GetItemID(item) )
|
||||
{
|
||||
case wxTEST_ITEM_NULL:
|
||||
children.push_back(GetDataViewItem(m_root));
|
||||
return 1;
|
||||
|
||||
case wxTEST_ITEM_ROOT:
|
||||
children.push_back(GetDataViewItem(m_child));
|
||||
return 1;
|
||||
|
||||
case wxTEST_ITEM_CHILD:
|
||||
children.push_back(GetDataViewItem(m_grandChild));
|
||||
|
||||
if ( m_allItemsVisible )
|
||||
{
|
||||
children.push_back(GetDataViewItem(m_grandchildHidden));
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
case wxTEST_ITEM_GRANDCHILD:
|
||||
children.push_back(GetDataViewItem(m_leaf));
|
||||
|
||||
if ( m_allItemsVisible )
|
||||
{
|
||||
children.push_back(GetDataViewItem(m_leafHidden));
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
case wxTEST_ITEM_LEAF:
|
||||
case wxTEST_ITEM_LEAF_HIDDEN:
|
||||
case wxTEST_ITEM_GRANDCHILD_HIDDEN:
|
||||
FAIL( "The item is not a container" );
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum wxItemsOrder
|
||||
{
|
||||
wxORDER_LEAF_THEN_GRANCHILD,
|
||||
wxORDER_GRANCHILD_THEN_LEAF
|
||||
};
|
||||
|
||||
void ShowChildren(wxItemsOrder order)
|
||||
{
|
||||
m_allItemsVisible = true;
|
||||
switch ( order )
|
||||
{
|
||||
case wxORDER_LEAF_THEN_GRANCHILD:
|
||||
ItemAdded(GetDataViewItem(m_grandChild), GetDataViewItem(m_leafHidden));
|
||||
ItemAdded(GetDataViewItem(m_child), GetDataViewItem(m_grandchildHidden));
|
||||
break;
|
||||
|
||||
case wxORDER_GRANCHILD_THEN_LEAF:
|
||||
ItemAdded(GetDataViewItem(m_child), GetDataViewItem(m_grandchildHidden));
|
||||
ItemAdded(GetDataViewItem(m_grandChild), GetDataViewItem(m_leafHidden));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void HideChildren()
|
||||
{
|
||||
m_allItemsVisible = false;
|
||||
ItemDeleted(GetDataViewItem(m_grandChild), GetDataViewItem(m_leafHidden));
|
||||
ItemDeleted(GetDataViewItem(m_child), GetDataViewItem(m_grandchildHidden));
|
||||
}
|
||||
|
||||
private:
|
||||
wxTestItem GetItemID(const wxDataViewItem &dataViewItem) const
|
||||
{
|
||||
if ( dataViewItem.GetID() == nullptr )
|
||||
return wxTEST_ITEM_NULL;
|
||||
return *static_cast<wxTestItem*>(dataViewItem.GetID());
|
||||
}
|
||||
|
||||
wxTestItem m_root;
|
||||
wxTestItem m_child;
|
||||
wxTestItem m_grandChild;
|
||||
wxTestItem m_leaf;
|
||||
wxTestItem m_leafHidden;
|
||||
wxTestItem m_grandchildHidden;
|
||||
|
||||
// Whether wxTEST_ITEM_GRANDCHILD_HIDDEN item should be visible or not.
|
||||
bool m_allItemsVisible;
|
||||
};
|
||||
|
||||
|
||||
class DataViewCtrlWithCustomModelTestCase
|
||||
{
|
||||
public:
|
||||
DataViewCtrlWithCustomModelTestCase();
|
||||
~DataViewCtrlWithCustomModelTestCase();
|
||||
|
||||
protected:
|
||||
enum wxItemExistence
|
||||
{
|
||||
wxITEM_APPEAR,
|
||||
wxITEM_DISAPPEAR
|
||||
};
|
||||
|
||||
void UpdateAndWaitForItem(const wxDataViewItem& item, wxItemExistence existence)
|
||||
{
|
||||
m_dvc->Refresh();
|
||||
m_dvc->Update();
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// Unfortunately it's not enough to call wxYield() once, so wait up to
|
||||
// 0.5 sec.
|
||||
WaitFor("wxDataViewCtrl upder", [this, item, existence]() {
|
||||
const bool isItemRectEmpty = m_dvc->GetItemRect(item).IsEmpty();
|
||||
switch ( existence )
|
||||
{
|
||||
case wxITEM_APPEAR:
|
||||
if ( !isItemRectEmpty )
|
||||
return true;
|
||||
break;
|
||||
|
||||
case wxITEM_DISAPPEAR:
|
||||
if ( isItemRectEmpty )
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
#else // !__WXGTK__
|
||||
wxUnusedVar(item);
|
||||
wxUnusedVar(existence);
|
||||
#endif // __WXGTK__
|
||||
}
|
||||
|
||||
// The dataview control.
|
||||
wxDataViewCtrl *m_dvc;
|
||||
|
||||
// The dataview model.
|
||||
DataViewCtrlTestModel *m_model;
|
||||
|
||||
// Its items.
|
||||
wxDataViewItem m_root,
|
||||
m_child,
|
||||
m_grandchild,
|
||||
m_leaf,
|
||||
m_leafHidden,
|
||||
m_grandchildHidden;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(DataViewCtrlWithCustomModelTestCase);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
DataViewCtrlTestCase::DataViewCtrlTestCase(long style)
|
||||
{
|
||||
m_dvc = new wxDataViewTreeCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
style);
|
||||
|
||||
m_root = m_dvc->AppendContainer(wxDataViewItem(), "The root");
|
||||
m_child1 = m_dvc->AppendContainer(m_root, "child1");
|
||||
m_grandchild = m_dvc->AppendItem(m_child1, "grandchild");
|
||||
m_child2 = m_dvc->AppendItem(m_root, "child2");
|
||||
|
||||
m_dvc->Layout();
|
||||
m_dvc->Expand(m_root);
|
||||
m_dvc->Refresh();
|
||||
m_dvc->Update();
|
||||
}
|
||||
|
||||
DataViewCtrlTestCase::~DataViewCtrlTestCase()
|
||||
{
|
||||
delete m_dvc;
|
||||
}
|
||||
|
||||
MultiColumnsDataViewCtrlTestCase::MultiColumnsDataViewCtrlTestCase()
|
||||
: m_size(200, 100),
|
||||
m_firstColumnWidth(50)
|
||||
{
|
||||
m_dvc = new wxDataViewListCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
|
||||
m_firstColumn =
|
||||
m_dvc->AppendTextColumn(wxString(), wxDATAVIEW_CELL_INERT, m_firstColumnWidth);
|
||||
m_lastColumn =
|
||||
m_dvc->AppendTextColumn(wxString(), wxDATAVIEW_CELL_INERT);
|
||||
|
||||
// Set size after columns appending to extend size of the last column.
|
||||
m_dvc->SetSize(m_size);
|
||||
m_dvc->Layout();
|
||||
m_dvc->Refresh();
|
||||
m_dvc->Update();
|
||||
}
|
||||
|
||||
MultiColumnsDataViewCtrlTestCase::~MultiColumnsDataViewCtrlTestCase()
|
||||
{
|
||||
delete m_dvc;
|
||||
}
|
||||
|
||||
DataViewCtrlWithCustomModelTestCase::DataViewCtrlWithCustomModelTestCase()
|
||||
{
|
||||
m_dvc = new wxDataViewCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
wxDV_SINGLE);
|
||||
|
||||
m_model = new DataViewCtrlTestModel();
|
||||
m_dvc->AssociateModel(m_model);
|
||||
m_model->DecRef();
|
||||
|
||||
m_dvc->AppendColumn(
|
||||
new wxDataViewColumn(
|
||||
"Value",
|
||||
new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT),
|
||||
0,
|
||||
m_dvc->FromDIP(200),
|
||||
wxALIGN_LEFT,
|
||||
wxDATAVIEW_COL_RESIZABLE));
|
||||
|
||||
m_root = m_model->GetDataViewItem(DataViewCtrlTestModel::wxTEST_ITEM_ROOT);
|
||||
m_child = m_model->GetDataViewItem(DataViewCtrlTestModel::wxTEST_ITEM_CHILD);
|
||||
m_grandchild =
|
||||
m_model->GetDataViewItem(DataViewCtrlTestModel::wxTEST_ITEM_GRANDCHILD);
|
||||
m_leaf =
|
||||
m_model->GetDataViewItem(DataViewCtrlTestModel::wxTEST_ITEM_LEAF);
|
||||
m_leafHidden =
|
||||
m_model->GetDataViewItem(DataViewCtrlTestModel::wxTEST_ITEM_LEAF_HIDDEN);
|
||||
m_grandchildHidden =
|
||||
m_model->GetDataViewItem(DataViewCtrlTestModel::wxTEST_ITEM_GRANDCHILD_HIDDEN);
|
||||
|
||||
m_dvc->Layout();
|
||||
m_dvc->Expand(m_root);
|
||||
m_dvc->Refresh();
|
||||
m_dvc->Update();
|
||||
}
|
||||
|
||||
DataViewCtrlWithCustomModelTestCase::~DataViewCtrlWithCustomModelTestCase()
|
||||
{
|
||||
delete m_dvc;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase,
|
||||
"wxDVC::Selection",
|
||||
"[wxDataViewCtrl][select]")
|
||||
{
|
||||
// Check selection round-trip.
|
||||
wxDataViewItemArray sel;
|
||||
sel.push_back(m_child1);
|
||||
sel.push_back(m_grandchild);
|
||||
REQUIRE_NOTHROW( m_dvc->SetSelections(sel) );
|
||||
|
||||
wxDataViewItemArray sel2;
|
||||
CHECK( m_dvc->GetSelections(sel2) == wxSsize(sel) );
|
||||
|
||||
CHECK( sel2 == sel );
|
||||
|
||||
// Invalid items in GetSelections() input are supposed to be just skipped.
|
||||
sel.clear();
|
||||
sel.push_back(wxDataViewItem());
|
||||
REQUIRE_NOTHROW( m_dvc->SetSelections(sel) );
|
||||
|
||||
CHECK( m_dvc->GetSelections(sel2) == 0 );
|
||||
CHECK( sel2.empty() );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase,
|
||||
"wxDVC::DeleteSelected",
|
||||
"[wxDataViewCtrl][delete]")
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
wxString useASAN;
|
||||
if ( wxGetEnv("wxUSE_ASAN", &useASAN) && useASAN == "1" )
|
||||
{
|
||||
WARN("Skipping test resulting in a memory leak report with wxGTK");
|
||||
return;
|
||||
}
|
||||
#endif // __WXGTK__
|
||||
|
||||
wxDataViewItemArray sel;
|
||||
sel.push_back(m_child1);
|
||||
sel.push_back(m_grandchild);
|
||||
sel.push_back(m_child2);
|
||||
m_dvc->SetSelections(sel);
|
||||
|
||||
// delete a selected item
|
||||
m_dvc->DeleteItem(m_child1);
|
||||
|
||||
m_dvc->GetSelections(sel);
|
||||
|
||||
// m_child1 and its children should be removed from the selection now
|
||||
REQUIRE( sel.size() == 1 );
|
||||
CHECK( sel[0] == m_child2 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase,
|
||||
"wxDVC::DeleteNotSelected",
|
||||
"[wxDataViewCtrl][delete]")
|
||||
{
|
||||
// TODO not working on OS X as expected
|
||||
#ifdef __WXOSX__
|
||||
WARN("Disabled under MacOS because this test currently fails");
|
||||
#else
|
||||
wxDataViewItemArray sel;
|
||||
sel.push_back(m_child1);
|
||||
sel.push_back(m_grandchild);
|
||||
m_dvc->SetSelections(sel);
|
||||
|
||||
// delete unselected item
|
||||
m_dvc->DeleteItem(m_child2);
|
||||
|
||||
m_dvc->GetSelections(sel);
|
||||
|
||||
// m_child1 and its children should be unaffected
|
||||
REQUIRE( sel.size() == 2 );
|
||||
CHECK( sel[0] == m_child1 );
|
||||
CHECK( sel[1] == m_grandchild );
|
||||
#endif
|
||||
}
|
||||
|
||||
void DataViewCtrlTestCase::TestSelectionFor0and1()
|
||||
{
|
||||
wxDataViewItemArray selections;
|
||||
|
||||
// Initially there is no selection.
|
||||
CHECK( m_dvc->GetSelectedItemsCount() == 0 );
|
||||
CHECK( !m_dvc->HasSelection() );
|
||||
CHECK( !m_dvc->GetSelection().IsOk() );
|
||||
|
||||
CHECK( !m_dvc->GetSelections(selections) );
|
||||
CHECK( selections.empty() );
|
||||
|
||||
// Select one item.
|
||||
m_dvc->Select(m_child1);
|
||||
CHECK( m_dvc->GetSelectedItemsCount() == 1 );
|
||||
CHECK( m_dvc->HasSelection() );
|
||||
CHECK( m_dvc->GetSelection().IsOk() );
|
||||
REQUIRE( m_dvc->GetSelections(selections) == 1 );
|
||||
CHECK( selections[0] == m_child1 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase,
|
||||
"wxDVC::GetSelectionForMulti",
|
||||
"[wxDataViewCtrl][select]")
|
||||
{
|
||||
wxDataViewItemArray selections;
|
||||
|
||||
TestSelectionFor0and1();
|
||||
|
||||
m_dvc->Select(m_child2);
|
||||
|
||||
CHECK( m_dvc->GetSelectedItemsCount() == 2 );
|
||||
CHECK( m_dvc->HasSelection() );
|
||||
CHECK( !m_dvc->GetSelection().IsOk() );
|
||||
REQUIRE( m_dvc->GetSelections(selections) == 2 );
|
||||
CHECK( selections[1] == m_child2 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
"wxDVC::SingleSelection",
|
||||
"[wxDataViewCtrl][selection]")
|
||||
{
|
||||
TestSelectionFor0and1();
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
"wxDVC::IsExpanded",
|
||||
"[wxDataViewCtrl][expand]")
|
||||
{
|
||||
CHECK( m_dvc->IsExpanded(m_root) );
|
||||
CHECK( !m_dvc->IsExpanded(m_child1) );
|
||||
// No idea why, but the native NSOutlineView isItemExpanded: method returns
|
||||
// true for this item for some reason.
|
||||
#ifdef __WXOSX__
|
||||
WARN("Disabled under MacOS: IsExpanded() returns true for grand child");
|
||||
#else
|
||||
CHECK( !m_dvc->IsExpanded(m_grandchild) );
|
||||
#endif
|
||||
CHECK( !m_dvc->IsExpanded(m_child2) );
|
||||
|
||||
m_dvc->Collapse(m_root);
|
||||
CHECK( !m_dvc->IsExpanded(m_root) );
|
||||
|
||||
m_dvc->ExpandChildren(m_root);
|
||||
CHECK( m_dvc->IsExpanded(m_root) );
|
||||
CHECK( m_dvc->IsExpanded(m_child1) );
|
||||
|
||||
// Expanding an already expanded node must still expand all its children.
|
||||
m_dvc->Collapse(m_child1);
|
||||
CHECK( !m_dvc->IsExpanded(m_child1) );
|
||||
m_dvc->ExpandChildren(m_root);
|
||||
CHECK( m_dvc->IsExpanded(m_child1) );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(DataViewCtrlWithCustomModelTestCase,
|
||||
"wxDVC::Expand",
|
||||
"[wxDataViewCtrl][expand]")
|
||||
{
|
||||
CHECK( m_dvc->IsExpanded(m_root) );
|
||||
CHECK( !m_dvc->IsExpanded(m_child) );
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// We need to let the native control have some events to lay itself out.
|
||||
wxYield();
|
||||
#endif // __WXGTK__
|
||||
|
||||
// Unfortunately we can't combine test options with SECTION() so use
|
||||
// the additional enum variable.
|
||||
enum
|
||||
{
|
||||
wxOPTIONS_EXPAND_ADD_LEAF_THEN_GRANCHILD,
|
||||
wxOPTIONS_DONT_EXPAND_ADD_LEAF_THEN_GRANCHILD,
|
||||
wxOPTIONS_EXPAND_ADD_GRANCHILD_THEN_LEAF,
|
||||
wxOPTIONS_DONT_EXPAND_ADD_GRANCHILD_THEN_LEAF
|
||||
} options wxDUMMY_INITIALIZE(wxOPTIONS_EXPAND_ADD_LEAF_THEN_GRANCHILD);
|
||||
|
||||
SECTION( "Was Expanded, Add The Leaf Then The Grandchild" )
|
||||
{
|
||||
options = wxOPTIONS_EXPAND_ADD_LEAF_THEN_GRANCHILD;
|
||||
}
|
||||
|
||||
SECTION( "Was Not Expanded, Add The Leaf Then The Grandchild" )
|
||||
{
|
||||
options = wxOPTIONS_DONT_EXPAND_ADD_LEAF_THEN_GRANCHILD;
|
||||
}
|
||||
|
||||
SECTION( "Was Expanded, Add The Grandchild Then The Leaf" )
|
||||
{
|
||||
options = wxOPTIONS_EXPAND_ADD_GRANCHILD_THEN_LEAF;
|
||||
}
|
||||
|
||||
SECTION( "Was Not Expanded, Add The Grandchild Then The Leaf" )
|
||||
{
|
||||
options = wxOPTIONS_DONT_EXPAND_ADD_GRANCHILD_THEN_LEAF;
|
||||
}
|
||||
|
||||
switch ( options )
|
||||
{
|
||||
case wxOPTIONS_EXPAND_ADD_LEAF_THEN_GRANCHILD:
|
||||
case wxOPTIONS_EXPAND_ADD_GRANCHILD_THEN_LEAF:
|
||||
CHECK( m_dvc->GetItemRect(m_grandchild).IsEmpty() );
|
||||
CHECK( m_dvc->GetItemRect(m_leafHidden).IsEmpty() );
|
||||
CHECK( m_dvc->GetItemRect(m_grandchildHidden).IsEmpty() );
|
||||
|
||||
m_dvc->Expand(m_child);
|
||||
m_dvc->Expand(m_grandchild);
|
||||
UpdateAndWaitForItem(m_grandchild, wxITEM_APPEAR);
|
||||
|
||||
CHECK( !m_dvc->GetItemRect(m_grandchild).IsEmpty() );
|
||||
CHECK( !m_dvc->GetItemRect(m_leaf).IsEmpty() );
|
||||
CHECK( m_dvc->GetItemRect(m_leafHidden).IsEmpty() );
|
||||
CHECK( m_dvc->GetItemRect(m_grandchildHidden).IsEmpty() );
|
||||
|
||||
m_dvc->Collapse(m_grandchild);
|
||||
m_dvc->Collapse(m_child);
|
||||
break;
|
||||
|
||||
case wxOPTIONS_DONT_EXPAND_ADD_LEAF_THEN_GRANCHILD:
|
||||
case wxOPTIONS_DONT_EXPAND_ADD_GRANCHILD_THEN_LEAF:
|
||||
// Do nothing.
|
||||
break;
|
||||
}
|
||||
|
||||
// Check wxDataViewModel::ItemAdded().
|
||||
switch ( options )
|
||||
{
|
||||
case wxOPTIONS_EXPAND_ADD_LEAF_THEN_GRANCHILD:
|
||||
case wxOPTIONS_DONT_EXPAND_ADD_LEAF_THEN_GRANCHILD:
|
||||
m_model->ShowChildren(DataViewCtrlTestModel::wxORDER_LEAF_THEN_GRANCHILD);
|
||||
break;
|
||||
|
||||
case wxOPTIONS_EXPAND_ADD_GRANCHILD_THEN_LEAF:
|
||||
case wxOPTIONS_DONT_EXPAND_ADD_GRANCHILD_THEN_LEAF:
|
||||
m_model->ShowChildren(DataViewCtrlTestModel::wxORDER_GRANCHILD_THEN_LEAF);
|
||||
break;
|
||||
}
|
||||
|
||||
m_dvc->Expand(m_child);
|
||||
m_dvc->Expand(m_grandchild);
|
||||
UpdateAndWaitForItem(m_leaf, wxITEM_APPEAR);
|
||||
|
||||
CHECK( m_dvc->IsExpanded(m_child) );
|
||||
CHECK( m_dvc->IsExpanded(m_grandchild) );
|
||||
CHECK( !m_dvc->GetItemRect(m_grandchild).IsEmpty() );
|
||||
CHECK( !m_dvc->GetItemRect(m_leaf).IsEmpty() );
|
||||
CHECK( !m_dvc->GetItemRect(m_leafHidden).IsEmpty() );
|
||||
CHECK( !m_dvc->GetItemRect(m_grandchildHidden).IsEmpty() );
|
||||
|
||||
m_model->HideChildren();
|
||||
UpdateAndWaitForItem(m_leafHidden, wxITEM_DISAPPEAR);
|
||||
|
||||
CHECK( m_dvc->GetItemRect(m_leafHidden).IsEmpty() );
|
||||
// Check that the problem with nodes duplication in ItemAdded() fixed.
|
||||
CHECK( m_dvc->GetItemRect(m_grandchildHidden).IsEmpty() );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
"wxDVC::GetItemRect",
|
||||
"[wxDataViewCtrl][item]")
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// We need to let the native control have some events to lay itself out.
|
||||
wxYield();
|
||||
#endif // __WXGTK__
|
||||
|
||||
const wxRect rect1 = m_dvc->GetItemRect(m_child1);
|
||||
const wxRect rect2 = m_dvc->GetItemRect(m_child2);
|
||||
|
||||
CHECK( rect1 != wxRect() );
|
||||
CHECK( rect2 != wxRect() );
|
||||
|
||||
CHECK( rect1.x == rect2.x );
|
||||
CHECK( rect1.width == rect2.width );
|
||||
CHECK( rect1.height == rect2.height );
|
||||
|
||||
{
|
||||
INFO("First child: " << rect1 << ", second one: " << rect2);
|
||||
CHECK( rect1.y < rect2.y );
|
||||
}
|
||||
|
||||
// This forces generic implementation to add m_grandchild to the tree, as
|
||||
// it does it only on demand. We want the item to really be there to check
|
||||
// that GetItemRect() returns an empty rectangle for collapsed items.
|
||||
m_dvc->Expand(m_child1);
|
||||
m_dvc->Collapse(m_child1);
|
||||
|
||||
const wxRect rectNotShown = m_dvc->GetItemRect(m_grandchild);
|
||||
CHECK( rectNotShown == wxRect() );
|
||||
|
||||
// Append enough items to make the window scrollable.
|
||||
for ( int i = 3; i < 100; ++i )
|
||||
m_dvc->AppendItem(m_root, wxString::Format("child%d", i));
|
||||
|
||||
const wxDataViewItem last = m_dvc->AppendItem(m_root, "last");
|
||||
|
||||
// This should scroll the window to bring this item into view.
|
||||
m_dvc->EnsureVisible(last);
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// Wait for the list control to be relaid out.
|
||||
WaitFor("wxDataViewCtrl layout", [this]() {
|
||||
return m_dvc->GetTopItem() != m_root;
|
||||
});
|
||||
#endif // __WXGTK__
|
||||
|
||||
// Check that this was indeed the case.
|
||||
const wxDataViewItem top = m_dvc->GetTopItem();
|
||||
CHECK( top != m_root );
|
||||
|
||||
// Verify that the coordinates are returned in physical coordinates of the
|
||||
// window and not the logical coordinates affected by scrolling.
|
||||
const wxRect rectScrolled = m_dvc->GetItemRect(top);
|
||||
CHECK( rectScrolled.GetBottom() > 0 );
|
||||
CHECK( rectScrolled.GetTop() <= m_dvc->GetClientSize().y );
|
||||
|
||||
// Also check that the root item is not currently visible (because it's
|
||||
// scrolled off).
|
||||
const wxRect rectRoot = m_dvc->GetItemRect(m_root);
|
||||
CHECK( rectRoot == wxRect() );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
"wxDVC::DeleteAllItems",
|
||||
"[wxDataViewCtrl][delete]")
|
||||
{
|
||||
// The invalid item corresponds to the root of tree store model, so it
|
||||
// should have a single item (our m_root) initially.
|
||||
CHECK( m_dvc->GetChildCount(wxDataViewItem()) == 1 );
|
||||
|
||||
m_dvc->DeleteAllItems();
|
||||
|
||||
// And none at all after deleting all the items.
|
||||
CHECK( m_dvc->GetChildCount(wxDataViewItem()) == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(MultiColumnsDataViewCtrlTestCase,
|
||||
"wxDVC::AppendTextColumn",
|
||||
"[wxDataViewCtrl][column]")
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// Wait for the list control to be realized.
|
||||
WaitFor("wxDataViewCtrl to be realized", [this]() {
|
||||
return m_firstColumn->GetWidth() != 0;
|
||||
});
|
||||
#endif
|
||||
|
||||
// Check the width of the first column.
|
||||
CHECK( m_firstColumn->GetWidth() == m_firstColumnWidth );
|
||||
|
||||
// Check that the last column was extended to fit client area.
|
||||
const int lastColumnMaxWidth =
|
||||
m_dvc->GetClientSize().GetWidth() - m_firstColumnWidth;
|
||||
// In GTK and under Mac the width of the last column is less then
|
||||
// a remaining client area.
|
||||
const int lastColumnMinWidth = lastColumnMaxWidth - 10;
|
||||
CHECK( m_lastColumn->GetWidth() <= lastColumnMaxWidth );
|
||||
CHECK( m_lastColumn->GetWidth() >= lastColumnMinWidth );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase,
|
||||
"wxDVC::KeyEvents",
|
||||
"[wxDataViewCtrl][event]")
|
||||
{
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter keyEvents(m_dvc, wxEVT_KEY_DOWN);
|
||||
|
||||
m_dvc->SetFocus();
|
||||
wxYield();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
sim.Char(WXK_DOWN);
|
||||
wxYield();
|
||||
|
||||
CHECK( keyEvents.GetCount() == 1 );
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
#endif //wxUSE_DATAVIEWCTRL
|
||||
168
libs/wxWidgets-3.3.1/tests/controls/datepickerctrltest.cpp
Normal file
168
libs/wxWidgets-3.3.1/tests/controls/datepickerctrltest.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/datepickerctrltest.cpp
|
||||
// Purpose: wxDatePickerCtrl unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-06-18
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_DATEPICKCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/button.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/datectrl.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "testdate.h"
|
||||
|
||||
class DatePickerCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DatePickerCtrlTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( DatePickerCtrlTestCase );
|
||||
CPPUNIT_TEST( Value );
|
||||
CPPUNIT_TEST( Range );
|
||||
WXUISIM_TEST( Focus );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Value();
|
||||
void Range();
|
||||
void Focus();
|
||||
|
||||
wxDatePickerCtrl* m_datepicker;
|
||||
wxButton* m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(DatePickerCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( DatePickerCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DatePickerCtrlTestCase, "DatePickerCtrlTestCase" );
|
||||
|
||||
void DatePickerCtrlTestCase::setUp()
|
||||
{
|
||||
m_datepicker = new wxDatePickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
m_button = nullptr;
|
||||
}
|
||||
|
||||
void DatePickerCtrlTestCase::tearDown()
|
||||
{
|
||||
delete m_button;
|
||||
delete m_datepicker;
|
||||
}
|
||||
|
||||
void DatePickerCtrlTestCase::Value()
|
||||
{
|
||||
const wxDateTime dt(18, wxDateTime::Jul, 2011);
|
||||
m_datepicker->SetValue(dt);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( dt, m_datepicker->GetValue() );
|
||||
|
||||
// We don't use wxDP_ALLOWNONE currently, hence a value is required.
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( m_datepicker->SetValue(wxDateTime()) );
|
||||
}
|
||||
|
||||
void DatePickerCtrlTestCase::Range()
|
||||
{
|
||||
// Initially we have no valid range but MSW version still has (built in)
|
||||
// minimum as it doesn't support dates before 1601-01-01, hence don't rely
|
||||
// on GetRange() returning false.
|
||||
wxDateTime dtRangeStart, dtRangeEnd;
|
||||
|
||||
// Default end date for QT is 31/12/7999 which is considered valid,
|
||||
// therefore we should omit this assertion for QT
|
||||
#ifndef __WXQT__
|
||||
m_datepicker->GetRange(&dtRangeStart, &dtRangeEnd);
|
||||
CPPUNIT_ASSERT( !dtRangeEnd.IsValid() );
|
||||
#endif
|
||||
|
||||
// After we set it we should be able to get it back.
|
||||
const wxDateTime
|
||||
dtStart(15, wxDateTime::Feb, 1923),
|
||||
dtEnd(18, wxDateTime::Jun, 2011);
|
||||
|
||||
m_datepicker->SetRange(dtStart, dtEnd);
|
||||
CPPUNIT_ASSERT( m_datepicker->GetRange(&dtRangeStart, &dtRangeEnd) );
|
||||
CPPUNIT_ASSERT_EQUAL( dtStart, dtRangeStart );
|
||||
CPPUNIT_ASSERT_EQUAL( dtEnd, dtRangeEnd );
|
||||
|
||||
// Setting dates inside the range should work, including the range end
|
||||
// points.
|
||||
m_datepicker->SetValue(dtStart);
|
||||
CPPUNIT_ASSERT_EQUAL( dtStart, m_datepicker->GetValue() );
|
||||
|
||||
m_datepicker->SetValue(dtEnd);
|
||||
CPPUNIT_ASSERT_EQUAL( dtEnd, m_datepicker->GetValue() );
|
||||
|
||||
|
||||
// Setting dates outside the range should not work.
|
||||
m_datepicker->SetValue(dtEnd + wxTimeSpan::Day());
|
||||
CPPUNIT_ASSERT_EQUAL( dtEnd, m_datepicker->GetValue() );
|
||||
|
||||
m_datepicker->SetValue(dtStart - wxTimeSpan::Day());
|
||||
CPPUNIT_ASSERT_EQUAL( dtEnd, m_datepicker->GetValue() );
|
||||
|
||||
|
||||
// Changing the range should clamp the current value to it if necessary.
|
||||
const wxDateTime
|
||||
dtBeforeEnd = dtEnd - wxDateSpan::Day();
|
||||
m_datepicker->SetRange(dtStart, dtBeforeEnd);
|
||||
CPPUNIT_ASSERT_EQUAL( dtBeforeEnd, m_datepicker->GetValue() );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
static wxPoint GetRectCenter(const wxRect& r)
|
||||
{
|
||||
return (r.GetTopRight() + r.GetBottomLeft()) / 2;
|
||||
}
|
||||
|
||||
void DatePickerCtrlTestCase::Focus()
|
||||
{
|
||||
// Create another control just to give focus to it initially.
|
||||
m_button = new wxButton(wxTheApp->GetTopWindow(), wxID_OK);
|
||||
m_button->Move(0, m_datepicker->GetSize().y * 3);
|
||||
m_button->SetFocus();
|
||||
wxYield();
|
||||
|
||||
CHECK( !m_datepicker->HasFocus() );
|
||||
|
||||
EventCounter setFocus(m_datepicker, wxEVT_SET_FOCUS);
|
||||
EventCounter killFocus(m_datepicker, wxEVT_KILL_FOCUS);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
sim.MouseMove(GetRectCenter(m_datepicker->GetScreenRect()));
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
REQUIRE( m_datepicker->HasFocus() );
|
||||
CHECK( setFocus.GetCount() == 1 );
|
||||
CHECK( killFocus.GetCount() == 0 );
|
||||
|
||||
sim.MouseMove(GetRectCenter(m_button->GetScreenRect()));
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CHECK( !m_datepicker->HasFocus() );
|
||||
CHECK( setFocus.GetCount() == 1 );
|
||||
CHECK( killFocus.GetCount() == 1 );
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
#endif // wxUSE_DATEPICKCTRL
|
||||
145
libs/wxWidgets-3.3.1/tests/controls/dialogtest.cpp
Normal file
145
libs/wxWidgets-3.3.1/tests/controls/dialogtest.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/dialogtest.cpp
|
||||
// Purpose: wxWindow unit test
|
||||
// Author: Vaclav Slavik
|
||||
// Created: 2012-08-30
|
||||
// Copyright: (c) 2012 Vaclav Slavik
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#include "wx/testing.h"
|
||||
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/filedlg.h"
|
||||
|
||||
// This test suite tests helpers from wx/testing.h intended for testing of code
|
||||
// that calls modal dialogs. It does not test the implementation of wxWidgets'
|
||||
// dialogs.
|
||||
|
||||
TEST_CASE("Modal::MessageDialog", "[modal]")
|
||||
{
|
||||
int rc;
|
||||
|
||||
#if wxUSE_FILEDLG
|
||||
#define FILE_DIALOG_TEST ,\
|
||||
wxExpectModal<wxFileDialog>(wxGetCwd() + "/test.txt").Optional()
|
||||
#else
|
||||
#define FILE_DIALOG_TEST
|
||||
#endif
|
||||
|
||||
wxTEST_DIALOG
|
||||
(
|
||||
rc = wxMessageBox("Should I fail?", "Question", wxYES|wxNO),
|
||||
wxExpectModal<wxMessageDialog>(wxNO)
|
||||
FILE_DIALOG_TEST
|
||||
);
|
||||
|
||||
CHECK( rc == wxNO );
|
||||
}
|
||||
|
||||
#if wxUSE_FILEDLG
|
||||
TEST_CASE("Modal::FileDialog", "[modal]")
|
||||
{
|
||||
#if defined(__WXQT__) && defined(__WINDOWS__)
|
||||
WARN("Skipping test known to fail under wxQt for Windows");
|
||||
return;
|
||||
#else
|
||||
wxFileDialog dlg(nullptr);
|
||||
int rc;
|
||||
|
||||
wxTEST_DIALOG
|
||||
(
|
||||
rc = dlg.ShowModal(),
|
||||
wxExpectModal<wxFileDialog>(wxGetCwd() + "/test.txt")
|
||||
);
|
||||
|
||||
CHECK( rc == wxID_OK );
|
||||
|
||||
CHECK( dlg.GetFilename() == "test.txt" );
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
// The native file dialog in GTK+ 3 launches an async operation which tries
|
||||
// to dereference the already deleted dialog object if we don't let it to
|
||||
// complete before leaving this function.
|
||||
wxYield();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
class MyDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
MyDialog(wxWindow *parent) : wxDialog(parent, wxID_ANY, "Entry"), m_value(-1)
|
||||
{
|
||||
// Dummy. Imagine it's a real dialog that shows some number-entry
|
||||
// controls.
|
||||
}
|
||||
|
||||
int m_value;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
class wxExpectModal<MyDialog> : public wxExpectModalBase<MyDialog>
|
||||
{
|
||||
public:
|
||||
wxExpectModal(int valueToSet) : m_valueToSet(valueToSet) {}
|
||||
|
||||
protected:
|
||||
virtual int OnInvoked(MyDialog *dlg) const override
|
||||
{
|
||||
// Simulate the user entering the expected number:
|
||||
dlg->m_value = m_valueToSet;
|
||||
return wxID_OK;
|
||||
}
|
||||
|
||||
int m_valueToSet;
|
||||
};
|
||||
|
||||
TEST_CASE("Modal::CustomDialog", "[modal]")
|
||||
{
|
||||
MyDialog dlg(nullptr);
|
||||
|
||||
wxTEST_DIALOG
|
||||
(
|
||||
dlg.ShowModal(),
|
||||
wxExpectModal<MyDialog>(42)
|
||||
);
|
||||
|
||||
CHECK( dlg.m_value == 42 );
|
||||
}
|
||||
|
||||
|
||||
class MyModalDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
MyModalDialog() : wxDialog (nullptr, wxID_ANY, "Modal Dialog")
|
||||
{
|
||||
m_wasModal = false;
|
||||
Bind( wxEVT_INIT_DIALOG, &MyModalDialog::OnInit, this );
|
||||
}
|
||||
|
||||
void OnInit(wxInitDialogEvent& WXUNUSED(event))
|
||||
{
|
||||
m_wasModal = IsModal();
|
||||
CallAfter( &MyModalDialog::EndModal, wxID_OK );
|
||||
}
|
||||
|
||||
bool WasModal() const
|
||||
{
|
||||
return m_wasModal;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_wasModal;
|
||||
};
|
||||
|
||||
TEST_CASE("Modal::InitDialog", "[modal]")
|
||||
{
|
||||
MyModalDialog dlg;
|
||||
dlg.ShowModal();
|
||||
CHECK( dlg.WasModal() );
|
||||
}
|
||||
77
libs/wxWidgets-3.3.1/tests/controls/frametest.cpp
Normal file
77
libs/wxWidgets-3.3.1/tests/controls/frametest.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/frametest.cpp
|
||||
// Purpose: wxFrame unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-10
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/frame.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
|
||||
class FrameTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
FrameTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( FrameTestCase );
|
||||
CPPUNIT_TEST( Iconize );
|
||||
CPPUNIT_TEST( Close );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Iconize();
|
||||
void Close();
|
||||
|
||||
wxFrame *m_frame;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(FrameTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FrameTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FrameTestCase, "FrameTestCase" );
|
||||
|
||||
void FrameTestCase::setUp()
|
||||
{
|
||||
m_frame = new wxFrame(nullptr, wxID_ANY, "test frame");
|
||||
m_frame->Show();
|
||||
}
|
||||
|
||||
void FrameTestCase::tearDown()
|
||||
{
|
||||
m_frame->Destroy();
|
||||
}
|
||||
|
||||
void FrameTestCase::Iconize()
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
EventCounter iconize(m_frame, wxEVT_ICONIZE);
|
||||
|
||||
m_frame->Iconize();
|
||||
m_frame->Iconize(false);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, iconize.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void FrameTestCase::Close()
|
||||
{
|
||||
EventCounter close(m_frame, wxEVT_CLOSE_WINDOW);
|
||||
|
||||
m_frame->Close();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
|
||||
}
|
||||
107
libs/wxWidgets-3.3.1/tests/controls/gaugetest.cpp
Normal file
107
libs/wxWidgets-3.3.1/tests/controls/gaugetest.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/gaugetest.cpp
|
||||
// Purpose: wxGauge unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-15
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_GAUGE
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/gauge.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
class GaugeTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
GaugeTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( GaugeTestCase );
|
||||
CPPUNIT_TEST( Direction );
|
||||
CPPUNIT_TEST( Range );
|
||||
CPPUNIT_TEST( Value );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Direction();
|
||||
void Range();
|
||||
void Value();
|
||||
|
||||
wxGauge* m_gauge;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(GaugeTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( GaugeTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GaugeTestCase, "GaugeTestCase" );
|
||||
|
||||
void GaugeTestCase::setUp()
|
||||
{
|
||||
m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100);
|
||||
}
|
||||
|
||||
void GaugeTestCase::tearDown()
|
||||
{
|
||||
wxTheApp->GetTopWindow()->DestroyChildren();
|
||||
}
|
||||
|
||||
void GaugeTestCase::Direction()
|
||||
{
|
||||
//We should default to a horizontal gauge
|
||||
CPPUNIT_ASSERT(!m_gauge->IsVertical());
|
||||
|
||||
wxDELETE(m_gauge);
|
||||
m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100,
|
||||
wxDefaultPosition, wxDefaultSize, wxGA_VERTICAL);
|
||||
|
||||
CPPUNIT_ASSERT(m_gauge->IsVertical());
|
||||
|
||||
wxDELETE(m_gauge);
|
||||
m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100,
|
||||
wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
|
||||
|
||||
CPPUNIT_ASSERT(!m_gauge->IsVertical());
|
||||
}
|
||||
|
||||
void GaugeTestCase::Range()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(100, m_gauge->GetRange());
|
||||
|
||||
m_gauge->SetRange(50);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(50, m_gauge->GetRange());
|
||||
|
||||
m_gauge->SetRange(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetRange());
|
||||
}
|
||||
|
||||
void GaugeTestCase::Value()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetValue());
|
||||
|
||||
m_gauge->SetValue(50);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(50, m_gauge->GetValue());
|
||||
|
||||
m_gauge->SetValue(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetValue());
|
||||
|
||||
m_gauge->SetValue(100);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(100, m_gauge->GetValue());
|
||||
}
|
||||
|
||||
#endif //wxUSE_GAUGE
|
||||
2852
libs/wxWidgets-3.3.1/tests/controls/gridtest.cpp
Normal file
2852
libs/wxWidgets-3.3.1/tests/controls/gridtest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
145
libs/wxWidgets-3.3.1/tests/controls/headerctrltest.cpp
Normal file
145
libs/wxWidgets-3.3.1/tests/controls/headerctrltest.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/headerctrltest.cpp
|
||||
// Purpose: wxHeaderCtrl unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-11-26
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/headerctrl.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class HeaderCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
HeaderCtrlTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( HeaderCtrlTestCase );
|
||||
CPPUNIT_TEST( AddDelete );
|
||||
CPPUNIT_TEST( BestSize );
|
||||
CPPUNIT_TEST( Reorder );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void AddDelete();
|
||||
void BestSize();
|
||||
void Reorder();
|
||||
|
||||
wxHeaderCtrlSimple *m_header;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(HeaderCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( HeaderCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HeaderCtrlTestCase, "HeaderCtrlTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void HeaderCtrlTestCase::setUp()
|
||||
{
|
||||
m_header = new wxHeaderCtrlSimple(wxTheApp->GetTopWindow());
|
||||
}
|
||||
|
||||
void HeaderCtrlTestCase::tearDown()
|
||||
{
|
||||
delete m_header;
|
||||
m_header = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void HeaderCtrlTestCase::AddDelete()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_header->GetColumnCount() );
|
||||
|
||||
m_header->AppendColumn(wxHeaderColumnSimple("Column 1"));
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_header->GetColumnCount() );
|
||||
|
||||
m_header->AppendColumn(wxHeaderColumnSimple("Column 2"));
|
||||
CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
|
||||
|
||||
m_header->InsertColumn(wxHeaderColumnSimple("Column 0"), 0);
|
||||
CPPUNIT_ASSERT_EQUAL( 3, m_header->GetColumnCount() );
|
||||
|
||||
m_header->DeleteColumn(2);
|
||||
CPPUNIT_ASSERT_EQUAL( 2, m_header->GetColumnCount() );
|
||||
}
|
||||
|
||||
void HeaderCtrlTestCase::BestSize()
|
||||
{
|
||||
const wxSize sizeEmpty = m_header->GetBestSize();
|
||||
// this fails under wxGTK where wxControl::GetBestSize() is 0 in horizontal
|
||||
// direction
|
||||
//CPPUNIT_ASSERT( sizeEmpty.x > 0 );
|
||||
CPPUNIT_ASSERT( sizeEmpty.y > 0 );
|
||||
|
||||
m_header->AppendColumn(wxHeaderColumnSimple("Foo"));
|
||||
m_header->AppendColumn(wxHeaderColumnSimple("Bar"));
|
||||
const wxSize size = m_header->GetBestSize();
|
||||
CPPUNIT_ASSERT_EQUAL( sizeEmpty.y, size.y );
|
||||
}
|
||||
|
||||
void HeaderCtrlTestCase::Reorder()
|
||||
{
|
||||
static const int COL_COUNT = 4;
|
||||
|
||||
int n;
|
||||
|
||||
for ( n = 0; n < COL_COUNT; n++ )
|
||||
m_header->AppendColumn(wxHeaderColumnSimple(wxString::Format("%d", n)));
|
||||
|
||||
wxArrayInt order = m_header->GetColumnsOrder(); // initial order: [0 1 2 3]
|
||||
for ( n = 0; n < COL_COUNT; n++ )
|
||||
CPPUNIT_ASSERT_EQUAL( n, order[n] );
|
||||
|
||||
wxHeaderCtrl::MoveColumnInOrderArray(order, 0, 2);
|
||||
m_header->SetColumnsOrder(order); // change order to [1 2 0 3]
|
||||
|
||||
order = m_header->GetColumnsOrder();
|
||||
CPPUNIT_ASSERT_EQUAL( 1, order[0] );
|
||||
CPPUNIT_ASSERT_EQUAL( 2, order[1] );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, order[2] );
|
||||
CPPUNIT_ASSERT_EQUAL( 3, order[3] );
|
||||
|
||||
order[2] = 3;
|
||||
order[3] = 0;
|
||||
m_header->SetColumnsOrder(order); // and now [1 2 3 0]
|
||||
order = m_header->GetColumnsOrder();
|
||||
CPPUNIT_ASSERT_EQUAL( 1, order[0] );
|
||||
CPPUNIT_ASSERT_EQUAL( 2, order[1] );
|
||||
CPPUNIT_ASSERT_EQUAL( 3, order[2] );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, order[3] );
|
||||
|
||||
wxHeaderCtrl::MoveColumnInOrderArray(order, 1, 3);
|
||||
m_header->SetColumnsOrder(order); // finally [2 3 0 1]
|
||||
order = m_header->GetColumnsOrder();
|
||||
CPPUNIT_ASSERT_EQUAL( 2, order[0] );
|
||||
CPPUNIT_ASSERT_EQUAL( 3, order[1] );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, order[2] );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, order[3] );
|
||||
}
|
||||
|
||||
56
libs/wxWidgets-3.3.1/tests/controls/htmllboxtest.cpp
Normal file
56
libs/wxWidgets-3.3.1/tests/controls/htmllboxtest.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/htmllboxtest.cpp
|
||||
// Purpose: wxSimpleHtmlListBoxNameStr unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2010-11-27
|
||||
// Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_HTML
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/htmllbox.h"
|
||||
#include "itemcontainertest.h"
|
||||
|
||||
class HtmlListBoxTestCase : public ItemContainerTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
HtmlListBoxTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_htmllbox; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_htmllbox; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( HtmlListBoxTestCase );
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
wxSimpleHtmlListBox* m_htmllbox;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(HtmlListBoxTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(HtmlListBoxTestCase,
|
||||
"[HtmlListBoxTestCase][item-container]");
|
||||
|
||||
void HtmlListBoxTestCase::setUp()
|
||||
{
|
||||
m_htmllbox = new wxSimpleHtmlListBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
void HtmlListBoxTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_htmllbox);
|
||||
}
|
||||
|
||||
#endif //wxUSE_HTML
|
||||
103
libs/wxWidgets-3.3.1/tests/controls/hyperlinkctrltest.cpp
Normal file
103
libs/wxWidgets-3.3.1/tests/controls/hyperlinkctrltest.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/hyperlinkctrltest.cpp
|
||||
// Purpose: wxHyperlinkCtrl unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-08-05
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_HYPERLINKCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/hyperlink.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "testableframe.h"
|
||||
#include "asserthelper.h"
|
||||
|
||||
class HyperlinkCtrlTestCase
|
||||
{
|
||||
public:
|
||||
HyperlinkCtrlTestCase()
|
||||
{
|
||||
m_hyperlink = new wxHyperlinkCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"wxWidgets", "http://wxwidgets.org");
|
||||
}
|
||||
|
||||
~HyperlinkCtrlTestCase()
|
||||
{
|
||||
delete m_hyperlink;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxHyperlinkCtrl* m_hyperlink;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(HyperlinkCtrlTestCase);
|
||||
};
|
||||
|
||||
TEST_CASE_METHOD(HyperlinkCtrlTestCase, "wxHyperlinkCtrl::Colour",
|
||||
"[hyperlinkctrl]")
|
||||
{
|
||||
#ifndef __WXGTK__
|
||||
CHECK(m_hyperlink->GetHoverColour().IsOk());
|
||||
CHECK(m_hyperlink->GetNormalColour().IsOk());
|
||||
CHECK(m_hyperlink->GetVisitedColour().IsOk());
|
||||
|
||||
// Changing hover colour doesn't work in wxMSW and Wine doesn't seem to
|
||||
// implement either LM_SETITEM or LM_GETITEM correctly, so skip this there.
|
||||
#ifdef __WXMSW__
|
||||
if ( wxIsRunningUnderWine() )
|
||||
{
|
||||
WARN("Skipping testing wxHyperlinkCtrl colours under Wine.");
|
||||
return;
|
||||
}
|
||||
#else // __WXMSW__
|
||||
m_hyperlink->SetHoverColour(*wxGREEN);
|
||||
CHECK( m_hyperlink->GetHoverColour() == *wxGREEN );
|
||||
#endif // __WXMSW__/!__WXMSW__
|
||||
|
||||
m_hyperlink->SetNormalColour(*wxRED);
|
||||
CHECK( m_hyperlink->GetNormalColour() == *wxRED );
|
||||
|
||||
m_hyperlink->SetVisitedColour(*wxBLUE);
|
||||
CHECK( m_hyperlink->GetVisitedColour() == *wxBLUE );
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(HyperlinkCtrlTestCase, "wxHyperlinkCtrl::Url",
|
||||
"[hyperlinkctrl]")
|
||||
{
|
||||
CHECK( m_hyperlink->GetURL() == "http://wxwidgets.org" );
|
||||
|
||||
m_hyperlink->SetURL("http://google.com");
|
||||
|
||||
CHECK( m_hyperlink->GetURL() == "http://google.com" );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(HyperlinkCtrlTestCase, "wxHyperlinkCtrl::Click",
|
||||
"[hyperlinkctrl]")
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter hyperlink(m_hyperlink, wxEVT_HYPERLINK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
sim.MouseMove(m_hyperlink->GetScreenPosition() + wxPoint(10, 10));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CHECK( hyperlink.GetCount() == 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //wxUSE_HYPERLINKCTRL
|
||||
43
libs/wxWidgets-3.3.1/tests/controls/infobar.cpp
Normal file
43
libs/wxWidgets-3.3.1/tests/controls/infobar.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/infobar.cpp
|
||||
// Purpose: wxInfoBar tests
|
||||
// Author: Blake Madden
|
||||
// Created: 2025-6-02
|
||||
// Copyright: (c) 2025 Blake Madden
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_INFOBAR
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/infobar.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
TEST_CASE("wxInfoBar::Buttons", "[wxInfoBar]")
|
||||
{
|
||||
const std::unique_ptr<wxInfoBar>
|
||||
info(new wxInfoBar(wxTheApp->GetTopWindow(), wxID_ANY, wxINFOBAR_CHECKBOX));
|
||||
|
||||
CHECK(info->GetButtonCount() == 0);
|
||||
|
||||
const int buttonId = wxID_HIGHEST + 1000;
|
||||
info->AddButton(buttonId, "test");
|
||||
|
||||
CHECK(info->GetButtonCount() == 1);
|
||||
CHECK(info->GetButtonId(0) == buttonId);
|
||||
CHECK(info->HasButtonId(buttonId));
|
||||
|
||||
info->RemoveButton(buttonId);
|
||||
CHECK(info->GetButtonCount() == 0);
|
||||
}
|
||||
|
||||
#endif // wxUSE_INFOBAR
|
||||
360
libs/wxWidgets-3.3.1/tests/controls/itemcontainertest.cpp
Normal file
360
libs/wxWidgets-3.3.1/tests/controls/itemcontainertest.cpp
Normal file
@@ -0,0 +1,360 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/itemcontainertest.cpp
|
||||
// Purpose: wxItemContainer unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-06-29
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/ctrlsub.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/scopeguard.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
#include "itemcontainertest.h"
|
||||
|
||||
void ItemContainerTestCase::Append()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
container->Append("item 0");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 0", container->GetString(0));
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
container->Append(testitems);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", container->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", container->GetString(2));
|
||||
|
||||
wxString arritems[] = { "item 3", "item 4" };
|
||||
|
||||
container->Append(2, arritems);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 3", container->GetString(3));
|
||||
CPPUNIT_ASSERT_EQUAL("item 4", container->GetString(4));
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::Insert()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, container->Insert("item 0", 0) );
|
||||
CPPUNIT_ASSERT_EQUAL("item 0", container->GetString(0));
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 1, container->Insert(testitems, 0) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", container->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", container->GetString(1));
|
||||
|
||||
wxString arritems[] = { "item 3", "item 4" };
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 2, container->Insert(2, arritems, 1) );
|
||||
CPPUNIT_ASSERT_EQUAL("item 3", container->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("item 4", container->GetString(2));
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::Count()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
CPPUNIT_ASSERT(container->IsEmpty());
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( container->GetString(0) );
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
testitems.Add("item 3");
|
||||
|
||||
container->Append(testitems);
|
||||
|
||||
CPPUNIT_ASSERT(!container->IsEmpty());
|
||||
CPPUNIT_ASSERT_EQUAL(4, container->GetCount());
|
||||
|
||||
container->Delete(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(3, container->GetCount());
|
||||
|
||||
container->Delete(0);
|
||||
container->Delete(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, container->GetCount());
|
||||
|
||||
container->Insert(testitems, 1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(5, container->GetCount());
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( container->GetString(10) );
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::ItemSelection()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
testitems.Add("ITEM 2"); // The same as the last one except for case.
|
||||
|
||||
container->Append(testitems);
|
||||
|
||||
container->SetSelection(wxNOT_FOUND);
|
||||
CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("", container->GetStringSelection());
|
||||
|
||||
container->SetSelection(1);
|
||||
CPPUNIT_ASSERT_EQUAL(1, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", container->GetStringSelection());
|
||||
|
||||
CPPUNIT_ASSERT( container->SetStringSelection("item 2") );
|
||||
CPPUNIT_ASSERT_EQUAL(2, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection());
|
||||
|
||||
// Check that selecting a non-existent item fails.
|
||||
CPPUNIT_ASSERT( !container->SetStringSelection("bloordyblop") );
|
||||
|
||||
// Check that SetStringSelection() is case-insensitive.
|
||||
CPPUNIT_ASSERT( container->SetStringSelection("ITEM 2") );
|
||||
CPPUNIT_ASSERT_EQUAL(2, container->GetSelection());
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection());
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::FindString()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
testitems.Add("item 3");
|
||||
|
||||
container->Append(testitems);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, container->FindString("item 1"));
|
||||
CPPUNIT_ASSERT_EQUAL(1, container->FindString("ITEM 1"));
|
||||
CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, container->FindString("ITEM 1", true));
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::ClientData()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
wxStringClientData* item0data = new wxStringClientData("item0data");
|
||||
wxStringClientData* item1data = new wxStringClientData("item1data");
|
||||
wxStringClientData* item2data = new wxStringClientData("item2data");
|
||||
|
||||
container->Append("item 0", item0data);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<wxClientData*>(item0data),
|
||||
container->GetClientObject(0));
|
||||
|
||||
container->Append("item 1");
|
||||
container->SetClientObject(1, item1data);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<wxClientData*>(item1data),
|
||||
container->GetClientObject(1));
|
||||
|
||||
container->Insert("item 2", 2, item2data);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<wxClientData*>(item2data),
|
||||
container->GetClientObject(2));
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientObject((unsigned)-1, item0data) );
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientObject(12345, item0data) );
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::VoidData()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
wxString item0data("item0data"), item1data("item0data"),
|
||||
item2data("item0data");
|
||||
|
||||
void* item0 = &item0data;
|
||||
void* item1 = &item1data;
|
||||
void* item2 = &item2data;
|
||||
|
||||
container->Append("item 0", item0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(item0, container->GetClientData(0));
|
||||
|
||||
container->Append("item 1");
|
||||
container->SetClientData(1, item1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(item1, container->GetClientData(1));
|
||||
|
||||
container->Insert("item 2", 2, item2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(item2, container->GetClientData(2));
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientData((unsigned)-1, nullptr) );
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientData(12345, nullptr) );
|
||||
|
||||
// wxMSW used to hace problems retrieving the client data of -1 from a few
|
||||
// standard controls, especially if the last error was set before doing it,
|
||||
// so test for this specially.
|
||||
const wxUIntPtr minus1 = static_cast<wxUIntPtr>(-1);
|
||||
container->Append("item -1", wxUIntToPtr(minus1));
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
::SetLastError(ERROR_INVALID_DATA);
|
||||
#endif
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( minus1, wxPtrToUInt(container->GetClientData(3)) );
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::Set()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
|
||||
container->Append(testitems);
|
||||
|
||||
wxArrayString newtestitems;
|
||||
newtestitems.Add("new item 0");
|
||||
newtestitems.Add("new item 1");
|
||||
newtestitems.Add("new item 2");
|
||||
newtestitems.Add("new item 3");
|
||||
|
||||
container->Set(newtestitems);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(4, container->GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL("new item 1", container->GetString(1));
|
||||
|
||||
wxString arrnewitems[] = { "even newer 0", "event newer 1" };
|
||||
|
||||
container->Set(2, arrnewitems);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, container->GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL("even newer 0", container->GetString(0));
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::SetString()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
testitems.Add("item 3");
|
||||
|
||||
container->Append(testitems);
|
||||
|
||||
container->SetSelection(0);
|
||||
container->SetString(0, "new item 0");
|
||||
CPPUNIT_ASSERT_EQUAL("new item 0", container->GetString(0));
|
||||
|
||||
// Modifying the item shouldn't deselect it.
|
||||
CPPUNIT_ASSERT_EQUAL(0, container->GetSelection());
|
||||
|
||||
// wxOSX doesn't support having empty items in some containers.
|
||||
#ifndef __WXOSX__
|
||||
container->SetString(2, "");
|
||||
CPPUNIT_ASSERT_EQUAL("", container->GetString(2));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::SelectionAfterDelete()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
container->Append("item 0");
|
||||
container->Append("item 1");
|
||||
container->Append("item 2");
|
||||
container->Append("item 3");
|
||||
|
||||
container->SetSelection(1);
|
||||
CHECK( container->GetSelection() == 1 );
|
||||
|
||||
container->Delete(3);
|
||||
CHECK( container->GetSelection() == 1 );
|
||||
|
||||
container->Delete(1);
|
||||
CHECK( container->GetSelection() == wxNOT_FOUND );
|
||||
|
||||
container->SetSelection(1);
|
||||
container->Delete(1);
|
||||
CHECK( container->GetSelection() == wxNOT_FOUND );
|
||||
|
||||
container->SetSelection(0);
|
||||
container->Delete(0);
|
||||
CHECK( container->GetSelection() == wxNOT_FOUND );
|
||||
}
|
||||
|
||||
void ItemContainerTestCase::SetSelection()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
container->Append("first");
|
||||
container->Append("second");
|
||||
|
||||
// This class is used to check that SetSelection() doesn't generate any
|
||||
// events, as documented.
|
||||
class CommandEventHandler : public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
virtual bool ProcessEvent(wxEvent& event) override
|
||||
{
|
||||
CPPUNIT_ASSERT_MESSAGE
|
||||
(
|
||||
"unexpected command event from SetSelection",
|
||||
!event.IsCommandEvent()
|
||||
);
|
||||
|
||||
return wxEvtHandler::ProcessEvent(event);
|
||||
}
|
||||
} h;
|
||||
|
||||
wxWindow * const win = GetContainerWindow();
|
||||
win->PushEventHandler(&h);
|
||||
wxON_BLOCK_EXIT_OBJ1( *win, wxWindow::PopEventHandler, false );
|
||||
|
||||
container->SetSelection(0);
|
||||
CPPUNIT_ASSERT_EQUAL( 0, container->GetSelection() );
|
||||
|
||||
container->SetSelection(1);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, container->GetSelection() );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
void ItemContainerTestCase::SimSelect()
|
||||
{
|
||||
wxItemContainer * const container = GetContainer();
|
||||
|
||||
container->Append("first");
|
||||
container->Append("second");
|
||||
container->Append("third");
|
||||
|
||||
GetContainerWindow()->SetFocus();
|
||||
wxYield();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
CPPUNIT_ASSERT( sim.Select("third") );
|
||||
CPPUNIT_ASSERT_EQUAL( 2, container->GetSelection() );
|
||||
|
||||
CPPUNIT_ASSERT( sim.Select("first") );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, container->GetSelection() );
|
||||
|
||||
CPPUNIT_ASSERT( !sim.Select("tenth") );
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
65
libs/wxWidgets-3.3.1/tests/controls/itemcontainertest.h
Normal file
65
libs/wxWidgets-3.3.1/tests/controls/itemcontainertest.h
Normal file
@@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/itemcontainertest.h
|
||||
// Purpose: wxItemContainer unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-06-29
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_CONTROLS_ITEMCONTAINERTEST_H_
|
||||
#define _WX_TESTS_CONTROLS_ITEMCONTAINERTEST_H_
|
||||
|
||||
class ItemContainerTestCase
|
||||
{
|
||||
public:
|
||||
ItemContainerTestCase() { }
|
||||
virtual ~ItemContainerTestCase() { }
|
||||
|
||||
protected:
|
||||
// this function must be overridden by the derived classes to return the
|
||||
// text entry object we're testing, typically this is done by creating a
|
||||
// control implementing wxItemContainer interface in setUp() virtual method and
|
||||
// just returning it from here
|
||||
virtual wxItemContainer *GetContainer() const = 0;
|
||||
|
||||
// and this one must be overridden to return the window which implements
|
||||
// wxItemContainer interface -- usually it will return the same pointer as
|
||||
// GetContainer(), just as a different type
|
||||
virtual wxWindow *GetContainerWindow() const = 0;
|
||||
|
||||
// this should be inserted in the derived class CPPUNIT_TEST_SUITE
|
||||
// definition to run all wxItemContainer tests as part of it
|
||||
#define wxITEM_CONTAINER_TESTS() \
|
||||
CPPUNIT_TEST( Append ); \
|
||||
CPPUNIT_TEST( Insert ); \
|
||||
CPPUNIT_TEST( Count ); \
|
||||
CPPUNIT_TEST( ItemSelection ); \
|
||||
CPPUNIT_TEST( FindString ); \
|
||||
CPPUNIT_TEST( ClientData ); \
|
||||
CPPUNIT_TEST( VoidData ); \
|
||||
CPPUNIT_TEST( Set ); \
|
||||
CPPUNIT_TEST( SetSelection ); \
|
||||
CPPUNIT_TEST( SetString ); \
|
||||
CPPUNIT_TEST( SelectionAfterDelete ); \
|
||||
WXUISIM_TEST( SimSelect );
|
||||
|
||||
void Append();
|
||||
void Insert();
|
||||
void Count();
|
||||
void ItemSelection();
|
||||
void FindString();
|
||||
void ClientData();
|
||||
void VoidData();
|
||||
void Set();
|
||||
void SetSelection();
|
||||
void SetString();
|
||||
void SelectionAfterDelete();
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
virtual void SimSelect();
|
||||
#endif
|
||||
|
||||
private:
|
||||
wxDECLARE_NO_COPY_CLASS(ItemContainerTestCase);
|
||||
};
|
||||
|
||||
#endif // _WX_TESTS_CONTROLS_ITEMCONTAINERTEST_H_
|
||||
149
libs/wxWidgets-3.3.1/tests/controls/label.cpp
Normal file
149
libs/wxWidgets-3.3.1/tests/controls/label.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/label.cpp
|
||||
// Purpose: wxControl and wxStaticText label tests
|
||||
// Author: Francesco Montorsi
|
||||
// Created: 2010-3-21
|
||||
// Copyright: (c) 2010 Francesco Montorsi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/stattext.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
#include "wx/generic/stattextg.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
const char* const ORIGINAL_LABEL = "origin label";
|
||||
|
||||
// The actual testing function. It will change the label of the provided
|
||||
// control, which is assumed to be ORIGINAL_LABEL initially.
|
||||
void DoTestLabel(wxControl* c)
|
||||
{
|
||||
CHECK( c->GetLabel() == ORIGINAL_LABEL );
|
||||
|
||||
const wxString testLabelArray[] = {
|
||||
"label without mnemonics and markup",
|
||||
"label with &mnemonic",
|
||||
"label with <span foreground='blue'>some</span> <b>markup</b>",
|
||||
"label with <span foreground='blue'>some</span> <b>markup</b> and &mnemonic",
|
||||
"label with an && (ampersand)",
|
||||
"label with an && (&ersand)",
|
||||
"", // empty label should work too
|
||||
};
|
||||
|
||||
for ( unsigned int s = 0; s < WXSIZEOF(testLabelArray); s++ )
|
||||
{
|
||||
const wxString& l = testLabelArray[s];
|
||||
|
||||
// GetLabel() should always return the string passed to SetLabel()
|
||||
c->SetLabel(l);
|
||||
CHECK( c->GetLabel() == l );
|
||||
|
||||
// GetLabelText() should always return unescaped version of the label
|
||||
CHECK( c->GetLabelText() == wxControl::RemoveMnemonics(l) );
|
||||
|
||||
// GetLabelText() should always return the string passed to SetLabelText()
|
||||
c->SetLabelText(l);
|
||||
CHECK( c->GetLabelText() == l );
|
||||
|
||||
// And GetLabel() should be the escaped version of the text
|
||||
CHECK( l == wxControl::RemoveMnemonics(c->GetLabel()) );
|
||||
}
|
||||
|
||||
// Check that both "&" and "&" work in markup.
|
||||
#if wxUSE_MARKUP
|
||||
c->SetLabelMarkup("mnemonic in &markup");
|
||||
CHECK( c->GetLabel() == "mnemonic in &markup" );
|
||||
CHECK( c->GetLabelText() == "mnemonic in markup" );
|
||||
|
||||
c->SetLabelMarkup("mnemonic in &markup");
|
||||
CHECK( c->GetLabel() == "mnemonic in &markup" );
|
||||
CHECK( c->GetLabelText() == "mnemonic in markup" );
|
||||
|
||||
c->SetLabelMarkup("&& finally");
|
||||
CHECK( c->GetLabel() == "&& finally" );
|
||||
CHECK( c->GetLabelText() == "& finally" );
|
||||
|
||||
c->SetLabelMarkup("&& finally");
|
||||
CHECK( c->GetLabel() == "&& finally" );
|
||||
CHECK( c->GetLabelText() == "& finally" );
|
||||
#endif // wxUSE_MARKUP
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_CASE("wxControl::Label", "[wxControl][label]")
|
||||
{
|
||||
SECTION("wxStaticText")
|
||||
{
|
||||
const std::unique_ptr<wxStaticText>
|
||||
st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
|
||||
DoTestLabel(st.get());
|
||||
}
|
||||
|
||||
SECTION("wxStaticText/ellipsized")
|
||||
{
|
||||
const std::unique_ptr<wxStaticText>
|
||||
st(new wxStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxST_ELLIPSIZE_START));
|
||||
DoTestLabel(st.get());
|
||||
}
|
||||
|
||||
SECTION("wxGenericStaticText")
|
||||
{
|
||||
const std::unique_ptr<wxGenericStaticText>
|
||||
gst(new wxGenericStaticText(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
|
||||
DoTestLabel(gst.get());
|
||||
}
|
||||
|
||||
SECTION("wxCheckBox")
|
||||
{
|
||||
const std::unique_ptr<wxCheckBox>
|
||||
cb(new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
|
||||
DoTestLabel(cb.get());
|
||||
}
|
||||
|
||||
SECTION("wxTextCtrl")
|
||||
{
|
||||
const std::unique_ptr<wxTextCtrl>
|
||||
tc(new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, ORIGINAL_LABEL));
|
||||
|
||||
// Setting the label of a wxTextCtrl should _not_ work, it has value
|
||||
// and not a label.
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( tc->SetLabel("something else") );
|
||||
CHECK( tc->GetValue() == ORIGINAL_LABEL );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("wxControl::RemoveMnemonics", "[wxControl][label][mnemonics]")
|
||||
{
|
||||
CHECK( "mnemonic" == wxControl::RemoveMnemonics("&mnemonic") );
|
||||
CHECK( "&mnemonic" == wxControl::RemoveMnemonics("&&mnemonic") );
|
||||
CHECK( "&mnemonic" == wxControl::RemoveMnemonics("&&&mnemonic") );
|
||||
}
|
||||
|
||||
TEST_CASE("wxControl::FindAccelIndex", "[wxControl][label][mnemonics]")
|
||||
{
|
||||
CHECK( wxControl::FindAccelIndex("foo") == wxNOT_FOUND );
|
||||
CHECK( wxControl::FindAccelIndex("&foo") == 0 );
|
||||
CHECK( wxControl::FindAccelIndex("f&oo") == 1 );
|
||||
CHECK( wxControl::FindAccelIndex("foo && bar") == wxNOT_FOUND );
|
||||
CHECK( wxControl::FindAccelIndex("foo && &bar") == 6 );
|
||||
}
|
||||
671
libs/wxWidgets-3.3.1/tests/controls/listbasetest.cpp
Normal file
671
libs/wxWidgets-3.3.1/tests/controls/listbasetest.cpp
Normal file
@@ -0,0 +1,671 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/listbasetest.cpp
|
||||
// Purpose: Common wxListCtrl and wxListView tests
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-20
|
||||
// Copyright: (c) 2008,2025 Vadim Zeitlin <vadim@wxwidgets.org>,
|
||||
// (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_LISTCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "listbasetest.h"
|
||||
#include "testableframe.h"
|
||||
#include "asserthelper.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/artprov.h"
|
||||
#include "wx/stopwatch.h"
|
||||
|
||||
void ListBaseTestCase::ColumnsOrder()
|
||||
{
|
||||
#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
int n;
|
||||
wxListItem li;
|
||||
li.SetMask(wxLIST_MASK_TEXT);
|
||||
|
||||
// first set up some columns
|
||||
static const int NUM_COLS = 3;
|
||||
|
||||
list->InsertColumn(0, "Column 0");
|
||||
list->InsertColumn(1, "Column 1");
|
||||
list->InsertColumn(2, "Column 2");
|
||||
|
||||
// and a couple of test items too
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->SetItem(0, 1, "first in first");
|
||||
|
||||
list->InsertItem(1, "Item 1");
|
||||
list->SetItem(1, 2, "second in second");
|
||||
|
||||
|
||||
// check that the order is natural in the beginning
|
||||
const wxArrayInt orderOrig = list->GetColumnsOrder();
|
||||
for ( n = 0; n < NUM_COLS; n++ )
|
||||
CHECK( orderOrig[n] == n );
|
||||
|
||||
// then rearrange them: using { 2, 0, 1 } order means that column 2 is
|
||||
// shown first, then column 0 and finally column 1
|
||||
wxArrayInt order(3);
|
||||
order[0] = 2;
|
||||
order[1] = 0;
|
||||
order[2] = 1;
|
||||
list->SetColumnsOrder(order);
|
||||
|
||||
// check that we get back the same order as we set
|
||||
const wxArrayInt orderNew = list->GetColumnsOrder();
|
||||
for ( n = 0; n < NUM_COLS; n++ )
|
||||
CHECK( orderNew[n] == order[n] );
|
||||
|
||||
// and the order -> index mappings for individual columns
|
||||
for ( n = 0; n < NUM_COLS; n++ )
|
||||
CHECK( list->GetColumnIndexFromOrder(n) == order[n] );
|
||||
|
||||
// and also the reverse mapping
|
||||
CHECK( list->GetColumnOrder(0) == 1 );
|
||||
CHECK( list->GetColumnOrder(1) == 2 );
|
||||
CHECK( list->GetColumnOrder(2) == 0 );
|
||||
|
||||
|
||||
// finally check that accessors still use indices, not order
|
||||
CHECK( list->GetColumn(0, li) );
|
||||
CHECK( li.GetText() == "Column 0" );
|
||||
|
||||
li.SetId(0);
|
||||
li.SetColumn(1);
|
||||
CHECK( list->GetItem(li) );
|
||||
CHECK( li.GetText() == "first in first" );
|
||||
|
||||
li.SetId(1);
|
||||
li.SetColumn(2);
|
||||
CHECK( list->GetItem(li) );
|
||||
CHECK( li.GetText() == "second in second" );
|
||||
#endif // wxHAS_LISTCTRL_COLUMN_ORDER
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ListBaseTestCase::ItemRect()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
// set up for the test
|
||||
list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50);
|
||||
list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40);
|
||||
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->SetItem(0, 1, "first column");
|
||||
list->SetItem(0, 1, "second column");
|
||||
|
||||
// do test
|
||||
wxRect r;
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( list->GetItemRect(1, r) );
|
||||
CHECK( list->GetItemRect(0, r) );
|
||||
CHECK( r.GetWidth() == 150 );
|
||||
|
||||
CHECK( list->GetSubItemRect(0, 0, r) );
|
||||
CHECK( r.GetWidth() == 60 );
|
||||
|
||||
CHECK( list->GetSubItemRect(0, 1, r) );
|
||||
CHECK( r.GetWidth() == 50 );
|
||||
|
||||
CHECK( list->GetSubItemRect(0, 2, r) );
|
||||
CHECK( r.GetWidth() == 40 );
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( list->GetSubItemRect(0, 3, r) );
|
||||
|
||||
|
||||
// As we have a header, the top item shouldn't be at (0, 0), but somewhere
|
||||
// below the header.
|
||||
//
|
||||
// Notice that we consider that the header can't be less than 10 pixels
|
||||
// because we don't know its exact height.
|
||||
CHECK( list->GetItemRect(0, r) );
|
||||
CHECK( r.y >= 10 );
|
||||
|
||||
// However if we remove the header now, the item should be at (0, 0).
|
||||
list->SetWindowStyle(wxLC_REPORT | wxLC_NO_HEADER);
|
||||
CHECK( list->GetItemRect(0, r) );
|
||||
CHECK( r.y == 0 );
|
||||
}
|
||||
|
||||
void ListBaseTestCase::ItemText()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->InsertColumn(0, "First");
|
||||
list->InsertColumn(1, "Second");
|
||||
|
||||
list->InsertItem(0, "0,0");
|
||||
CHECK( list->GetItemText(0) == "0,0" );
|
||||
CHECK( list->GetItemText(0, 1) == "" );
|
||||
|
||||
list->SetItem(0, 1, "0,1");
|
||||
CHECK( list->GetItemText(0, 1) == "0,1" );
|
||||
}
|
||||
|
||||
void ListBaseTestCase::ChangeMode()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->InsertColumn(0, "Header");
|
||||
list->InsertItem(0, "First");
|
||||
list->InsertItem(1, "Second");
|
||||
CHECK( list->GetItemCount() == 2 );
|
||||
|
||||
// check that switching the mode preserves the items
|
||||
list->SetWindowStyle(wxLC_ICON);
|
||||
CHECK( list->GetItemCount() == 2 );
|
||||
CHECK( list->GetItemText(0) == "First" );
|
||||
|
||||
// and so does switching back
|
||||
list->SetWindowStyle(wxLC_REPORT);
|
||||
CHECK( list->GetItemCount() == 2 );
|
||||
CHECK( list->GetItemText(0) == "First" );
|
||||
}
|
||||
|
||||
void ListBaseTestCase::MultiSelect()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
#if defined(__WXGTK__) && !defined(__WXGTK3__)
|
||||
// FIXME: This test fails on GitHub CI under wxGTK2 although works fine on
|
||||
// development machine, no idea why though!
|
||||
if ( IsAutomaticTest() )
|
||||
return;
|
||||
#endif // wxGTK2
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
EventCounter focused(list, wxEVT_LIST_ITEM_FOCUSED);
|
||||
EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED);
|
||||
EventCounter deselected(list, wxEVT_LIST_ITEM_DESELECTED);
|
||||
|
||||
list->InsertColumn(0, "Header");
|
||||
|
||||
for ( int i = 0; i < 10; ++i )
|
||||
list->InsertItem(i, wxString::Format("Item %d", i));
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
list->GetItemRect(2, pos); // Choose the third item as anchor
|
||||
|
||||
// We move in slightly so we are not on the edge
|
||||
wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick(); // select the anchor
|
||||
wxYield();
|
||||
|
||||
list->GetItemRect(5, pos);
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.KeyDown(WXK_SHIFT);
|
||||
sim.MouseClick();
|
||||
sim.KeyUp(WXK_SHIFT);
|
||||
wxYield();
|
||||
|
||||
// when the first item was selected the focus changes to it, but not
|
||||
// on subsequent clicks
|
||||
CHECK( list->GetSelectedItemCount() == 4 ); // item 2 to 5 (inclusive) are selected
|
||||
CHECK( focused.GetCount() == 2 ); // count the focus which was on the anchor
|
||||
CHECK( selected.GetCount() == 4 );
|
||||
CHECK( deselected.GetCount() == 0 );
|
||||
|
||||
focused.Clear();
|
||||
selected.Clear();
|
||||
deselected.Clear();
|
||||
|
||||
sim.Char(WXK_END, wxMOD_SHIFT); // extend the selection to the last item
|
||||
wxYield();
|
||||
|
||||
CHECK( list->GetSelectedItemCount() == 8 ); // item 2 to 9 (inclusive) are selected
|
||||
CHECK( focused.GetCount() == 1 ); // focus is on the last item
|
||||
CHECK( selected.GetCount() == 4); // only newly selected items got the event
|
||||
CHECK( deselected.GetCount() == 0 );
|
||||
|
||||
focused.Clear();
|
||||
selected.Clear();
|
||||
deselected.Clear();
|
||||
|
||||
sim.Char(WXK_HOME, wxMOD_SHIFT); // select from anchor to the first item
|
||||
wxYield();
|
||||
|
||||
CHECK( list->GetSelectedItemCount() == 3 ); // item 0 to 2 (inclusive) are selected
|
||||
CHECK( focused.GetCount() == 1 ); // focus is on item 0
|
||||
CHECK( selected.GetCount() == 2 ); // events are only generated for item 0 and 1
|
||||
CHECK( deselected.GetCount() == 7 ); // item 2 (exclusive) to 9 are deselected
|
||||
|
||||
focused.Clear();
|
||||
selected.Clear();
|
||||
deselected.Clear();
|
||||
|
||||
list->EnsureVisible(0);
|
||||
wxYield();
|
||||
|
||||
list->GetItemRect(2, pos);
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CHECK( list->GetSelectedItemCount() == 1 ); // anchor is the only selected item
|
||||
CHECK( focused.GetCount() == 1 ); // because the focus changed from item 0 to anchor
|
||||
CHECK( selected.GetCount() == 0 ); // anchor is already in selection state
|
||||
CHECK( deselected.GetCount() == 2 ); // items 0 and 1 are deselected
|
||||
|
||||
focused.Clear();
|
||||
selected.Clear();
|
||||
deselected.Clear();
|
||||
|
||||
list->GetItemRect(3, pos);
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
// select and deselect item 3 while leaving item 2 selected
|
||||
for ( int i = 0; i < 2; ++i )
|
||||
{
|
||||
sim.MouseMove(point + wxPoint(i*10, 0));
|
||||
wxYield();
|
||||
|
||||
sim.KeyDown(WXK_CONTROL);
|
||||
sim.MouseClick();
|
||||
sim.KeyUp(WXK_CONTROL);
|
||||
wxYield();
|
||||
}
|
||||
|
||||
// select only item 3
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CHECK( list->GetSelectedItemCount() == 1 ); // item 3 is the only selected item
|
||||
CHECK( focused.GetCount() == 1 ); // because the focus changed from anchor to item 3
|
||||
CHECK( selected.GetCount() == 2 ); // item 3 was selected twice
|
||||
CHECK( deselected.GetCount() == 2 ); // anchor and item 3 were each deselected once
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
}
|
||||
|
||||
void ListBaseTestCase::ItemClick()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// FIXME: This test fails on MSW buildbot slaves although works fine on
|
||||
// development machine, no idea why. It seems to be a problem with
|
||||
// wxUIActionSimulator rather the wxListCtrl control itself however.
|
||||
if ( IsAutomaticTest() )
|
||||
return;
|
||||
#endif // __WXMSW__
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50);
|
||||
list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40);
|
||||
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->SetItem(0, 1, "first column");
|
||||
list->SetItem(0, 2, "second column");
|
||||
|
||||
EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED);
|
||||
EventCounter focused(list, wxEVT_LIST_ITEM_FOCUSED);
|
||||
EventCounter activated(list, wxEVT_LIST_ITEM_ACTIVATED);
|
||||
EventCounter rclick(list, wxEVT_LIST_ITEM_RIGHT_CLICK);
|
||||
EventCounter deselected(list, wxEVT_LIST_ITEM_DESELECTED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
list->GetItemRect(0, pos);
|
||||
|
||||
//We move in slightly so we are not on the edge
|
||||
wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
// We want a point within the listctrl but below any items
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 50);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
// when the first item was selected the focus changes to it, but not
|
||||
// on subsequent clicks
|
||||
CHECK( focused.GetCount() == 1 );
|
||||
CHECK( selected.GetCount() == 1 );
|
||||
CHECK( deselected.GetCount() == 1 );
|
||||
CHECK( activated.GetCount() == 1 );
|
||||
CHECK( rclick.GetCount() == 1 );
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
}
|
||||
|
||||
void ListBaseTestCase::KeyDown()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
EventCounter keydown(list, wxEVT_LIST_KEY_DOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
list->SetFocus();
|
||||
wxYield();
|
||||
sim.Text("aAbB"); // 4 letters + 2 shift mods.
|
||||
wxYield();
|
||||
|
||||
CHECK( keydown.GetCount() == 6 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBaseTestCase::DeleteItems()
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
EventCounter deleteitem(list, wxEVT_LIST_DELETE_ITEM);
|
||||
EventCounter deleteall(list, wxEVT_LIST_DELETE_ALL_ITEMS);
|
||||
|
||||
|
||||
list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50);
|
||||
list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40);
|
||||
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->InsertItem(1, "Item 1");
|
||||
list->InsertItem(2, "Item 1");
|
||||
|
||||
list->DeleteItem(0);
|
||||
list->DeleteItem(0);
|
||||
list->DeleteAllItems();
|
||||
|
||||
//Add some new items to tests ClearAll with
|
||||
list->InsertColumn(0, "Column 0");
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->InsertItem(1, "Item 1");
|
||||
|
||||
//Check that ClearAll actually sends a DELETE_ALL_ITEMS event
|
||||
list->ClearAll();
|
||||
|
||||
//ClearAll and DeleteAllItems shouldn't send an event if there was nothing
|
||||
//to clear
|
||||
list->ClearAll();
|
||||
list->DeleteAllItems();
|
||||
|
||||
CHECK( deleteitem.GetCount() == 2 );
|
||||
CHECK( deleteall.GetCount() == 2 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBaseTestCase::InsertItem()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
EventCounter insert(list, wxEVT_LIST_INSERT_ITEM);
|
||||
|
||||
list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
|
||||
wxListItem item;
|
||||
item.SetId(0);
|
||||
item.SetText("some text");
|
||||
|
||||
list->InsertItem(item);
|
||||
list->InsertItem(1, "more text");
|
||||
|
||||
CHECK( insert.GetCount() == 2 );
|
||||
}
|
||||
|
||||
void ListBaseTestCase::Find()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
// set up for the test
|
||||
list->InsertColumn(0, "Column 0");
|
||||
list->InsertColumn(1, "Column 1");
|
||||
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->SetItem(0, 1, "first column");
|
||||
|
||||
list->InsertItem(1, "Item 1");
|
||||
list->SetItem(1, 1, "first column");
|
||||
|
||||
list->InsertItem(2, "Item 40");
|
||||
list->SetItem(2, 1, "first column");
|
||||
|
||||
list->InsertItem(3, "ITEM 01");
|
||||
list->SetItem(3, 1, "first column");
|
||||
|
||||
CHECK( list->FindItem(-1, "Item 1") == 1 );
|
||||
CHECK( list->FindItem(-1, "Item 4", true) == 2 );
|
||||
CHECK( list->FindItem(1, "Item 40") == 2 );
|
||||
CHECK( list->FindItem(2, "Item 0", true) == 3 );
|
||||
}
|
||||
|
||||
void ListBaseTestCase::Visible()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->InsertColumn(0, "Column 0");
|
||||
list->InsertItem(0, wxString::Format("string 0"));
|
||||
|
||||
int count = list->GetCountPerPage();
|
||||
|
||||
for( int i = 1; i < count + 10; i++ )
|
||||
{
|
||||
list->InsertItem(i, wxString::Format("string %d", i));
|
||||
}
|
||||
|
||||
CHECK( list->GetItemCount() == count + 10 );
|
||||
CHECK( list->GetTopItem() == 0 );
|
||||
CHECK(list->IsVisible(0));
|
||||
CHECK(!list->IsVisible(count + 1));
|
||||
|
||||
CHECK(list->EnsureVisible(count + 9));
|
||||
CHECK(list->IsVisible(count + 9));
|
||||
CHECK(!list->IsVisible(9));
|
||||
|
||||
CHECK(list->GetTopItem() != 0);
|
||||
}
|
||||
|
||||
void ListBaseTestCase::ItemFormatting()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->InsertColumn(0, "Column 0");
|
||||
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->InsertItem(1, "Item 1");
|
||||
list->InsertItem(2, "Item 2");
|
||||
|
||||
list->SetTextColour(*wxYELLOW);
|
||||
list->SetBackgroundColour(*wxGREEN);
|
||||
list->SetItemTextColour(0, *wxRED);
|
||||
list->SetItemBackgroundColour(1, *wxBLUE);
|
||||
|
||||
CHECK( list->GetBackgroundColour() == *wxGREEN );
|
||||
CHECK( list->GetItemBackgroundColour(1) == *wxBLUE );
|
||||
|
||||
CHECK( list->GetTextColour() == *wxYELLOW );
|
||||
CHECK( list->GetItemTextColour(0) == *wxRED );
|
||||
}
|
||||
|
||||
void ListBaseTestCase::EditLabel()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->SetWindowStyleFlag(wxLC_REPORT | wxLC_EDIT_LABELS);
|
||||
|
||||
list->InsertColumn(0, "Column 0");
|
||||
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->InsertItem(1, "Item 1");
|
||||
|
||||
EventCounter beginedit(list, wxEVT_LIST_BEGIN_LABEL_EDIT);
|
||||
EventCounter endedit(list, wxEVT_LIST_END_LABEL_EDIT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
list->EditLabel(0);
|
||||
wxYield();
|
||||
|
||||
sim.Text("sometext");
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_RETURN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK( beginedit.GetCount() == 1 );
|
||||
CHECK( endedit.GetCount() == 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBaseTestCase::ImageList()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
wxSize size(32, 32);
|
||||
|
||||
wxImageList* imglist = new wxImageList(size.x, size.y);
|
||||
imglist->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size));
|
||||
imglist->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size));
|
||||
imglist->Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size));
|
||||
|
||||
list->AssignImageList(imglist, wxIMAGE_LIST_NORMAL);
|
||||
|
||||
CHECK( list->GetImageList(wxIMAGE_LIST_NORMAL) == imglist );
|
||||
}
|
||||
|
||||
void ListBaseTestCase::HitTest()
|
||||
{
|
||||
#ifdef __WXMSW__ // ..until proven to work with other platforms
|
||||
wxListCtrl* const list = GetList();
|
||||
list->SetWindowStyle(wxLC_REPORT);
|
||||
|
||||
// set small image list
|
||||
wxSize size(16, 16);
|
||||
wxImageList* m_imglistSmall = new wxImageList(size.x, size.y);
|
||||
m_imglistSmall->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_LIST, size));
|
||||
list->AssignImageList(m_imglistSmall, wxIMAGE_LIST_SMALL);
|
||||
|
||||
// insert 2 columns
|
||||
list->InsertColumn(0, "Column 0");
|
||||
list->InsertColumn(1, "Column 1");
|
||||
|
||||
// and a couple of test items too
|
||||
list->InsertItem(0, "Item 0", 0);
|
||||
list->SetItem(0, 1, "0, 1");
|
||||
|
||||
list->InsertItem(1, "Item 1", 0);
|
||||
|
||||
// enable checkboxes to test state icon
|
||||
list->EnableCheckBoxes();
|
||||
|
||||
// get coordinates
|
||||
wxRect rectSubItem0, rectIcon;
|
||||
list->GetSubItemRect(0, 0, rectSubItem0); // column 0
|
||||
list->GetItemRect(0, rectIcon, wxLIST_RECT_ICON); // icon
|
||||
int y = rectSubItem0.GetTop() + (rectSubItem0.GetBottom() -
|
||||
rectSubItem0.GetTop()) / 2;
|
||||
int flags = 0;
|
||||
|
||||
// state icon (checkbox)
|
||||
int xCheckBox = rectSubItem0.GetLeft() + (rectIcon.GetLeft() -
|
||||
rectSubItem0.GetLeft()) / 2;
|
||||
list->HitTest(wxPoint(xCheckBox, y), flags);
|
||||
CHECK( flags == wxLIST_HITTEST_ONITEMSTATEICON );
|
||||
|
||||
// icon
|
||||
int xIcon = rectIcon.GetLeft() + (rectIcon.GetRight() - rectIcon.GetLeft()) / 2;
|
||||
list->HitTest(wxPoint(xIcon, y), flags);
|
||||
CHECK( flags == wxLIST_HITTEST_ONITEMICON );
|
||||
|
||||
// label, beyond column 0
|
||||
wxRect rectItem;
|
||||
list->GetItemRect(0, rectItem); // entire item
|
||||
int xHit = rectSubItem0.GetRight() + (rectItem.GetRight() - rectSubItem0.GetRight()) / 2;
|
||||
list->HitTest(wxPoint(xHit, y), flags);
|
||||
CHECK( flags == wxLIST_HITTEST_ONITEMLABEL );
|
||||
#endif // __WXMSW__
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//From the sample but fixed so it actually inverts
|
||||
int wxCALLBACK
|
||||
MyCompareFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr WXUNUSED(sortData))
|
||||
{
|
||||
// inverse the order
|
||||
if (item1 < item2)
|
||||
return 1;
|
||||
if (item1 > item2)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ListBaseTestCase::Sort()
|
||||
{
|
||||
wxListCtrl* const list = GetList();
|
||||
|
||||
list->InsertColumn(0, "Column 0");
|
||||
|
||||
list->InsertItem(0, "Item 0");
|
||||
list->SetItemData(0, 0);
|
||||
list->InsertItem(1, "Item 1");
|
||||
list->SetItemData(1, 1);
|
||||
|
||||
list->SortItems(MyCompareFunction, 0);
|
||||
|
||||
CHECK( list->GetItemText(0) == "Item 1" );
|
||||
CHECK( list->GetItemText(1) == "Item 0" );
|
||||
}
|
||||
|
||||
#endif //wxUSE_LISTCTRL
|
||||
74
libs/wxWidgets-3.3.1/tests/controls/listbasetest.h
Normal file
74
libs/wxWidgets-3.3.1/tests/controls/listbasetest.h
Normal file
@@ -0,0 +1,74 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/listbasetest.cpp
|
||||
// Purpose: Common wxListCtrl and wxListView tests
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-20
|
||||
// Copyright: (c) 2008,2025 Vadim Zeitlin <vadim@wxwidgets.org>,
|
||||
// (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_CONTROLS_LISTBASETEST_H_
|
||||
#define _WX_TESTS_CONTROLS_LISTBASETEST_H_
|
||||
|
||||
class ListBaseTestCase
|
||||
{
|
||||
public:
|
||||
ListBaseTestCase() { }
|
||||
virtual ~ListBaseTestCase() { }
|
||||
|
||||
protected:
|
||||
virtual wxListCtrl *GetList() const = 0;
|
||||
|
||||
void ColumnsOrder();
|
||||
void ItemRect();
|
||||
void ItemText();
|
||||
void ChangeMode();
|
||||
void MultiSelect();
|
||||
void ItemClick();
|
||||
void KeyDown();
|
||||
void DeleteItems();
|
||||
void InsertItem();
|
||||
void Find();
|
||||
void Visible();
|
||||
void ItemFormatting();
|
||||
void EditLabel();
|
||||
void ImageList();
|
||||
void HitTest();
|
||||
void Sort();
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ListBaseTestCase);
|
||||
};
|
||||
|
||||
// In the macros below, ClassName is the name of the class (without "wx"
|
||||
// prefix), i.e. an identifier, and ClassTag is the string containing the
|
||||
// tag to be used in the test registration macro.
|
||||
|
||||
// Define a test case delegating to ListBaseTestCase.
|
||||
#define wxLIST_TEST_CASE(ClassName, ClassTag, TestName) \
|
||||
TEST_CASE_METHOD(ClassName ## TestCase, \
|
||||
#ClassName "::" #TestName, \
|
||||
ClassTag) \
|
||||
{ \
|
||||
TestName(); \
|
||||
}
|
||||
|
||||
// Define all common test cases.
|
||||
#define wxLIST_BASE_TESTS(ClassName, TagName) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, ColumnsOrder) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, ItemRect) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, ItemText) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, ChangeMode) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, ItemClick) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, KeyDown) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, MultiSelect) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, DeleteItems) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, InsertItem) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, Find) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, Visible) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, ItemFormatting) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, EditLabel) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, ImageList) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, HitTest) \
|
||||
wxLIST_TEST_CASE(ClassName, TagName, Sort)
|
||||
|
||||
#endif
|
||||
81
libs/wxWidgets-3.3.1/tests/controls/listbooktest.cpp
Normal file
81
libs/wxWidgets-3.3.1/tests/controls/listbooktest.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/listbooktest.cpp
|
||||
// Purpose: wxListbook unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-02
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_LISTBOOK
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/panel.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/listbook.h"
|
||||
#include "wx/listctrl.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
class ListbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ListbookTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_listbook; }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_LISTBOOK_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_LISTBOOK_PAGE_CHANGING; }
|
||||
|
||||
virtual bool HasBrokenMnemonics() const override { return true; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( ListbookTestCase );
|
||||
wxBOOK_CTRL_BASE_TESTS();
|
||||
CPPUNIT_TEST( ListView );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void ListView();
|
||||
|
||||
wxListbook *m_listbook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ListbookTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ListbookTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ListbookTestCase, "ListbookTestCase" );
|
||||
|
||||
void ListbookTestCase::setUp()
|
||||
{
|
||||
m_listbook = new wxListbook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 300));
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
void ListbookTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_listbook);
|
||||
}
|
||||
|
||||
void ListbookTestCase::ListView()
|
||||
{
|
||||
wxListView* listview = m_listbook->GetListView();
|
||||
|
||||
CPPUNIT_ASSERT(listview);
|
||||
CPPUNIT_ASSERT_EQUAL(3, listview->GetItemCount());
|
||||
CPPUNIT_ASSERT_EQUAL("Panel 1", listview->GetItemText(0));
|
||||
}
|
||||
|
||||
#endif //wxUSE_LISTBOOK
|
||||
292
libs/wxWidgets-3.3.1/tests/controls/listboxtest.cpp
Normal file
292
libs/wxWidgets-3.3.1/tests/controls/listboxtest.cpp
Normal file
@@ -0,0 +1,292 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/listbox.cpp
|
||||
// Purpose: wxListBox unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-06-29
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_LISTBOX
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/listbox.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
class ListBoxTestCase : public ItemContainerTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ListBoxTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_list; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_list; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( ListBoxTestCase );
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST( Sort );
|
||||
CPPUNIT_TEST( MultipleSelect );
|
||||
WXUISIM_TEST( ClickEvents );
|
||||
WXUISIM_TEST( ClickNotOnItem );
|
||||
CPPUNIT_TEST( HitTest );
|
||||
//We also run all tests as an ownerdrawn list box. We do not need to
|
||||
//run the wxITEM_CONTAINER_TESTS as they are tested with wxCheckListBox
|
||||
#ifdef __WXMSW__
|
||||
CPPUNIT_TEST( PseudoTest_OwnerDrawn );
|
||||
CPPUNIT_TEST( Sort );
|
||||
CPPUNIT_TEST( MultipleSelect );
|
||||
WXUISIM_TEST( ClickEvents );
|
||||
WXUISIM_TEST( ClickNotOnItem );
|
||||
CPPUNIT_TEST( HitTest );
|
||||
#endif
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Sort();
|
||||
void MultipleSelect();
|
||||
void ClickEvents();
|
||||
void ClickNotOnItem();
|
||||
void HitTest();
|
||||
void PseudoTest_OwnerDrawn() { ms_ownerdrawn = true; }
|
||||
|
||||
static bool ms_ownerdrawn;
|
||||
|
||||
wxListBox* m_list;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ListBoxTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(ListBoxTestCase,
|
||||
"[ListBoxTestCase][item-container]");
|
||||
|
||||
//initialise the static variable
|
||||
bool ListBoxTestCase::ms_ownerdrawn = false;
|
||||
|
||||
void ListBoxTestCase::setUp()
|
||||
{
|
||||
if( ms_ownerdrawn )
|
||||
{
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(300, 200), 0, nullptr,
|
||||
wxLB_OWNERDRAW);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(300, 200));
|
||||
}
|
||||
}
|
||||
|
||||
void ListBoxTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_list);
|
||||
}
|
||||
|
||||
void ListBoxTestCase::Sort()
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
wxDELETE(m_list);
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxLB_SORT);
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("aaa");
|
||||
testitems.Add("Aaa");
|
||||
testitems.Add("aba");
|
||||
testitems.Add("aaab");
|
||||
testitems.Add("aab");
|
||||
testitems.Add("AAA");
|
||||
|
||||
m_list->Append(testitems);
|
||||
|
||||
#ifndef __WXQT__
|
||||
CPPUNIT_ASSERT_EQUAL("AAA", m_list->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("Aaa", m_list->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("aaa", m_list->GetString(2));
|
||||
CPPUNIT_ASSERT_EQUAL("aaab", m_list->GetString(3));
|
||||
CPPUNIT_ASSERT_EQUAL("aab", m_list->GetString(4));
|
||||
CPPUNIT_ASSERT_EQUAL("aba", m_list->GetString(5));
|
||||
#else
|
||||
CPPUNIT_ASSERT_EQUAL("aaa", m_list->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("Aaa", m_list->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("AAA", m_list->GetString(2));
|
||||
CPPUNIT_ASSERT_EQUAL("aaab", m_list->GetString(3));
|
||||
CPPUNIT_ASSERT_EQUAL("aab", m_list->GetString(4));
|
||||
CPPUNIT_ASSERT_EQUAL("aba", m_list->GetString(5));
|
||||
#endif
|
||||
|
||||
m_list->Append("a", wxUIntToPtr(1));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("a", m_list->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL(wxUIntToPtr(1), m_list->GetClientData(0));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBoxTestCase::MultipleSelect()
|
||||
{
|
||||
wxDELETE(m_list);
|
||||
m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, 0, nullptr,
|
||||
wxLB_MULTIPLE);
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
testitems.Add("item 3");
|
||||
|
||||
m_list->Append(testitems);
|
||||
|
||||
m_list->SetSelection(0);
|
||||
|
||||
wxArrayInt selected;
|
||||
m_list->GetSelections(selected);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.Count());
|
||||
CPPUNIT_ASSERT_EQUAL(0, selected.Item(0));
|
||||
|
||||
m_list->SetSelection(2);
|
||||
|
||||
m_list->GetSelections(selected);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, selected.Count());
|
||||
CPPUNIT_ASSERT_EQUAL(2, selected.Item(1));
|
||||
|
||||
m_list->Deselect(0);
|
||||
|
||||
m_list->GetSelections(selected);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.Count());
|
||||
CPPUNIT_ASSERT_EQUAL(2, selected.Item(0));
|
||||
|
||||
CPPUNIT_ASSERT(!m_list->IsSelected(0));
|
||||
CPPUNIT_ASSERT(!m_list->IsSelected(1));
|
||||
CPPUNIT_ASSERT(m_list->IsSelected(2));
|
||||
CPPUNIT_ASSERT(!m_list->IsSelected(3));
|
||||
|
||||
m_list->SetSelection(0);
|
||||
m_list->SetSelection(wxNOT_FOUND);
|
||||
|
||||
m_list->GetSelections(selected);
|
||||
CPPUNIT_ASSERT_EQUAL(0, selected.Count());
|
||||
}
|
||||
|
||||
void ListBoxTestCase::ClickEvents()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter selected(frame, wxEVT_LISTBOX);
|
||||
EventCounter dclicked(frame, wxEVT_LISTBOX_DCLICK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
m_list->Append(testitems);
|
||||
|
||||
m_list->Refresh();
|
||||
m_list->Update();
|
||||
|
||||
sim.MouseMove(m_list->ClientToScreen(wxPoint(10, 10)));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.GetCount());
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, dclicked.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBoxTestCase::ClickNotOnItem()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
|
||||
wxTestableFrame);
|
||||
|
||||
EventCounter selected(frame, wxEVT_LISTBOX);
|
||||
EventCounter dclicked(frame, wxEVT_LISTBOX_DCLICK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
m_list->Append(testitems);
|
||||
|
||||
// It is important to set a valid selection: if the control doesn't have
|
||||
// any, clicking anywhere in it, even outside of any item, selects the
|
||||
// first item in the control under GTK resulting in a selection changed
|
||||
// event. This is not a wx bug, just the native platform behaviour so
|
||||
// simply avoid it by starting with a valid selection.
|
||||
m_list->SetSelection(0);
|
||||
|
||||
m_list->Refresh();
|
||||
m_list->Update();
|
||||
|
||||
sim.MouseMove(m_list->ClientToScreen(wxPoint(m_list->GetSize().x - 10, m_list->GetSize().y - 10)));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
//If we are not clicking on an item we shouldn't have any events
|
||||
CPPUNIT_ASSERT_EQUAL(0, selected.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, dclicked.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListBoxTestCase::HitTest()
|
||||
{
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 0");
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
m_list->Append(testitems);
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// The control needs to be realized for HitTest() to work.
|
||||
wxYield();
|
||||
#endif
|
||||
|
||||
wxPoint p(5, 5);
|
||||
#ifdef __WXOSX__
|
||||
// On macOS >= 11 wxListBox has a new layout because underlying
|
||||
// NSTableView has a new style with padding so we need to move
|
||||
// the point to be tested to another position.
|
||||
if ( wxCheckOsVersion(11, 0) )
|
||||
{
|
||||
p = wxPoint(10, 10);
|
||||
}
|
||||
#endif
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_list->HitTest(p) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( wxNOT_FOUND, m_list->HitTest(290, 190) );
|
||||
}
|
||||
|
||||
#endif //wxUSE_LISTBOX
|
||||
223
libs/wxWidgets-3.3.1/tests/controls/listctrltest.cpp
Normal file
223
libs/wxWidgets-3.3.1/tests/controls/listctrltest.cpp
Normal file
@@ -0,0 +1,223 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/listctrltest.cpp
|
||||
// Purpose: wxListCtrl unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-11-26
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_LISTCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "wx/artprov.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "listbasetest.h"
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class ListCtrlTestCase : public ListBaseTestCase
|
||||
{
|
||||
public:
|
||||
ListCtrlTestCase();
|
||||
virtual ~ListCtrlTestCase() override;
|
||||
|
||||
virtual wxListCtrl *GetList() const override { return m_list; }
|
||||
|
||||
protected:
|
||||
wxListCtrl *m_list;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ListCtrlTestCase);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ListCtrlTestCase::ListCtrlTestCase()
|
||||
{
|
||||
m_list = new wxListCtrl(wxTheApp->GetTopWindow());
|
||||
m_list->SetWindowStyle(wxLC_REPORT | wxLC_EDIT_LABELS);
|
||||
m_list->SetSize(400, 200);
|
||||
|
||||
wxTheApp->GetTopWindow()->Raise();
|
||||
}
|
||||
|
||||
ListCtrlTestCase::~ListCtrlTestCase()
|
||||
{
|
||||
DeleteTestWindow(m_list);
|
||||
}
|
||||
|
||||
wxLIST_BASE_TESTS(ListCtrl, "[listctrl]")
|
||||
|
||||
// Note that wxLIST_BASE_TESTS() already defines "ListCtrl::EditLabel" test.
|
||||
TEST_CASE_METHOD(ListCtrlTestCase, "ListCtrl::CallEditLabel", "[listctrl]")
|
||||
{
|
||||
EventCounter editItem(m_list, wxEVT_LIST_BEGIN_LABEL_EDIT);
|
||||
EventCounter endEditItem(m_list, wxEVT_LIST_END_LABEL_EDIT);
|
||||
|
||||
m_list->InsertColumn(0, "Column 0");
|
||||
m_list->InsertItem(0, "foo");
|
||||
m_list->EditLabel(0);
|
||||
|
||||
m_list->EndEditLabel(true);
|
||||
|
||||
CHECK(editItem.GetCount() == 1);
|
||||
CHECK(endEditItem.GetCount() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ListCtrlTestCase, "ListCtrl::SubitemRect", "[listctrl]")
|
||||
{
|
||||
wxBitmap bmp = wxArtProvider::GetBitmap(wxART_ERROR);
|
||||
|
||||
wxImageList* const iml = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
|
||||
iml->Add(bmp);
|
||||
m_list->AssignImageList(iml, wxIMAGE_LIST_SMALL);
|
||||
|
||||
m_list->InsertColumn(0, "Column 0");
|
||||
m_list->InsertColumn(1, "Column 1");
|
||||
m_list->InsertColumn(2, "Column 2");
|
||||
for ( int i = 0; i < 3; i++ )
|
||||
{
|
||||
long index = m_list->InsertItem(i, wxString::Format("This is item %d", i), 0);
|
||||
m_list->SetItem(index, 1, wxString::Format("Column 1 item %d", i));
|
||||
m_list->SetItem(index, 2, wxString::Format("Column 2 item %d", i));
|
||||
}
|
||||
|
||||
wxRect rectLabel, rectIcon, rectItem;
|
||||
|
||||
// First check a subitem with an icon: it should have a valid icon
|
||||
// rectangle and the label rectangle should be adjacent to it.
|
||||
m_list->GetSubItemRect(1, 0, rectItem, wxLIST_RECT_BOUNDS);
|
||||
m_list->GetSubItemRect(1, 0, rectIcon, wxLIST_RECT_ICON);
|
||||
m_list->GetSubItemRect(1, 0, rectLabel, wxLIST_RECT_LABEL);
|
||||
|
||||
CHECK(!rectIcon.IsEmpty());
|
||||
// Note that we can't use "==" here, in the native MSW version there is a
|
||||
// gap between the item rectangle and the icon one.
|
||||
CHECK(rectIcon.GetLeft() >= rectItem.GetLeft());
|
||||
CHECK(rectLabel.GetLeft() == rectIcon.GetRight() + 1);
|
||||
CHECK(rectLabel.GetRight() == rectItem.GetRight());
|
||||
|
||||
// For a subitem without an icon, label rectangle is the same one as the
|
||||
// entire item one and the icon rectangle should be empty.
|
||||
m_list->GetSubItemRect(1, 1, rectItem, wxLIST_RECT_BOUNDS);
|
||||
m_list->GetSubItemRect(1, 1, rectIcon, wxLIST_RECT_ICON);
|
||||
m_list->GetSubItemRect(1, 1, rectLabel, wxLIST_RECT_LABEL);
|
||||
|
||||
CHECK(rectIcon.IsEmpty());
|
||||
// Here we can't check for exact equality either as there can be a margin.
|
||||
CHECK(rectLabel.GetLeft() >= rectItem.GetLeft());
|
||||
CHECK(rectLabel.GetRight() == rectItem.GetRight());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ListCtrlTestCase, "ListCtrl::ColumnCount", "[listctrl]")
|
||||
{
|
||||
CHECK(m_list->GetColumnCount() == 0);
|
||||
m_list->InsertColumn(0, "Column 0");
|
||||
m_list->InsertColumn(1, "Column 1");
|
||||
CHECK(m_list->GetColumnCount() == 2);
|
||||
|
||||
// Recreate the control in other modes to check the count there as well.
|
||||
delete m_list;
|
||||
m_list = new wxListCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_LIST);
|
||||
CHECK(m_list->GetColumnCount() == 1);
|
||||
|
||||
delete m_list;
|
||||
m_list = new wxListCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_ICON);
|
||||
CHECK(m_list->GetColumnCount() == 0);
|
||||
|
||||
delete m_list;
|
||||
m_list = new wxListCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_SMALL_ICON);
|
||||
CHECK(m_list->GetColumnCount() == 0);
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(ListCtrlTestCase, "ListCtrl::ColumnDrag", "[listctrl]")
|
||||
{
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter begindrag(m_list, wxEVT_LIST_COL_BEGIN_DRAG);
|
||||
EventCounter dragging(m_list, wxEVT_LIST_COL_DRAGGING);
|
||||
EventCounter enddrag(m_list, wxEVT_LIST_COL_END_DRAG);
|
||||
|
||||
m_list->InsertColumn(0, "Column 0");
|
||||
m_list->InsertColumn(1, "Column 1");
|
||||
m_list->InsertColumn(2, "Column 2");
|
||||
m_list->Update();
|
||||
m_list->SetFocus();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxPoint pt = m_list->ClientToScreen(wxPoint(m_list->GetColumnWidth(0), 5));
|
||||
|
||||
sim.MouseMove(pt);
|
||||
wxYield();
|
||||
|
||||
sim.MouseDown();
|
||||
wxYield();
|
||||
|
||||
sim.MouseMove(pt.x + 50, pt.y);
|
||||
wxYield();
|
||||
|
||||
sim.MouseUp();
|
||||
wxYield();
|
||||
|
||||
CHECK( begindrag.GetCount() == 1 );
|
||||
CHECK( dragging.GetCount() > 0 );
|
||||
CHECK( enddrag.GetCount() == 1 );
|
||||
|
||||
m_list->ClearAll();
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ListCtrlTestCase, "ListCtrl::ColumnClick", "[listctrl]")
|
||||
{
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter colclick(m_list, wxEVT_LIST_COL_CLICK);
|
||||
EventCounter colrclick(m_list, wxEVT_LIST_COL_RIGHT_CLICK);
|
||||
|
||||
|
||||
m_list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
sim.MouseMove(m_list->ClientToScreen(wxPoint(4, 4)));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CHECK( colclick.GetCount() == 1 );
|
||||
CHECK( colrclick.GetCount() == 1 );
|
||||
|
||||
m_list->ClearAll();
|
||||
}
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
#endif // wxUSE_LISTCTRL
|
||||
123
libs/wxWidgets-3.3.1/tests/controls/listviewtest.cpp
Normal file
123
libs/wxWidgets-3.3.1/tests/controls/listviewtest.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/listviewtest.cpp
|
||||
// Purpose: wxListView unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-10
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_LISTCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "listbasetest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
class ListViewTestCase : public ListBaseTestCase
|
||||
{
|
||||
public:
|
||||
ListViewTestCase();
|
||||
virtual ~ListViewTestCase() override;
|
||||
|
||||
virtual wxListCtrl *GetList() const override { return m_list; }
|
||||
|
||||
protected:
|
||||
wxListView *m_list;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ListViewTestCase);
|
||||
};
|
||||
|
||||
ListViewTestCase::ListViewTestCase()
|
||||
{
|
||||
m_list = new wxListView(wxTheApp->GetTopWindow());
|
||||
m_list->SetWindowStyle(wxLC_REPORT);
|
||||
m_list->SetSize(400, 200);
|
||||
}
|
||||
|
||||
ListViewTestCase::~ListViewTestCase()
|
||||
{
|
||||
DeleteTestWindow(m_list);
|
||||
}
|
||||
|
||||
wxLIST_BASE_TESTS(ListView, "[listctrl][listview]")
|
||||
|
||||
TEST_CASE_METHOD(ListViewTestCase, "ListView::Selection", "[listctrl][listview]")
|
||||
{
|
||||
m_list->InsertColumn(0, "Column 0");
|
||||
|
||||
m_list->InsertItem(0, "Item 0");
|
||||
m_list->InsertItem(1, "Item 1");
|
||||
m_list->InsertItem(2, "Item 2");
|
||||
m_list->InsertItem(3, "Item 3");
|
||||
|
||||
m_list->Select(0);
|
||||
m_list->Select(2);
|
||||
m_list->Select(3);
|
||||
|
||||
CHECK(m_list->IsSelected(0));
|
||||
CHECK(!m_list->IsSelected(1));
|
||||
|
||||
long sel = m_list->GetFirstSelected();
|
||||
|
||||
CHECK( sel == 0 );
|
||||
|
||||
sel = m_list->GetNextSelected(sel);
|
||||
|
||||
CHECK( sel == 2 );
|
||||
|
||||
sel = m_list->GetNextSelected(sel);
|
||||
|
||||
CHECK( sel == 3 );
|
||||
|
||||
sel = m_list->GetNextSelected(sel);
|
||||
|
||||
CHECK( sel == -1 );
|
||||
|
||||
m_list->Select(0, false);
|
||||
|
||||
CHECK(!m_list->IsSelected(0));
|
||||
CHECK( m_list->GetFirstSelected() == 2 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ListViewTestCase, "ListView::Focus", "[listctrl][listview]")
|
||||
{
|
||||
EventCounter focused(m_list, wxEVT_LIST_ITEM_FOCUSED);
|
||||
|
||||
m_list->InsertColumn(0, "Column 0");
|
||||
|
||||
m_list->InsertItem(0, "Item 0");
|
||||
m_list->InsertItem(1, "Item 1");
|
||||
m_list->InsertItem(2, "Item 2");
|
||||
m_list->InsertItem(3, "Item 3");
|
||||
|
||||
CHECK( focused.GetCount() == 0 );
|
||||
CHECK( m_list->GetFocusedItem() == -1 );
|
||||
|
||||
m_list->Focus(0);
|
||||
|
||||
CHECK( focused.GetCount() == 1 );
|
||||
CHECK( m_list->GetFocusedItem() == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(ListViewTestCase, "ListView::AppendColumn", "[listctrl][listview]")
|
||||
{
|
||||
m_list->AppendColumn("Column 0");
|
||||
m_list->AppendColumn("Column 1");
|
||||
|
||||
m_list->InsertItem(0, "First item");
|
||||
m_list->SetItem(0, 1, "First subitem");
|
||||
|
||||
// Appending a column shouldn't change the existing items.
|
||||
m_list->AppendColumn("Column 2");
|
||||
|
||||
CHECK( m_list->GetItemText(0) == "First item" );
|
||||
CHECK( m_list->GetItemText(0, 1) == "First subitem" );
|
||||
}
|
||||
|
||||
#endif
|
||||
216
libs/wxWidgets-3.3.1/tests/controls/markuptest.cpp
Normal file
216
libs/wxWidgets-3.3.1/tests/controls/markuptest.cpp
Normal file
@@ -0,0 +1,216 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/markup.cpp
|
||||
// Purpose: wxMarkupParser and related classes unit tests
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-02-17
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/private/markupparser.h"
|
||||
|
||||
class MarkupTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
MarkupTestCase() { }
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( MarkupTestCase );
|
||||
CPPUNIT_TEST( RoundTrip );
|
||||
CPPUNIT_TEST( Quote );
|
||||
CPPUNIT_TEST( Strip );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void RoundTrip();
|
||||
void Quote();
|
||||
void Strip();
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(MarkupTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( MarkupTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MarkupTestCase, "MarkupTestCase" );
|
||||
|
||||
void MarkupTestCase::RoundTrip()
|
||||
{
|
||||
// Define a wxMarkupParserOutput object which produces the same markup
|
||||
// string on output. This is, of course, perfectly useless, but allows us
|
||||
// to test that parsing works as expected.
|
||||
class RoundTripOutput : public wxMarkupParserOutput
|
||||
{
|
||||
public:
|
||||
RoundTripOutput() { }
|
||||
|
||||
void Reset() { m_text.clear(); }
|
||||
|
||||
const wxString& GetText() const { return m_text; }
|
||||
|
||||
|
||||
virtual void OnText(const wxString& text) override { m_text += text; }
|
||||
|
||||
virtual void OnBoldStart() override { m_text += "<b>"; }
|
||||
virtual void OnBoldEnd() override { m_text += "</b>"; }
|
||||
|
||||
virtual void OnItalicStart() override { m_text += "<i>"; }
|
||||
virtual void OnItalicEnd() override { m_text += "</i>"; }
|
||||
|
||||
virtual void OnUnderlinedStart() override { m_text += "<u>"; }
|
||||
virtual void OnUnderlinedEnd() override { m_text += "</u>"; }
|
||||
|
||||
virtual void OnStrikethroughStart() override { m_text += "<s>"; }
|
||||
virtual void OnStrikethroughEnd() override { m_text += "</s>"; }
|
||||
|
||||
virtual void OnBigStart() override { m_text += "<big>"; }
|
||||
virtual void OnBigEnd() override { m_text += "</big>"; }
|
||||
|
||||
virtual void OnSmallStart() override { m_text += "<small>"; }
|
||||
virtual void OnSmallEnd() override { m_text += "</small>"; }
|
||||
|
||||
virtual void OnTeletypeStart() override { m_text += "<tt>"; }
|
||||
virtual void OnTeletypeEnd() override { m_text += "</tt>"; }
|
||||
|
||||
virtual void OnSpanStart(const wxMarkupSpanAttributes& attrs) override
|
||||
{
|
||||
m_text << "<span";
|
||||
|
||||
if ( !attrs.m_fgCol.empty() )
|
||||
m_text << " foreground='" << attrs.m_fgCol << "'";
|
||||
|
||||
if ( !attrs.m_bgCol.empty() )
|
||||
m_text << " background='" << attrs.m_bgCol << "'";
|
||||
|
||||
if ( !attrs.m_fontFace.empty() )
|
||||
m_text << " face='" << attrs.m_fontFace << "'";
|
||||
|
||||
wxString size;
|
||||
switch ( attrs.m_sizeKind )
|
||||
{
|
||||
case wxMarkupSpanAttributes::Size_Unspecified:
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::Size_Relative:
|
||||
size << (attrs.m_fontSize > 0 ? "larger" : "smaller");
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::Size_Symbolic:
|
||||
{
|
||||
CPPUNIT_ASSERT( attrs.m_fontSize >= -3 );
|
||||
CPPUNIT_ASSERT( attrs.m_fontSize <= 3 );
|
||||
static const char *cssSizes[] =
|
||||
{
|
||||
"xx-small", "x-small", "small",
|
||||
"medium",
|
||||
"large", "x-large", "xx-large",
|
||||
};
|
||||
|
||||
size << cssSizes[attrs.m_fontSize + 3];
|
||||
}
|
||||
break;
|
||||
|
||||
case wxMarkupSpanAttributes::Size_PointParts:
|
||||
size.Printf("%u", attrs.m_fontSize);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !size.empty() )
|
||||
m_text << " size='" << size << '\'';
|
||||
|
||||
// TODO: Handle the rest of attributes.
|
||||
|
||||
m_text << ">";
|
||||
}
|
||||
|
||||
virtual void OnSpanEnd(const wxMarkupSpanAttributes& WXUNUSED(attrs)) override
|
||||
{
|
||||
m_text += "</span>";
|
||||
}
|
||||
|
||||
private:
|
||||
wxString m_text;
|
||||
};
|
||||
|
||||
|
||||
RoundTripOutput output;
|
||||
wxMarkupParser parser(output);
|
||||
|
||||
#define CHECK_PARSES_OK(text) \
|
||||
output.Reset(); \
|
||||
CPPUNIT_ASSERT( parser.Parse(text) ); \
|
||||
CPPUNIT_ASSERT_EQUAL( text, output.GetText() )
|
||||
|
||||
#define CHECK_PARSES_AS(text, result) \
|
||||
output.Reset(); \
|
||||
CPPUNIT_ASSERT( parser.Parse(text) ); \
|
||||
CPPUNIT_ASSERT_EQUAL( result, output.GetText() )
|
||||
|
||||
#define CHECK_DOESNT_PARSE(text) \
|
||||
CPPUNIT_ASSERT( !parser.Parse(text) )
|
||||
|
||||
CHECK_PARSES_OK( "" );
|
||||
CHECK_PARSES_OK( "foo" );
|
||||
CHECK_PARSES_OK( "foo<b>bar</b>" );
|
||||
CHECK_PARSES_OK( "1<big>2<small>3</small>4<big>5</big></big>6" );
|
||||
CHECK_PARSES_OK( "first <span foreground='red'>second</span> last" );
|
||||
CHECK_PARSES_OK( "first <span foreground='red' "
|
||||
"background='#ffffff'>second </span> last" );
|
||||
CHECK_PARSES_OK( "<span size='10240'>10pt</span>" );
|
||||
CHECK_PARSES_OK( "<span size='x-small'>much smaller</span>" );
|
||||
CHECK_PARSES_OK( "<span size='larger'>larger</span>" );
|
||||
CHECK_PARSES_OK
|
||||
(
|
||||
"<u>Please</u> notice: <i><b>any</b></i> <span foreground='grey'>"
|
||||
"<s><tt>bugs</tt></s></span> in this code are <span foreground='red' "
|
||||
"size='xx-large'>NOT</span> allowed."
|
||||
);
|
||||
|
||||
CHECK_PARSES_OK( "foo&bar" );
|
||||
CHECK_PARSES_AS( "foo&bar", "foo&bar" );
|
||||
CHECK_PARSES_AS( "<O'Reilly>", "<O'Reilly>" );
|
||||
|
||||
CHECK_DOESNT_PARSE( "<" );
|
||||
CHECK_DOESNT_PARSE( "<b" );
|
||||
CHECK_DOESNT_PARSE( "<b>" );
|
||||
CHECK_DOESNT_PARSE( "<b></i>" );
|
||||
CHECK_DOESNT_PARSE( "<b><i></b></i>" );
|
||||
CHECK_DOESNT_PARSE( "<foo></foo>" );
|
||||
|
||||
#undef CHECK_PARSES_OK
|
||||
#undef CHECK_DOESNT_PARSE
|
||||
}
|
||||
|
||||
void MarkupTestCase::Quote()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( "", wxMarkupParser::Quote("") );
|
||||
CPPUNIT_ASSERT_EQUAL( "foo", wxMarkupParser::Quote("foo") );
|
||||
CPPUNIT_ASSERT_EQUAL( "<foo>", wxMarkupParser::Quote("<foo>") );
|
||||
CPPUNIT_ASSERT_EQUAL( "B&B", wxMarkupParser::Quote("B&B") );
|
||||
CPPUNIT_ASSERT_EQUAL( """", wxMarkupParser::Quote("\"\"") );
|
||||
}
|
||||
|
||||
void MarkupTestCase::Strip()
|
||||
{
|
||||
#define CHECK_STRIP( text, stripped ) \
|
||||
CPPUNIT_ASSERT_EQUAL( stripped, wxMarkupParser::Strip(text) )
|
||||
|
||||
CHECK_STRIP( "", "" );
|
||||
CHECK_STRIP( "foo", "foo" );
|
||||
CHECK_STRIP( "<foo>", "<foo>" );
|
||||
CHECK_STRIP( "<b>Big</b> problem", "Big problem" );
|
||||
CHECK_STRIP( "<span foreground='red'>c</span>"
|
||||
"<span background='green'>o</span>"
|
||||
"<span background='blue'>l</span>"
|
||||
"<span background='green'>o</span>"
|
||||
"<span foreground='yellow'>u</span>"
|
||||
"<span background='green'>r</span>",
|
||||
"colour" );
|
||||
|
||||
#undef CHECK_STRIP
|
||||
}
|
||||
304
libs/wxWidgets-3.3.1/tests/controls/notebooktest.cpp
Normal file
304
libs/wxWidgets-3.3.1/tests/controls/notebooktest.cpp
Normal file
@@ -0,0 +1,304 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/notebooktest.cpp
|
||||
// Purpose: wxNotebook unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-02
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_NOTEBOOK
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/panel.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/notebook.h"
|
||||
|
||||
#include "asserthelper.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class NotebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
NotebookTestCase() { m_notebook = nullptr; m_numPageChanges = 0; }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_notebook; }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_NOTEBOOK_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_NOTEBOOK_PAGE_CHANGING; }
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE( NotebookTestCase );
|
||||
wxBOOK_CTRL_BASE_TESTS();
|
||||
CPPUNIT_TEST( Image );
|
||||
CPPUNIT_TEST( RowCount );
|
||||
CPPUNIT_TEST( NoEventsOnDestruction );
|
||||
CPPUNIT_TEST( GetTabRect );
|
||||
CPPUNIT_TEST( HitTestFlags );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void RowCount();
|
||||
void NoEventsOnDestruction();
|
||||
void GetTabRect();
|
||||
void HitTestFlags();
|
||||
|
||||
void OnPageChanged(wxNotebookEvent&) { m_numPageChanges++; }
|
||||
|
||||
wxNotebook *m_notebook;
|
||||
|
||||
int m_numPageChanges;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(NotebookTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( NotebookTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( NotebookTestCase, "NotebookTestCase" );
|
||||
|
||||
void NotebookTestCase::setUp()
|
||||
{
|
||||
m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
void NotebookTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_notebook);
|
||||
}
|
||||
|
||||
void NotebookTestCase::RowCount()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(1, m_notebook->GetRowCount());
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxDELETE(m_notebook);
|
||||
m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200),
|
||||
wxNB_MULTILINE);
|
||||
|
||||
for( unsigned int i = 0; i < 10; i++ )
|
||||
{
|
||||
m_notebook->AddPage(new wxPanel(m_notebook), "Panel", false, 0);
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT( m_notebook->GetRowCount() != 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void NotebookTestCase::NoEventsOnDestruction()
|
||||
{
|
||||
// We can't use EventCounter helper here as it doesn't deal with the window
|
||||
// it's connected to being destroyed during its life-time, so do it
|
||||
// manually.
|
||||
m_notebook->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED,
|
||||
&NotebookTestCase::OnPageChanged, this);
|
||||
|
||||
// Normally deleting a page before the selected one results in page
|
||||
// selection changing and the corresponding event.
|
||||
m_notebook->DeletePage(static_cast<size_t>(0));
|
||||
CHECK( m_numPageChanges == 1 );
|
||||
|
||||
// But deleting the entire control shouldn't generate any events, yet it
|
||||
// used to do under GTK+ 3 when a page different from the first one was
|
||||
// selected.
|
||||
m_notebook->ChangeSelection(1);
|
||||
m_notebook->Destroy();
|
||||
m_notebook = nullptr;
|
||||
CHECK( m_numPageChanges == 1 );
|
||||
}
|
||||
|
||||
TEST_CASE("wxNotebook::AddPageEvents", "[wxNotebook][AddPage][event]")
|
||||
{
|
||||
wxNotebook* const
|
||||
notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
std::unique_ptr<wxNotebook> cleanup(notebook);
|
||||
|
||||
CHECK( notebook->GetSelection() == wxNOT_FOUND );
|
||||
|
||||
EventCounter countPageChanging(notebook, wxEVT_NOTEBOOK_PAGE_CHANGING);
|
||||
EventCounter countPageChanged(notebook, wxEVT_NOTEBOOK_PAGE_CHANGED);
|
||||
|
||||
// Add the first page, it is special.
|
||||
notebook->AddPage(new wxPanel(notebook), "Initial page");
|
||||
|
||||
// The selection should have been changed.
|
||||
CHECK( notebook->GetSelection() == 0 );
|
||||
|
||||
// But no events should have been generated.
|
||||
CHECK( countPageChanging.GetCount() == 0 );
|
||||
CHECK( countPageChanged.GetCount() == 0 );
|
||||
|
||||
|
||||
// Add another page without selecting it.
|
||||
notebook->AddPage(new wxPanel(notebook), "Unselected page");
|
||||
|
||||
// Selection shouldn't have changed.
|
||||
CHECK( notebook->GetSelection() == 0 );
|
||||
|
||||
// And no events should have been generated, of course.
|
||||
CHECK( countPageChanging.GetCount() == 0 );
|
||||
CHECK( countPageChanged.GetCount() == 0 );
|
||||
|
||||
|
||||
// Finally add another page and do select it.
|
||||
notebook->AddPage(new wxPanel(notebook), "Selected page", true);
|
||||
|
||||
// It should have become selected.
|
||||
CHECK( notebook->GetSelection() == 2 );
|
||||
|
||||
// And events for the selection change should have been generated.
|
||||
CHECK( countPageChanging.GetCount() == 1 );
|
||||
CHECK( countPageChanged.GetCount() == 1 );
|
||||
}
|
||||
|
||||
void NotebookTestCase::GetTabRect()
|
||||
{
|
||||
wxNotebook *notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200));
|
||||
std::unique_ptr<wxNotebook> cleanup(notebook);
|
||||
|
||||
notebook->AddPage(new wxPanel(notebook), "Page");
|
||||
|
||||
// This function is only really implemented for wxMSW and wxUniv currently.
|
||||
#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
||||
// Create many pages, so that at least some of the are not visible.
|
||||
for ( size_t i = 0; i < 30; i++ )
|
||||
notebook->AddPage(new wxPanel(notebook), "Page");
|
||||
|
||||
const wxRect rectPage = notebook->GetTabRect(0);
|
||||
REQUIRE(rectPage.width != 0);
|
||||
REQUIRE(rectPage.height != 0);
|
||||
|
||||
int x = rectPage.x + rectPage.width;
|
||||
for ( size_t i = 1; i < notebook->GetPageCount(); i++ )
|
||||
{
|
||||
wxRect r = notebook->GetTabRect(i);
|
||||
|
||||
if (wxIsRunningUnderWine())
|
||||
{
|
||||
// Wine behaves different than Windows. Windows reports the size of a
|
||||
// tab even if it is not visible while Wine returns an empty rectangle.
|
||||
if ( r == wxRect() )
|
||||
{
|
||||
WARN("Skipping test for pages after " << i << " under Wine.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
INFO("Page #" << i << ": rect=" << r);
|
||||
REQUIRE(r.x == x);
|
||||
REQUIRE(r.y == rectPage.y);
|
||||
REQUIRE(r.width == rectPage.width);
|
||||
REQUIRE(r.height == rectPage.height);
|
||||
|
||||
x += r.width;
|
||||
}
|
||||
#else // !(__WXMSW__ || __WXUNIVERSAL__)
|
||||
WX_ASSERT_FAILS_WITH_ASSERT( notebook->GetTabRect(0) );
|
||||
#endif // ports
|
||||
}
|
||||
|
||||
void NotebookTestCase::HitTestFlags()
|
||||
{
|
||||
std::unique_ptr<wxNotebook> notebook;
|
||||
|
||||
#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
||||
long style = 0;
|
||||
|
||||
SECTION("Top") { style = wxBK_TOP; }
|
||||
SECTION("Bottom") { style = wxBK_BOTTOM; }
|
||||
SECTION("Left") { style = wxBK_LEFT; }
|
||||
SECTION("Right") { style = wxBK_RIGHT; }
|
||||
|
||||
INFO("Style=" << style);
|
||||
|
||||
const bool isVertical = style == wxBK_TOP || style == wxBK_BOTTOM;
|
||||
|
||||
// HitTest() uses TCM_HITTEST for the vertical orientations and it doesn't
|
||||
// seem to work correctly under Wine, so skip the test there (for the
|
||||
// horizontal tabs we use our own code which does work even under Wine).
|
||||
if ( isVertical && wxIsRunningUnderWine() )
|
||||
return;
|
||||
|
||||
notebook.reset(new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxPoint(0, 0), wxSize(400, 200),
|
||||
style));
|
||||
|
||||
// Simulate an icon of standard size, its contents doesn't matter.
|
||||
const wxSize imageSize(16, 16);
|
||||
wxBookCtrlBase::Images images;
|
||||
images.push_back(wxBitmapBundle::FromBitmap(wxBitmap(imageSize)));
|
||||
notebook->SetImages(images);
|
||||
|
||||
notebook->AddPage(new wxPanel(notebook.get()), "First Page", false, 0);
|
||||
|
||||
const wxRect r = notebook->GetTabRect(0);
|
||||
INFO("Rect=" << r);
|
||||
|
||||
wxPoint pt;
|
||||
if ( isVertical )
|
||||
pt.y = r.y + r.height / 2;
|
||||
else
|
||||
pt.x = r.x + r.width / 2;
|
||||
|
||||
int nowhere = 0;
|
||||
int onIcon = 0;
|
||||
int onLabel = 0;
|
||||
int onItem = 0;
|
||||
|
||||
const int d = isVertical ? r.width : r.height;
|
||||
for (int i = 0; i < d; i++)
|
||||
{
|
||||
long flags = 0;
|
||||
notebook->HitTest(pt, &flags);
|
||||
|
||||
if (flags & wxBK_HITTEST_NOWHERE)
|
||||
nowhere++;
|
||||
|
||||
if (flags & wxBK_HITTEST_ONICON)
|
||||
onIcon++;
|
||||
|
||||
if (flags & wxBK_HITTEST_ONLABEL)
|
||||
onLabel++;
|
||||
|
||||
if (flags & wxBK_HITTEST_ONITEM)
|
||||
onItem++;
|
||||
|
||||
if (isVertical)
|
||||
pt.x++;
|
||||
else
|
||||
pt.y++;
|
||||
}
|
||||
|
||||
CHECK(nowhere);
|
||||
CHECK(onIcon);
|
||||
CHECK(onLabel);
|
||||
CHECK(onItem);
|
||||
#else // !(__WXMSW__ || __WXUNIVERSAL__)
|
||||
notebook.reset(new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxSize(400, 200)));
|
||||
notebook->AddPage(new wxPanel(notebook.get()), "First Page");
|
||||
|
||||
WX_ASSERT_FAILS_WITH_ASSERT(notebook->GetTabRect(0));
|
||||
#endif // ports
|
||||
}
|
||||
|
||||
#endif //wxUSE_NOTEBOOK
|
||||
188
libs/wxWidgets-3.3.1/tests/controls/ownerdrawncomboboxtest.cpp
Normal file
188
libs/wxWidgets-3.3.1/tests/controls/ownerdrawncomboboxtest.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/ownerdrawncomboboxtest.cpp
|
||||
// Purpose: OwnerDrawnComboBox unit test
|
||||
// Author: Jaakko Salli
|
||||
// Created: 2010-12-17
|
||||
// Copyright: (c) 2010 Jaakko Salli
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_ODCOMBOBOX
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/odcombo.h"
|
||||
|
||||
#include "textentrytest.h"
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class OwnerDrawnComboBoxTestCase : public TextEntryTestCase,
|
||||
public ItemContainerTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
OwnerDrawnComboBoxTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxTextEntry *GetTestEntry() const override { return m_combo; }
|
||||
virtual wxWindow *GetTestWindow() const override { return m_combo; }
|
||||
|
||||
virtual wxItemContainer *GetContainer() const override { return m_combo; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_combo; }
|
||||
|
||||
virtual void CheckStringSelection(const char * WXUNUSED(sel)) override
|
||||
{
|
||||
// do nothing here, as explained in TextEntryTestCase comment, our
|
||||
// GetStringSelection() is the wxChoice, not wxTextEntry, one and there
|
||||
// is no way to return the selection contents directly
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE( OwnerDrawnComboBoxTestCase );
|
||||
wxTEXT_ENTRY_TESTS();
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST( Size );
|
||||
CPPUNIT_TEST( PopDismiss );
|
||||
CPPUNIT_TEST( Sort );
|
||||
CPPUNIT_TEST( ReadOnly );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Size();
|
||||
void PopDismiss();
|
||||
void Sort();
|
||||
void ReadOnly();
|
||||
|
||||
wxOwnerDrawnComboBox *m_combo;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(OwnerDrawnComboBoxTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(OwnerDrawnComboBoxTestCase,
|
||||
"[OwnerDrawnComboBoxTestCase][item-container]");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::setUp()
|
||||
{
|
||||
m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
}
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::tearDown()
|
||||
{
|
||||
delete m_combo;
|
||||
m_combo = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::Size()
|
||||
{
|
||||
// under MSW changing combobox size is a non-trivial operation because of
|
||||
// confusion between the size of the control with and without dropdown, so
|
||||
// check that it does work as expected
|
||||
|
||||
const int heightOrig = m_combo->GetSize().y;
|
||||
|
||||
// check that the height doesn't change if we don't touch it
|
||||
m_combo->SetSize(100, -1);
|
||||
CPPUNIT_ASSERT_EQUAL( heightOrig, m_combo->GetSize().y );
|
||||
|
||||
// check that setting both big and small (but not too small, there is a
|
||||
// limit on how small the control can become under MSW) heights works
|
||||
m_combo->SetSize(-1, 50);
|
||||
CPPUNIT_ASSERT_EQUAL( 50, m_combo->GetSize().y );
|
||||
|
||||
m_combo->SetSize(-1, 10);
|
||||
CPPUNIT_ASSERT_EQUAL( 10, m_combo->GetSize().y );
|
||||
|
||||
// and also that restoring it works (this used to be broken before 2.9.1)
|
||||
m_combo->SetSize(-1, heightOrig);
|
||||
CPPUNIT_ASSERT_EQUAL( heightOrig, m_combo->GetSize().y );
|
||||
}
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::PopDismiss()
|
||||
{
|
||||
EventCounter drop(m_combo, wxEVT_COMBOBOX_DROPDOWN);
|
||||
EventCounter close(m_combo, wxEVT_COMBOBOX_CLOSEUP);
|
||||
|
||||
m_combo->Popup();
|
||||
m_combo->Dismiss();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, drop.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
|
||||
}
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::Sort()
|
||||
{
|
||||
delete m_combo;
|
||||
m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
0, nullptr,
|
||||
wxCB_SORT);
|
||||
|
||||
m_combo->Append("aaa");
|
||||
m_combo->Append("Aaa");
|
||||
m_combo->Append("aba");
|
||||
m_combo->Append("aaab");
|
||||
m_combo->Append("aab");
|
||||
m_combo->Append("AAA");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("AAA", m_combo->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("Aaa", m_combo->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("aaa", m_combo->GetString(2));
|
||||
CPPUNIT_ASSERT_EQUAL("aaab", m_combo->GetString(3));
|
||||
CPPUNIT_ASSERT_EQUAL("aab", m_combo->GetString(4));
|
||||
CPPUNIT_ASSERT_EQUAL("aba", m_combo->GetString(5));
|
||||
|
||||
m_combo->Append("a");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("a", m_combo->GetString(0));
|
||||
}
|
||||
|
||||
void OwnerDrawnComboBoxTestCase::ReadOnly()
|
||||
{
|
||||
wxArrayString testitems;
|
||||
testitems.Add("item 1");
|
||||
testitems.Add("item 2");
|
||||
|
||||
delete m_combo;
|
||||
m_combo = new wxOwnerDrawnComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
testitems,
|
||||
wxCB_READONLY);
|
||||
|
||||
m_combo->SetValue("item 1");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue());
|
||||
|
||||
m_combo->SetValue("not an item");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue());
|
||||
|
||||
// Since this uses FindString it is case insensitive
|
||||
m_combo->SetValue("ITEM 2");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("item 2", m_combo->GetValue());
|
||||
}
|
||||
|
||||
#endif // wxUSE_ODCOMBOBOX
|
||||
72
libs/wxWidgets-3.3.1/tests/controls/pickerbasetest.cpp
Normal file
72
libs/wxWidgets-3.3.1/tests/controls/pickerbasetest.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/pickerbasetest.cpp
|
||||
// Purpose: wxPickerBase unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-08-07
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_COLOURPICKERCTRL || \
|
||||
wxUSE_DIRPICKERCTRL || \
|
||||
wxUSE_FILEPICKERCTRL || \
|
||||
wxUSE_FONTPICKERCTRL
|
||||
|
||||
#include "wx/pickerbase.h"
|
||||
#include "pickerbasetest.h"
|
||||
|
||||
void PickerBaseTestCase::Margin()
|
||||
{
|
||||
wxPickerBase* const base = GetBase();
|
||||
|
||||
CPPUNIT_ASSERT(base->HasTextCtrl());
|
||||
CPPUNIT_ASSERT(base->GetInternalMargin() >= 0);
|
||||
|
||||
base->SetInternalMargin(15);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(15, base->GetInternalMargin());
|
||||
}
|
||||
|
||||
void PickerBaseTestCase::Proportion()
|
||||
{
|
||||
wxPickerBase* const base = GetBase();
|
||||
|
||||
CPPUNIT_ASSERT(base->HasTextCtrl());
|
||||
|
||||
base->SetPickerCtrlProportion(1);
|
||||
base->SetTextCtrlProportion(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, base->GetPickerCtrlProportion());
|
||||
CPPUNIT_ASSERT_EQUAL(1, base->GetTextCtrlProportion());
|
||||
}
|
||||
|
||||
void PickerBaseTestCase::Growable()
|
||||
{
|
||||
wxPickerBase* const base = GetBase();
|
||||
|
||||
CPPUNIT_ASSERT(base->HasTextCtrl());
|
||||
|
||||
base->SetPickerCtrlGrowable();
|
||||
base->SetTextCtrlGrowable();
|
||||
|
||||
CPPUNIT_ASSERT(base->IsPickerCtrlGrowable());
|
||||
CPPUNIT_ASSERT(base->IsTextCtrlGrowable());
|
||||
|
||||
base->SetPickerCtrlGrowable(false);
|
||||
base->SetTextCtrlGrowable(false);
|
||||
|
||||
CPPUNIT_ASSERT(!base->IsPickerCtrlGrowable());
|
||||
CPPUNIT_ASSERT(!base->IsTextCtrlGrowable());
|
||||
}
|
||||
|
||||
void PickerBaseTestCase::Controls()
|
||||
{
|
||||
wxPickerBase* const base = GetBase();
|
||||
|
||||
CPPUNIT_ASSERT(base->HasTextCtrl());
|
||||
CPPUNIT_ASSERT(base->GetTextCtrl() != nullptr);
|
||||
CPPUNIT_ASSERT(base->GetPickerCtrl() != nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
42
libs/wxWidgets-3.3.1/tests/controls/pickerbasetest.h
Normal file
42
libs/wxWidgets-3.3.1/tests/controls/pickerbasetest.h
Normal file
@@ -0,0 +1,42 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/pickerbasetest.cpp
|
||||
// Purpose: wxPickerBase unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-08-07
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_CONTROLS_PICKERBASETEST_H_
|
||||
#define _WX_TESTS_CONTROLS_PICKERBASETEST_H_
|
||||
|
||||
class PickerBaseTestCase
|
||||
{
|
||||
public:
|
||||
PickerBaseTestCase() { }
|
||||
virtual ~PickerBaseTestCase() { }
|
||||
|
||||
protected:
|
||||
// this function must be overridden by the derived classes to return the
|
||||
// text entry object we're testing, typically this is done by creating a
|
||||
// control implementing wxPickerBase interface in setUp() virtual method and
|
||||
// just returning it from here
|
||||
virtual wxPickerBase *GetBase() const = 0;
|
||||
|
||||
// this should be inserted in the derived class CPPUNIT_TEST_SUITE
|
||||
// definition to run all wxPickerBase tests as part of it
|
||||
#define wxPICKER_BASE_TESTS() \
|
||||
CPPUNIT_TEST( Margin ); \
|
||||
CPPUNIT_TEST( Proportion ); \
|
||||
CPPUNIT_TEST( Growable ); \
|
||||
CPPUNIT_TEST( Controls )
|
||||
|
||||
void Margin();
|
||||
void Proportion();
|
||||
void Growable();
|
||||
void Controls();
|
||||
|
||||
private:
|
||||
wxDECLARE_NO_COPY_CLASS(PickerBaseTestCase);
|
||||
};
|
||||
|
||||
#endif // _WX_TESTS_CONTROLS_PICKERBASETEST_H_
|
||||
220
libs/wxWidgets-3.3.1/tests/controls/pickertest.cpp
Normal file
220
libs/wxWidgets-3.3.1/tests/controls/pickertest.cpp
Normal file
@@ -0,0 +1,220 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/pickertest.cpp
|
||||
// Purpose: Tests for various wxPickerBase based classes
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-08-07
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_COLOURPICKERCTRL || \
|
||||
wxUSE_DIRPICKERCTRL || \
|
||||
wxUSE_FILEPICKERCTRL || \
|
||||
wxUSE_FONTPICKERCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/clrpicker.h"
|
||||
#include "wx/filepicker.h"
|
||||
#include "wx/fontpicker.h"
|
||||
#include "pickerbasetest.h"
|
||||
#include "asserthelper.h"
|
||||
|
||||
#if wxUSE_COLOURPICKERCTRL
|
||||
|
||||
class ColourPickerCtrlTestCase : public PickerBaseTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ColourPickerCtrlTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxPickerBase *GetBase() const override { return m_colour; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( ColourPickerCtrlTestCase );
|
||||
wxPICKER_BASE_TESTS();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
wxColourPickerCtrl *m_colour;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ColourPickerCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ColourPickerCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ColourPickerCtrlTestCase,
|
||||
"ColourPickerCtrlTestCase" );
|
||||
|
||||
void ColourPickerCtrlTestCase::setUp()
|
||||
{
|
||||
m_colour = new wxColourPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
*wxBLACK, wxDefaultPosition,
|
||||
wxDefaultSize, wxCLRP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
void ColourPickerCtrlTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_colour);
|
||||
}
|
||||
|
||||
#endif //wxUSE_COLOURPICKERCTRL
|
||||
|
||||
#if wxUSE_DIRPICKERCTRL
|
||||
|
||||
class DirPickerCtrlTestCase : public PickerBaseTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DirPickerCtrlTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxPickerBase *GetBase() const override { return m_dir; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( DirPickerCtrlTestCase );
|
||||
wxPICKER_BASE_TESTS();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
wxDirPickerCtrl *m_dir;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(DirPickerCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( DirPickerCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DirPickerCtrlTestCase,
|
||||
"DirPickerCtrlTestCase" );
|
||||
|
||||
void DirPickerCtrlTestCase::setUp()
|
||||
{
|
||||
m_dir = new wxDirPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxEmptyString, wxDirSelectorPromptStr,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDIRP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
void DirPickerCtrlTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_dir);
|
||||
}
|
||||
|
||||
#endif //wxUSE_DIRPICKERCTRL
|
||||
|
||||
#if wxUSE_FILEPICKERCTRL
|
||||
|
||||
class FilePickerCtrlTestCase : public PickerBaseTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
FilePickerCtrlTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxPickerBase *GetBase() const override { return m_file; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( FilePickerCtrlTestCase );
|
||||
wxPICKER_BASE_TESTS();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
wxFilePickerCtrl *m_file;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(FilePickerCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FilePickerCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FilePickerCtrlTestCase,
|
||||
"FilePickerCtrlTestCase" );
|
||||
|
||||
void FilePickerCtrlTestCase::setUp()
|
||||
{
|
||||
m_file = new wxFilePickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxEmptyString, wxFileSelectorPromptStr,
|
||||
wxFileSelectorDefaultWildcardStr,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxFLP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
void FilePickerCtrlTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_file);
|
||||
}
|
||||
|
||||
#endif //wxUSE_FILEPICKERCTRL
|
||||
|
||||
#if wxUSE_FONTPICKERCTRL
|
||||
|
||||
class FontPickerCtrlTestCase : public PickerBaseTestCase,
|
||||
public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
FontPickerCtrlTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxPickerBase *GetBase() const override { return m_font; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( FontPickerCtrlTestCase );
|
||||
wxPICKER_BASE_TESTS();
|
||||
CPPUNIT_TEST( ColourSelection );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void ColourSelection();
|
||||
|
||||
wxFontPickerCtrl *m_font;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(FontPickerCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FontPickerCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontPickerCtrlTestCase,
|
||||
"FontPickerCtrlTestCase" );
|
||||
|
||||
void FontPickerCtrlTestCase::setUp()
|
||||
{
|
||||
m_font = new wxFontPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxNullFont, wxDefaultPosition, wxDefaultSize,
|
||||
wxFNTP_USE_TEXTCTRL);
|
||||
}
|
||||
|
||||
void FontPickerCtrlTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_font);
|
||||
}
|
||||
|
||||
void FontPickerCtrlTestCase::ColourSelection()
|
||||
{
|
||||
wxColour selectedColour(0xFF4269UL);
|
||||
|
||||
CHECK( m_font->GetSelectedColour() != selectedColour );
|
||||
|
||||
m_font->SetSelectedColour(selectedColour);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Font picker did not react to color selection",
|
||||
m_font->GetSelectedColour(), selectedColour);
|
||||
}
|
||||
#endif //wxUSE_FONTPICKERCTRL
|
||||
|
||||
#endif
|
||||
1846
libs/wxWidgets-3.3.1/tests/controls/propgridtest.cpp
Normal file
1846
libs/wxWidgets-3.3.1/tests/controls/propgridtest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
211
libs/wxWidgets-3.3.1/tests/controls/radioboxtest.cpp
Normal file
211
libs/wxWidgets-3.3.1/tests/controls/radioboxtest.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/radioboxtest.cpp
|
||||
// Purpose: wxRadioBox unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-14
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_RADIOBOX
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/radiobox.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/tooltip.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RadioBoxTestCase
|
||||
{
|
||||
protected:
|
||||
RadioBoxTestCase();
|
||||
~RadioBoxTestCase();
|
||||
|
||||
wxRadioBox* m_radio;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(RadioBoxTestCase);
|
||||
};
|
||||
|
||||
RadioBoxTestCase::RadioBoxTestCase()
|
||||
{
|
||||
wxArrayString choices;
|
||||
choices.push_back("item 0");
|
||||
choices.push_back("item 1");
|
||||
choices.push_back("item 2");
|
||||
|
||||
m_radio = new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "RadioBox",
|
||||
wxDefaultPosition, wxDefaultSize, choices);
|
||||
}
|
||||
|
||||
RadioBoxTestCase::~RadioBoxTestCase()
|
||||
{
|
||||
wxTheApp->GetTopWindow()->DestroyChildren();
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::FindString", "[radiobox][find]")
|
||||
{
|
||||
CHECK( m_radio->FindString("not here") == wxNOT_FOUND );
|
||||
CHECK( m_radio->FindString("item 1") == 1 );
|
||||
CHECK( m_radio->FindString("ITEM 2") == 2 );
|
||||
CHECK( m_radio->FindString("ITEM 2", true) == wxNOT_FOUND );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::RowColCount", "[radiobox]")
|
||||
{
|
||||
#ifndef __WXGTK__
|
||||
wxArrayString choices;
|
||||
choices.push_back("item 0");
|
||||
choices.push_back("item 1");
|
||||
choices.push_back("item 2");
|
||||
|
||||
m_radio = new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "RadioBox",
|
||||
wxDefaultPosition, wxDefaultSize, choices, 2);
|
||||
|
||||
CHECK( m_radio->GetColumnCount() == 2 );
|
||||
CHECK( m_radio->GetRowCount() == 2 );
|
||||
|
||||
m_radio = new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "RadioBox",
|
||||
wxDefaultPosition, wxDefaultSize, choices, 1,
|
||||
wxRA_SPECIFY_ROWS);
|
||||
|
||||
CHECK( m_radio->GetColumnCount() == 3 );
|
||||
CHECK( m_radio->GetRowCount() == 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::Enable", "[radiobox][enable]")
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
m_radio->Enable(false);
|
||||
|
||||
CHECK(!m_radio->IsItemEnabled(0));
|
||||
|
||||
m_radio->Enable(1, true);
|
||||
|
||||
CHECK(!m_radio->IsItemEnabled(0));
|
||||
CHECK(m_radio->IsItemEnabled(1));
|
||||
CHECK(!m_radio->IsItemEnabled(2));
|
||||
|
||||
m_radio->Enable(true);
|
||||
|
||||
CHECK(m_radio->IsItemEnabled(0));
|
||||
CHECK(m_radio->IsItemEnabled(1));
|
||||
CHECK(m_radio->IsItemEnabled(2));
|
||||
|
||||
m_radio->Enable(0, false);
|
||||
|
||||
CHECK(!m_radio->IsItemEnabled(0));
|
||||
CHECK(m_radio->IsItemEnabled(1));
|
||||
CHECK(m_radio->IsItemEnabled(2));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::Show", "[radiobox][show]")
|
||||
{
|
||||
m_radio->Show(false);
|
||||
|
||||
CHECK(!m_radio->IsItemShown(0));
|
||||
|
||||
m_radio->Show(1, true);
|
||||
|
||||
CHECK(!m_radio->IsItemShown(0));
|
||||
CHECK(m_radio->IsItemShown(1));
|
||||
CHECK(!m_radio->IsItemShown(2));
|
||||
|
||||
m_radio->Show(true);
|
||||
|
||||
CHECK(m_radio->IsItemShown(0));
|
||||
CHECK(m_radio->IsItemShown(1));
|
||||
CHECK(m_radio->IsItemShown(2));
|
||||
|
||||
m_radio->Show(0, false);
|
||||
|
||||
CHECK(!m_radio->IsItemShown(0));
|
||||
CHECK(m_radio->IsItemShown(1));
|
||||
CHECK(m_radio->IsItemShown(2));
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::HelpText", "[radiobox][help]")
|
||||
{
|
||||
CHECK( m_radio->GetItemHelpText(0) == wxEmptyString );
|
||||
|
||||
m_radio->SetItemHelpText(1, "Item 1 help");
|
||||
|
||||
CHECK( m_radio->GetItemHelpText(1) == "Item 1 help" );
|
||||
|
||||
m_radio->SetItemHelpText(1, "");
|
||||
|
||||
CHECK( m_radio->GetItemHelpText(1) == wxEmptyString );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::ToolTip", "[radiobox][tooltip]")
|
||||
{
|
||||
#if defined (__WXMSW__) || defined(__WXGTK__) || defined(__WXQT__)
|
||||
//GetItemToolTip returns null if there is no tooltip set
|
||||
CHECK(!m_radio->GetItemToolTip(0));
|
||||
|
||||
m_radio->SetItemToolTip(1, "Item 1 help");
|
||||
|
||||
CHECK( m_radio->GetItemToolTip(1)->GetTip() == "Item 1 help" );
|
||||
|
||||
m_radio->SetItemToolTip(1, "");
|
||||
|
||||
//However if we set a blank tip this does count as a tooltip
|
||||
CHECK(!m_radio->GetItemToolTip(1));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::Selection", "[radiobox][selection]")
|
||||
{
|
||||
//Until other item containers the first item is selected by default
|
||||
CHECK( m_radio->GetSelection() == 0 );
|
||||
CHECK( m_radio->GetStringSelection() == "item 0" );
|
||||
|
||||
m_radio->SetSelection(1);
|
||||
|
||||
CHECK( m_radio->GetSelection() == 1 );
|
||||
CHECK( m_radio->GetStringSelection() == "item 1" );
|
||||
|
||||
m_radio->SetStringSelection("item 2");
|
||||
|
||||
CHECK( m_radio->GetSelection() == 2 );
|
||||
CHECK( m_radio->GetStringSelection() == "item 2" );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::Count", "[radiobox]")
|
||||
{
|
||||
//A trivial test for the item count as items can neither
|
||||
//be added or removed
|
||||
CHECK( m_radio->GetCount() == 3 );
|
||||
CHECK(!m_radio->IsEmpty());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioBoxTestCase, "RadioBox::SetString", "[radiobox]")
|
||||
{
|
||||
m_radio->SetString(0, "new item 0");
|
||||
m_radio->SetString(2, "");
|
||||
|
||||
CHECK( m_radio->GetString(0) == "new item 0" );
|
||||
CHECK( m_radio->GetString(2) == "" );
|
||||
}
|
||||
|
||||
TEST_CASE("RadioBox::NoItems", "[radiobox]")
|
||||
{
|
||||
std::unique_ptr<wxRadioBox>
|
||||
radio(new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "Empty",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
0, nullptr,
|
||||
1, wxRA_SPECIFY_COLS));
|
||||
|
||||
CHECK( radio->GetCount() == 0 );
|
||||
CHECK( radio->IsEmpty() );
|
||||
|
||||
CHECK_NOTHROW( radio->SetFocus() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_RADIOBOX
|
||||
276
libs/wxWidgets-3.3.1/tests/controls/radiobuttontest.cpp
Normal file
276
libs/wxWidgets-3.3.1/tests/controls/radiobuttontest.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/radiobuttontest.cpp
|
||||
// Purpose: wxRadioButton unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-30
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_RADIOBTN
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/panel.h"
|
||||
#include "wx/radiobut.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/stattext.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/uiaction.h"
|
||||
#include "testableframe.h"
|
||||
#include "testwindow.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RadioButtonTestCase
|
||||
{
|
||||
public:
|
||||
RadioButtonTestCase();
|
||||
~RadioButtonTestCase();
|
||||
|
||||
protected:
|
||||
wxRadioButton* m_radio;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(RadioButtonTestCase);
|
||||
};
|
||||
|
||||
RadioButtonTestCase::RadioButtonTestCase()
|
||||
{
|
||||
m_radio = new wxRadioButton(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
"wxRadioButton");
|
||||
m_radio->Update();
|
||||
m_radio->Refresh();
|
||||
}
|
||||
|
||||
RadioButtonTestCase::~RadioButtonTestCase()
|
||||
{
|
||||
delete m_radio;
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Click", "[radiobutton]")
|
||||
{
|
||||
// OS X doesn't support selecting a single radio button
|
||||
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__)
|
||||
EventCounter selected(m_radio, wxEVT_RADIOBUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
wxYield();
|
||||
|
||||
sim.MouseMove(m_radio->GetScreenPosition() + wxPoint(10, 10));
|
||||
sim.MouseClick();
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK(selected.GetCount() == 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Value", "[radiobutton]")
|
||||
{
|
||||
#ifndef __WXGTK__
|
||||
EventCounter selected(m_radio, wxEVT_RADIOBUTTON);
|
||||
|
||||
m_radio->SetValue(true);
|
||||
|
||||
CHECK(m_radio->GetValue());
|
||||
|
||||
m_radio->SetValue(false);
|
||||
|
||||
CHECK(!m_radio->GetValue());
|
||||
|
||||
CHECK(selected.GetCount() == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Group", "[radiobutton]")
|
||||
{
|
||||
wxWindow* const parent = wxTheApp->GetTopWindow();
|
||||
|
||||
// Create two different radio groups.
|
||||
std::unique_ptr<wxRadioButton> g1radio0(new wxRadioButton(parent, wxID_ANY, "radio 1.0",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxRB_GROUP));
|
||||
|
||||
std::unique_ptr<wxRadioButton> g1radio1(new wxRadioButton(parent, wxID_ANY, "radio 1.1"));
|
||||
|
||||
std::unique_ptr<wxRadioButton> g2radio0(new wxRadioButton(parent, wxID_ANY, "radio 2.0",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxRB_GROUP));
|
||||
|
||||
std::unique_ptr<wxRadioButton> g2radio1(new wxRadioButton(parent, wxID_ANY, "radio 2.1"));
|
||||
|
||||
// Check that having another control between radio buttons doesn't break
|
||||
// grouping.
|
||||
std::unique_ptr<wxStaticText> text(new wxStaticText(parent, wxID_ANY, "Label"));
|
||||
std::unique_ptr<wxRadioButton> g2radio2(new wxRadioButton(parent, wxID_ANY, "radio 2.2"));
|
||||
|
||||
g1radio0->SetValue(true);
|
||||
g2radio0->SetValue(true);
|
||||
|
||||
CHECK(g1radio0->GetValue());
|
||||
CHECK(!g1radio1->GetValue());
|
||||
CHECK(g2radio0->GetValue());
|
||||
CHECK(!g2radio1->GetValue());
|
||||
|
||||
g1radio1->SetValue(true);
|
||||
g2radio1->SetValue(true);
|
||||
|
||||
CHECK(!g1radio0->GetValue());
|
||||
CHECK(g1radio1->GetValue());
|
||||
CHECK(!g2radio0->GetValue());
|
||||
CHECK(g2radio1->GetValue());
|
||||
|
||||
g2radio2->SetValue(true);
|
||||
CHECK(!g2radio0->GetValue());
|
||||
CHECK(!g2radio1->GetValue());
|
||||
CHECK(g2radio2->GetValue());
|
||||
|
||||
g1radio0->SetValue(true);
|
||||
g2radio0->SetValue(true);
|
||||
|
||||
CHECK(g1radio0->GetValue());
|
||||
CHECK(!g1radio1->GetValue());
|
||||
CHECK(g2radio0->GetValue());
|
||||
CHECK(!g2radio1->GetValue());
|
||||
|
||||
|
||||
// Check that group navigation functions behave as expected.
|
||||
|
||||
// GetFirstInGroup()
|
||||
CHECK_SAME_WINDOW(g1radio0->GetFirstInGroup(), g1radio0);
|
||||
CHECK_SAME_WINDOW(g1radio1->GetFirstInGroup(), g1radio0);
|
||||
|
||||
CHECK_SAME_WINDOW(g2radio0->GetFirstInGroup(), g2radio0);
|
||||
CHECK_SAME_WINDOW(g2radio1->GetFirstInGroup(), g2radio0);
|
||||
CHECK_SAME_WINDOW(g2radio2->GetFirstInGroup(), g2radio0);
|
||||
|
||||
// GetLastInGroup()
|
||||
CHECK_SAME_WINDOW(g1radio0->GetLastInGroup(), g1radio1);
|
||||
CHECK_SAME_WINDOW(g1radio1->GetLastInGroup(), g1radio1);
|
||||
|
||||
CHECK_SAME_WINDOW(g2radio0->GetLastInGroup(), g2radio2);
|
||||
CHECK_SAME_WINDOW(g2radio1->GetLastInGroup(), g2radio2);
|
||||
CHECK_SAME_WINDOW(g2radio2->GetLastInGroup(), g2radio2);
|
||||
|
||||
// GetNextInGroup()
|
||||
CHECK_SAME_WINDOW(g1radio0->GetNextInGroup(), g1radio1);
|
||||
CHECK_SAME_WINDOW(g1radio1->GetNextInGroup(), nullptr);
|
||||
|
||||
CHECK_SAME_WINDOW(g2radio0->GetNextInGroup(), g2radio1);
|
||||
CHECK_SAME_WINDOW(g2radio1->GetNextInGroup(), g2radio2);
|
||||
CHECK_SAME_WINDOW(g2radio2->GetNextInGroup(), nullptr);
|
||||
|
||||
// GetPreviousInGroup()
|
||||
CHECK_SAME_WINDOW(g1radio0->GetPreviousInGroup(), nullptr);
|
||||
CHECK_SAME_WINDOW(g1radio1->GetPreviousInGroup(), g1radio0);
|
||||
|
||||
CHECK_SAME_WINDOW(g2radio0->GetPreviousInGroup(), nullptr);
|
||||
CHECK_SAME_WINDOW(g2radio1->GetPreviousInGroup(), g2radio0);
|
||||
CHECK_SAME_WINDOW(g2radio2->GetPreviousInGroup(), g2radio1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(RadioButtonTestCase, "RadioButton::Single", "[radiobutton]")
|
||||
{
|
||||
//Create a group of 2 buttons, having second button selected
|
||||
std::unique_ptr<wxRadioButton> gradio0(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, wxRB_GROUP));
|
||||
|
||||
std::unique_ptr<wxRadioButton> gradio1(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton"));
|
||||
|
||||
gradio1->SetValue(true);
|
||||
|
||||
//Create a "single" button (by default it will not be selected)
|
||||
std::unique_ptr<wxRadioButton> sradio(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize, wxRB_SINGLE));
|
||||
|
||||
//Create a non-grouped button and select it
|
||||
std::unique_ptr<wxRadioButton> ngradio(new wxRadioButton(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY, "wxRadioButton"));
|
||||
|
||||
ngradio->SetValue(true);
|
||||
|
||||
//Select the "single" button
|
||||
sradio->SetValue(true);
|
||||
|
||||
CHECK(gradio1->GetValue());
|
||||
CHECK(ngradio->GetValue());
|
||||
|
||||
// Also check that navigation works as expected with "single" buttons.
|
||||
CHECK_SAME_WINDOW(sradio->GetFirstInGroup(), sradio);
|
||||
CHECK_SAME_WINDOW(sradio->GetLastInGroup(), sradio);
|
||||
CHECK_SAME_WINDOW(sradio->GetPreviousInGroup(), nullptr);
|
||||
CHECK_SAME_WINDOW(sradio->GetNextInGroup(), nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("RadioButton::Focus", "[radiobutton][focus]")
|
||||
{
|
||||
// Create a container panel just to be able to destroy all the windows
|
||||
// created here at once by simply destroying it.
|
||||
wxWindow* const tlw = wxTheApp->GetTopWindow();
|
||||
std::unique_ptr<wxPanel> parentPanel(new wxPanel(tlw));
|
||||
|
||||
// Create a panel containing 2 radio buttons and another control outside
|
||||
// this panel, so that we could give focus to something different and then
|
||||
// return it back to the panel.
|
||||
wxPanel* const radioPanel = new wxPanel(parentPanel.get());
|
||||
wxRadioButton* const radio1 = new wxRadioButton(radioPanel, wxID_ANY, "1");
|
||||
wxRadioButton* const radio2 = new wxRadioButton(radioPanel, wxID_ANY, "2");
|
||||
wxSizer* const radioSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
radioSizer->Add(radio1);
|
||||
radioSizer->Add(radio2);
|
||||
radioPanel->SetSizer(radioSizer);
|
||||
|
||||
wxButton* const dummyButton = new wxButton(parentPanel.get(), wxID_OK);
|
||||
|
||||
wxSizer* const sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->Add(radioPanel, wxSizerFlags(1).Expand());
|
||||
sizer->Add(dummyButton, wxSizerFlags().Expand());
|
||||
parentPanel->SetSizer(sizer);
|
||||
|
||||
parentPanel->SetSize(tlw->GetClientSize());
|
||||
parentPanel->Layout();
|
||||
|
||||
// Initially the first radio button should be checked.
|
||||
radio1->SetFocus();
|
||||
CHECK(radio1->GetValue());
|
||||
CHECK_FOCUS_IS(radio1);
|
||||
|
||||
// Switching focus from it shouldn't change this.
|
||||
dummyButton->SetFocus();
|
||||
CHECK(radio1->GetValue());
|
||||
|
||||
// Checking another radio button should make it checked and uncheck the
|
||||
// first one.
|
||||
radio2->SetValue(true);
|
||||
CHECK(!radio1->GetValue());
|
||||
CHECK(radio2->GetValue());
|
||||
|
||||
// While not changing focus.
|
||||
CHECK_FOCUS_IS(dummyButton);
|
||||
|
||||
// And giving the focus to the panel shouldn't change radio button
|
||||
// selection.
|
||||
radioPanel->SetFocus();
|
||||
|
||||
// Under MSW, focus is always on the selected button, but in the other
|
||||
// ports this is not necessarily the case, i.e. under wxGTK this check
|
||||
// would fail because focus gets set to the first button -- even though the
|
||||
// second one remains checked.
|
||||
#ifdef __WXMSW__
|
||||
CHECK_FOCUS_IS(radio2);
|
||||
#endif
|
||||
|
||||
CHECK(!radio1->GetValue());
|
||||
CHECK(radio2->GetValue());
|
||||
}
|
||||
|
||||
#endif //wxUSE_RADIOBTN
|
||||
158
libs/wxWidgets-3.3.1/tests/controls/rearrangelisttest.cpp
Normal file
158
libs/wxWidgets-3.3.1/tests/controls/rearrangelisttest.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/rearrangelisttest.cpp
|
||||
// Purpose: wxRearrangeList unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-05
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifndef __WXOSX_IPHONE__
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/rearrangectrl.h"
|
||||
#include "itemcontainertest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
class RearrangeListTestCase : public ItemContainerTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
RearrangeListTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxItemContainer *GetContainer() const override { return m_rearrange; }
|
||||
virtual wxWindow *GetContainerWindow() const override { return m_rearrange; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( RearrangeListTestCase );
|
||||
wxITEM_CONTAINER_TESTS();
|
||||
CPPUNIT_TEST( Move );
|
||||
CPPUNIT_TEST( MoveClientData );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Move();
|
||||
void MoveClientData();
|
||||
|
||||
wxRearrangeList* m_rearrange;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(RearrangeListTestCase);
|
||||
};
|
||||
|
||||
wxREGISTER_UNIT_TEST_WITH_TAGS(RearrangeListTestCase,
|
||||
"[RearrangeListTestCase][item-container]");
|
||||
|
||||
void RearrangeListTestCase::setUp()
|
||||
{
|
||||
//We do not add items here as the wxITEM_CONTAINER_TESTS add their own
|
||||
wxArrayInt order;
|
||||
wxArrayString items;
|
||||
|
||||
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, order,
|
||||
items);
|
||||
}
|
||||
|
||||
void RearrangeListTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_rearrange);
|
||||
}
|
||||
|
||||
void RearrangeListTestCase::Move()
|
||||
{
|
||||
wxArrayInt order;
|
||||
order.push_back(1);
|
||||
order.push_back(~2);
|
||||
order.push_back(0);
|
||||
|
||||
wxArrayString items;
|
||||
items.push_back("first");
|
||||
items.push_back("second");
|
||||
items.push_back("third");
|
||||
|
||||
wxDELETE(m_rearrange);
|
||||
|
||||
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, order,
|
||||
items);
|
||||
|
||||
//Confusingly setselection sets the physical item rather than the
|
||||
//item specified in the constructor
|
||||
m_rearrange->SetSelection(0);
|
||||
|
||||
CPPUNIT_ASSERT(!m_rearrange->CanMoveCurrentUp());
|
||||
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentDown());
|
||||
|
||||
m_rearrange->SetSelection(1);
|
||||
|
||||
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentUp());
|
||||
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentDown());
|
||||
|
||||
m_rearrange->SetSelection(2);
|
||||
|
||||
CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentUp());
|
||||
CPPUNIT_ASSERT(!m_rearrange->CanMoveCurrentDown());
|
||||
|
||||
m_rearrange->MoveCurrentUp();
|
||||
m_rearrange->SetSelection(0);
|
||||
m_rearrange->MoveCurrentDown();
|
||||
|
||||
wxArrayInt neworder = m_rearrange->GetCurrentOrder();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(neworder[0], 0);
|
||||
CPPUNIT_ASSERT_EQUAL(neworder[1], 1);
|
||||
CPPUNIT_ASSERT_EQUAL(neworder[2], ~2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("first", m_rearrange->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("second", m_rearrange->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("third", m_rearrange->GetString(2));
|
||||
}
|
||||
|
||||
void RearrangeListTestCase::MoveClientData()
|
||||
{
|
||||
wxArrayInt order;
|
||||
order.push_back(0);
|
||||
order.push_back(1);
|
||||
order.push_back(2);
|
||||
|
||||
wxArrayString items;
|
||||
items.push_back("first");
|
||||
items.push_back("second");
|
||||
items.push_back("third");
|
||||
|
||||
wxClientData* item0data = new wxStringClientData("item0data");
|
||||
wxClientData* item1data = new wxStringClientData("item1data");
|
||||
wxClientData* item2data = new wxStringClientData("item2data");
|
||||
|
||||
wxDELETE(m_rearrange);
|
||||
|
||||
m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize, order,
|
||||
items);
|
||||
|
||||
m_rearrange->SetClientObject(0, item0data);
|
||||
m_rearrange->SetClientObject(1, item1data);
|
||||
m_rearrange->SetClientObject(2, item2data);
|
||||
|
||||
m_rearrange->SetSelection(0);
|
||||
m_rearrange->MoveCurrentDown();
|
||||
|
||||
m_rearrange->SetSelection(2);
|
||||
m_rearrange->MoveCurrentUp();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(item1data, m_rearrange->GetClientObject(0));
|
||||
CPPUNIT_ASSERT_EQUAL(item2data, m_rearrange->GetClientObject(1));
|
||||
CPPUNIT_ASSERT_EQUAL(item0data, m_rearrange->GetClientObject(2));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("second", m_rearrange->GetString(0));
|
||||
CPPUNIT_ASSERT_EQUAL("third", m_rearrange->GetString(1));
|
||||
CPPUNIT_ASSERT_EQUAL("first", m_rearrange->GetString(2));
|
||||
}
|
||||
|
||||
#endif
|
||||
881
libs/wxWidgets-3.3.1/tests/controls/richtextctrltest.cpp
Normal file
881
libs/wxWidgets-3.3.1/tests/controls/richtextctrltest.cpp
Normal file
@@ -0,0 +1,881 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/richtextctrltest.cpp
|
||||
// Purpose: wxRichTextCtrl unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-07
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_RICHTEXT
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/richtext/richtextctrl.h"
|
||||
#include "wx/richtext/richtextstyles.h"
|
||||
#include "testableframe.h"
|
||||
#include "asserthelper.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
class RichTextCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
RichTextCtrlTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( RichTextCtrlTestCase );
|
||||
CPPUNIT_TEST( IsModified );
|
||||
WXUISIM_TEST( CharacterEvent );
|
||||
WXUISIM_TEST( DeleteEvent );
|
||||
WXUISIM_TEST( ReturnEvent );
|
||||
CPPUNIT_TEST( StyleEvent );
|
||||
CPPUNIT_TEST( BufferResetEvent );
|
||||
WXUISIM_TEST( UrlEvent );
|
||||
WXUISIM_TEST( TextEvent );
|
||||
CPPUNIT_TEST( CutCopyPaste );
|
||||
CPPUNIT_TEST( UndoRedo );
|
||||
CPPUNIT_TEST( CaretPosition );
|
||||
CPPUNIT_TEST( Selection );
|
||||
WXUISIM_TEST( Editable );
|
||||
CPPUNIT_TEST( Range );
|
||||
CPPUNIT_TEST( Alignment );
|
||||
CPPUNIT_TEST( Bold );
|
||||
CPPUNIT_TEST( Italic );
|
||||
CPPUNIT_TEST( Underline );
|
||||
CPPUNIT_TEST( Indent );
|
||||
CPPUNIT_TEST( LineSpacing );
|
||||
CPPUNIT_TEST( ParagraphSpacing );
|
||||
CPPUNIT_TEST( TextColour );
|
||||
CPPUNIT_TEST( NumberedBullet );
|
||||
CPPUNIT_TEST( SymbolBullet );
|
||||
CPPUNIT_TEST( FontSize );
|
||||
CPPUNIT_TEST( Font );
|
||||
CPPUNIT_TEST( Delete );
|
||||
CPPUNIT_TEST( Url );
|
||||
CPPUNIT_TEST( Table );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void IsModified();
|
||||
void CharacterEvent();
|
||||
void DeleteEvent();
|
||||
void ReturnEvent();
|
||||
void StyleEvent();
|
||||
void BufferResetEvent();
|
||||
void UrlEvent();
|
||||
void TextEvent();
|
||||
void CutCopyPaste();
|
||||
void UndoRedo();
|
||||
void CaretPosition();
|
||||
void Selection();
|
||||
void Editable();
|
||||
void Range();
|
||||
void Alignment();
|
||||
void Bold();
|
||||
void Italic();
|
||||
void Underline();
|
||||
void Indent();
|
||||
void LineSpacing();
|
||||
void ParagraphSpacing();
|
||||
void TextColour();
|
||||
void NumberedBullet();
|
||||
void SymbolBullet();
|
||||
void FontSize();
|
||||
void Font();
|
||||
void Delete();
|
||||
void Url();
|
||||
void Table();
|
||||
|
||||
wxRichTextCtrl* m_rich;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(RichTextCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( RichTextCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RichTextCtrlTestCase, "RichTextCtrlTestCase" );
|
||||
|
||||
void RichTextCtrlTestCase::setUp()
|
||||
{
|
||||
m_rich = new wxRichTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxSize(400, 200), wxWANTS_CHARS);
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_rich);
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::IsModified()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( false, m_rich->IsModified() );
|
||||
m_rich->WriteText("abcdef");
|
||||
CPPUNIT_ASSERT_EQUAL( true, m_rich->IsModified() );
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::CharacterEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
EventCounter character(m_rich, wxEVT_RICHTEXT_CHARACTER);
|
||||
EventCounter content(m_rich, wxEVT_RICHTEXT_CONTENT_INSERTED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
sim.Text("abcdef");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(6, character.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(6, content.GetCount());
|
||||
|
||||
character.Clear();
|
||||
content.Clear();
|
||||
|
||||
//As these are not characters they shouldn't count
|
||||
sim.Char(WXK_RETURN);
|
||||
sim.Char(WXK_SHIFT);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, character.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, content.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::DeleteEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
EventCounter deleteevent(m_rich, wxEVT_RICHTEXT_DELETE);
|
||||
EventCounter contentdelete(m_rich, wxEVT_RICHTEXT_CONTENT_DELETED);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
sim.Text("abcdef");
|
||||
sim.Char(WXK_BACK);
|
||||
sim.Char(WXK_DELETE);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, deleteevent.GetCount());
|
||||
//Only one as the delete doesn't delete anthing
|
||||
CPPUNIT_ASSERT_EQUAL(1, contentdelete.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::ReturnEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
EventCounter returnevent(m_rich, wxEVT_RICHTEXT_RETURN);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
sim.Char(WXK_RETURN);
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, returnevent.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::StyleEvent()
|
||||
{
|
||||
EventCounter stylechanged(m_rich, wxEVT_RICHTEXT_STYLE_CHANGED);
|
||||
|
||||
m_rich->SetValue("Sometext");
|
||||
m_rich->SetStyle(0, 8, wxTextAttr(*wxRED, *wxWHITE));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, stylechanged.GetCount());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::BufferResetEvent()
|
||||
{
|
||||
EventCounter reset(m_rich, wxEVT_RICHTEXT_BUFFER_RESET);
|
||||
|
||||
m_rich->AppendText("more text!");
|
||||
m_rich->SetValue("");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, reset.GetCount());
|
||||
|
||||
reset.Clear();
|
||||
m_rich->AppendText("more text!");
|
||||
m_rich->Clear();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, reset.GetCount());
|
||||
|
||||
reset.Clear();
|
||||
|
||||
//We expect a buffer reset here as setvalue clears the existing text
|
||||
m_rich->SetValue("replace");
|
||||
CPPUNIT_ASSERT_EQUAL(1, reset.GetCount());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::UrlEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
EventCounter url(m_rich, wxEVT_TEXT_URL);
|
||||
|
||||
m_rich->BeginURL("http://www.wxwidgets.org");
|
||||
m_rich->WriteText("http://www.wxwidgets.org");
|
||||
m_rich->EndURL();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
sim.MouseMove(m_rich->ClientToScreen(wxPoint(10, 10)));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, url.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::TextEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter updated(m_rich, wxEVT_TEXT);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
sim.Text("abcdef");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::CutCopyPaste()
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
m_rich->AppendText("sometext");
|
||||
m_rich->SelectAll();
|
||||
|
||||
if(m_rich->CanCut() && m_rich->CanPaste())
|
||||
{
|
||||
m_rich->Cut();
|
||||
CPPUNIT_ASSERT(m_rich->IsEmpty());
|
||||
|
||||
wxYield();
|
||||
|
||||
m_rich->Paste();
|
||||
CPPUNIT_ASSERT_EQUAL("sometext", m_rich->GetValue());
|
||||
}
|
||||
|
||||
m_rich->SelectAll();
|
||||
|
||||
if(m_rich->CanCopy() && m_rich->CanPaste())
|
||||
{
|
||||
m_rich->Copy();
|
||||
m_rich->Clear();
|
||||
CPPUNIT_ASSERT(m_rich->IsEmpty());
|
||||
|
||||
wxYield();
|
||||
|
||||
m_rich->Paste();
|
||||
CPPUNIT_ASSERT_EQUAL("sometext", m_rich->GetValue());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::UndoRedo()
|
||||
{
|
||||
m_rich->AppendText("sometext");
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->CanUndo());
|
||||
|
||||
m_rich->Undo();
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsEmpty());
|
||||
CPPUNIT_ASSERT(m_rich->CanRedo());
|
||||
|
||||
m_rich->Redo();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("sometext", m_rich->GetValue());
|
||||
|
||||
m_rich->AppendText("Batch undo");
|
||||
m_rich->SelectAll();
|
||||
|
||||
//Also test batch operations
|
||||
m_rich->BeginBatchUndo("batchtest");
|
||||
|
||||
m_rich->ApplyBoldToSelection();
|
||||
m_rich->ApplyItalicToSelection();
|
||||
|
||||
m_rich->EndBatchUndo();
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->CanUndo());
|
||||
|
||||
m_rich->Undo();
|
||||
|
||||
CPPUNIT_ASSERT(!m_rich->IsSelectionBold());
|
||||
CPPUNIT_ASSERT(!m_rich->IsSelectionItalics());
|
||||
CPPUNIT_ASSERT(m_rich->CanRedo());
|
||||
|
||||
m_rich->Redo();
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionBold());
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionItalics());
|
||||
|
||||
//And surpressing undo
|
||||
m_rich->BeginSuppressUndo();
|
||||
|
||||
m_rich->AppendText("Can't undo this");
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->CanUndo());
|
||||
|
||||
m_rich->EndSuppressUndo();
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::CaretPosition()
|
||||
{
|
||||
m_rich->AddParagraph("This is paragraph one");
|
||||
m_rich->AddParagraph("Paragraph two\n has \nlots of\n lines");
|
||||
|
||||
m_rich->SetInsertionPoint(2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, m_rich->GetCaretPosition());
|
||||
|
||||
m_rich->MoveToParagraphStart();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_rich->GetCaretPosition());
|
||||
|
||||
m_rich->MoveRight();
|
||||
m_rich->MoveRight(2);
|
||||
m_rich->MoveLeft(1);
|
||||
m_rich->MoveLeft(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, m_rich->GetCaretPosition());
|
||||
|
||||
m_rich->MoveToParagraphEnd();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(21, m_rich->GetCaretPosition());
|
||||
|
||||
m_rich->MoveToLineStart();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_rich->GetCaretPosition());
|
||||
|
||||
m_rich->MoveToLineEnd();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(21, m_rich->GetCaretPosition());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Selection()
|
||||
{
|
||||
m_rich->SetValue("some more text");
|
||||
|
||||
m_rich->SelectAll();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("some more text", m_rich->GetStringSelection());
|
||||
|
||||
m_rich->SelectNone();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("", m_rich->GetStringSelection());
|
||||
|
||||
m_rich->SelectWord(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("some", m_rich->GetStringSelection());
|
||||
|
||||
m_rich->SetSelection(5, 14);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("more text", m_rich->GetStringSelection());
|
||||
|
||||
wxRichTextRange range(5, 9);
|
||||
|
||||
m_rich->SetSelectionRange(range);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("more", m_rich->GetStringSelection());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Editable()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter updated(m_rich, wxEVT_TEXT);
|
||||
|
||||
m_rich->SetFocus();
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
sim.Text("abcdef");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
|
||||
updated.Clear();
|
||||
|
||||
m_rich->SetEditable(false);
|
||||
sim.Text("gh");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Range()
|
||||
{
|
||||
wxRichTextRange range(0, 10);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, range.GetStart());
|
||||
CPPUNIT_ASSERT_EQUAL(10, range.GetEnd());
|
||||
CPPUNIT_ASSERT_EQUAL(11, range.GetLength());
|
||||
CPPUNIT_ASSERT(range.Contains(5));
|
||||
|
||||
wxRichTextRange outside(12, 14);
|
||||
|
||||
CPPUNIT_ASSERT(outside.IsOutside(range));
|
||||
|
||||
wxRichTextRange inside(6, 7);
|
||||
|
||||
CPPUNIT_ASSERT(inside.IsWithin(range));
|
||||
|
||||
range.LimitTo(inside);
|
||||
|
||||
CPPUNIT_ASSERT(inside == range);
|
||||
CPPUNIT_ASSERT(inside + range == outside);
|
||||
CPPUNIT_ASSERT(outside - range == inside);
|
||||
|
||||
range.SetStart(4);
|
||||
range.SetEnd(6);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(4, range.GetStart());
|
||||
CPPUNIT_ASSERT_EQUAL(6, range.GetEnd());
|
||||
CPPUNIT_ASSERT_EQUAL(3, range.GetLength());
|
||||
|
||||
inside.SetRange(6, 4);
|
||||
inside.Swap();
|
||||
|
||||
CPPUNIT_ASSERT(inside == range);
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Alignment()
|
||||
{
|
||||
m_rich->SetValue("text to align");
|
||||
m_rich->SelectAll();
|
||||
|
||||
m_rich->ApplyAlignmentToSelection(wxTEXT_ALIGNMENT_RIGHT);
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionAligned(wxTEXT_ALIGNMENT_RIGHT));
|
||||
|
||||
m_rich->BeginAlignment(wxTEXT_ALIGNMENT_CENTRE);
|
||||
m_rich->AddParagraph("middle aligned");
|
||||
m_rich->EndAlignment();
|
||||
|
||||
m_rich->SetSelection(20, 25);
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionAligned(wxTEXT_ALIGNMENT_CENTRE));
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Bold()
|
||||
{
|
||||
m_rich->SetValue("text to bold");
|
||||
m_rich->SelectAll();
|
||||
m_rich->ApplyBoldToSelection();
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionBold());
|
||||
|
||||
m_rich->BeginBold();
|
||||
m_rich->AddParagraph("bold paragraph");
|
||||
m_rich->EndBold();
|
||||
m_rich->AddParagraph("not bold paragraph");
|
||||
|
||||
m_rich->SetSelection(15, 20);
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionBold());
|
||||
|
||||
m_rich->SetSelection(30, 35);
|
||||
|
||||
CPPUNIT_ASSERT(!m_rich->IsSelectionBold());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Italic()
|
||||
{
|
||||
m_rich->SetValue("text to italic");
|
||||
m_rich->SelectAll();
|
||||
m_rich->ApplyItalicToSelection();
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionItalics());
|
||||
|
||||
m_rich->BeginItalic();
|
||||
m_rich->AddParagraph("italic paragraph");
|
||||
m_rich->EndItalic();
|
||||
m_rich->AddParagraph("not italic paragraph");
|
||||
|
||||
m_rich->SetSelection(20, 25);
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionItalics());
|
||||
|
||||
m_rich->SetSelection(35, 40);
|
||||
|
||||
CPPUNIT_ASSERT(!m_rich->IsSelectionItalics());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Underline()
|
||||
{
|
||||
m_rich->SetValue("text to underline");
|
||||
m_rich->SelectAll();
|
||||
m_rich->ApplyUnderlineToSelection();
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionUnderlined());
|
||||
|
||||
m_rich->BeginUnderline();
|
||||
m_rich->AddParagraph("underline paragraph");
|
||||
m_rich->EndUnderline();
|
||||
m_rich->AddParagraph("not underline paragraph");
|
||||
|
||||
m_rich->SetSelection(20, 25);
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->IsSelectionUnderlined());
|
||||
|
||||
m_rich->SetSelection(40, 45);
|
||||
|
||||
CPPUNIT_ASSERT(!m_rich->IsSelectionUnderlined());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Indent()
|
||||
{
|
||||
m_rich->BeginLeftIndent(12, -5);
|
||||
m_rich->BeginRightIndent(14);
|
||||
m_rich->AddParagraph("A paragraph with indents");
|
||||
m_rich->EndLeftIndent();
|
||||
m_rich->EndRightIndent();
|
||||
m_rich->AddParagraph("No more indent");
|
||||
|
||||
wxTextAttr indent;
|
||||
m_rich->GetStyle(5, indent);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(12, indent.GetLeftIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(-5, indent.GetLeftSubIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(14, indent.GetRightIndent());
|
||||
|
||||
m_rich->GetStyle(35, indent);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, indent.GetLeftIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(0, indent.GetLeftSubIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(0, indent.GetRightIndent());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::LineSpacing()
|
||||
{
|
||||
m_rich->BeginLineSpacing(20);
|
||||
m_rich->AddParagraph("double spaced");
|
||||
m_rich->EndLineSpacing();
|
||||
m_rich->BeginLineSpacing(wxTEXT_ATTR_LINE_SPACING_HALF);
|
||||
m_rich->AddParagraph("1.5 spaced");
|
||||
m_rich->EndLineSpacing();
|
||||
m_rich->AddParagraph("normally spaced");
|
||||
|
||||
wxTextAttr spacing;
|
||||
m_rich->GetStyle(5, spacing);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(20, spacing.GetLineSpacing());
|
||||
|
||||
m_rich->GetStyle(20, spacing);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(15, spacing.GetLineSpacing());
|
||||
|
||||
m_rich->GetStyle(30, spacing);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(10, spacing.GetLineSpacing());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::ParagraphSpacing()
|
||||
{
|
||||
m_rich->BeginParagraphSpacing(15, 20);
|
||||
m_rich->AddParagraph("spaced paragraph");
|
||||
m_rich->EndParagraphSpacing();
|
||||
m_rich->AddParagraph("non-spaced paragraph");
|
||||
|
||||
wxTextAttr spacing;
|
||||
m_rich->GetStyle(5, spacing);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(15, spacing.GetParagraphSpacingBefore());
|
||||
CPPUNIT_ASSERT_EQUAL(20, spacing.GetParagraphSpacingAfter());
|
||||
|
||||
m_rich->GetStyle(25, spacing);
|
||||
|
||||
//Make sure we test against the defaults
|
||||
CPPUNIT_ASSERT_EQUAL(m_rich->GetBasicStyle().GetParagraphSpacingBefore(),
|
||||
spacing.GetParagraphSpacingBefore());
|
||||
CPPUNIT_ASSERT_EQUAL(m_rich->GetBasicStyle().GetParagraphSpacingAfter(),
|
||||
spacing.GetParagraphSpacingAfter());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::TextColour()
|
||||
{
|
||||
m_rich->BeginTextColour(*wxRED);
|
||||
m_rich->AddParagraph("red paragraph");
|
||||
m_rich->EndTextColour();
|
||||
m_rich->AddParagraph("default paragraph");
|
||||
|
||||
wxTextAttr colour;
|
||||
m_rich->GetStyle(5, colour);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(*wxRED, colour.GetTextColour());
|
||||
|
||||
m_rich->GetStyle(25, colour);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(m_rich->GetBasicStyle().GetTextColour(),
|
||||
colour.GetTextColour());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::NumberedBullet()
|
||||
{
|
||||
m_rich->BeginNumberedBullet(1, 15, 20);
|
||||
m_rich->AddParagraph("bullet one");
|
||||
m_rich->EndNumberedBullet();
|
||||
m_rich->BeginNumberedBullet(2, 25, -5);
|
||||
m_rich->AddParagraph("bullet two");
|
||||
m_rich->EndNumberedBullet();
|
||||
|
||||
wxTextAttr bullet;
|
||||
m_rich->GetStyle(5, bullet);
|
||||
|
||||
CPPUNIT_ASSERT(bullet.HasBulletStyle());
|
||||
CPPUNIT_ASSERT(bullet.HasBulletNumber());
|
||||
CPPUNIT_ASSERT_EQUAL(1, bullet.GetBulletNumber());
|
||||
CPPUNIT_ASSERT_EQUAL(15, bullet.GetLeftIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(20, bullet.GetLeftSubIndent());
|
||||
|
||||
m_rich->GetStyle(15, bullet);
|
||||
|
||||
CPPUNIT_ASSERT(bullet.HasBulletStyle());
|
||||
CPPUNIT_ASSERT(bullet.HasBulletNumber());
|
||||
CPPUNIT_ASSERT_EQUAL(2, bullet.GetBulletNumber());
|
||||
CPPUNIT_ASSERT_EQUAL(25, bullet.GetLeftIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(-5, bullet.GetLeftSubIndent());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::SymbolBullet()
|
||||
{
|
||||
m_rich->BeginSymbolBullet("*", 15, 20);
|
||||
m_rich->AddParagraph("bullet one");
|
||||
m_rich->EndSymbolBullet();
|
||||
m_rich->BeginSymbolBullet("%", 25, -5);
|
||||
m_rich->AddParagraph("bullet two");
|
||||
m_rich->EndSymbolBullet();
|
||||
|
||||
wxTextAttr bullet;
|
||||
m_rich->GetStyle(5, bullet);
|
||||
|
||||
CPPUNIT_ASSERT(bullet.HasBulletStyle());
|
||||
CPPUNIT_ASSERT(bullet.HasBulletText());
|
||||
CPPUNIT_ASSERT_EQUAL("*", bullet.GetBulletText());
|
||||
CPPUNIT_ASSERT_EQUAL(15, bullet.GetLeftIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(20, bullet.GetLeftSubIndent());
|
||||
|
||||
m_rich->GetStyle(15, bullet);
|
||||
|
||||
CPPUNIT_ASSERT(bullet.HasBulletStyle());
|
||||
CPPUNIT_ASSERT(bullet.HasBulletText());
|
||||
CPPUNIT_ASSERT_EQUAL("%", bullet.GetBulletText());
|
||||
CPPUNIT_ASSERT_EQUAL(25, bullet.GetLeftIndent());
|
||||
CPPUNIT_ASSERT_EQUAL(-5, bullet.GetLeftSubIndent());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::FontSize()
|
||||
{
|
||||
m_rich->BeginFontSize(24);
|
||||
m_rich->AddParagraph("Large text");
|
||||
m_rich->EndFontSize();
|
||||
|
||||
wxTextAttr size;
|
||||
m_rich->GetStyle(5, size);
|
||||
|
||||
CPPUNIT_ASSERT(size.HasFontSize());
|
||||
CPPUNIT_ASSERT_EQUAL(24, size.GetFontSize());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Font()
|
||||
{
|
||||
wxFont font(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
m_rich->BeginFont(font);
|
||||
m_rich->AddParagraph("paragraph with font");
|
||||
m_rich->EndFont();
|
||||
|
||||
wxTextAttr fontstyle;
|
||||
m_rich->GetStyle(5, fontstyle);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(font, fontstyle.GetFont());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Delete()
|
||||
{
|
||||
m_rich->AddParagraph("here is a long long line in a paragraph");
|
||||
m_rich->SetSelection(0, 6);
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->CanDeleteSelection());
|
||||
|
||||
m_rich->DeleteSelection();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("is a long long line in a paragraph", m_rich->GetValue());
|
||||
|
||||
m_rich->SetSelection(0, 5);
|
||||
|
||||
CPPUNIT_ASSERT(m_rich->CanDeleteSelection());
|
||||
|
||||
m_rich->DeleteSelectedContent();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("long long line in a paragraph", m_rich->GetValue());
|
||||
|
||||
m_rich->Delete(wxRichTextRange(14, 29));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("long long line", m_rich->GetValue());
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Url()
|
||||
{
|
||||
m_rich->BeginURL("http://www.wxwidgets.org");
|
||||
m_rich->WriteText("http://www.wxwidgets.org");
|
||||
m_rich->EndURL();
|
||||
|
||||
wxTextAttr url;
|
||||
m_rich->GetStyle(5, url);
|
||||
|
||||
CPPUNIT_ASSERT(url.HasURL());
|
||||
CPPUNIT_ASSERT_EQUAL("http://www.wxwidgets.org", url.GetURL());
|
||||
}
|
||||
|
||||
// Helper function for ::Table()
|
||||
wxRichTextTable* GetCurrentTableInstance(wxRichTextParagraph* para)
|
||||
{
|
||||
wxRichTextTable* table = wxDynamicCast(para->FindObjectAtPosition(0), wxRichTextTable);
|
||||
CPPUNIT_ASSERT(table);
|
||||
return table;
|
||||
}
|
||||
|
||||
void RichTextCtrlTestCase::Table()
|
||||
{
|
||||
m_rich->BeginSuppressUndo();
|
||||
wxRichTextTable* table = m_rich->WriteTable(1, 1);
|
||||
m_rich->EndSuppressUndo();
|
||||
CPPUNIT_ASSERT(table);
|
||||
CPPUNIT_ASSERT(m_rich->CanUndo() == false);
|
||||
|
||||
// Run the tests twice: first for the original table, then for a contained one
|
||||
for (int t = 0; t < 2; ++t)
|
||||
{
|
||||
// Undo() and Redo() switch table instances, so invalidating 'table'
|
||||
// The containing paragraph isn't altered, and so can be used to find the current object
|
||||
wxRichTextParagraph* para = wxDynamicCast(table->GetParent(), wxRichTextParagraph);
|
||||
CPPUNIT_ASSERT(para);
|
||||
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 1);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 1);
|
||||
|
||||
// Test adding columns and rows
|
||||
for (size_t n = 0; n < 3; ++n)
|
||||
{
|
||||
m_rich->BeginBatchUndo("Add col and row");
|
||||
|
||||
table->AddColumns(0, 1);
|
||||
table->AddRows(0, 1);
|
||||
|
||||
m_rich->EndBatchUndo();
|
||||
}
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 4);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 4);
|
||||
|
||||
// Test deleting columns and rows
|
||||
for (size_t n = 0; n < 3; ++n)
|
||||
{
|
||||
m_rich->BeginBatchUndo("Delete col and row");
|
||||
|
||||
table->DeleteColumns(table->GetColumnCount() - 1, 1);
|
||||
table->DeleteRows(table->GetRowCount() - 1, 1);
|
||||
|
||||
m_rich->EndBatchUndo();
|
||||
}
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 1);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 1);
|
||||
|
||||
// Test undo, first of the deletions...
|
||||
CPPUNIT_ASSERT(m_rich->CanUndo());
|
||||
for (size_t n = 0; n < 3; ++n)
|
||||
{
|
||||
m_rich->Undo();
|
||||
}
|
||||
table = GetCurrentTableInstance(para);
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 4);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 4);
|
||||
|
||||
// ...then the additions
|
||||
for (size_t n = 0; n < 3; ++n)
|
||||
{
|
||||
m_rich->Undo();
|
||||
}
|
||||
table = GetCurrentTableInstance(para);
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 1);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 1);
|
||||
CPPUNIT_ASSERT(m_rich->CanUndo() == false);
|
||||
|
||||
// Similarly test redo. Additions:
|
||||
CPPUNIT_ASSERT(m_rich->CanRedo());
|
||||
for (size_t n = 0; n < 3; ++n)
|
||||
{
|
||||
m_rich->Redo();
|
||||
}
|
||||
table = GetCurrentTableInstance(para);
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 4);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 4);
|
||||
|
||||
// Deletions:
|
||||
for (size_t n = 0; n < 3; ++n)
|
||||
{
|
||||
m_rich->Redo();
|
||||
}
|
||||
table = GetCurrentTableInstance(para);
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 1);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 1);
|
||||
CPPUNIT_ASSERT(m_rich->CanRedo() == false);
|
||||
|
||||
// Now test multiple addition and deletion, and also suppression
|
||||
m_rich->BeginSuppressUndo();
|
||||
table->AddColumns(0, 3);
|
||||
table->AddRows(0, 3);
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 4);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 4);
|
||||
|
||||
// Only delete 2 of these. This makes it easy to be sure we're dealing with the child table when we loop
|
||||
table->DeleteColumns(0, 2);
|
||||
table->DeleteRows(0, 2);
|
||||
CPPUNIT_ASSERT(table->GetColumnCount() == 2);
|
||||
CPPUNIT_ASSERT(table->GetRowCount() == 2);
|
||||
m_rich->EndSuppressUndo();
|
||||
|
||||
m_rich->GetCommandProcessor()->ClearCommands(); // otherwise the command-history from this loop will cause CPPUNIT_ASSERT failures in the next one
|
||||
|
||||
if (t == 0)
|
||||
{
|
||||
// For round 2, re-run the tests on another table inside the last cell of the first one
|
||||
wxRichTextCell* cell = table->GetCell(table->GetRowCount() - 1, table->GetColumnCount() - 1);
|
||||
CPPUNIT_ASSERT(cell);
|
||||
m_rich->SetFocusObject(cell);
|
||||
m_rich->BeginSuppressUndo();
|
||||
table = m_rich->WriteTable(1, 1);
|
||||
m_rich->EndSuppressUndo();
|
||||
CPPUNIT_ASSERT(table);
|
||||
}
|
||||
}
|
||||
|
||||
// Test ClearTable()
|
||||
table->ClearTable();
|
||||
CPPUNIT_ASSERT_EQUAL(0, table->GetCells().GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, table->GetColumnCount());
|
||||
CPPUNIT_ASSERT_EQUAL(0, table->GetRowCount());
|
||||
|
||||
m_rich->Clear();
|
||||
m_rich->SetFocusObject(nullptr);
|
||||
}
|
||||
|
||||
#endif //wxUSE_RICHTEXT
|
||||
125
libs/wxWidgets-3.3.1/tests/controls/searchctrltest.cpp
Normal file
125
libs/wxWidgets-3.3.1/tests/controls/searchctrltest.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/searchctrltest.cpp
|
||||
// Purpose: wxSearchCtrl unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2013-01-20
|
||||
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_SEARCHCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/srchctrl.h"
|
||||
|
||||
#include "testwindow.h"
|
||||
|
||||
class SearchCtrlTestCase
|
||||
{
|
||||
public:
|
||||
SearchCtrlTestCase()
|
||||
: m_search(new wxSearchCtrl(wxTheApp->GetTopWindow(), wxID_ANY))
|
||||
{
|
||||
}
|
||||
|
||||
~SearchCtrlTestCase()
|
||||
{
|
||||
delete m_search;
|
||||
}
|
||||
|
||||
void CheckStringSelection(const char *sel)
|
||||
{
|
||||
wxTextEntry * const entry = m_search;
|
||||
CHECK( sel == entry->GetStringSelection() );
|
||||
}
|
||||
|
||||
void AssertSelection(int from, int to, const char *sel)
|
||||
{
|
||||
wxTextEntry * const entry = m_search;
|
||||
|
||||
CHECK( entry->HasSelection() );
|
||||
|
||||
long fromReal,
|
||||
toReal;
|
||||
entry->GetSelection(&fromReal, &toReal);
|
||||
CHECK( from == fromReal );
|
||||
CHECK( to == toReal );
|
||||
|
||||
CHECK( from == entry->GetInsertionPoint() );
|
||||
|
||||
CheckStringSelection(sel);
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSearchCtrl* const m_search;
|
||||
};
|
||||
|
||||
#define SEARCH_CTRL_TEST_CASE(name, tags) \
|
||||
TEST_CASE_METHOD(SearchCtrlTestCase, name, tags)
|
||||
|
||||
// TODO OS X test only passes when run solo ...
|
||||
#ifndef __WXOSX__
|
||||
SEARCH_CTRL_TEST_CASE("wxSearchCtrl::Focus", "[wxSearchCtrl][focus]")
|
||||
{
|
||||
m_search->SetFocus();
|
||||
CHECK_FOCUS_IS( m_search );
|
||||
}
|
||||
#endif // !__WXOSX__
|
||||
|
||||
SEARCH_CTRL_TEST_CASE("wxSearchCtrl::ChangeValue", "[wxSearchCtrl][text]")
|
||||
{
|
||||
CHECK( m_search->GetValue() == wxString() );
|
||||
|
||||
m_search->ChangeValue("foo");
|
||||
CHECK( m_search->GetValue() == "foo" );
|
||||
|
||||
m_search->Clear();
|
||||
CHECK( m_search->GetValue() == "" );
|
||||
}
|
||||
|
||||
SEARCH_CTRL_TEST_CASE("wxSearchCtrl::SetValue", "[wxSearchCtrl][set_value]")
|
||||
{
|
||||
// Work around bug with hint implementation in wxGTK2.
|
||||
#if defined(__WXGTK__) && !defined(__WXGTK3__)
|
||||
m_search->Clear();
|
||||
#endif
|
||||
CHECK( m_search->IsEmpty() );
|
||||
|
||||
m_search->SetValue("foo");
|
||||
CHECK( m_search->GetValue() == "foo" );
|
||||
|
||||
m_search->SetValue("");
|
||||
CHECK( m_search->IsEmpty() );
|
||||
|
||||
m_search->SetValue("hi");
|
||||
CHECK( "hi" == m_search->GetValue() );
|
||||
|
||||
m_search->SetValue("bye");
|
||||
CHECK( "bye" == m_search->GetValue() );
|
||||
}
|
||||
|
||||
SEARCH_CTRL_TEST_CASE("wxSearchCtrl::Selection", "[wxSearchCtrl][selection]")
|
||||
{
|
||||
wxTextEntry * const entry = m_search;
|
||||
|
||||
entry->SetValue("0123456789");
|
||||
|
||||
entry->SetSelection(2, 4);
|
||||
AssertSelection(2, 4, "23"); // not "234"!
|
||||
|
||||
entry->SetSelection(3, -1);
|
||||
AssertSelection(3, 10, "3456789");
|
||||
|
||||
entry->SelectAll();
|
||||
AssertSelection(0, 10, "0123456789");
|
||||
|
||||
entry->SetSelection(0, 0);
|
||||
CHECK( !entry->HasSelection() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_SEARCHCTRL
|
||||
66
libs/wxWidgets-3.3.1/tests/controls/simplebooktest.cpp
Normal file
66
libs/wxWidgets-3.3.1/tests/controls/simplebooktest.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/simplebooktest.cpp
|
||||
// Purpose: wxSimplebook unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2013-06-23
|
||||
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_BOOKCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/panel.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/simplebook.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
class SimplebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
SimplebookTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_simplebook; }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_BOOKCTRL_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_BOOKCTRL_PAGE_CHANGING; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( SimplebookTestCase );
|
||||
wxBOOK_CTRL_BASE_TESTS();
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
wxSimplebook *m_simplebook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(SimplebookTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( SimplebookTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SimplebookTestCase, "SimplebookTestCase" );
|
||||
|
||||
void SimplebookTestCase::setUp()
|
||||
{
|
||||
m_simplebook = new wxSimplebook(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
void SimplebookTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_simplebook);
|
||||
}
|
||||
|
||||
#endif // wxUSE_BOOKCTRL
|
||||
|
||||
234
libs/wxWidgets-3.3.1/tests/controls/slidertest.cpp
Normal file
234
libs/wxWidgets-3.3.1/tests/controls/slidertest.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/slidertest.cpp
|
||||
// Purpose: wxSlider unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-20
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_SLIDER
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/slider.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/uiaction.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
class SliderTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
SliderTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( SliderTestCase );
|
||||
#ifndef __WXOSX__
|
||||
WXUISIM_TEST( PageUpDown );
|
||||
WXUISIM_TEST( LineUpDown );
|
||||
WXUISIM_TEST( EvtSlider );
|
||||
WXUISIM_TEST( LinePageSize );
|
||||
#endif
|
||||
CPPUNIT_TEST( Value );
|
||||
CPPUNIT_TEST( Range );
|
||||
WXUISIM_TEST( Thumb );
|
||||
CPPUNIT_TEST( PseudoTest_Inversed );
|
||||
CPPUNIT_TEST( Value );
|
||||
CPPUNIT_TEST( Range );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void PageUpDown();
|
||||
void LineUpDown();
|
||||
void EvtSlider();
|
||||
void LinePageSize();
|
||||
void Value();
|
||||
void Range();
|
||||
void Thumb();
|
||||
void PseudoTest_Inversed() { ms_inversed = true; }
|
||||
|
||||
static bool ms_inversed;
|
||||
|
||||
wxSlider* m_slider;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(SliderTestCase);
|
||||
};
|
||||
|
||||
bool SliderTestCase::ms_inversed = false;
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( SliderTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SliderTestCase, "SliderTestCase" );
|
||||
|
||||
void SliderTestCase::setUp()
|
||||
{
|
||||
long style = wxSL_HORIZONTAL;
|
||||
|
||||
if ( ms_inversed )
|
||||
style |= wxSL_INVERSE;
|
||||
|
||||
m_slider = new wxSlider(wxTheApp->GetTopWindow(), wxID_ANY, 50, 0, 100,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
void SliderTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_slider);
|
||||
}
|
||||
|
||||
void SliderTestCase::PageUpDown()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter pageup(m_slider, wxEVT_SCROLL_PAGEUP);
|
||||
EventCounter pagedown(m_slider, wxEVT_SCROLL_PAGEDOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_slider->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_PAGEUP);
|
||||
sim.Char(WXK_PAGEDOWN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, pageup.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, pagedown.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void SliderTestCase::LineUpDown()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter lineup(m_slider, wxEVT_SCROLL_LINEUP);
|
||||
EventCounter linedown(m_slider, wxEVT_SCROLL_LINEDOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_slider->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
sim.Char(WXK_DOWN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, lineup.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, linedown.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void SliderTestCase::EvtSlider()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter slider(m_slider, wxEVT_SLIDER);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_slider->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
sim.Char(WXK_DOWN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, slider.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
void SliderTestCase::LinePageSize()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_slider->SetFocus();
|
||||
wxYield();
|
||||
|
||||
m_slider->SetPageSize(20);
|
||||
|
||||
sim.Char(WXK_PAGEUP);
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(20, m_slider->GetPageSize());
|
||||
CPPUNIT_ASSERT_EQUAL(30, m_slider->GetValue());
|
||||
|
||||
m_slider->SetLineSize(2);
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, m_slider->GetLineSize());
|
||||
CPPUNIT_ASSERT_EQUAL(28, m_slider->GetValue());
|
||||
#endif
|
||||
}
|
||||
|
||||
void SliderTestCase::Value()
|
||||
{
|
||||
m_slider->SetValue(30);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(30, m_slider->GetValue());
|
||||
|
||||
//When setting a value larger that max or smaller than min
|
||||
//max and min are set
|
||||
m_slider->SetValue(-1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_slider->GetValue());
|
||||
|
||||
m_slider->SetValue(110);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(100, m_slider->GetValue());
|
||||
}
|
||||
|
||||
void SliderTestCase::Range()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_slider->GetMin());
|
||||
CPPUNIT_ASSERT_EQUAL(100, m_slider->GetMax());
|
||||
|
||||
// Changing range shouldn't change the value.
|
||||
m_slider->SetValue(17);
|
||||
m_slider->SetRange(0, 200);
|
||||
CPPUNIT_ASSERT_EQUAL(17, m_slider->GetValue());
|
||||
|
||||
//Test negative ranges
|
||||
m_slider->SetRange(-50, 0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(-50, m_slider->GetMin());
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_slider->GetMax());
|
||||
}
|
||||
|
||||
void SliderTestCase::Thumb()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter track(m_slider, wxEVT_SCROLL_THUMBTRACK);
|
||||
EventCounter release(m_slider, wxEVT_SCROLL_THUMBRELEASE);
|
||||
EventCounter changed(m_slider, wxEVT_SCROLL_CHANGED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_slider->SetValue(0);
|
||||
|
||||
// use the slider real position for dragging the mouse.
|
||||
const int ypos = m_slider->GetSize().y / 2;
|
||||
sim.MouseDragDrop(m_slider->ClientToScreen(wxPoint(10, ypos)),m_slider->ClientToScreen(wxPoint(50, ypos)));
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT(track.GetCount() != 0);
|
||||
CPPUNIT_ASSERT_EQUAL(1, release.GetCount());
|
||||
#if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXQT__)
|
||||
CPPUNIT_ASSERT_EQUAL(1, changed.GetCount());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
295
libs/wxWidgets-3.3.1/tests/controls/spinctrldbltest.cpp
Normal file
295
libs/wxWidgets-3.3.1/tests/controls/spinctrldbltest.cpp
Normal file
@@ -0,0 +1,295 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/spinctrldbltest.cpp
|
||||
// Purpose: wxSpinCtrlDouble unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-22
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_SPINCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/spinctrl.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class SpinCtrlDoubleTestCase
|
||||
{
|
||||
public:
|
||||
SpinCtrlDoubleTestCase(int style = wxSP_ARROW_KEYS)
|
||||
: m_spin(new wxSpinCtrlDouble(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style))
|
||||
{
|
||||
}
|
||||
|
||||
~SpinCtrlDoubleTestCase()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrlDouble* const m_spin;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(SpinCtrlDoubleTestCase);
|
||||
};
|
||||
|
||||
class SpinCtrlDoubleTestCaseWrap : public SpinCtrlDoubleTestCase
|
||||
{
|
||||
public:
|
||||
SpinCtrlDoubleTestCaseWrap()
|
||||
: SpinCtrlDoubleTestCase(wxSP_ARROW_KEYS | wxSP_WRAP)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST_CASE("SpinCtrlDouble::NoEventsInCtor", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
// Verify that creating the control does not generate any events. This is
|
||||
// unexpected and shouldn't happen.
|
||||
std::unique_ptr<wxSpinCtrlDouble> m_spin(new wxSpinCtrlDouble);
|
||||
|
||||
EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
|
||||
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
0., 100., 17.);
|
||||
|
||||
CHECK( updatedSpin.GetCount() == 0 );
|
||||
CHECK( updatedText.GetCount() == 0 );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
"SpinCtrlDouble::Arrows", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
EventCounter updated(m_spin, wxEVT_SPINCTRLDOUBLE);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_spin->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
wxYield();
|
||||
|
||||
CHECK( updated.GetCount() == 1 );
|
||||
CHECK( m_spin->GetValue() == 1.0 );
|
||||
updated.Clear();
|
||||
|
||||
sim.Char(WXK_DOWN);
|
||||
wxYield();
|
||||
|
||||
CHECK( updated.GetCount() == 1 );
|
||||
CHECK( m_spin->GetValue() == 0.0 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCaseWrap,
|
||||
"SpinCtrlDouble::Wrap", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_spin->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_DOWN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK( m_spin->GetValue() == 100.0 );
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK( m_spin->GetValue() == 0.0 );
|
||||
}
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
"SpinCtrlDouble::Range", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
CHECK( m_spin->GetMin() == 0.0 );
|
||||
CHECK( m_spin->GetMax() == 100.0 );
|
||||
|
||||
// Test that the value is adjusted to be inside the new valid range but
|
||||
// that this doesn't result in any events (as this is not something done by
|
||||
// the user).
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
|
||||
m_spin->SetRange(1., 10.);
|
||||
CHECK( m_spin->GetValue() == 1. );
|
||||
|
||||
CHECK( updatedSpin.GetCount() == 0 );
|
||||
CHECK( updatedText.GetCount() == 0 );
|
||||
}
|
||||
|
||||
//Test negative ranges
|
||||
m_spin->SetRange(-10.0, 10.0);
|
||||
|
||||
CHECK( m_spin->GetMin() == -10.0 );
|
||||
CHECK( m_spin->GetMax() == 10.0 );
|
||||
|
||||
#ifndef __WXQT__
|
||||
//Test backwards ranges
|
||||
m_spin->SetRange(75.0, 50.0);
|
||||
|
||||
CHECK( m_spin->GetMin() == 75.0 );
|
||||
CHECK( m_spin->GetMax() == 50.0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
"SpinCtrlDouble::Value", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRLDOUBLE);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
|
||||
m_spin->SetDigits(2);
|
||||
m_spin->SetIncrement(0.1);
|
||||
|
||||
CHECK( m_spin->GetValue() == 0.0 );
|
||||
|
||||
m_spin->SetValue(50.0);
|
||||
CHECK( m_spin->GetValue() == 50.0 );
|
||||
|
||||
m_spin->SetValue(49.1);
|
||||
CHECK( m_spin->GetValue() == 49.1 );
|
||||
|
||||
// Calling SetValue() shouldn't have generated any events.
|
||||
CHECK( updatedSpin.GetCount() == 0 );
|
||||
CHECK( updatedText.GetCount() == 0 );
|
||||
|
||||
// Also test that setting the text value works.
|
||||
CHECK( m_spin->GetTextValue() == "49.10" );
|
||||
|
||||
m_spin->SetValue("57.30");
|
||||
CHECK( m_spin->GetTextValue() == "57.30" );
|
||||
CHECK( m_spin->GetValue() == 57.3 );
|
||||
|
||||
CHECK( updatedSpin.GetCount() == 0 );
|
||||
CHECK( updatedText.GetCount() == 0 );
|
||||
|
||||
m_spin->SetValue("");
|
||||
#ifndef __WXQT__
|
||||
CHECK( m_spin->GetTextValue() == "" );
|
||||
#else
|
||||
CHECK( m_spin->GetTextValue() == "0.00" ); // the control automatically displays minVal
|
||||
#endif
|
||||
CHECK( m_spin->GetValue() == 0 );
|
||||
|
||||
CHECK( updatedSpin.GetCount() == 0 );
|
||||
CHECK( updatedText.GetCount() == 0 );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
"SpinCtrlDouble::Increment", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
CHECK( m_spin->GetIncrement() == 1.0 );
|
||||
|
||||
m_spin->SetDigits(1);
|
||||
m_spin->SetIncrement(0.1);
|
||||
|
||||
CHECK( m_spin->GetIncrement() == 0.1 );
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_spin->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK( m_spin->GetValue() == 0.1 );
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlDoubleTestCase,
|
||||
"SpinCtrlDouble::Digits", "[spinctrl][spinctrldouble]")
|
||||
{
|
||||
// Setting increment should adjust the number of digits shown to be big
|
||||
// enough to show numbers with the corresponding granularity.
|
||||
m_spin->SetIncrement(0.1);
|
||||
m_spin->SetValue(1.23456789);
|
||||
CHECK( m_spin->GetTextValue() == "1.2" );
|
||||
|
||||
m_spin->SetIncrement(0.01);
|
||||
m_spin->SetValue(1.23456789);
|
||||
CHECK( m_spin->GetTextValue() == "1.23" );
|
||||
|
||||
m_spin->SetDigits(5);
|
||||
CHECK( m_spin->GetDigits() == 5 );
|
||||
m_spin->SetValue(1.23456789);
|
||||
CHECK( m_spin->GetTextValue() == "1.23457" );
|
||||
|
||||
// The number of digits shouldn't (implicitly) decrease however.
|
||||
m_spin->SetIncrement(0.001);
|
||||
m_spin->SetValue(1.23456789);
|
||||
CHECK( m_spin->GetTextValue() == "1.23457" );
|
||||
|
||||
// Check that using increment greater than 1 also works.
|
||||
m_spin->SetDigits(0);
|
||||
m_spin->SetIncrement(2.5);
|
||||
m_spin->SetValue(7.5);
|
||||
CHECK( m_spin->GetTextValue() == "7.5" );
|
||||
}
|
||||
|
||||
static inline unsigned int GetInitialDigits(double inc)
|
||||
{
|
||||
std::unique_ptr<wxSpinCtrlDouble> sc(new wxSpinCtrlDouble
|
||||
(
|
||||
wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxEmptyString,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxSP_ARROW_KEYS,
|
||||
0, 50, 0,
|
||||
inc
|
||||
));
|
||||
return sc->GetDigits();
|
||||
}
|
||||
|
||||
TEST_CASE("SpinCtrlDouble::InitialDigits", "[spinctrldouble][initialdigits]")
|
||||
{
|
||||
REQUIRE(GetInitialDigits(15) == 0);
|
||||
REQUIRE(GetInitialDigits(10) == 0);
|
||||
REQUIRE(GetInitialDigits(1) == 0);
|
||||
REQUIRE(GetInitialDigits(0.999) == 1);
|
||||
REQUIRE(GetInitialDigits(0.15) == 1);
|
||||
REQUIRE(GetInitialDigits(0.11) == 1);
|
||||
REQUIRE(GetInitialDigits(0.1) == 1);
|
||||
REQUIRE(GetInitialDigits(0.0999) == 2);
|
||||
REQUIRE(GetInitialDigits(0.015) == 2);
|
||||
REQUIRE(GetInitialDigits(0.011) == 2);
|
||||
REQUIRE(GetInitialDigits(0.01) == 2);
|
||||
REQUIRE(GetInitialDigits(9.99e-5) == 5);
|
||||
REQUIRE(GetInitialDigits(1e-5) == 5);
|
||||
REQUIRE(GetInitialDigits(9.9999e-10) == 10);
|
||||
REQUIRE(GetInitialDigits(1e-10) == 10);
|
||||
REQUIRE(GetInitialDigits(9.9999e-20) == 20);
|
||||
REQUIRE(GetInitialDigits(1e-20) == 20);
|
||||
REQUIRE(GetInitialDigits(9.9999e-21) == 20);
|
||||
REQUIRE(GetInitialDigits(1e-21) == 20);
|
||||
REQUIRE(GetInitialDigits(9.9999e-22) == 20);
|
||||
REQUIRE(GetInitialDigits(1e-22) == 20);
|
||||
}
|
||||
|
||||
#endif
|
||||
403
libs/wxWidgets-3.3.1/tests/controls/spinctrltest.cpp
Normal file
403
libs/wxWidgets-3.3.1/tests/controls/spinctrltest.cpp
Normal file
@@ -0,0 +1,403 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/spinctrltest.cpp
|
||||
// Purpose: wxSpinCtrl unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-21
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_SPINCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/spinctrl.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
class SpinCtrlTestCase1
|
||||
{
|
||||
public:
|
||||
SpinCtrlTestCase1()
|
||||
: m_spin(new wxSpinCtrl())
|
||||
{
|
||||
}
|
||||
|
||||
~SpinCtrlTestCase1()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrl* m_spin;
|
||||
};
|
||||
|
||||
class SpinCtrlTestCase2
|
||||
{
|
||||
public:
|
||||
SpinCtrlTestCase2()
|
||||
: m_spin(new wxSpinCtrl(wxTheApp->GetTopWindow()))
|
||||
{
|
||||
}
|
||||
|
||||
~SpinCtrlTestCase2()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrl* m_spin;
|
||||
};
|
||||
|
||||
class SpinCtrlTestCase3
|
||||
{
|
||||
public:
|
||||
SpinCtrlTestCase3()
|
||||
: m_spin(new wxSpinCtrl(wxTheApp->GetTopWindow()))
|
||||
{
|
||||
m_spin->Bind(wxEVT_SPINCTRL, &SpinCtrlTestCase3::OnSpinSetValue, this);
|
||||
}
|
||||
|
||||
~SpinCtrlTestCase3()
|
||||
{
|
||||
delete m_spin;
|
||||
}
|
||||
|
||||
private:
|
||||
void OnSpinSetValue(wxSpinEvent &e)
|
||||
{
|
||||
// Constrain the value to be in the 1..16 range or 32.
|
||||
int newVal = e.GetValue();
|
||||
|
||||
if ( newVal == 31 )
|
||||
m_spin->SetValue(16);
|
||||
else if ( newVal > 16 )
|
||||
m_spin->SetValue(32);
|
||||
}
|
||||
|
||||
protected:
|
||||
wxSpinCtrl* m_spin;
|
||||
};
|
||||
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Init", "[spinctrl]")
|
||||
{
|
||||
// Initial value is defined by "initial" argument which is 0 by default.
|
||||
CHECK(m_spin->GetValue() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::Init2", "[spinctrl]")
|
||||
{
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
0, 100, 17);
|
||||
|
||||
// Recreate the control with another "initial" to check this.
|
||||
CHECK(m_spin->GetValue() == 17);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::Init3", "[spinctrl]")
|
||||
{
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
0, 200, 150);
|
||||
|
||||
// Recreate the control with another "initial" outside of standard spin
|
||||
// ctrl range.
|
||||
CHECK(m_spin->GetValue() == 150);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::Init4", "[spinctrl]")
|
||||
{
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "99",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
0, 100, 17);
|
||||
|
||||
// Recreate the control with another "initial" outside of standard spin
|
||||
// ctrl range.
|
||||
// But if the text string is specified, it takes precedence.
|
||||
CHECK(m_spin->GetValue() == 99);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::InitOutOfRange", "[spinctrl]")
|
||||
{
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
10, 20, 0);
|
||||
|
||||
// Recreate the control with another "initial" outside of the valid range:
|
||||
// it shouldn't be taken into account.
|
||||
CHECK(m_spin->GetValue() == 10);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::NoEventsInCtor", "[spinctrl]")
|
||||
{
|
||||
// Verify that creating the control does not generate any events. This is
|
||||
// unexpected and shouldn't happen.
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize, 0,
|
||||
0, 100, 17);
|
||||
|
||||
CHECK(updatedSpin.GetCount() == 0);
|
||||
CHECK(updatedText.GetCount() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Arrows", "[spinctrl]")
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter updated(m_spin, wxEVT_SPINCTRL);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_spin->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK(updated.GetCount() == 1);
|
||||
CHECK(m_spin->GetValue() == 1);
|
||||
updated.Clear();
|
||||
|
||||
sim.Char(WXK_DOWN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK(updated.GetCount() == 1);
|
||||
CHECK(m_spin->GetValue() == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::Wrap", "[spinctrl]")
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS | wxSP_WRAP);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_spin->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_DOWN);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK(m_spin->GetValue() == 100);
|
||||
|
||||
sim.Char(WXK_UP);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK(m_spin->GetValue() == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Range", "[spinctrl]")
|
||||
{
|
||||
CHECK(m_spin->GetMin() == 0);
|
||||
CHECK(m_spin->GetMax() == 100);
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
// Test that the value is adjusted to be inside the new valid range but
|
||||
// that this doesn't result in any events (as this is not something done by
|
||||
// the user).
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
|
||||
m_spin->SetRange(1, 10);
|
||||
CHECK(m_spin->GetValue() == 1);
|
||||
|
||||
CHECK(updatedSpin.GetCount() == 0);
|
||||
CHECK(updatedText.GetCount() == 0);
|
||||
}
|
||||
|
||||
// Test negative ranges
|
||||
m_spin->SetRange(-10, 10);
|
||||
|
||||
CHECK(m_spin->GetMin() == -10);
|
||||
CHECK(m_spin->GetMax() == 10);
|
||||
|
||||
// With base 16 only ranges including values >= 0 are allowed
|
||||
m_spin->SetRange(0, 10);
|
||||
int oldMinVal = m_spin->GetMin();
|
||||
int oldMaxVal = m_spin->GetMax();
|
||||
CHECK(oldMinVal == 0);
|
||||
CHECK(oldMaxVal == 10);
|
||||
|
||||
CHECK(m_spin->SetBase(16) == true);
|
||||
CHECK(m_spin->GetBase() == 16);
|
||||
|
||||
// New range should be silently ignored
|
||||
m_spin->SetRange(-20, 20);
|
||||
CHECK(m_spin->GetMin() == oldMinVal);
|
||||
CHECK(m_spin->GetMax() == oldMaxVal);
|
||||
|
||||
// This range should be accepted
|
||||
m_spin->SetRange(2, 8);
|
||||
CHECK(m_spin->GetMin() == 2);
|
||||
CHECK(m_spin->GetMax() == 8);
|
||||
|
||||
CHECK(m_spin->SetBase(10) == true);
|
||||
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
#ifndef __WXQT__
|
||||
//Test backwards ranges
|
||||
m_spin->SetRange(75, 50);
|
||||
|
||||
CHECK(m_spin->GetMin() == 75);
|
||||
CHECK(m_spin->GetMax() == 50);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Value", "[spinctrl]")
|
||||
{
|
||||
EventCounter updatedSpin(m_spin, wxEVT_SPINCTRL);
|
||||
EventCounter updatedText(m_spin, wxEVT_TEXT);
|
||||
|
||||
CHECK(m_spin->GetValue() == 0);
|
||||
|
||||
m_spin->SetValue(50);
|
||||
CHECK(m_spin->GetValue() == 50);
|
||||
|
||||
m_spin->SetValue(-10);
|
||||
CHECK(m_spin->GetValue() == 0);
|
||||
|
||||
m_spin->SetValue(110);
|
||||
CHECK(m_spin->GetValue() == 100);
|
||||
|
||||
// Calling SetValue() shouldn't have generated any events.
|
||||
CHECK(updatedSpin.GetCount() == 0);
|
||||
CHECK(updatedText.GetCount() == 0);
|
||||
|
||||
// Also test that setting the text value works.
|
||||
CHECK( m_spin->GetTextValue() == "100" );
|
||||
|
||||
m_spin->SetValue("57");
|
||||
CHECK( m_spin->GetTextValue() == "57" );
|
||||
CHECK( m_spin->GetValue() == 57 );
|
||||
|
||||
CHECK(updatedSpin.GetCount() == 0);
|
||||
CHECK(updatedText.GetCount() == 0);
|
||||
|
||||
m_spin->SetValue("");
|
||||
#ifndef __WXQT__
|
||||
CHECK( m_spin->GetTextValue() == "" );
|
||||
#else
|
||||
CHECK( m_spin->GetTextValue() == "0" ); // the control automatically displays minVal
|
||||
#endif
|
||||
CHECK( m_spin->GetValue() == 0 );
|
||||
|
||||
CHECK(updatedSpin.GetCount() == 0);
|
||||
CHECK(updatedText.GetCount() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase2, "SpinCtrl::Base", "[spinctrl]")
|
||||
{
|
||||
CHECK(m_spin->GetMin() == 0);
|
||||
CHECK(m_spin->GetMax() == 100);
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
// Only 10 and 16 bases are allowed
|
||||
CHECK(m_spin->SetBase(10) == true);
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
CHECK_FALSE(m_spin->SetBase(8));
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
CHECK_FALSE(m_spin->SetBase(2));
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
CHECK(m_spin->SetBase(16) == true);
|
||||
CHECK(m_spin->GetBase() == 16);
|
||||
|
||||
CHECK(m_spin->SetBase(10) == true);
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
// When range contains negative values only base 10 is allowed
|
||||
m_spin->SetRange(-10, 10);
|
||||
CHECK(m_spin->GetMin() == -10);
|
||||
CHECK(m_spin->GetMax() == 10);
|
||||
|
||||
CHECK_FALSE(m_spin->SetBase(8));
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
CHECK_FALSE(m_spin->SetBase(2));
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
CHECK_FALSE(m_spin->SetBase(16));
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
|
||||
CHECK(m_spin->SetBase(10) == true);
|
||||
CHECK(m_spin->GetBase() == 10);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase3, "SpinCtrl::SetValueInsideEventHandler", "[spinctrl]")
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
// A dummy control with which we change the focus.
|
||||
wxTextCtrl* text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
text->Move(m_spin->GetSize().x, m_spin->GetSize().y * 3);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
// run multiple times to make sure there are no issues with keeping old value
|
||||
for ( size_t i = 0; i < 2; i++ )
|
||||
{
|
||||
m_spin->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_DELETE);
|
||||
sim.Char(WXK_DELETE);
|
||||
sim.Text("20");
|
||||
wxYield();
|
||||
|
||||
text->SetFocus();
|
||||
wxYield();
|
||||
|
||||
CHECK(m_spin->GetValue() == 32);
|
||||
}
|
||||
|
||||
delete text;
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(SpinCtrlTestCase1, "SpinCtrl::Increment", "[spinctrl]")
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS | wxSP_WRAP);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
CHECK( m_spin->GetIncrement() == 1 );
|
||||
|
||||
m_spin->SetFocus();
|
||||
wxYield();
|
||||
m_spin->SetIncrement( 5 );
|
||||
sim.Char(WXK_UP);
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK(m_spin->GetValue() == 5);
|
||||
|
||||
int increment = m_spin->GetIncrement();
|
||||
|
||||
CHECK( increment == 5 );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
165
libs/wxWidgets-3.3.1/tests/controls/styledtextctrltest.cpp
Normal file
165
libs/wxWidgets-3.3.1/tests/controls/styledtextctrltest.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/styledtextctrltest.cpp
|
||||
// Purpose: wxStyledTextCtrl unit test
|
||||
// Author: New Pagodi
|
||||
// Created: 2019-03-10
|
||||
// Copyright: (c) 2019 wxWidgets development team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_STC
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/stc/stc.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
#include "testwindow.h"
|
||||
|
||||
#if defined(__WXOSX_COCOA__) || defined(__WXMSW__) || defined(__WXGTK__)
|
||||
|
||||
class StcPopupWindowsTestCase
|
||||
{
|
||||
public:
|
||||
StcPopupWindowsTestCase()
|
||||
: m_stc(new wxStyledTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY))
|
||||
{
|
||||
m_focusAlwaysRetained=true;
|
||||
m_calltipClickReceived=false;
|
||||
|
||||
m_stc->Bind(wxEVT_KILL_FOCUS,
|
||||
&StcPopupWindowsTestCase::OnKillSTCFocus, this);
|
||||
m_stc->Bind(wxEVT_STC_CALLTIP_CLICK,
|
||||
&StcPopupWindowsTestCase::OnCallTipClick, this);
|
||||
}
|
||||
|
||||
~StcPopupWindowsTestCase()
|
||||
{
|
||||
delete m_stc;
|
||||
}
|
||||
|
||||
void OnKillSTCFocus(wxFocusEvent& WXUNUSED(event))
|
||||
{
|
||||
m_focusAlwaysRetained=false;
|
||||
}
|
||||
|
||||
void OnCallTipClick(wxStyledTextEvent& WXUNUSED(event))
|
||||
{
|
||||
m_calltipClickReceived=true;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxStyledTextCtrl* const m_stc;
|
||||
bool m_focusAlwaysRetained;
|
||||
bool m_calltipClickReceived;
|
||||
};
|
||||
|
||||
// This set of tests is used to verify that an autocompletion popup does not
|
||||
// take focus from its parent styled text control.
|
||||
TEST_CASE_METHOD(StcPopupWindowsTestCase,
|
||||
"wxStyledTextCtrl::AutoComp",
|
||||
"[wxStyledTextCtrl][focus]")
|
||||
{
|
||||
m_stc->SetFocus();
|
||||
m_focusAlwaysRetained = true;
|
||||
m_stc->AutoCompShow(0,"ability able about above abroad absence absent");
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
// Pressing the tab key should cause the current entry in the list to be
|
||||
// entered into the styled text control. However with GTK+, characters sent
|
||||
// with the UI simulator seem to arrive too late, so select the current
|
||||
// entry with a double click instead.
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
#ifdef __WXGTK__
|
||||
wxPoint zeroPosition = m_stc->PointFromPosition(0);
|
||||
int textHt = m_stc->TextHeight(0);
|
||||
int textWd = m_stc->TextWidth(0,"ability");
|
||||
wxPoint autoCompPoint(zeroPosition.x + textWd/2,
|
||||
zeroPosition.y + textHt + textHt/2);
|
||||
wxPoint scrnPoint = m_stc->ClientToScreen(autoCompPoint);
|
||||
sim.MouseMove(scrnPoint);
|
||||
sim.MouseDblClick();
|
||||
#else
|
||||
sim.Char(WXK_TAB);
|
||||
#endif // __WXGTK__
|
||||
::wxYield();
|
||||
CHECK( m_stc->GetText() == "ability" );
|
||||
#endif //wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
if ( m_stc->AutoCompActive() )
|
||||
m_stc->AutoCompCancel();
|
||||
|
||||
CHECK_FOCUS_IS( m_stc );
|
||||
|
||||
// Unfortunately under GTK we do get focus loss events, at least sometimes
|
||||
// (and actually more often than not, especially with GTK2, but this
|
||||
// happens with GTK3 too).
|
||||
#ifndef __WXGTK__
|
||||
CHECK( m_focusAlwaysRetained );
|
||||
#endif // !__WXGTK__
|
||||
}
|
||||
|
||||
// This test is used to verify that a call tip receives mouse clicks. However
|
||||
// the clicks do sent with the UI simulator do not seem to be received on
|
||||
// cocoa for some reason, so skip the test there for now.
|
||||
#if !defined(__WXOSX_COCOA__)
|
||||
TEST_CASE_METHOD(StcPopupWindowsTestCase,
|
||||
"wxStyledTextCtrl::Calltip",
|
||||
"[wxStyledTextCtrl][focus]")
|
||||
{
|
||||
m_stc->SetFocus();
|
||||
m_calltipClickReceived = false;
|
||||
m_focusAlwaysRetained = true;
|
||||
|
||||
wxString calltipText = "This is a calltip.";
|
||||
m_stc->CallTipShow(0,calltipText);
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
wxUIActionSimulator sim;
|
||||
wxPoint zeroPosition = m_stc->PointFromPosition(0);
|
||||
int textHt = m_stc->TextHeight(0);
|
||||
int textWd = m_stc->TextWidth(0,calltipText);
|
||||
|
||||
// zeroPosition is the top left of position 0 and the call tip should have
|
||||
// roughly the same height as textHt (there seems to be some extra padding
|
||||
// that makes it a little taller, but it's roughly the same height),
|
||||
// so (zeroPosition.x+textWd/2,zeroPosition.y+textHt+textHt/2) should
|
||||
// be the middle of the calltip.
|
||||
wxPoint calltipMidPoint(zeroPosition.x + textWd/2,
|
||||
zeroPosition.y + textHt + textHt/2);
|
||||
wxPoint scrnPoint = m_stc->ClientToScreen(calltipMidPoint);
|
||||
sim.MouseMove(scrnPoint);
|
||||
sim.MouseClick();
|
||||
::wxYield();
|
||||
|
||||
CHECK( m_calltipClickReceived );
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
if ( m_stc->CallTipActive() )
|
||||
m_stc->CallTipCancel();
|
||||
|
||||
// Verify that clicking the call tip did not take focus from the STC.
|
||||
//
|
||||
// Unfortunately this test fails for unknown reasons under Xvfb (but only
|
||||
// there).
|
||||
if ( !IsRunningUnderXVFB() )
|
||||
CHECK_FOCUS_IS( m_stc );
|
||||
|
||||
// With wxGTK there is the same problem here as in the test above.
|
||||
#ifndef __WXGTK__
|
||||
CHECK( m_focusAlwaysRetained );
|
||||
#endif // !__WXGTK__
|
||||
}
|
||||
|
||||
#endif // !defined(__WXOSX_COCOA__)
|
||||
|
||||
#endif // defined(__WXOSX_COCOA__) || defined(__WXMSW__) || defined(__WXGTK__)
|
||||
|
||||
#endif // wxUSE_STC
|
||||
|
||||
1778
libs/wxWidgets-3.3.1/tests/controls/textctrltest.cpp
Normal file
1778
libs/wxWidgets-3.3.1/tests/controls/textctrltest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
570
libs/wxWidgets-3.3.1/tests/controls/textentrytest.cpp
Normal file
570
libs/wxWidgets-3.3.1/tests/controls/textentrytest.cpp
Normal file
@@ -0,0 +1,570 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/textentrytest.cpp
|
||||
// Purpose: TestEntryTestCase implementation
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-09-19 (extracted from textctrltest.cpp)
|
||||
// Copyright: (c) 2007, 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/event.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include "wx/textentry.h"
|
||||
#include "wx/timer.h"
|
||||
#include "wx/window.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "textentrytest.h"
|
||||
#include "testableframe.h"
|
||||
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
void TextEntryTestCase::SetValue()
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
CPPUNIT_ASSERT( entry->IsEmpty() );
|
||||
|
||||
entry->SetValue("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( "foo", entry->GetValue() );
|
||||
|
||||
entry->SetValue("");
|
||||
CPPUNIT_ASSERT( entry->IsEmpty() );
|
||||
|
||||
entry->SetValue("hi");
|
||||
CPPUNIT_ASSERT_EQUAL( "hi", entry->GetValue() );
|
||||
|
||||
entry->SetValue("bye");
|
||||
CPPUNIT_ASSERT_EQUAL( "bye", entry->GetValue() );
|
||||
}
|
||||
|
||||
void TextEntryTestCase::TextChangeEvents()
|
||||
{
|
||||
EventCounter updated(GetTestWindow(), wxEVT_TEXT);
|
||||
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
// notice that SetValue() generates an event even if the text didn't change
|
||||
entry->SetValue("");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->SetValue("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->SetValue("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->SetValue("");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->ChangeValue("bar");
|
||||
CPPUNIT_ASSERT_EQUAL( 0, updated.GetCount() );
|
||||
|
||||
entry->AppendText("bar");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->Replace(3, 6, "baz");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->Remove(0, 3);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->WriteText("foo");
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->Clear();
|
||||
CPPUNIT_ASSERT_EQUAL( 1, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->ChangeValue("");
|
||||
CPPUNIT_ASSERT_EQUAL( 0, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->ChangeValue("non-empty");
|
||||
CPPUNIT_ASSERT_EQUAL( 0, updated.GetCount() );
|
||||
updated.Clear();
|
||||
|
||||
entry->ChangeValue("");
|
||||
CPPUNIT_ASSERT_EQUAL( 0, updated.GetCount() );
|
||||
updated.Clear();
|
||||
}
|
||||
|
||||
void TextEntryTestCase::CheckStringSelection(const char *sel)
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( sel, GetTestEntry()->GetStringSelection() );
|
||||
}
|
||||
|
||||
void TextEntryTestCase::AssertSelection(int from, int to, const char *sel)
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
CPPUNIT_ASSERT( entry->HasSelection() );
|
||||
|
||||
long fromReal,
|
||||
toReal;
|
||||
entry->GetSelection(&fromReal, &toReal);
|
||||
CPPUNIT_ASSERT_EQUAL( from, fromReal );
|
||||
CPPUNIT_ASSERT_EQUAL( to, toReal );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( from, entry->GetInsertionPoint() );
|
||||
|
||||
CheckStringSelection(sel);
|
||||
}
|
||||
|
||||
void TextEntryTestCase::Selection()
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
entry->SetValue("0123456789");
|
||||
|
||||
entry->SetSelection(2, 4);
|
||||
AssertSelection(2, 4, "23"); // not "234"!
|
||||
|
||||
entry->SetSelection(3, -1);
|
||||
AssertSelection(3, 10, "3456789");
|
||||
|
||||
entry->SelectAll();
|
||||
AssertSelection(0, 10, "0123456789");
|
||||
|
||||
entry->SetSelection(0, 0);
|
||||
CPPUNIT_ASSERT( !entry->HasSelection() );
|
||||
}
|
||||
|
||||
void TextEntryTestCase::InsertionPoint()
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, entry->GetLastPosition() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetValue("0"); // should put the insertion point in front
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetLastPosition() );
|
||||
CPPUNIT_ASSERT_EQUAL( 0, entry->GetInsertionPoint() );
|
||||
|
||||
entry->AppendText("12"); // should update the insertion point position
|
||||
CPPUNIT_ASSERT_EQUAL( 3, entry->GetLastPosition() );
|
||||
CPPUNIT_ASSERT_EQUAL( 3, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetInsertionPoint(1);
|
||||
CPPUNIT_ASSERT_EQUAL( 3, entry->GetLastPosition() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetValue("012"); // shouldn't change the position if no real change
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
|
||||
|
||||
entry->ChangeValue("012"); // same as for SetValue()
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetInsertionPointEnd();
|
||||
CPPUNIT_ASSERT_EQUAL( 3, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetInsertionPoint(0);
|
||||
entry->WriteText("-"); // should move it after the written text
|
||||
CPPUNIT_ASSERT_EQUAL( 4, entry->GetLastPosition() );
|
||||
CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
|
||||
|
||||
entry->SetValue("something different"); // should still reset the caret
|
||||
CPPUNIT_ASSERT_EQUAL( 0, entry->GetInsertionPoint() );
|
||||
}
|
||||
|
||||
void TextEntryTestCase::Replace()
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
entry->SetValue("Hello replace!"
|
||||
"0123456789012");
|
||||
entry->SetInsertionPoint(0);
|
||||
|
||||
entry->Replace(6, 13, "changed");
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("Hello changed!"
|
||||
"0123456789012",
|
||||
entry->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(13, entry->GetInsertionPoint());
|
||||
|
||||
entry->Replace(13, -1, "");
|
||||
CPPUNIT_ASSERT_EQUAL("Hello changed", entry->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(13, entry->GetInsertionPoint());
|
||||
|
||||
entry->Replace(0, 6, "Un");
|
||||
CPPUNIT_ASSERT_EQUAL("Unchanged", entry->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(2, entry->GetInsertionPoint());
|
||||
}
|
||||
|
||||
void TextEntryTestCase::WriteText()
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
entry->SetValue("foo");
|
||||
entry->SetInsertionPoint(3);
|
||||
entry->WriteText("bar");
|
||||
CPPUNIT_ASSERT_EQUAL( "foobar", entry->GetValue() );
|
||||
|
||||
entry->SetValue("foo");
|
||||
entry->SetInsertionPoint(0);
|
||||
entry->WriteText("bar");
|
||||
CPPUNIT_ASSERT_EQUAL( "barfoo", entry->GetValue() );
|
||||
|
||||
entry->SetValue("abxxxhi");
|
||||
entry->SetSelection(2, 5);
|
||||
entry->WriteText("cdefg");
|
||||
CPPUNIT_ASSERT_EQUAL( "abcdefghi", entry->GetValue() );
|
||||
CPPUNIT_ASSERT_EQUAL( 7, entry->GetInsertionPoint() );
|
||||
CPPUNIT_ASSERT_EQUAL( false, entry->HasSelection() );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
class TextEventHandler
|
||||
{
|
||||
public:
|
||||
explicit TextEventHandler(wxWindow* win)
|
||||
: m_win(win)
|
||||
{
|
||||
m_win->Bind(wxEVT_TEXT, &TextEventHandler::OnText, this);
|
||||
}
|
||||
|
||||
~TextEventHandler()
|
||||
{
|
||||
m_win->Unbind(wxEVT_TEXT, &TextEventHandler::OnText, this);
|
||||
}
|
||||
|
||||
const wxString& GetLastString() const
|
||||
{
|
||||
return m_string;
|
||||
}
|
||||
|
||||
private:
|
||||
void OnText(wxCommandEvent& event)
|
||||
{
|
||||
m_string = event.GetString();
|
||||
}
|
||||
|
||||
wxWindow* const m_win;
|
||||
|
||||
wxString m_string;
|
||||
};
|
||||
|
||||
void TextEntryTestCase::Editable()
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
wxWindow * const window = GetTestWindow();
|
||||
|
||||
EventCounter updated(window, wxEVT_TEXT);
|
||||
|
||||
window->SetFocus();
|
||||
wxYield();
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// For some reason, wxBitmapComboBox doesn't appear on the screen without
|
||||
// this (due to wxTLW size hacks perhaps?). It would be nice to avoid doing
|
||||
// this, but without this hack the test often (although not always) fails.
|
||||
wxMilliSleep(50);
|
||||
#endif // __WGTK__
|
||||
|
||||
// Check that we get the expected number of events.
|
||||
wxUIActionSimulator sim;
|
||||
sim.Text("abcdef");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(6, updated.GetCount());
|
||||
|
||||
wxYield();
|
||||
|
||||
// And that the event carries the right value.
|
||||
TextEventHandler handler(window);
|
||||
|
||||
sim.Text("g");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdefg", handler.GetLastString());
|
||||
|
||||
// ... even if we generate the event programmatically and whether it uses
|
||||
// the same value as the control has right now
|
||||
entry->SetValue("abcdefg");
|
||||
CPPUNIT_ASSERT_EQUAL("abcdefg", handler.GetLastString());
|
||||
|
||||
// ... or not
|
||||
entry->SetValue("abcdef");
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", handler.GetLastString());
|
||||
|
||||
// Check that making the control not editable does indeed prevent it from
|
||||
// being edited.
|
||||
updated.Clear();
|
||||
|
||||
entry->SetEditable(false);
|
||||
sim.Text("gh");
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue());
|
||||
CPPUNIT_ASSERT_EQUAL(0, updated.GetCount());
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
void TextEntryTestCase::Hint()
|
||||
{
|
||||
GetTestEntry()->SetHint("This is a hint");
|
||||
CPPUNIT_ASSERT_EQUAL("", GetTestEntry()->GetValue());
|
||||
}
|
||||
|
||||
void TextEntryTestCase::CopyPaste()
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
entry->AppendText("sometext");
|
||||
entry->SelectAll();
|
||||
|
||||
if(entry->CanCopy() && entry->CanPaste())
|
||||
{
|
||||
entry->Copy();
|
||||
entry->Clear();
|
||||
CPPUNIT_ASSERT(entry->IsEmpty());
|
||||
|
||||
wxYield();
|
||||
|
||||
entry->Paste();
|
||||
CPPUNIT_ASSERT_EQUAL("sometext", entry->GetValue());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TextEntryTestCase::UndoRedo()
|
||||
{
|
||||
wxTextEntry * const entry = GetTestEntry();
|
||||
|
||||
entry->AppendText("sometext");
|
||||
|
||||
if(entry->CanUndo())
|
||||
{
|
||||
entry->Undo();
|
||||
CPPUNIT_ASSERT(entry->IsEmpty());
|
||||
|
||||
if(entry->CanRedo())
|
||||
{
|
||||
entry->Redo();
|
||||
CPPUNIT_ASSERT_EQUAL("sometext", entry->GetValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
enum ProcessEnter
|
||||
{
|
||||
ProcessEnter_No,
|
||||
ProcessEnter_ButSkip,
|
||||
ProcessEnter_WithoutSkipping
|
||||
};
|
||||
|
||||
class TestDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
explicit TestDialog(const TextLikeControlCreator& controlCreator,
|
||||
ProcessEnter processEnter)
|
||||
: wxDialog(wxTheApp->GetTopWindow(), wxID_ANY, "Test dialog"),
|
||||
m_control
|
||||
(
|
||||
controlCreator.Create
|
||||
(
|
||||
this,
|
||||
processEnter == ProcessEnter_No ? 0 : wxTE_PROCESS_ENTER
|
||||
)
|
||||
),
|
||||
m_processEnter(processEnter),
|
||||
m_gotEnter(false)
|
||||
{
|
||||
wxSizer* const sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->Add(m_control, wxSizerFlags().Expand());
|
||||
sizer->Add(CreateStdDialogButtonSizer(wxOK));
|
||||
SetSizerAndFit(sizer);
|
||||
|
||||
CallAfter(&TestDialog::SimulateEnter);
|
||||
|
||||
m_timer.Bind(wxEVT_TIMER, &TestDialog::OnTimeOut, this);
|
||||
m_timer.StartOnce(2000);
|
||||
}
|
||||
|
||||
bool GotEnter() const { return m_gotEnter; }
|
||||
|
||||
private:
|
||||
void OnTextEnter(wxCommandEvent& e)
|
||||
{
|
||||
m_gotEnter = true;
|
||||
|
||||
switch ( m_processEnter )
|
||||
{
|
||||
case ProcessEnter_No:
|
||||
FAIL("Shouldn't be getting wxEVT_TEXT_ENTER at all");
|
||||
break;
|
||||
|
||||
case ProcessEnter_ButSkip:
|
||||
e.Skip();
|
||||
break;
|
||||
|
||||
case ProcessEnter_WithoutSkipping:
|
||||
// Close the dialog with a different exit code than what
|
||||
// pressing the OK button would have generated.
|
||||
EndModal(wxID_APPLY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnText(wxCommandEvent& WXUNUSED(e))
|
||||
{
|
||||
// This should only happen for the multiline text controls.
|
||||
switch ( m_processEnter )
|
||||
{
|
||||
case ProcessEnter_No:
|
||||
case ProcessEnter_ButSkip:
|
||||
// We consider that the text succeeded, but in a different way,
|
||||
// so use a different ID to be able to distinguish between this
|
||||
// scenario and Enter activating the default button.
|
||||
EndModal(wxID_CLOSE);
|
||||
break;
|
||||
|
||||
case ProcessEnter_WithoutSkipping:
|
||||
FAIL("Shouldn't be getting wxEVT_TEXT if handled");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnTimeOut(wxTimerEvent&)
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void SimulateEnter()
|
||||
{
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
// Calling SetFocus() is somehow not enough to give the focus to this
|
||||
// window when running this test with wxGTK, apparently because the
|
||||
// dialog itself needs to be raised to the front first, so simulate a
|
||||
// click doing this.
|
||||
sim.MouseMove(m_control->GetScreenPosition() + wxPoint(5, 5));
|
||||
wxYield();
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
// Note that clicking it is still not enough to give it focus with
|
||||
// wxGTK either, so we still need to call SetFocus() nevertheless: but
|
||||
// now it works.
|
||||
m_control->SetFocus();
|
||||
|
||||
sim.Char(WXK_RETURN);
|
||||
}
|
||||
|
||||
wxControl* const m_control;
|
||||
const ProcessEnter m_processEnter;
|
||||
wxTimer m_timer;
|
||||
bool m_gotEnter;
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
// Note that we must use event table macros here instead of Bind() because
|
||||
// binding wxEVT_TEXT_ENTER handler for a control without wxTE_PROCESS_ENTER
|
||||
// style would fail with an assertion failure, due to wx helpfully complaining
|
||||
// about it.
|
||||
wxBEGIN_EVENT_TABLE(TestDialog, wxDialog)
|
||||
EVT_TEXT(wxID_ANY, TestDialog::OnText)
|
||||
EVT_TEXT_ENTER(wxID_ANY, TestDialog::OnTextEnter)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void TestProcessEnter(const TextLikeControlCreator& controlCreator)
|
||||
{
|
||||
if ( !EnableUITests() )
|
||||
{
|
||||
WARN("Skipping wxTE_PROCESS_ENTER tests: wxUIActionSimulator use disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
SECTION("Without wxTE_PROCESS_ENTER")
|
||||
{
|
||||
TestDialog dlg(controlCreator, ProcessEnter_No);
|
||||
REQUIRE( dlg.ShowModal() == wxID_OK );
|
||||
CHECK( !dlg.GotEnter() );
|
||||
}
|
||||
|
||||
SECTION("With wxTE_PROCESS_ENTER but skipping")
|
||||
{
|
||||
TestDialog dlgProcessEnter(controlCreator, ProcessEnter_ButSkip);
|
||||
REQUIRE( dlgProcessEnter.ShowModal() == wxID_OK );
|
||||
CHECK( dlgProcessEnter.GotEnter() );
|
||||
}
|
||||
|
||||
SECTION("With wxTE_PROCESS_ENTER without skipping")
|
||||
{
|
||||
TestDialog dlgProcessEnter(controlCreator, ProcessEnter_WithoutSkipping);
|
||||
REQUIRE( dlgProcessEnter.ShowModal() == wxID_APPLY );
|
||||
CHECK( dlgProcessEnter.GotEnter() );
|
||||
}
|
||||
|
||||
SECTION("Without wxTE_PROCESS_ENTER but with wxTE_MULTILINE")
|
||||
{
|
||||
std::unique_ptr<TextLikeControlCreator>
|
||||
multiLineCreator(controlCreator.CloneAsMultiLine());
|
||||
if ( !multiLineCreator )
|
||||
return;
|
||||
|
||||
TestDialog dlg(*multiLineCreator, ProcessEnter_No);
|
||||
REQUIRE( dlg.ShowModal() == wxID_CLOSE );
|
||||
CHECK( !dlg.GotEnter() );
|
||||
}
|
||||
|
||||
SECTION("With wxTE_PROCESS_ENTER and wxTE_MULTILINE but skipping")
|
||||
{
|
||||
std::unique_ptr<TextLikeControlCreator>
|
||||
multiLineCreator(controlCreator.CloneAsMultiLine());
|
||||
if ( !multiLineCreator )
|
||||
return;
|
||||
|
||||
TestDialog dlg(*multiLineCreator, ProcessEnter_ButSkip);
|
||||
REQUIRE( dlg.ShowModal() == wxID_CLOSE );
|
||||
CHECK( dlg.GotEnter() );
|
||||
}
|
||||
|
||||
SECTION("With wxTE_PROCESS_ENTER and wxTE_MULTILINE without skipping")
|
||||
{
|
||||
std::unique_ptr<TextLikeControlCreator>
|
||||
multiLineCreator(controlCreator.CloneAsMultiLine());
|
||||
if ( !multiLineCreator )
|
||||
return;
|
||||
|
||||
TestDialog dlg(*multiLineCreator, ProcessEnter_WithoutSkipping);
|
||||
REQUIRE( dlg.ShowModal() == wxID_APPLY );
|
||||
CHECK( dlg.GotEnter() );
|
||||
}
|
||||
}
|
||||
|
||||
#else // !wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
void TestProcessEnter(const TextLikeControlCreator& WXUNUSED(controlCreator))
|
||||
{
|
||||
WARN("Skipping wxTE_PROCESS_ENTER tests: wxUIActionSimulator not available");
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR/!wxUSE_UIACTIONSIMULATOR
|
||||
106
libs/wxWidgets-3.3.1/tests/controls/textentrytest.h
Normal file
106
libs/wxWidgets-3.3.1/tests/controls/textentrytest.h
Normal file
@@ -0,0 +1,106 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/textentrytest.h
|
||||
// Purpose: Base class implementing wxTextEntry unit tests
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-09-19 (extracted from textctrltest.cpp)
|
||||
// Copyright: (c) 2007, 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TESTS_CONTROLS_TEXTENTRYTEST_H_
|
||||
#define _WX_TESTS_CONTROLS_TEXTENTRYTEST_H_
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxTextEntry;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// abstract base class testing wxTextEntry methods
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class TextEntryTestCase
|
||||
{
|
||||
public:
|
||||
TextEntryTestCase() { }
|
||||
virtual ~TextEntryTestCase() { }
|
||||
|
||||
protected:
|
||||
// this function must be overridden by the derived classes to return the
|
||||
// text entry object we're testing, typically this is done by creating a
|
||||
// control implementing wxTextEntry interface in setUp() virtual method and
|
||||
// just returning it from here
|
||||
virtual wxTextEntry *GetTestEntry() const = 0;
|
||||
|
||||
// and this one must be overridden to return the window which implements
|
||||
// wxTextEntry interface -- usually it will return the same pointer as
|
||||
// GetTestEntry(), just as a different type
|
||||
virtual wxWindow *GetTestWindow() const = 0;
|
||||
|
||||
// this should be inserted in the derived class CPPUNIT_TEST_SUITE
|
||||
// definition to run all wxTextEntry tests as part of it
|
||||
#define wxTEXT_ENTRY_TESTS() \
|
||||
CPPUNIT_TEST( SetValue ); \
|
||||
CPPUNIT_TEST( TextChangeEvents ); \
|
||||
CPPUNIT_TEST( Selection ); \
|
||||
CPPUNIT_TEST( InsertionPoint ); \
|
||||
CPPUNIT_TEST( Replace ); \
|
||||
WXUISIM_TEST( Editable ); \
|
||||
CPPUNIT_TEST( Hint ); \
|
||||
CPPUNIT_TEST( CopyPaste ); \
|
||||
CPPUNIT_TEST( UndoRedo ); \
|
||||
CPPUNIT_TEST( WriteText )
|
||||
|
||||
void SetValue();
|
||||
void TextChangeEvents();
|
||||
void Selection();
|
||||
void InsertionPoint();
|
||||
void Replace();
|
||||
void Editable();
|
||||
void Hint();
|
||||
void CopyPaste();
|
||||
void UndoRedo();
|
||||
void WriteText();
|
||||
|
||||
private:
|
||||
// Selection() test helper: verify that selection is as described by the
|
||||
// function parameters
|
||||
void AssertSelection(int from, int to, const char *sel);
|
||||
|
||||
// helper of AssertSelection(): check that the text selected in the control
|
||||
// is the given one
|
||||
//
|
||||
// this is necessary to disable testing this in wxComboBox test as it
|
||||
// doesn't provide any way to access the string selection directly, its
|
||||
// GetStringSelection() method returns the currently selected string in the
|
||||
// wxChoice part of the control, not the selected text
|
||||
virtual void CheckStringSelection(const char *sel);
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TextEntryTestCase);
|
||||
};
|
||||
|
||||
// Helper used for creating the control of the specific type (currently either
|
||||
// wxTextCtrl or wxComboBox) with the given flag.
|
||||
class TextLikeControlCreator
|
||||
{
|
||||
public:
|
||||
TextLikeControlCreator() {}
|
||||
|
||||
// Create the control of the right type using the given parent and style.
|
||||
virtual wxControl* Create(wxWindow* parent, int style) const = 0;
|
||||
|
||||
// Return another creator similar to this one, but creating multiline
|
||||
// version of the control. If the returned pointer is non-null, it must be
|
||||
// deleted by the caller.
|
||||
virtual TextLikeControlCreator* CloneAsMultiLine() const { return nullptr; }
|
||||
|
||||
// Give it a virtual dtor to avoid warnings even though this class is not
|
||||
// supposed to be used polymorphically.
|
||||
virtual ~TextLikeControlCreator() {}
|
||||
|
||||
private:
|
||||
wxDECLARE_NO_COPY_CLASS(TextLikeControlCreator);
|
||||
};
|
||||
|
||||
// Use the given control creator to check that various combinations of
|
||||
// specifying and not specifying wxTE_PROCESS_ENTER and handling or not
|
||||
// handling the resulting event work as expected.
|
||||
void TestProcessEnter(const TextLikeControlCreator& controlCreator);
|
||||
|
||||
#endif // _WX_TESTS_CONTROLS_TEXTENTRYTEST_H_
|
||||
101
libs/wxWidgets-3.3.1/tests/controls/togglebuttontest.cpp
Normal file
101
libs/wxWidgets-3.3.1/tests/controls/togglebuttontest.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/togglebuttontest.cpp
|
||||
// Purpose: wxToggleButton unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-14
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_TOGGLEBTN
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/tglbtn.h"
|
||||
|
||||
class ToggleButtonTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ToggleButtonTestCase() { }
|
||||
|
||||
void setUp() override;
|
||||
void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( ToggleButtonTestCase );
|
||||
WXUISIM_TEST( Click );
|
||||
CPPUNIT_TEST( Value );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Click();
|
||||
void Value();
|
||||
|
||||
wxToggleButton* m_button;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ToggleButtonTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ToggleButtonTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ToggleButtonTestCase, "ToggleButtonTestCase" );
|
||||
|
||||
void ToggleButtonTestCase::setUp()
|
||||
{
|
||||
m_button = new wxToggleButton(wxTheApp->GetTopWindow(), wxID_ANY, "wxToggleButton");
|
||||
}
|
||||
|
||||
void ToggleButtonTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_button);
|
||||
}
|
||||
|
||||
void ToggleButtonTestCase::Click()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
EventCounter clicked(m_button, wxEVT_TOGGLEBUTTON);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
//We move in slightly to account for window decorations
|
||||
sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10));
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(m_button->GetValue());
|
||||
clicked.Clear();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, clicked.GetCount());
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ToggleButtonTestCase::Value()
|
||||
{
|
||||
EventCounter clicked(m_button, wxEVT_BUTTON);
|
||||
|
||||
m_button->SetValue(true);
|
||||
|
||||
CPPUNIT_ASSERT(m_button->GetValue());
|
||||
|
||||
m_button->SetValue(false);
|
||||
|
||||
CPPUNIT_ASSERT(!m_button->GetValue());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( 0, clicked.GetCount() );
|
||||
}
|
||||
|
||||
#endif //wxUSE_TOGGLEBTN
|
||||
79
libs/wxWidgets-3.3.1/tests/controls/toolbooktest.cpp
Normal file
79
libs/wxWidgets-3.3.1/tests/controls/toolbooktest.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/toolbooktest.cpp
|
||||
// Purpose: wxToolbook unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-02
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_TOOLBOOK
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/panel.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/toolbook.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
class ToolbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ToolbookTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_toolbook; }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_TOOLBOOK_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_TOOLBOOK_PAGE_CHANGING; }
|
||||
|
||||
virtual void Realize() override { m_toolbook->GetToolBar()->Realize(); }
|
||||
|
||||
CPPUNIT_TEST_SUITE( ToolbookTestCase );
|
||||
wxBOOK_CTRL_BASE_TESTS();
|
||||
CPPUNIT_TEST( ToolBar );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void ToolBar();
|
||||
|
||||
wxToolbook *m_toolbook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(ToolbookTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ToolbookTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ToolbookTestCase, "ToolbookTestCase" );
|
||||
|
||||
void ToolbookTestCase::setUp()
|
||||
{
|
||||
m_toolbook = new wxToolbook(wxTheApp->GetTopWindow(), wxID_ANY, wxDefaultPosition, wxSize(400, 200));
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
void ToolbookTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_toolbook);
|
||||
}
|
||||
|
||||
void ToolbookTestCase::ToolBar()
|
||||
{
|
||||
wxToolBar* toolbar = static_cast<wxToolBar*>(m_toolbook->GetToolBar());
|
||||
|
||||
CPPUNIT_ASSERT(toolbar);
|
||||
CPPUNIT_ASSERT_EQUAL(3, toolbar->GetToolsCount());
|
||||
}
|
||||
|
||||
#endif //wxUSE_TOOLBOOK
|
||||
159
libs/wxWidgets-3.3.1/tests/controls/treebooktest.cpp
Normal file
159
libs/wxWidgets-3.3.1/tests/controls/treebooktest.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/treebooktest.cpp
|
||||
// Purpose: wxtreebook unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-02
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_TREEBOOK
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/panel.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/treebook.h"
|
||||
#include "bookctrlbasetest.h"
|
||||
|
||||
class TreebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
TreebookTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
virtual wxBookCtrlBase *GetBase() const override { return m_treebook; }
|
||||
|
||||
virtual wxEventType GetChangedEvent() const override
|
||||
{ return wxEVT_TREEBOOK_PAGE_CHANGED; }
|
||||
|
||||
virtual wxEventType GetChangingEvent() const override
|
||||
{ return wxEVT_TREEBOOK_PAGE_CHANGING; }
|
||||
|
||||
CPPUNIT_TEST_SUITE( TreebookTestCase );
|
||||
wxBOOK_CTRL_BASE_TESTS();
|
||||
CPPUNIT_TEST( Image );
|
||||
CPPUNIT_TEST( SubPages );
|
||||
CPPUNIT_TEST( ContainerPage );
|
||||
CPPUNIT_TEST( Expand );
|
||||
CPPUNIT_TEST( Delete );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void SubPages();
|
||||
void ContainerPage();
|
||||
void Expand();
|
||||
void Delete();
|
||||
|
||||
wxTreebook *m_treebook;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TreebookTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( TreebookTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreebookTestCase, "TreebookTestCase" );
|
||||
|
||||
void TreebookTestCase::setUp()
|
||||
{
|
||||
m_treebook = new wxTreebook(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
AddPanels();
|
||||
}
|
||||
|
||||
void TreebookTestCase::tearDown()
|
||||
{
|
||||
wxDELETE(m_treebook);
|
||||
}
|
||||
|
||||
void TreebookTestCase::SubPages()
|
||||
{
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook);
|
||||
|
||||
m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2, m_treebook->GetPageParent(3));
|
||||
|
||||
m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, m_treebook->GetPageParent(2));
|
||||
|
||||
m_treebook->AddSubPage(subpanel3, "Subpanel 3", false, 2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(3, m_treebook->GetPageParent(5));
|
||||
}
|
||||
|
||||
void TreebookTestCase::ContainerPage()
|
||||
{
|
||||
// Get rid of the pages added in setUp().
|
||||
m_treebook->DeleteAllPages();
|
||||
CHECK( m_treebook->GetPageCount() == 0 );
|
||||
|
||||
// Adding a page without the associated window should be allowed.
|
||||
REQUIRE_NOTHROW( m_treebook->AddPage(nullptr, "Container page") );
|
||||
CHECK( m_treebook->GetPageParent(0) == -1 );
|
||||
|
||||
m_treebook->AddSubPage(new wxPanel(m_treebook), "Child page");
|
||||
CHECK( m_treebook->GetPageParent(1) == 0 );
|
||||
}
|
||||
|
||||
void TreebookTestCase::Expand()
|
||||
{
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook);
|
||||
|
||||
m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0);
|
||||
m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1);
|
||||
m_treebook->AddSubPage(subpanel3, "Subpanel 3", false, 2);
|
||||
|
||||
CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(1));
|
||||
CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(3));
|
||||
|
||||
m_treebook->CollapseNode(1);
|
||||
|
||||
CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(1));
|
||||
|
||||
m_treebook->ExpandNode(3, false);
|
||||
|
||||
CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(3));
|
||||
|
||||
m_treebook->ExpandNode(1);
|
||||
|
||||
CPPUNIT_ASSERT(m_treebook->IsNodeExpanded(1));
|
||||
}
|
||||
|
||||
void TreebookTestCase::Delete()
|
||||
{
|
||||
wxPanel* subpanel1 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel2 = new wxPanel(m_treebook);
|
||||
wxPanel* subpanel3 = new wxPanel(m_treebook);
|
||||
|
||||
m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0);
|
||||
m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1);
|
||||
m_treebook->AddSubPage(subpanel3, "Subpanel 3", false, 2);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(6, m_treebook->GetPageCount());
|
||||
|
||||
m_treebook->DeletePage(3);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(3, m_treebook->GetPageCount());
|
||||
|
||||
m_treebook->DeletePage(1);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, m_treebook->GetPageCount());
|
||||
|
||||
m_treebook->DeletePage(0);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(0, m_treebook->GetPageCount());
|
||||
}
|
||||
|
||||
#endif // wxUSE_TREEBOOK
|
||||
705
libs/wxWidgets-3.3.1/tests/controls/treectrltest.cpp
Normal file
705
libs/wxWidgets-3.3.1/tests/controls/treectrltest.cpp
Normal file
@@ -0,0 +1,705 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/treectrltest.cpp
|
||||
// Purpose: wxTreeCtrl unit test
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-11-26
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_TREECTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/artprov.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/treectrl.h"
|
||||
#include "wx/uiaction.h"
|
||||
#include "testableframe.h"
|
||||
#include "waitfor.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class TreeCtrlTestCase
|
||||
{
|
||||
public:
|
||||
explicit TreeCtrlTestCase(int exStyle = 0)
|
||||
{
|
||||
m_tree = new wxTreeCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
wxTR_DEFAULT_STYLE | wxTR_EDIT_LABELS | exStyle);
|
||||
|
||||
m_root = m_tree->AddRoot("root");
|
||||
m_child1 = m_tree->AppendItem(m_root, "child1");
|
||||
m_child2 = m_tree->AppendItem(m_root, "child2");
|
||||
m_grandchild = m_tree->AppendItem(m_child1, "grandchild");
|
||||
|
||||
m_tree->SetSize(400, 200);
|
||||
m_tree->ExpandAll();
|
||||
m_tree->Refresh();
|
||||
m_tree->Update();
|
||||
}
|
||||
|
||||
~TreeCtrlTestCase()
|
||||
{
|
||||
delete m_tree;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// the tree control itself
|
||||
wxTreeCtrl *m_tree = nullptr;
|
||||
|
||||
// and some of its items
|
||||
wxTreeItemId m_root,
|
||||
m_child1,
|
||||
m_child2,
|
||||
m_grandchild;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TreeCtrlTestCase);
|
||||
};
|
||||
|
||||
// Notice that toggling the wxTR_HIDE_ROOT window style with ToggleWindowStyle
|
||||
// has no effect under wxMSW if wxTreeCtrl::AddRoot() has already been called.
|
||||
// So we need this fixture (used by HasChildren and GetCount below) to create
|
||||
// the wxTreeCtrl with this style before AddRoot() is called.
|
||||
class TreeCtrlHideRootTestCase : public TreeCtrlTestCase
|
||||
{
|
||||
public:
|
||||
TreeCtrlHideRootTestCase() : TreeCtrlTestCase(wxTR_HIDE_ROOT)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlHideRootTestCase, "wxTreeCtrl::HasChildren", "[treectrl]")
|
||||
{
|
||||
CHECK( m_tree->HasChildren(m_root) );
|
||||
CHECK( m_tree->HasChildren(m_child1) );
|
||||
CHECK_FALSE( m_tree->HasChildren(m_child2) );
|
||||
CHECK_FALSE( m_tree->HasChildren(m_grandchild) );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlHideRootTestCase, "wxTreeCtrl::GetCount", "[treectrl]")
|
||||
{
|
||||
CHECK(m_tree->GetCount() == 3);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::SelectItemSingle", "[treectrl]")
|
||||
{
|
||||
// this test should be only ran in single-selection control
|
||||
CHECK_FALSE( m_tree->HasFlag(wxTR_MULTIPLE) );
|
||||
|
||||
// initially nothing is selected
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
|
||||
// selecting an item should make it selected
|
||||
m_tree->SelectItem(m_child1);
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
|
||||
// selecting it again shouldn't change anything
|
||||
m_tree->SelectItem(m_child1);
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
|
||||
// selecting another item should switch the selection to it
|
||||
m_tree->SelectItem(m_child2);
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
|
||||
// selecting it again still shouldn't change anything
|
||||
m_tree->SelectItem(m_child2);
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
|
||||
// deselecting an item should remove the selection entirely
|
||||
m_tree->UnselectItem(m_child2);
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child2) );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::SelectItemMulti", "[treectrl]")
|
||||
{
|
||||
// this test should be only ran in multi-selection control
|
||||
m_tree->ToggleWindowStyle(wxTR_MULTIPLE);
|
||||
|
||||
// initially nothing is selected
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
|
||||
// selecting an item should make it selected
|
||||
m_tree->SelectItem(m_child1);
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
|
||||
// selecting it again shouldn't change anything
|
||||
m_tree->SelectItem(m_child1);
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
|
||||
// selecting another item shouldn't deselect the previously selected one
|
||||
m_tree->SelectItem(m_child2);
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
|
||||
// selecting it again still shouldn't change anything
|
||||
m_tree->SelectItem(m_child2);
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
|
||||
// deselecting one of the items should leave the others selected
|
||||
m_tree->UnselectItem(m_child1);
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
|
||||
// collapsing a branch with selected items should still leave them selected
|
||||
m_tree->Expand(m_child1);
|
||||
m_tree->SelectItem(m_grandchild);
|
||||
CHECK( m_tree->IsSelected(m_grandchild) );
|
||||
m_tree->Collapse(m_child1);
|
||||
CHECK( m_tree->IsSelected(m_grandchild) );
|
||||
m_tree->Expand(m_child1);
|
||||
CHECK( m_tree->IsSelected(m_grandchild) );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteItem", "[treectrl]")
|
||||
{
|
||||
EventCounter deleteitem(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme");
|
||||
m_tree->AppendItem(todelete, "deleteme2");
|
||||
m_tree->Delete(todelete);
|
||||
|
||||
CHECK(deleteitem.GetCount() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteChildren", "[treectrl]")
|
||||
{
|
||||
EventCounter deletechildren(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
m_tree->AppendItem(m_child1, "another grandchild");
|
||||
m_tree->DeleteChildren(m_child1);
|
||||
|
||||
CHECK( deletechildren.GetCount() == 2 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::DeleteAllItems", "[treectrl]")
|
||||
{
|
||||
EventCounter deleteall(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
m_tree->DeleteAllItems();
|
||||
|
||||
CHECK( deleteall.GetCount() == 4 );
|
||||
}
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::ItemClick", "[treectrl]")
|
||||
{
|
||||
EventCounter activated(m_tree, wxEVT_TREE_ITEM_ACTIVATED);
|
||||
EventCounter rclick(m_tree, wxEVT_TREE_ITEM_RIGHT_CLICK);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
m_tree->GetBoundingRect(m_child1, pos, true);
|
||||
|
||||
// We move in slightly so we are not on the edge
|
||||
wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CHECK(activated.GetCount() == 1);
|
||||
CHECK(rclick.GetCount() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::LabelEdit", "[treectrl]")
|
||||
{
|
||||
EventCounter beginedit(m_tree, wxEVT_TREE_BEGIN_LABEL_EDIT);
|
||||
EventCounter endedit(m_tree, wxEVT_TREE_END_LABEL_EDIT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
#ifdef __WXQT__
|
||||
m_tree->SetFocus();
|
||||
wxYield();
|
||||
#endif
|
||||
|
||||
m_tree->SetFocusedItem(m_tree->GetRootItem());
|
||||
m_tree->EditLabel(m_tree->GetRootItem());
|
||||
|
||||
sim.Text("newroottext");
|
||||
wxYield();
|
||||
|
||||
CHECK(beginedit.GetCount() == 1);
|
||||
|
||||
sim.Char(WXK_RETURN);
|
||||
wxYield();
|
||||
|
||||
CHECK(endedit.GetCount() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::KeyDown", "[treectrl]")
|
||||
{
|
||||
EventCounter keydown(m_tree, wxEVT_TREE_KEY_DOWN);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_tree->SetFocus();
|
||||
wxYield();
|
||||
sim.Text("aAbB");
|
||||
wxYield();
|
||||
|
||||
CHECK(keydown.GetCount() == 6);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::CollapseExpandEvents", "[treectrl]")
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// Works locally, but not when run on Travis CI.
|
||||
if ( IsAutomaticTest() )
|
||||
return;
|
||||
#endif
|
||||
|
||||
m_tree->CollapseAll();
|
||||
|
||||
EventCounter collapsed(m_tree, wxEVT_TREE_ITEM_COLLAPSED);
|
||||
EventCounter collapsing(m_tree, wxEVT_TREE_ITEM_COLLAPSING);
|
||||
EventCounter expanded(m_tree, wxEVT_TREE_ITEM_EXPANDED);
|
||||
EventCounter expanding(m_tree, wxEVT_TREE_ITEM_EXPANDING);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
m_tree->GetBoundingRect(m_root, pos, true);
|
||||
|
||||
// We move in slightly so we are not on the edge
|
||||
wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CHECK(expanding.GetCount() == 1);
|
||||
CHECK(expanded.GetCount() == 1);
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// Don't even know the reason why, but GTK has to sleep
|
||||
// no less than 1200 for the test case to succeed.
|
||||
wxMilliSleep(1200);
|
||||
#endif
|
||||
|
||||
sim.MouseDblClick();
|
||||
wxYield();
|
||||
|
||||
CHECK(collapsing.GetCount() == 1);
|
||||
CHECK(collapsed.GetCount() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::SelectionChange", "[treectrl]")
|
||||
{
|
||||
m_tree->ExpandAll();
|
||||
|
||||
// This is currently needed to work around a problem under wxMSW: clicking
|
||||
// on an item in an unfocused control generates two selection change events
|
||||
// because of the SetFocus() call in TVN_SELCHANGED handler in wxMSW code.
|
||||
// This is, of course, wrong on its own, but fixing it without breaking
|
||||
// anything else is non-obvious, so for now at least work around this
|
||||
// problem in the test.
|
||||
m_tree->SetFocus();
|
||||
|
||||
bool vetoChange = false;
|
||||
|
||||
SECTION("Without veto selection change"){ }
|
||||
SECTION("With veto selection change")
|
||||
{
|
||||
vetoChange = true;
|
||||
}
|
||||
|
||||
int changed = 0;
|
||||
int changing = 0;
|
||||
|
||||
auto handler = [&](wxTreeEvent& event)
|
||||
{
|
||||
const auto eventType = event.GetEventType();
|
||||
|
||||
if ( eventType == wxEVT_TREE_SEL_CHANGING )
|
||||
{
|
||||
++changing;
|
||||
|
||||
if ( vetoChange && changed == 1 )
|
||||
{
|
||||
event.Veto();
|
||||
}
|
||||
}
|
||||
else if ( eventType == wxEVT_TREE_SEL_CHANGED )
|
||||
{
|
||||
++changed;
|
||||
}
|
||||
};
|
||||
|
||||
m_tree->Bind(wxEVT_TREE_SEL_CHANGED, handler);
|
||||
m_tree->Bind(wxEVT_TREE_SEL_CHANGING, handler);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect poschild1, poschild2;
|
||||
m_tree->GetBoundingRect(m_child1, poschild1, true);
|
||||
m_tree->GetBoundingRect(m_child2, poschild2, true);
|
||||
|
||||
// We move in slightly so we are not on the edge
|
||||
wxPoint point1 = m_tree->ClientToScreen(poschild1.GetPosition()) + wxPoint(4, 4);
|
||||
wxPoint point2 = m_tree->ClientToScreen(poschild2.GetPosition()) + wxPoint(4, 4);
|
||||
|
||||
sim.MouseMove(point1);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CHECK(changed == 1);
|
||||
CHECK(changing == 1);
|
||||
|
||||
sim.MouseMove(point2);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CHECK(changed == (vetoChange ? 1 : 2));
|
||||
CHECK(changing == 2);
|
||||
|
||||
if ( vetoChange )
|
||||
{
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child2) );
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::SelectItemMultiInteractive", "[treectrl]")
|
||||
{
|
||||
#if defined(__WXGTK__) && !defined(__WXGTK3__)
|
||||
// FIXME: This test fails on GitHub CI under wxGTK2 although works fine on
|
||||
// development machine, no idea why though!
|
||||
if ( IsAutomaticTest() )
|
||||
return;
|
||||
#endif // wxGTK2
|
||||
|
||||
// this test should be only ran in multi-selection control
|
||||
m_tree->ToggleWindowStyle(wxTR_MULTIPLE);
|
||||
|
||||
m_tree->ExpandAll();
|
||||
|
||||
// This is currently needed to work around a problem under wxMSW: clicking
|
||||
// on an item in an unfocused control generates two selection change events
|
||||
// because of the SetFocus() call in TVN_SELCHANGED handler in wxMSW code.
|
||||
// This is, of course, wrong on its own, but fixing it without breaking
|
||||
// anything else is non-obvious, so for now at least work around this
|
||||
// problem in the test.
|
||||
m_tree->SetFocus();
|
||||
|
||||
EventCounter beginedit(m_tree, wxEVT_TREE_BEGIN_LABEL_EDIT);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect poschild1, poschild2;
|
||||
m_tree->GetBoundingRect(m_child1, poschild1, true);
|
||||
m_tree->GetBoundingRect(m_child2, poschild2, true);
|
||||
|
||||
// We move in slightly so we are not on the edge
|
||||
wxPoint point1 = m_tree->ClientToScreen(poschild1.GetPosition()) + wxPoint(4, 4);
|
||||
wxPoint point2 = m_tree->ClientToScreen(poschild2.GetPosition()) + wxPoint(4, 4);
|
||||
|
||||
sim.MouseMove(point1);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
sim.MouseMove(point2);
|
||||
wxYield();
|
||||
|
||||
sim.KeyDown(WXK_CONTROL);
|
||||
sim.MouseClick();
|
||||
sim.KeyUp(WXK_CONTROL);
|
||||
wxYield();
|
||||
|
||||
// m_child1 and m_child2 should be selected.
|
||||
CHECK( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
CHECK( beginedit.GetCount() == 0 );
|
||||
|
||||
// Time needed (in ms) for the editor to display. The test will not pass
|
||||
// if the value is less than 400, 510, 800 under wxQt, wxGTK, wxMSW resp.
|
||||
const int BEGIN_EDIT_TIMEOUT = 800;
|
||||
|
||||
YieldForAWhile(BEGIN_EDIT_TIMEOUT);
|
||||
sim.MouseClick();
|
||||
YieldForAWhile(BEGIN_EDIT_TIMEOUT);
|
||||
|
||||
// Only m_child2 should be selected now.
|
||||
CHECK_FALSE( m_tree->IsSelected(m_child1) );
|
||||
CHECK( m_tree->IsSelected(m_child2) );
|
||||
CHECK( beginedit.GetCount() == 0 ); // No editing should take place in the event of deselection.
|
||||
|
||||
sim.MouseClick();
|
||||
YieldForAWhile(BEGIN_EDIT_TIMEOUT);
|
||||
|
||||
CHECK( beginedit.GetCount() == 1 ); // Start editing as usual.
|
||||
|
||||
sim.Char(WXK_RETURN); // End editing and close the editor.
|
||||
wxYield();
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Menu", "[treectrl]")
|
||||
{
|
||||
EventCounter menu(m_tree, wxEVT_TREE_ITEM_MENU);
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
m_tree->GetBoundingRect(m_child1, pos, true);
|
||||
|
||||
// We move in slightly so we are not on the edge
|
||||
wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick(wxMOUSE_BTN_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CHECK(menu.GetCount() == 1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::KeyNavigation", "[treectrl]")
|
||||
{
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_tree->CollapseAll();
|
||||
|
||||
m_tree->SelectItem(m_root);
|
||||
wxYield();
|
||||
|
||||
m_tree->SetFocus();
|
||||
sim.Char(WXK_RIGHT);
|
||||
wxYield();
|
||||
|
||||
CHECK(m_tree->IsExpanded(m_root));
|
||||
|
||||
#ifdef wxHAS_GENERIC_TREECTRL
|
||||
sim.Char('-');
|
||||
#else
|
||||
sim.Char(WXK_LEFT);
|
||||
#endif
|
||||
|
||||
wxYield();
|
||||
|
||||
CHECK(!m_tree->IsExpanded(m_root));
|
||||
|
||||
wxYield();
|
||||
|
||||
sim.Char(WXK_RIGHT);
|
||||
sim.Char(WXK_DOWN);
|
||||
wxYield();
|
||||
|
||||
CHECK(m_tree->GetSelection() == m_child1);
|
||||
|
||||
sim.Char(WXK_DOWN);
|
||||
wxYield();
|
||||
|
||||
CHECK(m_tree->GetSelection() == m_child2);
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::ItemData", "[treectrl]")
|
||||
{
|
||||
wxTreeItemData* child1data = new wxTreeItemData();
|
||||
wxTreeItemData* appenddata = new wxTreeItemData();
|
||||
wxTreeItemData* insertdata = new wxTreeItemData();
|
||||
|
||||
m_tree->SetItemData(m_child1, child1data);
|
||||
|
||||
CHECK(m_tree->GetItemData(m_child1) == child1data);
|
||||
CHECK(child1data->GetId() == m_child1);
|
||||
|
||||
wxTreeItemId append = m_tree->AppendItem(m_root, "new", -1, -1, appenddata);
|
||||
|
||||
CHECK(m_tree->GetItemData(append) == appenddata);
|
||||
CHECK(appenddata->GetId() == append);
|
||||
|
||||
wxTreeItemId insert = m_tree->InsertItem(m_root, m_child1, "new", -1, -1,
|
||||
insertdata);
|
||||
|
||||
CHECK(m_tree->GetItemData(insert) == insertdata);
|
||||
CHECK(insertdata->GetId() == insert);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Iteration", "[treectrl]")
|
||||
{
|
||||
// Get first / next / last child
|
||||
wxTreeItemIdValue cookie;
|
||||
CHECK(m_tree->GetFirstChild(m_root, cookie) == m_child1);
|
||||
CHECK(m_tree->GetNextChild(m_root, cookie) == m_tree->GetLastChild(m_root));
|
||||
CHECK(m_tree->GetLastChild(m_root) == m_child2);
|
||||
|
||||
// Get next / previous sibling
|
||||
CHECK(m_tree->GetNextSibling(m_child1) == m_child2);
|
||||
CHECK(m_tree->GetPrevSibling(m_child2) == m_child1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Parent", "[treectrl]")
|
||||
{
|
||||
CHECK(m_tree->GetRootItem() == m_root);
|
||||
CHECK(m_tree->GetItemParent(m_child1) == m_root);
|
||||
CHECK(m_tree->GetItemParent(m_child2) == m_root);
|
||||
CHECK(m_tree->GetItemParent(m_grandchild) == m_child1);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::CollapseExpand", "[treectrl]")
|
||||
{
|
||||
m_tree->ExpandAll();
|
||||
|
||||
CHECK(m_tree->IsExpanded(m_root));
|
||||
CHECK(m_tree->IsExpanded(m_child1));
|
||||
|
||||
m_tree->CollapseAll();
|
||||
|
||||
CHECK_FALSE(m_tree->IsExpanded(m_root));
|
||||
CHECK_FALSE(m_tree->IsExpanded(m_child1));
|
||||
|
||||
m_tree->ExpandAllChildren(m_root);
|
||||
|
||||
CHECK(m_tree->IsExpanded(m_root));
|
||||
CHECK(m_tree->IsExpanded(m_child1));
|
||||
|
||||
m_tree->CollapseAllChildren(m_child1);
|
||||
|
||||
CHECK_FALSE(m_tree->IsExpanded(m_child1));
|
||||
|
||||
m_tree->Expand(m_child1);
|
||||
|
||||
CHECK(m_tree->IsExpanded(m_child1));
|
||||
|
||||
m_tree->Collapse(m_root);
|
||||
|
||||
CHECK_FALSE(m_tree->IsExpanded(m_root));
|
||||
CHECK(m_tree->IsExpanded(m_child1));
|
||||
|
||||
m_tree->CollapseAndReset(m_root);
|
||||
|
||||
CHECK_FALSE(m_tree->IsExpanded(m_root));
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::AssignImageList", "[treectrl]")
|
||||
{
|
||||
wxSize size(16, 16);
|
||||
|
||||
wxImageList *imagelist = new wxImageList(size.x, size.y);
|
||||
imagelist->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size));
|
||||
|
||||
wxImageList *statelist = new wxImageList(size.x, size.y);
|
||||
statelist->Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, size));
|
||||
|
||||
m_tree->AssignImageList(imagelist);
|
||||
m_tree->AssignStateImageList(statelist);
|
||||
|
||||
CHECK(m_tree->GetImageList() == imagelist);
|
||||
CHECK(m_tree->GetStateImageList() == statelist);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Focus", "[treectrl]")
|
||||
{
|
||||
m_tree->SetFocusedItem(m_child1);
|
||||
|
||||
CHECK(m_tree->GetFocusedItem() == m_child1);
|
||||
|
||||
m_tree->ClearFocusedItem();
|
||||
|
||||
CHECK_FALSE(m_tree->GetFocusedItem());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Bold", "[treectrl]")
|
||||
{
|
||||
CHECK_FALSE(m_tree->IsBold(m_child1));
|
||||
|
||||
m_tree->SetItemBold(m_child1);
|
||||
|
||||
CHECK(m_tree->IsBold(m_child1));
|
||||
|
||||
m_tree->SetItemBold(m_child1, false);
|
||||
|
||||
CHECK_FALSE(m_tree->IsBold(m_child1));
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Visible", "[treectrl]")
|
||||
{
|
||||
m_tree->CollapseAll();
|
||||
|
||||
CHECK(m_tree->IsVisible(m_root));
|
||||
CHECK_FALSE(m_tree->IsVisible(m_child1));
|
||||
|
||||
m_tree->EnsureVisible(m_grandchild);
|
||||
|
||||
CHECK(m_tree->IsVisible(m_grandchild));
|
||||
|
||||
m_tree->ExpandAll();
|
||||
|
||||
CHECK(m_tree->GetFirstVisibleItem() == m_root);
|
||||
CHECK(m_tree->GetNextVisible(m_root) == m_child1);
|
||||
CHECK(m_tree->GetNextVisible(m_child1) == m_grandchild);
|
||||
CHECK(m_tree->GetNextVisible(m_grandchild) == m_child2);
|
||||
|
||||
CHECK_FALSE(m_tree->GetNextVisible(m_child2));
|
||||
CHECK_FALSE(m_tree->GetPrevVisible(m_root));
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Scroll", "[treectrl]")
|
||||
{
|
||||
// This trivial test just checks that calling ScrollTo() with the root item
|
||||
// doesn't crash any longer, as it used to do when the root item was hidden.
|
||||
m_tree->ScrollTo(m_root);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(TreeCtrlTestCase, "wxTreeCtrl::Sort", "[treectrl]")
|
||||
{
|
||||
wxTreeItemId zitem = m_tree->AppendItem(m_root, "zzzz");
|
||||
wxTreeItemId aitem = m_tree->AppendItem(m_root, "aaaa");
|
||||
|
||||
m_tree->SortChildren(m_root);
|
||||
|
||||
wxTreeItemIdValue cookie;
|
||||
|
||||
CHECK(m_tree->GetFirstChild(m_root, cookie) == aitem);
|
||||
CHECK(m_tree->GetNextChild(m_root, cookie) == m_child1);
|
||||
CHECK(m_tree->GetNextChild(m_root, cookie) == m_child2);
|
||||
CHECK(m_tree->GetNextChild(m_root, cookie) == zitem);
|
||||
}
|
||||
|
||||
#endif //wxUSE_TREECTRL
|
||||
231
libs/wxWidgets-3.3.1/tests/controls/treelistctrltest.cpp
Normal file
231
libs/wxWidgets-3.3.1/tests/controls/treelistctrltest.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/treelistctrltest.cpp
|
||||
// Purpose: wxTreeListCtrl unit test.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2011-08-27
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_TREELISTCTRL
|
||||
|
||||
|
||||
#include "wx/treelist.h"
|
||||
|
||||
#include "wx/app.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class TreeListCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
TreeListCtrlTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( TreeListCtrlTestCase );
|
||||
CPPUNIT_TEST( Traversal );
|
||||
CPPUNIT_TEST( ItemText );
|
||||
CPPUNIT_TEST( ItemCheck );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
// Create the control with the given style.
|
||||
void Create(long style);
|
||||
|
||||
// Add an item to the tree and increment m_numItems.
|
||||
wxTreeListItem AddItem(const char *label,
|
||||
wxTreeListItem parent = wxTreeListItem(),
|
||||
const char *numFiles = "",
|
||||
const char *size = "");
|
||||
|
||||
|
||||
// Tests:
|
||||
void Traversal();
|
||||
void ItemText();
|
||||
void ItemCheck();
|
||||
|
||||
|
||||
// The control itself.
|
||||
wxTreeListCtrl *m_treelist;
|
||||
|
||||
// And some of its items.
|
||||
wxTreeListItem m_code,
|
||||
m_code_osx,
|
||||
m_code_osx_cocoa;
|
||||
|
||||
// Also the total number of items in it initially
|
||||
unsigned m_numItems;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TreeListCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( TreeListCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreeListCtrlTestCase, "TreeListCtrlTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxTreeListItem
|
||||
TreeListCtrlTestCase::AddItem(const char *label,
|
||||
wxTreeListItem parent,
|
||||
const char *numFiles,
|
||||
const char *size)
|
||||
{
|
||||
if ( !parent.IsOk() )
|
||||
parent = m_treelist->GetRootItem();
|
||||
|
||||
wxTreeListItem item = m_treelist->AppendItem(parent, label);
|
||||
m_treelist->SetItemText(item, 1, numFiles);
|
||||
m_treelist->SetItemText(item, 2, size);
|
||||
|
||||
m_numItems++;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void TreeListCtrlTestCase::Create(long style)
|
||||
{
|
||||
m_treelist = new wxTreeListCtrl(wxTheApp->GetTopWindow(),
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxSize(400, 200),
|
||||
style);
|
||||
|
||||
m_treelist->AppendColumn("Component");
|
||||
m_treelist->AppendColumn("# Files");
|
||||
m_treelist->AppendColumn("Size");
|
||||
|
||||
// Fill the control with the same data as used in the treelist sample:
|
||||
m_code = AddItem("Code");
|
||||
AddItem("wxMSW", m_code, "313", "3.94 MiB");
|
||||
AddItem("wxGTK", m_code, "180", "1.66 MiB");
|
||||
|
||||
m_code_osx = AddItem("wxOSX", m_code, "265", "2.36 MiB");
|
||||
AddItem("Core", m_code_osx, "31", "347 KiB");
|
||||
AddItem("Carbon", m_code_osx, "91", "1.34 MiB");
|
||||
m_code_osx_cocoa = AddItem("Cocoa", m_code_osx, "46", "512 KiB");
|
||||
|
||||
wxTreeListItem Documentation = AddItem("Documentation");
|
||||
AddItem("HTML", Documentation, "many");
|
||||
AddItem("CHM", Documentation, "1");
|
||||
|
||||
wxTreeListItem Samples = AddItem("Samples");
|
||||
AddItem("minimal", Samples, "1", "7 KiB");
|
||||
AddItem("widgets", Samples, "28", "419 KiB");
|
||||
|
||||
m_treelist->Refresh();
|
||||
m_treelist->Update();
|
||||
}
|
||||
|
||||
void TreeListCtrlTestCase::setUp()
|
||||
{
|
||||
m_numItems = 0;
|
||||
Create(wxTL_MULTIPLE | wxTL_3STATE);
|
||||
}
|
||||
|
||||
void TreeListCtrlTestCase::tearDown()
|
||||
{
|
||||
delete m_treelist;
|
||||
m_treelist = nullptr;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests themselves
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Test various tree traversal methods.
|
||||
void TreeListCtrlTestCase::Traversal()
|
||||
{
|
||||
// GetParent() tests:
|
||||
wxTreeListItem root = m_treelist->GetRootItem();
|
||||
CPPUNIT_ASSERT( !m_treelist->GetItemParent(root) );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( root, m_treelist->GetItemParent(m_code) );
|
||||
CPPUNIT_ASSERT_EQUAL( m_code, m_treelist->GetItemParent(m_code_osx) );
|
||||
|
||||
|
||||
// GetFirstChild() and GetNextSibling() tests:
|
||||
CPPUNIT_ASSERT_EQUAL( m_code, m_treelist->GetFirstChild(root) );
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
(
|
||||
m_code_osx,
|
||||
m_treelist->GetNextSibling
|
||||
(
|
||||
m_treelist->GetNextSibling
|
||||
(
|
||||
m_treelist->GetFirstChild(m_code)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Get{First,Next}Item() test:
|
||||
unsigned numItems = 0;
|
||||
for ( wxTreeListItem item = m_treelist->GetFirstItem();
|
||||
item.IsOk();
|
||||
item = m_treelist->GetNextItem(item) )
|
||||
{
|
||||
numItems++;
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( m_numItems, numItems );
|
||||
}
|
||||
|
||||
// Test accessing items text.
|
||||
void TreeListCtrlTestCase::ItemText()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( "Cocoa", m_treelist->GetItemText(m_code_osx_cocoa) );
|
||||
CPPUNIT_ASSERT_EQUAL( "46", m_treelist->GetItemText(m_code_osx_cocoa, 1) );
|
||||
|
||||
m_treelist->SetItemText(m_code_osx_cocoa, "wxCocoa");
|
||||
CPPUNIT_ASSERT_EQUAL( "wxCocoa", m_treelist->GetItemText(m_code_osx_cocoa) );
|
||||
|
||||
m_treelist->SetItemText(m_code_osx_cocoa, 1, "47");
|
||||
CPPUNIT_ASSERT_EQUAL( "47", m_treelist->GetItemText(m_code_osx_cocoa, 1) );
|
||||
}
|
||||
|
||||
// Test checking and unchecking items.
|
||||
void TreeListCtrlTestCase::ItemCheck()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_UNCHECKED,
|
||||
m_treelist->GetCheckedState(m_code) );
|
||||
|
||||
m_treelist->CheckItemRecursively(m_code);
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_CHECKED,
|
||||
m_treelist->GetCheckedState(m_code) );
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_CHECKED,
|
||||
m_treelist->GetCheckedState(m_code_osx) );
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_CHECKED,
|
||||
m_treelist->GetCheckedState(m_code_osx_cocoa) );
|
||||
|
||||
m_treelist->UncheckItem(m_code_osx_cocoa);
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_UNCHECKED,
|
||||
m_treelist->GetCheckedState(m_code_osx_cocoa) );
|
||||
|
||||
m_treelist->UpdateItemParentStateRecursively(m_code_osx_cocoa);
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_UNDETERMINED,
|
||||
m_treelist->GetCheckedState(m_code_osx) );
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_UNDETERMINED,
|
||||
m_treelist->GetCheckedState(m_code) );
|
||||
|
||||
m_treelist->CheckItemRecursively(m_code_osx, wxCHK_UNCHECKED);
|
||||
m_treelist->UpdateItemParentStateRecursively(m_code_osx_cocoa);
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_UNCHECKED,
|
||||
m_treelist->GetCheckedState(m_code_osx) );
|
||||
CPPUNIT_ASSERT_EQUAL( wxCHK_UNDETERMINED,
|
||||
m_treelist->GetCheckedState(m_code) );
|
||||
}
|
||||
|
||||
#endif // wxUSE_TREELISTCTRL
|
||||
152
libs/wxWidgets-3.3.1/tests/controls/virtlistctrltest.cpp
Normal file
152
libs/wxWidgets-3.3.1/tests/controls/virtlistctrltest.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/virtlistctrltest.cpp
|
||||
// Purpose: wxListCtrl unit tests for virtual mode
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2010-11-13
|
||||
// Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_LISTCTRL
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "testableframe.h"
|
||||
#include "wx/uiaction.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class VirtListCtrlTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
VirtListCtrlTestCase() { }
|
||||
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( VirtListCtrlTestCase );
|
||||
CPPUNIT_TEST( UpdateSelection );
|
||||
WXUISIM_TEST( DeselectedEvent );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void UpdateSelection();
|
||||
void DeselectedEvent();
|
||||
|
||||
wxListCtrl *m_list;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(VirtListCtrlTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( VirtListCtrlTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VirtListCtrlTestCase, "VirtListCtrlTestCase" );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void VirtListCtrlTestCase::setUp()
|
||||
{
|
||||
// Define a class overriding OnGetItemText() which must be overridden for
|
||||
// any virtual list control.
|
||||
class VirtListCtrl : public wxListCtrl
|
||||
{
|
||||
public:
|
||||
VirtListCtrl()
|
||||
: wxListCtrl(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||
wxPoint(0, 0), wxSize(400, 200),
|
||||
wxLC_REPORT | wxLC_VIRTUAL)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxString OnGetItemText(long item, long column) const override
|
||||
{
|
||||
return wxString::Format("Row %ld, col %ld", item, column);
|
||||
}
|
||||
};
|
||||
|
||||
m_list = new VirtListCtrl;
|
||||
m_list->AppendColumn("Col0");
|
||||
}
|
||||
|
||||
void VirtListCtrlTestCase::tearDown()
|
||||
{
|
||||
delete m_list;
|
||||
m_list = nullptr;
|
||||
}
|
||||
|
||||
void VirtListCtrlTestCase::UpdateSelection()
|
||||
{
|
||||
m_list->SetItemCount(10);
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_list->GetSelectedItemCount() );
|
||||
|
||||
m_list->SetItemState(7, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_list->GetSelectedItemCount() );
|
||||
|
||||
m_list->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||
CPPUNIT_ASSERT_EQUAL( 2, m_list->GetSelectedItemCount() );
|
||||
|
||||
// The item 7 is now invalid and so shouldn't be counted as selected any
|
||||
// more. Notice that under wxQt, the selection is lost/cleared when the
|
||||
// model is reset
|
||||
m_list->SetItemCount(5);
|
||||
#ifndef __WXQT__
|
||||
CPPUNIT_ASSERT_EQUAL( 1, m_list->GetSelectedItemCount() );
|
||||
#else
|
||||
CPPUNIT_ASSERT_EQUAL( 0, m_list->GetSelectedItemCount() );
|
||||
#endif
|
||||
}
|
||||
|
||||
void VirtListCtrlTestCase::DeselectedEvent()
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
m_list->SetItemCount(1);
|
||||
wxListCtrl* const list = m_list;
|
||||
|
||||
EventCounter selected(list, wxEVT_LIST_ITEM_SELECTED);
|
||||
EventCounter deselected(list, wxEVT_LIST_ITEM_DESELECTED);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
wxRect pos;
|
||||
list->GetItemRect(0, pos);
|
||||
|
||||
//We move in slightly so we are not on the edge
|
||||
wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 10);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
// We want a point within the listctrl but below any items
|
||||
point = list->ClientToScreen(pos.GetPosition()) + wxPoint(10, 50);
|
||||
|
||||
sim.MouseMove(point);
|
||||
wxYield();
|
||||
|
||||
sim.MouseClick();
|
||||
wxYield();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, selected.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(1, deselected.GetCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_LISTCTRL
|
||||
447
libs/wxWidgets-3.3.1/tests/controls/webtest.cpp
Normal file
447
libs/wxWidgets-3.3.1/tests/controls/webtest.cpp
Normal file
@@ -0,0 +1,447 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/webtest.cpp
|
||||
// Purpose: wxWebView unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2011-07-08
|
||||
// Copyright: (c) 2011 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#if wxUSE_WEBVIEW && (wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_WEBKIT2 || wxUSE_WEBVIEW_IE)
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "testableframe.h"
|
||||
#include "wx/webview.h"
|
||||
#include "asserthelper.h"
|
||||
#if wxUSE_WEBVIEW_IE
|
||||
#include "wx/msw/webview_ie.h"
|
||||
#endif
|
||||
#if wxUSE_WEBVIEW_WEBKIT2
|
||||
#include "waitfor.h"
|
||||
#endif
|
||||
|
||||
//Convenience macro
|
||||
#define ENSURE_LOADED CHECK( m_loaded->WaitEvent() )
|
||||
|
||||
class WebViewTestCase
|
||||
{
|
||||
public:
|
||||
WebViewTestCase()
|
||||
: m_browser(wxWebView::New()),
|
||||
m_loaded(new EventCounter(m_browser, wxEVT_WEBVIEW_LOADED))
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
if (wxWebView::IsBackendAvailable(wxWebViewBackendEdge))
|
||||
{
|
||||
// The blank page does not have an empty title with edge
|
||||
m_blankTitle = "about:blank";
|
||||
// Edge does not support about: url use a different URL instead
|
||||
m_alternateHistoryURL = "about:blank";
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if wxUSE_WEBVIEW_WEBKIT2
|
||||
m_alternateHistoryURL = "about:srcdoc";
|
||||
#else
|
||||
m_alternateHistoryURL = "about:";
|
||||
#endif
|
||||
}
|
||||
|
||||
~WebViewTestCase()
|
||||
{
|
||||
delete m_loaded;
|
||||
delete m_browser;
|
||||
}
|
||||
|
||||
protected:
|
||||
void LoadUrl(int times = 1)
|
||||
{
|
||||
//We alternate between urls as otherwise webkit merges them in the history
|
||||
//we use about and about blank to avoid the need for a network connection
|
||||
for(int i = 0; i < times; i++)
|
||||
{
|
||||
if(i % 2 == 1)
|
||||
m_browser->LoadURL("about:blank");
|
||||
else
|
||||
m_browser->LoadURL(m_alternateHistoryURL);
|
||||
ENSURE_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
void OnScriptResult(const wxWebViewEvent& evt)
|
||||
{
|
||||
m_asyncScriptResult = (evt.IsError()) ? 0 : 1;
|
||||
m_asyncScriptString = evt.GetString();
|
||||
}
|
||||
|
||||
void RunAsyncScript(const wxString& javascript)
|
||||
{
|
||||
m_browser->Bind(wxEVT_WEBVIEW_SCRIPT_RESULT, &WebViewTestCase::OnScriptResult, this);
|
||||
m_asyncScriptResult = -1;
|
||||
m_browser->RunScriptAsync(javascript);
|
||||
while (m_asyncScriptResult == -1)
|
||||
wxYield();
|
||||
m_browser->Unbind(wxEVT_WEBVIEW_SCRIPT_RESULT, &WebViewTestCase::OnScriptResult, this);
|
||||
}
|
||||
|
||||
wxWebView* const m_browser;
|
||||
EventCounter* const m_loaded;
|
||||
wxString m_blankTitle;
|
||||
wxString m_alternateHistoryURL;
|
||||
int m_asyncScriptResult;
|
||||
wxString m_asyncScriptString;
|
||||
};
|
||||
|
||||
TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]")
|
||||
{
|
||||
#if defined(__WXGTK__) && !defined(__WXGTK3__)
|
||||
wxString value;
|
||||
if ( !wxGetEnv("wxTEST_WEBVIEW_GTK2", &value) || value != "1" )
|
||||
{
|
||||
WARN("Skipping WebView tests known to fail with wxGTK 2, set "
|
||||
"wxTEST_WEBVIEW_GTK2=1 to force running them.");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_browser -> Create(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
ENSURE_LOADED;
|
||||
|
||||
SECTION("Title")
|
||||
{
|
||||
CHECK(m_browser->GetCurrentTitle() == "");
|
||||
|
||||
//Test title after loading raw html
|
||||
m_browser->SetPage("<html><title>Title</title><body>Text</body></html>", "");
|
||||
ENSURE_LOADED;
|
||||
CHECK(m_browser->GetCurrentTitle() == "Title");
|
||||
|
||||
//Test title after loading a url, we yield to let events process
|
||||
LoadUrl();
|
||||
CHECK(m_browser->GetCurrentTitle() == m_blankTitle);
|
||||
}
|
||||
|
||||
SECTION("URL")
|
||||
{
|
||||
CHECK(m_browser->GetCurrentURL() == "about:blank");
|
||||
|
||||
//After first loading about:blank the next in the sequence is about:
|
||||
LoadUrl();
|
||||
CHECK(m_browser->GetCurrentURL() == m_alternateHistoryURL);
|
||||
}
|
||||
|
||||
SECTION("History")
|
||||
{
|
||||
LoadUrl(3);
|
||||
|
||||
CHECK(m_browser->CanGoBack());
|
||||
CHECK(!m_browser->CanGoForward());
|
||||
|
||||
m_browser->GoBack();
|
||||
ENSURE_LOADED;
|
||||
|
||||
CHECK(m_browser->CanGoBack());
|
||||
CHECK(m_browser->CanGoForward());
|
||||
|
||||
m_browser->GoBack();
|
||||
ENSURE_LOADED;
|
||||
m_browser->GoBack();
|
||||
ENSURE_LOADED;
|
||||
|
||||
//We should now be at the start of the history
|
||||
CHECK(!m_browser->CanGoBack());
|
||||
CHECK(m_browser->CanGoForward());
|
||||
}
|
||||
|
||||
#if !wxUSE_WEBVIEW_WEBKIT2 && !defined(__WXOSX__)
|
||||
SECTION("HistoryEnable")
|
||||
{
|
||||
LoadUrl();
|
||||
m_browser->EnableHistory(false);
|
||||
|
||||
CHECK(!m_browser->CanGoForward());
|
||||
CHECK(!m_browser->CanGoBack());
|
||||
|
||||
LoadUrl();
|
||||
|
||||
CHECK(!m_browser->CanGoForward());
|
||||
CHECK(!m_browser->CanGoBack());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !wxUSE_WEBVIEW_WEBKIT2 && !defined(__WXOSX__)
|
||||
SECTION("HistoryClear")
|
||||
{
|
||||
LoadUrl(2);
|
||||
|
||||
//Now we are in the 'middle' of the history
|
||||
m_browser->GoBack();
|
||||
ENSURE_LOADED;
|
||||
|
||||
CHECK(m_browser->CanGoForward());
|
||||
CHECK(m_browser->CanGoBack());
|
||||
|
||||
m_browser->ClearHistory();
|
||||
|
||||
CHECK(!m_browser->CanGoForward());
|
||||
CHECK(!m_browser->CanGoBack());
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("HistoryList")
|
||||
{
|
||||
LoadUrl(2);
|
||||
m_browser->GoBack();
|
||||
ENSURE_LOADED;
|
||||
|
||||
CHECK(m_browser->GetBackwardHistory().size() == 1);
|
||||
CHECK(m_browser->GetForwardHistory().size() == 1);
|
||||
|
||||
m_browser->LoadHistoryItem(m_browser->GetForwardHistory()[0]);
|
||||
ENSURE_LOADED;
|
||||
|
||||
CHECK(!m_browser->CanGoForward());
|
||||
CHECK(m_browser->GetBackwardHistory().size() == 2);
|
||||
}
|
||||
|
||||
#if !defined(__WXOSX__) && (!defined(wxUSE_WEBVIEW_EDGE) || !wxUSE_WEBVIEW_EDGE)
|
||||
SECTION("Editable")
|
||||
{
|
||||
CHECK(!m_browser->IsEditable());
|
||||
|
||||
m_browser->SetEditable(true);
|
||||
|
||||
CHECK(m_browser->IsEditable());
|
||||
|
||||
m_browser->SetEditable(false);
|
||||
|
||||
CHECK(!m_browser->IsEditable());
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("Selection")
|
||||
{
|
||||
m_browser->SetPage("<html><body>Some <strong>strong</strong> text</body></html>", "");
|
||||
ENSURE_LOADED;
|
||||
CHECK(!m_browser->HasSelection());
|
||||
|
||||
m_browser->SelectAll();
|
||||
|
||||
#if wxUSE_WEBVIEW_WEBKIT2
|
||||
// With WebKit SelectAll() sends a request to perform the selection to
|
||||
// another process via proxy and there doesn't seem to be any way to
|
||||
// wait until this request is actually handled, so loop here for some a
|
||||
// bit before giving up. Avoid calling HasSelection() right away
|
||||
// without wxYielding a bit because this seems to cause the extension
|
||||
// to hang with webkit 2.40.0+.
|
||||
YieldForAWhile();
|
||||
#endif // wxUSE_WEBVIEW_WEBKIT2
|
||||
|
||||
CHECK(m_browser->HasSelection());
|
||||
CHECK(m_browser->GetSelectedText() == "Some strong text");
|
||||
|
||||
#if !defined(__WXOSX__) && (!defined(wxUSE_WEBVIEW_EDGE) || !wxUSE_WEBVIEW_EDGE)
|
||||
// The web engine doesn't necessarily represent the HTML in the same way as
|
||||
// we used above, e.g. IE uses upper case for all the tags while WebKit
|
||||
// under OS X inserts plenty of its own <span> tags, so don't test for
|
||||
// equality and just check that the source contains things we'd expect it
|
||||
// to.
|
||||
const wxString selSource = m_browser->GetSelectedSource();
|
||||
WX_ASSERT_MESSAGE
|
||||
(
|
||||
("Unexpected selection source: \"%s\"", selSource),
|
||||
selSource.Lower().Matches("*some*<strong*strong</strong>*text*")
|
||||
);
|
||||
#endif // !defined(__WXOSX__)
|
||||
|
||||
m_browser->ClearSelection();
|
||||
CHECK(!m_browser->HasSelection());
|
||||
}
|
||||
|
||||
SECTION("Zoom")
|
||||
{
|
||||
if(m_browser->CanSetZoomType(wxWEBVIEW_ZOOM_TYPE_LAYOUT))
|
||||
{
|
||||
m_browser->SetZoomType(wxWEBVIEW_ZOOM_TYPE_LAYOUT);
|
||||
CHECK(m_browser->GetZoomType() == wxWEBVIEW_ZOOM_TYPE_LAYOUT);
|
||||
|
||||
m_browser->SetZoom(wxWEBVIEW_ZOOM_TINY);
|
||||
CHECK(m_browser->GetZoom() == wxWEBVIEW_ZOOM_TINY);
|
||||
}
|
||||
|
||||
//Reset the zoom level
|
||||
m_browser->SetZoom(wxWEBVIEW_ZOOM_MEDIUM);
|
||||
|
||||
if(m_browser->CanSetZoomType(wxWEBVIEW_ZOOM_TYPE_TEXT))
|
||||
{
|
||||
m_browser->SetZoomType(wxWEBVIEW_ZOOM_TYPE_TEXT);
|
||||
CHECK(m_browser->GetZoomType() == wxWEBVIEW_ZOOM_TYPE_TEXT);
|
||||
|
||||
m_browser->SetZoom(wxWEBVIEW_ZOOM_TINY);
|
||||
CHECK(m_browser->GetZoom() == wxWEBVIEW_ZOOM_TINY);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("RunScript")
|
||||
{
|
||||
m_browser->
|
||||
SetPage("<html><head><script></script></head><body></body></html>", "");
|
||||
ENSURE_LOADED;
|
||||
|
||||
wxString result;
|
||||
#if wxUSE_WEBVIEW_IE && !wxUSE_WEBVIEW_EDGE
|
||||
// Define a specialized scope guard ensuring that we reset the emulation
|
||||
// level to its default value even if any asserts below fail.
|
||||
class ResetEmulationLevel
|
||||
{
|
||||
public:
|
||||
ResetEmulationLevel()
|
||||
{
|
||||
// Allow this to fail because it doesn't work in GitHub Actions
|
||||
// environment, but the tests below still pass there.
|
||||
if ( !wxWebViewIE::MSWSetModernEmulationLevel() )
|
||||
{
|
||||
WARN("Setting IE modern emulation level failed.");
|
||||
m_reset = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_reset = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DoReset()
|
||||
{
|
||||
if ( m_reset )
|
||||
{
|
||||
m_reset = false;
|
||||
if ( !wxWebViewIE::MSWSetModernEmulationLevel(false) )
|
||||
{
|
||||
WARN("Resetting IE modern emulation level failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~ResetEmulationLevel()
|
||||
{
|
||||
DoReset();
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_reset;
|
||||
} resetEmulationLevel;
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){var person = new Object();person.name = 'Bar'; \
|
||||
person.lastName = 'Foo';return person;}f();", &result));
|
||||
CHECK(result == "{\"name\":\"Bar\",\"lastName\":\"Foo\"}");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){ return [\"foo\", \"bar\"]; }f();", &result));
|
||||
CHECK(result == "[\"foo\",\"bar\"]");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){var d = new Date('10/08/2017 21:30:40'); \
|
||||
var tzoffset = d.getTimezoneOffset() * 60000; return new Date(d.getTime() - tzoffset);}f();",
|
||||
&result));
|
||||
CHECK(result == "\"2017-10-08T21:30:40.000Z\"");
|
||||
|
||||
resetEmulationLevel.DoReset();
|
||||
#endif // wxUSE_WEBVIEW_IE
|
||||
|
||||
CHECK(m_browser->RunScript("document.write(\"Hello World!\");"));
|
||||
CHECK(m_browser->GetPageText() == "Hello World!");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(a){return a;}f('Hello World!');", &result));
|
||||
CHECK(result == _("Hello World!"));
|
||||
|
||||
CHECK(m_browser->RunScript("function f(a){return a;}f('a\\\'aa\\n\\rb\\tb\\\\ccc\\\"ddd\\b\\fx');", &result));
|
||||
CHECK(result == _("a\'aa\n\rb\tb\\ccc\"ddd\b\fx"));
|
||||
|
||||
CHECK(m_browser->RunScript("function f(a){return a;}f(123);", &result));
|
||||
CHECK(wxAtoi(result) == 123);
|
||||
|
||||
CHECK(m_browser->
|
||||
RunScript("function f(a){return a;}f(2.34);", &result));
|
||||
double value;
|
||||
result.ToDouble(&value);
|
||||
CHECK(value == 2.34);
|
||||
|
||||
CHECK(m_browser->RunScript("function f(a){return a;}f(false);", &result));
|
||||
CHECK(result == "false");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){var person = new Object();person.lastName = 'Bar'; \
|
||||
person.name = 'Foo';return person;}f();", &result));
|
||||
CHECK(result == "{\"lastName\":\"Bar\",\"name\":\"Foo\"}");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){ return [\"foo\", \"bar\"]; }f();", &result));
|
||||
CHECK(result == "[\"foo\",\"bar\"]");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){var person = new Object();}f();", &result));
|
||||
CHECK(result == "undefined");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){return null;}f();", &result));
|
||||
CHECK(result == "null");
|
||||
|
||||
result = "";
|
||||
CHECK(!m_browser->RunScript("int main() { return 0; }", &result));
|
||||
CHECK(result.empty());
|
||||
|
||||
CHECK(m_browser->RunScript("function a() { return eval(\"function b() { \
|
||||
return eval(\\\"function c() { return eval(\\\\\\\"function d() { \
|
||||
return \\\\\\\\\\\\\\\"test\\\\\\\\\\\\\\\"; } d();\\\\\\\"); } \
|
||||
c();\\\"); } b();\"); } a();", &result));
|
||||
CHECK(result == "test");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(a){return a;}f(\"This is a backslash: \\\\\");",
|
||||
&result));
|
||||
CHECK(result == "This is a backslash: \\");
|
||||
|
||||
CHECK(m_browser->RunScript("function f(){var d = new Date('10/08/2016 21:30:40'); \
|
||||
var tzoffset = d.getTimezoneOffset() * 60000; return new Date(d.getTime() - tzoffset);}f();",
|
||||
&result));
|
||||
CHECK(result == "\"2016-10-08T21:30:40.000Z\"");
|
||||
|
||||
// Check for C++-style comments which used to be broken.
|
||||
CHECK(m_browser->RunScript("function f() {\n"
|
||||
" // A C++ style comment\n"
|
||||
" return 17;\n"
|
||||
"}f();", &result));
|
||||
CHECK(result == "17");
|
||||
|
||||
// Check for errors too.
|
||||
CHECK(!m_browser->RunScript("syntax(error"));
|
||||
CHECK(!m_browser->RunScript("syntax(error", &result));
|
||||
CHECK(!m_browser->RunScript("x.y.z"));
|
||||
}
|
||||
|
||||
SECTION("RunScriptAsync")
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
// IE doesn't support async script execution
|
||||
if (!wxWebView::IsBackendAvailable(wxWebViewBackendEdge))
|
||||
return;
|
||||
#endif
|
||||
RunAsyncScript("function f(a){return a;}f('Hello World!');");
|
||||
CHECK(m_asyncScriptResult == 1);
|
||||
CHECK(m_asyncScriptString == "Hello World!");
|
||||
|
||||
RunAsyncScript("int main() { return 0; }");
|
||||
CHECK(m_asyncScriptResult == 0);
|
||||
}
|
||||
|
||||
SECTION("SetPage")
|
||||
{
|
||||
m_browser->SetPage("<html><body>text</body></html>", "");
|
||||
ENSURE_LOADED;
|
||||
CHECK(m_browser->GetPageText() == "text");
|
||||
|
||||
m_browser->SetPage("<html><body>other text</body></html>", "");
|
||||
ENSURE_LOADED;
|
||||
CHECK(m_browser->GetPageText() == "other text");
|
||||
}
|
||||
}
|
||||
|
||||
#endif //wxUSE_WEBVIEW && (wxUSE_WEBVIEW_WEBKIT || wxUSE_WEBVIEW_WEBKIT2 || wxUSE_WEBVIEW_IE)
|
||||
520
libs/wxWidgets-3.3.1/tests/controls/windowtest.cpp
Normal file
520
libs/wxWidgets-3.3.1/tests/controls/windowtest.cpp
Normal file
@@ -0,0 +1,520 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/controls/windowtest.cpp
|
||||
// Purpose: wxWindow unit test
|
||||
// Author: Steven Lamerton
|
||||
// Created: 2010-07-10
|
||||
// Copyright: (c) 2010 Steven Lamerton
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/window.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/sizer.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "asserthelper.h"
|
||||
#include "testableframe.h"
|
||||
#include "testwindow.h"
|
||||
#include "waitfor.h"
|
||||
|
||||
#include "wx/uiaction.h"
|
||||
#include "wx/caret.h"
|
||||
#include "wx/cshelp.h"
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/tooltip.h"
|
||||
#include "wx/wupdlock.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class WindowTestCase
|
||||
{
|
||||
public:
|
||||
WindowTestCase()
|
||||
: m_window(new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY))
|
||||
{
|
||||
#ifdef __WXGTK3__
|
||||
// Without this, when running this test suite solo it succeeds,
|
||||
// but not when running it together with the other tests !!
|
||||
// Not needed when run under Xvfb display.
|
||||
YieldForAWhile();
|
||||
#endif
|
||||
}
|
||||
|
||||
~WindowTestCase()
|
||||
{
|
||||
wxTheApp->GetTopWindow()->DestroyChildren();
|
||||
}
|
||||
|
||||
protected:
|
||||
wxWindow* const m_window;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(WindowTestCase);
|
||||
};
|
||||
|
||||
static void DoTestShowHideEvent(wxWindow* window)
|
||||
{
|
||||
EventCounter show(window, wxEVT_SHOW);
|
||||
|
||||
CHECK(window->IsShown());
|
||||
|
||||
window->Show(false);
|
||||
|
||||
CHECK(!window->IsShown());
|
||||
|
||||
window->Show();
|
||||
|
||||
CHECK(window->IsShown());
|
||||
|
||||
CHECK( show.GetCount() == 2 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::ShowHideEvent", "[window]")
|
||||
{
|
||||
SECTION("Normal window")
|
||||
{
|
||||
DoTestShowHideEvent(m_window);
|
||||
}
|
||||
|
||||
SECTION("Frozen window")
|
||||
{
|
||||
wxWindowUpdateLocker freeze(m_window->GetParent() );
|
||||
REQUIRE( m_window->IsFrozen() );
|
||||
|
||||
DoTestShowHideEvent(m_window);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::KeyEvent", "[window]")
|
||||
{
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
if ( !EnableUITests() )
|
||||
return;
|
||||
|
||||
EventCounter keydown(m_window, wxEVT_KEY_DOWN);
|
||||
EventCounter keyup(m_window, wxEVT_KEY_UP);
|
||||
EventCounter keychar(m_window, wxEVT_CHAR);
|
||||
|
||||
wxUIActionSimulator sim;
|
||||
|
||||
m_window->SetFocus();
|
||||
wxYield();
|
||||
|
||||
sim.Text("text");
|
||||
sim.Char(WXK_SHIFT);
|
||||
wxYield();
|
||||
|
||||
CHECK( keydown.GetCount() == 5 );
|
||||
CHECK( keyup.GetCount() == 5 );
|
||||
CHECK( keychar.GetCount() == 4 );
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::FocusEvent", "[window]")
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
if ( IsAutomaticTest() )
|
||||
{
|
||||
// Skip this test when running under buildbot, it fails there for
|
||||
// unknown reason and this failure can't be reproduced locally.
|
||||
return;
|
||||
}
|
||||
|
||||
EventCounter setfocus(m_window, wxEVT_SET_FOCUS);
|
||||
EventCounter killfocus(m_window, wxEVT_KILL_FOCUS);
|
||||
|
||||
m_window->SetFocus();
|
||||
|
||||
CHECK(setfocus.WaitEvent(500));
|
||||
CHECK_FOCUS_IS( m_window );
|
||||
|
||||
wxButton* button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
|
||||
button->SetFocus();
|
||||
wxYield();
|
||||
|
||||
CHECK( killfocus.GetCount() == 1 );
|
||||
CHECK(!m_window->HasFocus());
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Mouse", "[window]")
|
||||
{
|
||||
wxCursor cursor(wxCURSOR_HAND);
|
||||
m_window->SetCursor(cursor);
|
||||
|
||||
CHECK(m_window->GetCursor().IsOk());
|
||||
|
||||
#if wxUSE_CARET
|
||||
CHECK(!m_window->GetCaret());
|
||||
|
||||
wxCaret* caret = nullptr;
|
||||
|
||||
// Try creating the caret in two different, but normally equivalent, ways.
|
||||
SECTION("Caret 1-step")
|
||||
{
|
||||
caret = new wxCaret(m_window, 16, 16);
|
||||
}
|
||||
|
||||
SECTION("Caret 2-step")
|
||||
{
|
||||
caret = new wxCaret();
|
||||
caret->Create(m_window, 16, 16);
|
||||
}
|
||||
|
||||
m_window->SetCaret(caret);
|
||||
|
||||
CHECK(m_window->GetCaret()->IsOk());
|
||||
#endif
|
||||
|
||||
m_window->CaptureMouse();
|
||||
|
||||
CHECK(m_window->HasCapture());
|
||||
|
||||
m_window->ReleaseMouse();
|
||||
|
||||
CHECK(!m_window->HasCapture());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Properties", "[window]")
|
||||
{
|
||||
m_window->SetLabel("label");
|
||||
|
||||
CHECK( m_window->GetLabel() == "label" );
|
||||
|
||||
m_window->SetName("name");
|
||||
|
||||
CHECK( m_window->GetName() == "name" );
|
||||
|
||||
//As we used wxID_ANY we should have a negative id
|
||||
CHECK(m_window->GetId() < 0);
|
||||
|
||||
m_window->SetId(wxID_HIGHEST + 10);
|
||||
|
||||
CHECK( m_window->GetId() == wxID_HIGHEST + 10 );
|
||||
}
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::ToolTip", "[window]")
|
||||
{
|
||||
CHECK(!m_window->GetToolTip());
|
||||
CHECK( m_window->GetToolTipText() == "" );
|
||||
|
||||
m_window->SetToolTip("text tip");
|
||||
|
||||
CHECK( m_window->GetToolTipText() == "text tip" );
|
||||
|
||||
m_window->UnsetToolTip();
|
||||
|
||||
CHECK(!m_window->GetToolTip());
|
||||
CHECK( m_window->GetToolTipText() == "" );
|
||||
|
||||
wxToolTip* tip = new wxToolTip("other tip");
|
||||
|
||||
m_window->SetToolTip(tip);
|
||||
|
||||
CHECK( m_window->GetToolTip() == tip );
|
||||
CHECK( m_window->GetToolTipText() == "other tip" );
|
||||
}
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Help", "[window]")
|
||||
{
|
||||
#if wxUSE_HELP
|
||||
wxHelpProvider::Set(new wxSimpleHelpProvider());
|
||||
|
||||
CHECK( m_window->GetHelpText() == "" );
|
||||
|
||||
m_window->SetHelpText("helptext");
|
||||
|
||||
CHECK( m_window->GetHelpText() == "helptext" );
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Parent", "[window]")
|
||||
{
|
||||
CHECK( m_window->GetGrandParent() == static_cast<wxWindow*>(nullptr) );
|
||||
CHECK( m_window->GetParent() == wxTheApp->GetTopWindow() );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Siblings", "[window]")
|
||||
{
|
||||
CHECK( m_window->GetNextSibling() == static_cast<wxWindow*>(nullptr) );
|
||||
CHECK( m_window->GetPrevSibling() == static_cast<wxWindow*>(nullptr) );
|
||||
|
||||
wxWindow* newwin = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);
|
||||
|
||||
CHECK( m_window->GetNextSibling() == newwin );
|
||||
CHECK( m_window->GetPrevSibling() == static_cast<wxWindow*>(nullptr) );
|
||||
|
||||
CHECK( newwin->GetNextSibling() == static_cast<wxWindow*>(nullptr) );
|
||||
CHECK( newwin->GetPrevSibling() == m_window );
|
||||
|
||||
wxDELETE(newwin);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Children", "[window]")
|
||||
{
|
||||
CHECK( m_window->GetChildren().GetCount() == 0 );
|
||||
|
||||
wxWindow* child1 = new wxWindow(m_window, wxID_ANY);
|
||||
|
||||
CHECK( m_window->GetChildren().GetCount() == 1 );
|
||||
|
||||
m_window->RemoveChild(child1);
|
||||
|
||||
CHECK( m_window->GetChildren().GetCount() == 0 );
|
||||
|
||||
child1->SetId(wxID_HIGHEST + 1);
|
||||
child1->SetName("child1");
|
||||
|
||||
m_window->AddChild(child1);
|
||||
|
||||
CHECK( m_window->GetChildren().GetCount() == 1 );
|
||||
CHECK( m_window->FindWindow(wxID_HIGHEST + 1) == child1 );
|
||||
CHECK( m_window->FindWindow("child1") == child1 );
|
||||
|
||||
m_window->DestroyChildren();
|
||||
|
||||
CHECK( m_window->GetChildren().GetCount() == 0 );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Focus", "[window]")
|
||||
{
|
||||
#ifndef __WXOSX__
|
||||
CHECK(!m_window->HasFocus());
|
||||
|
||||
if ( m_window->AcceptsFocus() )
|
||||
{
|
||||
m_window->SetFocus();
|
||||
CHECK_FOCUS_IS(m_window);
|
||||
}
|
||||
|
||||
//Set the focus back to the main window
|
||||
wxTheApp->GetTopWindow()->SetFocus();
|
||||
|
||||
if ( m_window->AcceptsFocusFromKeyboard() )
|
||||
{
|
||||
m_window->SetFocusFromKbd();
|
||||
CHECK_FOCUS_IS(m_window);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Positioning", "[window]")
|
||||
{
|
||||
//Some basic tests for consistency
|
||||
int x, y;
|
||||
m_window->GetPosition(&x, &y);
|
||||
|
||||
CHECK( m_window->GetPosition().x == x );
|
||||
CHECK( m_window->GetPosition().y == y );
|
||||
CHECK( m_window->GetRect().GetTopLeft() == m_window->GetPosition() );
|
||||
|
||||
m_window->GetScreenPosition(&x, &y);
|
||||
CHECK( m_window->GetScreenPosition().x == x );
|
||||
CHECK( m_window->GetScreenPosition().y == y );
|
||||
CHECK( m_window->GetScreenRect().GetTopLeft() == m_window->GetScreenPosition() );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::PositioningBeyondShortLimit", "[window]")
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
//Positioning under MSW is limited to short relative coordinates
|
||||
|
||||
//
|
||||
//Test window creation beyond SHRT_MAX
|
||||
int commonDim = 10;
|
||||
wxWindow* w = new wxWindow(m_window, wxID_ANY,
|
||||
wxPoint(0, SHRT_MAX + commonDim),
|
||||
wxSize(commonDim, commonDim));
|
||||
CHECK( w->GetPosition().y == SHRT_MAX + commonDim );
|
||||
|
||||
w->Move(0, 0);
|
||||
|
||||
//
|
||||
//Test window moving beyond SHRT_MAX
|
||||
w->Move(0, SHRT_MAX + commonDim);
|
||||
CHECK( w->GetPosition().y == SHRT_MAX + commonDim );
|
||||
|
||||
//
|
||||
//Test window moving below SHRT_MIN
|
||||
w->Move(0, SHRT_MIN - commonDim);
|
||||
CHECK( w->GetPosition().y == SHRT_MIN - commonDim );
|
||||
|
||||
//
|
||||
//Test deferred move beyond SHRT_MAX
|
||||
m_window->SetVirtualSize(-1, SHRT_MAX + 2 * commonDim);
|
||||
wxWindow* bigWin = new wxWindow(m_window, wxID_ANY, wxDefaultPosition,
|
||||
//size is also limited by SHRT_MAX
|
||||
wxSize(commonDim, SHRT_MAX));
|
||||
wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->Add(bigWin);
|
||||
sizer->AddSpacer(commonDim); //add some space to go beyond SHRT_MAX
|
||||
sizer->Add(w);
|
||||
m_window->SetSizer(sizer);
|
||||
m_window->Layout();
|
||||
CHECK( w->GetPosition().y == SHRT_MAX + commonDim );
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Show", "[window]")
|
||||
{
|
||||
CHECK(m_window->IsShown());
|
||||
|
||||
m_window->Hide();
|
||||
|
||||
CHECK(!m_window->IsShown());
|
||||
|
||||
m_window->Show();
|
||||
|
||||
CHECK(m_window->IsShown());
|
||||
|
||||
m_window->Show(false);
|
||||
|
||||
CHECK(!m_window->IsShown());
|
||||
|
||||
m_window->ShowWithEffect(wxSHOW_EFFECT_BLEND);
|
||||
|
||||
CHECK(m_window->IsShown());
|
||||
|
||||
m_window->HideWithEffect(wxSHOW_EFFECT_BLEND);
|
||||
|
||||
CHECK(!m_window->IsShown());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Enable", "[window]")
|
||||
{
|
||||
CHECK(m_window->IsEnabled());
|
||||
|
||||
m_window->Disable();
|
||||
|
||||
CHECK(!m_window->IsEnabled());
|
||||
|
||||
m_window->Enable();
|
||||
|
||||
CHECK(m_window->IsEnabled());
|
||||
|
||||
m_window->Enable(false);
|
||||
|
||||
CHECK(!m_window->IsEnabled());
|
||||
m_window->Enable();
|
||||
|
||||
|
||||
wxWindow* const child = new wxWindow(m_window, wxID_ANY);
|
||||
CHECK(child->IsEnabled());
|
||||
CHECK(child->IsThisEnabled());
|
||||
|
||||
m_window->Disable();
|
||||
CHECK(!child->IsEnabled());
|
||||
CHECK(child->IsThisEnabled());
|
||||
|
||||
child->Disable();
|
||||
CHECK(!child->IsEnabled());
|
||||
CHECK(!child->IsThisEnabled());
|
||||
|
||||
m_window->Enable();
|
||||
CHECK(!child->IsEnabled());
|
||||
CHECK(!child->IsThisEnabled());
|
||||
|
||||
child->Enable();
|
||||
CHECK(child->IsEnabled());
|
||||
CHECK(child->IsThisEnabled());
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::FindWindowBy", "[window]")
|
||||
{
|
||||
m_window->SetId(wxID_HIGHEST + 1);
|
||||
m_window->SetName("name");
|
||||
m_window->SetLabel("label");
|
||||
|
||||
CHECK( wxWindow::FindWindowById(wxID_HIGHEST + 1) == m_window );
|
||||
CHECK( wxWindow::FindWindowByName("name") == m_window );
|
||||
CHECK( wxWindow::FindWindowByLabel("label") == m_window );
|
||||
|
||||
CHECK( wxWindow::FindWindowById(wxID_HIGHEST + 3) == nullptr );
|
||||
CHECK( wxWindow::FindWindowByName("noname") == nullptr );
|
||||
CHECK( wxWindow::FindWindowByLabel("nolabel") == nullptr );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::SizerErrors", "[window][sizer][error]")
|
||||
{
|
||||
wxWindow* const child = new wxWindow(m_window, wxID_ANY);
|
||||
std::unique_ptr<wxSizer> const sizer1(new wxBoxSizer(wxHORIZONTAL));
|
||||
std::unique_ptr<wxSizer> const sizer2(new wxBoxSizer(wxHORIZONTAL));
|
||||
|
||||
REQUIRE_NOTHROW( sizer1->Add(child) );
|
||||
#ifdef __WXDEBUG__
|
||||
CHECK_THROWS_AS( sizer1->Add(child), TestAssertFailure );
|
||||
CHECK_THROWS_AS( sizer2->Add(child), TestAssertFailure );
|
||||
#else
|
||||
CHECK_NOTHROW( sizer1->Add(child) );
|
||||
CHECK_NOTHROW( sizer2->Add(child) );
|
||||
#endif
|
||||
|
||||
CHECK_NOTHROW( sizer1->Detach(child) );
|
||||
CHECK_NOTHROW( sizer2->Add(child) );
|
||||
|
||||
REQUIRE_NOTHROW( delete child );
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(WindowTestCase, "Window::Refresh", "[window]")
|
||||
{
|
||||
wxWindow* const parent = m_window;
|
||||
wxWindow* const child1 = new wxWindow(parent, wxID_ANY, wxPoint(10, 20), wxSize(80, 50));
|
||||
wxWindow* const child2 = new wxWindow(parent, wxID_ANY, wxPoint(110, 20), wxSize(80, 50));
|
||||
wxWindow* const child3 = new wxWindow(parent, wxID_ANY, wxPoint(210, 20), wxSize(80, 50));
|
||||
|
||||
m_window->SetSize(300, 100);
|
||||
|
||||
// to help see the windows when debugging
|
||||
parent->SetBackgroundColour(*wxBLACK);
|
||||
child1->SetBackgroundColour(*wxBLUE);
|
||||
child2->SetBackgroundColour(*wxRED);
|
||||
child3->SetBackgroundColour(*wxGREEN);
|
||||
|
||||
// Notice that using EventCounter here will give incorrect results,
|
||||
// so we have to bind each window to a distinct event handler instead.
|
||||
|
||||
bool isParentPainted;
|
||||
bool isChild1Painted;
|
||||
bool isChild2Painted;
|
||||
bool isChild3Painted;
|
||||
|
||||
const auto setFlagOnPaint = [](wxWindow* win, bool* flag)
|
||||
{
|
||||
win->Bind(wxEVT_PAINT, [=](wxPaintEvent&)
|
||||
{
|
||||
wxPaintDC dc(win);
|
||||
*flag = true;
|
||||
});
|
||||
};
|
||||
|
||||
setFlagOnPaint(parent, &isParentPainted);
|
||||
setFlagOnPaint(child1, &isChild1Painted);
|
||||
setFlagOnPaint(child2, &isChild2Painted);
|
||||
setFlagOnPaint(child3, &isChild3Painted);
|
||||
|
||||
// Prepare for the RefreshRect() call below
|
||||
wxYield();
|
||||
|
||||
// Now initialize/reset the flags before calling RefreshRect()
|
||||
isParentPainted =
|
||||
isChild1Painted =
|
||||
isChild2Painted =
|
||||
isChild3Painted = false;
|
||||
|
||||
parent->RefreshRect(wxRect(150, 10, 300, 80));
|
||||
|
||||
WaitFor("parent repaint", [&]() { return isParentPainted; }, 100);
|
||||
|
||||
// child1 should be the only window not to receive the wxEVT_PAINT event
|
||||
// because it does not intersect with the refreshed rectangle.
|
||||
CHECK(isParentPainted == true);
|
||||
CHECK(isChild1Painted == false);
|
||||
CHECK(isChild2Painted == true);
|
||||
CHECK(isChild3Painted == true);
|
||||
}
|
||||
2590
libs/wxWidgets-3.3.1/tests/datetime/datetimetest.cpp
Normal file
2590
libs/wxWidgets-3.3.1/tests/datetime/datetimetest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
710
libs/wxWidgets-3.3.1/tests/descrip.mms
Normal file
710
libs/wxWidgets-3.3.1/tests/descrip.mms
Normal file
@@ -0,0 +1,710 @@
|
||||
#*****************************************************************************
|
||||
# *
|
||||
# Make file for VMS *
|
||||
# Author : J.Jansen (joukj@hrem.nano.tudelft.nl) *
|
||||
# Date : 6 January 2021 *
|
||||
# *
|
||||
#*****************************************************************************
|
||||
.first
|
||||
define wx [-.include.wx]
|
||||
|
||||
.ifdef __WXMOTIF__
|
||||
TEST_CXXFLAGS = /define=(__WXMOTIF__=1,"wxUSE_GUI=0","CATCH_CONFIG_VARIADIC_MACROS=1")/name=(as_is,short)\
|
||||
/assume=(nostdnew,noglobal_array_new)
|
||||
TEST_GUI_CXXFLAGS = /define=(__WXMOTIF__=1,"wxUSE_GUI=1","CATCH_CONFIG_VARIADIC_MACROS=1")\
|
||||
/name=(as_is,short)\
|
||||
/assume=(nostdnew,noglobal_array_new)
|
||||
.else
|
||||
.ifdef __WXGTK__
|
||||
TEST_CXXFLAGS = /define=(__WXGTK__=1,"wxUSE_GUI=0","__USE_STD_IOSTREAM=1",\
|
||||
"_USE_STD_STAT=1","CATCH_CONFIG_VARIADIC_MACROS=1")\
|
||||
/float=ieee/name=(as_is,short)/ieee=denorm\
|
||||
/assume=(nostdnew,noglobal_array_new)/include=[]/list/show=all
|
||||
TEST_GUI_CXXFLAGS = /define=(__WXGTK__=1,"wxUSE_GUI=1","__USE_STD_IOSTREAM=1",\
|
||||
"CATCH_CONFIG_VARIADIC_MACROS=1")\
|
||||
/float=ieee/name=(as_is,short)/ieee=denorm\
|
||||
/assume=(nostdnew,noglobal_array_new)/include=[]/list/show=all
|
||||
.else
|
||||
.ifdef __WXX11__
|
||||
TEST_CXXFLAGS = /define=(__WXX11__=1,__WXUNIVERSAL__==1,"wxUSE_GUI=0",\
|
||||
"CATCH_CONFIG_VARIADIC_MACROS=1")/float=ieee\
|
||||
/name=(as_is,short)/assume=(nostdnew,noglobal_array_new)
|
||||
TEST_GUI_CXXFLAGS = /define=(__WXGTK__=1,"wxUSE_GUI=1",\
|
||||
"CATCH_CONFIG_VARIADIC_MACROS=1")\
|
||||
/float=ieee/name=(as_is,short)/ieee=denorm\
|
||||
/assume=(nostdnew,noglobal_array_new)
|
||||
.else
|
||||
.ifdef __WXGTK2__
|
||||
TEST_CXXFLAGS = /define=(__WXGTK__=1,VMS_GTK2==1,"wxUSE_GUI=0",\
|
||||
"CATCH_CONFIG_VARIADIC_MACROS=1")/float=ieee\
|
||||
/name=(as_is,short)/assume=(nostdnew,noglobal_array_new)
|
||||
TEST_GUI_CXXFLAGS = /define=(__WXGTK__=1,"wxUSE_GUI=1",\
|
||||
"CATCH_CONFIG_VARIADIC_MACROS=1")\
|
||||
/float=ieee/name=(as_is,short)/ieee=denorm\
|
||||
/assume=(nostdnew,noglobal_array_new)
|
||||
.else
|
||||
CXX_DEFINE =
|
||||
CC_DEFINE =
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.suffixes : .cpp
|
||||
|
||||
.cpp.obj :
|
||||
cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp
|
||||
|
||||
CXXC=cxx
|
||||
|
||||
TEST_OBJECTS = \
|
||||
test_anytest.obj,\
|
||||
test_archivetest.obj,\
|
||||
test_arrays.obj,\
|
||||
test_base64.obj,\
|
||||
test_cmdlinetest.obj,\
|
||||
test_fileconf.obj,\
|
||||
test_regconf.obj,\
|
||||
test_datetimetest.obj,\
|
||||
test_evthandler.obj,\
|
||||
test_evtsource.obj,\
|
||||
test_stopwatch.obj,\
|
||||
test_timertest.obj,\
|
||||
test_exec.obj,\
|
||||
test_dir.obj,\
|
||||
test_filefn.obj,\
|
||||
test_filetest.obj,\
|
||||
test_filekind.obj,\
|
||||
test_filenametest.obj,\
|
||||
test_filesystest.obj,\
|
||||
test_fontmaptest.obj,\
|
||||
test_formatconvertertest.obj,\
|
||||
test_hashes.obj,\
|
||||
test_output.obj,\
|
||||
test_input.obj,\
|
||||
test_intltest.obj,\
|
||||
test_lists.obj,\
|
||||
test_logtest.obj,\
|
||||
test_longlongtest.obj,\
|
||||
test_convautotest.obj,\
|
||||
test_mbconvtest.obj,\
|
||||
test_dynamiclib.obj,\
|
||||
test_environ.obj,\
|
||||
test_metatest.obj,\
|
||||
test_misctests.obj,\
|
||||
test_module.obj,\
|
||||
test_pathlist.obj,\
|
||||
test_typeinfotest.obj
|
||||
|
||||
TEST_OBJECTS1=test_ipc.obj,\
|
||||
test_socket.obj,\
|
||||
test_regextest.obj,\
|
||||
test_wxregextest.obj,\
|
||||
test_scopeguardtest.obj,\
|
||||
test_iostream.obj,\
|
||||
test_strings.obj,\
|
||||
test_stdstrings.obj,\
|
||||
test_tokenizer.obj,\
|
||||
test_unichar.obj,\
|
||||
test_unicode.obj,\
|
||||
test_crt.obj,\
|
||||
test_vsnprintf.obj,\
|
||||
test_datastreamtest.obj,\
|
||||
test_ffilestream.obj,\
|
||||
test_fileback.obj,\
|
||||
test_filestream.obj,\
|
||||
test_iostreams.obj,\
|
||||
test_largefile.obj,\
|
||||
test_memstream.obj,\
|
||||
test_socketstream.obj,\
|
||||
test_sstream.obj,\
|
||||
test_stdstream.obj,\
|
||||
test_tempfile.obj,\
|
||||
test_textstreamtest.obj,\
|
||||
test_zlibstream.obj,\
|
||||
test_textfiletest.obj,\
|
||||
test_atomic.obj,\
|
||||
test_misc.obj,\
|
||||
test_queue.obj,\
|
||||
test_tls.obj,\
|
||||
test_ftp.obj,\
|
||||
test_uris.obj,\
|
||||
test_url.obj,\
|
||||
test_evtconnection.obj,\
|
||||
test_weakref.obj,\
|
||||
test_xlocale.obj,\
|
||||
test_xmltest.obj
|
||||
|
||||
TEST_L_OBJs=test_ziptest.obj,\
|
||||
test_tartest.obj
|
||||
|
||||
TEST_GUI_OBJECTS = \
|
||||
test_gui_asserthelper.obj,\
|
||||
test_gui_testableframe.obj,\
|
||||
test_gui_rect.obj,\
|
||||
test_gui_size.obj,\
|
||||
test_gui_point.obj,\
|
||||
test_gui_bitmap.obj,\
|
||||
test_gui_colour.obj,\
|
||||
test_gui_ellipsization.obj,\
|
||||
test_gui_measuring.obj,\
|
||||
test_gui_config.obj,\
|
||||
test_gui_bitmapcomboboxtest.obj,\
|
||||
test_gui_bitmaptogglebuttontest.obj,\
|
||||
test_gui_bookctrlbasetest.obj,\
|
||||
test_gui_buttontest.obj
|
||||
|
||||
TEST_GUI_OBJECTS1=test_gui_checkboxtest.obj,\
|
||||
test_gui_checklistboxtest.obj,\
|
||||
test_gui_choicebooktest.obj,\
|
||||
test_gui_choicetest.obj,\
|
||||
test_gui_comboboxtest.obj,\
|
||||
test_gui_frametest.obj,\
|
||||
test_gui_gaugetest.obj,\
|
||||
test_gui_gridtest.obj,\
|
||||
test_gui_headerctrltest.obj,\
|
||||
test_gui_htmllboxtest.obj,\
|
||||
test_gui_hyperlinkctrltest.obj,\
|
||||
test_gui_itemcontainertest.obj,\
|
||||
test_gui_label.obj,\
|
||||
test_gui_listbasetest.obj,\
|
||||
test_gui_listbooktest.obj,\
|
||||
test_gui_listboxtest.obj,\
|
||||
test_gui_listctrltest.obj,\
|
||||
test_gui_listviewtest.obj,\
|
||||
test_gui_notebooktest.obj,\
|
||||
test_gui_pickerbasetest.obj,\
|
||||
test_gui_pickertest.obj,\
|
||||
test_gui_radioboxtest.obj,\
|
||||
test_gui_radiobuttontest.obj,\
|
||||
test_gui_rearrangelisttest.obj
|
||||
|
||||
TEST_GUI_OBJECTS2=test_gui_richtextctrltest.obj,\
|
||||
test_gui_slidertest.obj,\
|
||||
test_gui_spinctrldbltest.obj,\
|
||||
test_gui_spinctrltest.obj,\
|
||||
test_gui_styledtextctrltest.obj,\
|
||||
test_gui_textctrltest.obj,\
|
||||
test_gui_textentrytest.obj,\
|
||||
test_gui_togglebuttontest.obj,\
|
||||
test_gui_toolbooktest.obj,\
|
||||
test_gui_treebooktest.obj,\
|
||||
test_gui_treectrltest.obj,\
|
||||
test_gui_virtlistctrltest.obj,\
|
||||
test_gui_windowtest.obj,\
|
||||
test_gui_clone.obj,\
|
||||
test_gui_propagation.obj,\
|
||||
test_gui_keyboard.obj,\
|
||||
test_gui_fonttest.obj,\
|
||||
test_gui_image.obj,\
|
||||
test_gui_rawbmp.obj,\
|
||||
test_gui_htmlwindow.obj,\
|
||||
test_gui_accelentry.obj,\
|
||||
test_gui_menu.obj,\
|
||||
test_gui_guifuncs.obj,\
|
||||
test_gui_selstoretest.obj,\
|
||||
test_gui_garbage.obj,\
|
||||
test_gui_settings.obj,\
|
||||
test_gui_socket.obj,\
|
||||
test_gui_boxsizer.obj,\
|
||||
test_gui_clientsize.obj,\
|
||||
test_gui_setsize.obj,\
|
||||
test_gui_xrctest.obj
|
||||
|
||||
.ifdef __WXMOTIF__
|
||||
.else
|
||||
.ifdef __WXGTK__
|
||||
all : test_gtk.exe test_gui_gtk.exe
|
||||
write sys$output "tests created"
|
||||
|
||||
test_gtk.exe : test_test.obj $(TEST_OBJECTS) $(TEST_OBJECTS1) $(TEST_L_OBJS)
|
||||
library/create temp.olb $(TEST_OBJECTS)
|
||||
library temp.olb $(TEST_OBJECTS1)
|
||||
cxxlink/exec=test_gtk.exe test_test.obj,$(TEST_L_OBJS),temp.olb/lib,\
|
||||
sys$library:libcppunit.olb/lib,[-.lib]vms_gtk/opt
|
||||
delete temp.olb;*
|
||||
|
||||
test_gui_gtk.exe : test_gui_test.obj $(TEST_GUI_OBJECTS) $(TEST_GUI_OBJECTS1)\
|
||||
$(TEST_GUI_OBJECTS2)
|
||||
library/create temp.olb $(TEST_GUI_OBJECTS)
|
||||
library temp.olb $(TEST_GUI_OBJECTS1)
|
||||
library temp.olb $(TEST_GUI_OBJECTS2)
|
||||
cxxlink/exec=test_gui_gtk.exe test_gui_test.obj,temp.olb/lib,\
|
||||
sys$library:libcppunit.olb/lib,[-.lib]vms_gtk/opt
|
||||
.else
|
||||
.ifdef __WXX11__
|
||||
.else
|
||||
.ifdef __WXGTK2__
|
||||
.else
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
$(TEST_OBJECTS) : [-.include.wx]setup.h
|
||||
$(TEST_GUI_OBJECTS) : [-.include.wx]setup.h
|
||||
|
||||
test_test.obj : test.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) test.cpp
|
||||
|
||||
test_anytest.obj : [.any]anytest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.any]anytest.cpp
|
||||
|
||||
test_archivetest.obj : [.archive]archivetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.archive]archivetest.cpp
|
||||
|
||||
test_ziptest.obj : [.archive]ziptest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.archive]ziptest.cpp
|
||||
|
||||
test_tartest.obj : [.archive]tartest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.archive]tartest.cpp
|
||||
|
||||
test_arrays.obj : [.arrays]arrays.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.arrays]arrays.cpp
|
||||
|
||||
test_base64.obj : [.base64]base64.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.base64]base64.cpp
|
||||
|
||||
test_cmdlinetest.obj : [.cmdline]cmdlinetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.cmdline]cmdlinetest.cpp
|
||||
|
||||
test_fileconf.obj : [.config]fileconf.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.config]fileconf.cpp
|
||||
|
||||
test_regconf.obj : [.config]regconf.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.config]regconf.cpp
|
||||
|
||||
test_datetimetest.obj : [.datetime]datetimetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS)/warn=(disable=INTSIGNCHANGE)\
|
||||
[.datetime]datetimetest.cpp
|
||||
|
||||
test_evthandler.obj : [.events]evthandler.cpp
|
||||
.ifdef ALPHA
|
||||
pipe gsed\
|
||||
-e "s/handler.Connect(wxEVT_THREAD, wxThreadEventHandler(MyHandler::OnOverloadedHandler));//"\
|
||||
-e "s/handler.Connect(wxEVT_IDLE, wxIdleEventHandler(MyHandler::OnOverloadedHandler));//" \
|
||||
< [.events]evthandler.cpp > [.events]evthandler.cpp_
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.events]evthandler.cpp_
|
||||
delete [.events]evthandler.cpp_;*
|
||||
.else
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.events]evthandler.cpp
|
||||
.endif
|
||||
|
||||
test_evtsource.obj : [.events]evtsource.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.events]evtsource.cpp
|
||||
|
||||
test_stopwatch.obj : [.events]stopwatch.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.events]stopwatch.cpp
|
||||
|
||||
test_timertest.obj : [.events]timertest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.events]timertest.cpp
|
||||
|
||||
test_exec.obj : [.exec]exec.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.exec]exec.cpp
|
||||
|
||||
test_dir.obj : [.file]dir.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.file]dir.cpp
|
||||
|
||||
test_filefn.obj : [.file]filefn.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.file]filefn.cpp
|
||||
|
||||
test_filetest.obj : [.file]filetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.file]filetest.cpp
|
||||
|
||||
test_filekind.obj : [.filekind]filekind.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.filekind]filekind.cpp
|
||||
|
||||
test_filenametest.obj : [.filename]filenametest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.filename]filenametest.cpp
|
||||
|
||||
test_filesystest.obj : [.filesys]filesystest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.filesys]filesystest.cpp
|
||||
|
||||
test_fontmaptest.obj : [.fontmap]fontmaptest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.fontmap]fontmaptest.cpp
|
||||
|
||||
test_formatconvertertest.obj : [.formatconverter]formatconvertertest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.formatconverter]formatconvertertest.cpp
|
||||
|
||||
test_hashes.obj : [.hashes]hashes.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.hashes]hashes.cpp
|
||||
|
||||
test_output.obj : [.interactive]output.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.interactive]output.cpp
|
||||
|
||||
test_input.obj : [.interactive]input.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.interactive]input.cpp
|
||||
|
||||
test_intltest.obj : [.intl]intltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.intl]intltest.cpp
|
||||
|
||||
test_lists.obj : [.lists]lists.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.lists]lists.cpp
|
||||
|
||||
test_logtest.obj : [.log]logtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.log]logtest.cpp
|
||||
|
||||
test_longlongtest.obj : [.longlong]longlongtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.longlong]longlongtest.cpp
|
||||
|
||||
test_convautotest.obj : [.mbconv]convautotest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.mbconv]convautotest.cpp
|
||||
|
||||
test_mbconvtest.obj : [.mbconv]mbconvtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.mbconv]mbconvtest.cpp
|
||||
|
||||
test_dynamiclib.obj : [.misc]dynamiclib.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]dynamiclib.cpp
|
||||
|
||||
test_environ.obj : [.misc]environ.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]environ.cpp
|
||||
|
||||
test_metatest.obj : [.misc]metatest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]metatest.cpp
|
||||
|
||||
test_misctests.obj : [.misc]misctests.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]misctests.cpp
|
||||
|
||||
test_module.obj : [.misc]module.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]module.cpp
|
||||
|
||||
test_pathlist.obj : [.misc]pathlist.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]pathlist.cpp
|
||||
|
||||
test_typeinfotest.obj : [.misc]typeinfotest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.misc]typeinfotest.cpp
|
||||
|
||||
test_ipc.obj : [.net]ipc.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.net]ipc.cpp
|
||||
|
||||
test_socket.obj : [.net]socket.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS)/warn=(disable=REFTEMPORARY)\
|
||||
[.net]socket.cpp
|
||||
|
||||
test_regextest.obj : [.regex]regextest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.regex]regextest.cpp
|
||||
|
||||
test_wxregextest.obj : [.regex]wxregextest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.regex]wxregextest.cpp
|
||||
|
||||
test_scopeguardtest.obj : [.scopeguard]scopeguardtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.scopeguard]scopeguardtest.cpp
|
||||
|
||||
test_iostream.obj : [.strings]iostream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.strings]iostream.cpp
|
||||
|
||||
test_strings.obj : [.strings]strings.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS)/warn=(disable=INTSIGNCHANGE)\
|
||||
[.strings]strings.cpp
|
||||
|
||||
test_stdstrings.obj : [.strings]stdstrings.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.strings]stdstrings.cpp
|
||||
|
||||
test_tokenizer.obj : [.strings]tokenizer.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.strings]tokenizer.cpp
|
||||
|
||||
test_unichar.obj : [.strings]unichar.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.strings]unichar.cpp
|
||||
|
||||
test_unicode.obj : [.strings]unicode.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.strings]unicode.cpp
|
||||
|
||||
test_crt.obj : [.strings]crt.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.strings]crt.cpp
|
||||
|
||||
test_vsnprintf.obj : [.strings]vsnprintf.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.strings]vsnprintf.cpp
|
||||
|
||||
test_datastreamtest.obj : [.streams]datastreamtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]datastreamtest.cpp
|
||||
|
||||
test_ffilestream.obj : [.streams]ffilestream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]ffilestream.cpp
|
||||
|
||||
test_fileback.obj : [.streams]fileback.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]fileback.cpp
|
||||
|
||||
test_filestream.obj : [.streams]filestream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]filestream.cpp
|
||||
|
||||
test_iostreams.obj : [.streams]iostreams.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]iostreams.cpp
|
||||
|
||||
test_largefile.obj : [.streams]largefile.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS)/warn=(disable=INTSIGNCHANGE)\
|
||||
[.streams]largefile.cpp
|
||||
|
||||
test_memstream.obj : [.streams]memstream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]memstream.cpp
|
||||
|
||||
test_socketstream.obj : [.streams]socketstream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]socketstream.cpp
|
||||
|
||||
test_sstream.obj : [.streams]sstream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]sstream.cpp
|
||||
|
||||
test_stdstream.obj : [.streams]stdstream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]stdstream.cpp
|
||||
|
||||
test_tempfile.obj : [.streams]tempfile.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]tempfile.cpp
|
||||
|
||||
test_textstreamtest.obj : [.streams]textstreamtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]textstreamtest.cpp
|
||||
|
||||
test_zlibstream.obj : [.streams]zlibstream.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.streams]zlibstream.cpp
|
||||
|
||||
test_textfiletest.obj : [.textfile]textfiletest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.textfile]textfiletest.cpp
|
||||
|
||||
test_atomic.obj : [.thread]atomic.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.thread]atomic.cpp
|
||||
|
||||
test_misc.obj : [.thread]misc.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.thread]misc.cpp
|
||||
|
||||
test_queue.obj : [.thread]queue.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.thread]queue.cpp
|
||||
|
||||
test_tls.obj : [.thread]tls.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.thread]tls.cpp
|
||||
|
||||
test_ftp.obj : [.uris]ftp.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.uris]ftp.cpp
|
||||
|
||||
test_uris.obj : [.uris]uris.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.uris]uris.cpp
|
||||
|
||||
test_url.obj : [.uris]url.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.uris]url.cpp
|
||||
|
||||
test_evtconnection.obj : [.weakref]evtconnection.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.weakref]evtconnection.cpp
|
||||
|
||||
test_weakref.obj : [.weakref]weakref.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.weakref]weakref.cpp
|
||||
|
||||
test_xlocale.obj : [.xlocale]xlocale.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.xlocale]xlocale.cpp
|
||||
|
||||
test_xmltest.obj : [.xml]xmltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_CXXFLAGS) [.xml]xmltest.cpp
|
||||
|
||||
test_gui_test_rc.obj : test.rc
|
||||
$(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_5) $(__DEBUG_DEFINE_p_5) $(__EXCEPTIONS_DEFINE_p_5) $(__RTTI_DEFINE_p_5) $(__THREAD_DEFINE_p_5) --include-dir $(srcdir) $(__DLLFLAG_p_5) --include-dir [...]samples $(__RCDEFDIR_p_1) --include-dir $(top_srcdir)]include
|
||||
|
||||
test_gui_asserthelper.obj : asserthelper.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) asserthelper.cpp
|
||||
|
||||
test_gui_test.obj : test.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) test.cpp
|
||||
|
||||
test_gui_testableframe.obj : testableframe.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) testableframe.cpp
|
||||
|
||||
test_gui_rect.obj : [.geometry]rect.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.geometry]rect.cpp
|
||||
|
||||
test_gui_size.obj : [.geometry]size.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.geometry]size.cpp
|
||||
|
||||
test_gui_point.obj : [.geometry]point.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.geometry]point.cpp
|
||||
|
||||
test_gui_bitmap.obj : [.graphics]bitmap.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.graphics]bitmap.cpp
|
||||
|
||||
test_gui_colour.obj : [.graphics]colour.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.graphics]colour.cpp
|
||||
|
||||
test_gui_ellipsization.obj : [.graphics]ellipsization.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.graphics]ellipsization.cpp
|
||||
|
||||
test_gui_measuring.obj : [.graphics]measuring.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.graphics]measuring.cpp
|
||||
|
||||
test_gui_config.obj : [.config]config.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.config]config.cpp
|
||||
|
||||
test_gui_bitmapcomboboxtest.obj : [.controls]bitmapcomboboxtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]bitmapcomboboxtest.cpp
|
||||
|
||||
test_gui_bitmaptogglebuttontest.obj : [.controls]bitmaptogglebuttontest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]bitmaptogglebuttontest.cpp
|
||||
|
||||
test_gui_bookctrlbasetest.obj : [.controls]bookctrlbasetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]bookctrlbasetest.cpp
|
||||
|
||||
test_gui_buttontest.obj : [.controls]buttontest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]buttontest.cpp
|
||||
|
||||
test_gui_checkboxtest.obj : [.controls]checkboxtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]checkboxtest.cpp
|
||||
|
||||
test_gui_checklistboxtest.obj : [.controls]checklistboxtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]checklistboxtest.cpp
|
||||
|
||||
test_gui_choicebooktest.obj : [.controls]choicebooktest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]choicebooktest.cpp
|
||||
|
||||
test_gui_choicetest.obj : [.controls]choicetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]choicetest.cpp
|
||||
|
||||
test_gui_comboboxtest.obj : [.controls]comboboxtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]comboboxtest.cpp
|
||||
|
||||
test_gui_frametest.obj : [.controls]frametest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]frametest.cpp
|
||||
|
||||
test_gui_gaugetest.obj : [.controls]gaugetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]gaugetest.cpp
|
||||
|
||||
test_gui_gridtest.obj : [.controls]gridtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]gridtest.cpp
|
||||
|
||||
test_gui_headerctrltest.obj : [.controls]headerctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]headerctrltest.cpp
|
||||
|
||||
test_gui_htmllboxtest.obj : [.controls]htmllboxtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]htmllboxtest.cpp
|
||||
|
||||
test_gui_hyperlinkctrltest.obj : [.controls]hyperlinkctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]hyperlinkctrltest.cpp
|
||||
|
||||
test_gui_itemcontainertest.obj : [.controls]itemcontainertest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]itemcontainertest.cpp
|
||||
|
||||
test_gui_label.obj : [.controls]label.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]label.cpp
|
||||
|
||||
test_gui_infobar.obj : [.controls]infobar.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]infobar.cpp
|
||||
|
||||
test_gui_listbasetest.obj : [.controls]listbasetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]listbasetest.cpp
|
||||
|
||||
test_gui_listbooktest.obj : [.controls]listbooktest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]listbooktest.cpp
|
||||
|
||||
test_gui_listboxtest.obj : [.controls]listboxtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]listboxtest.cpp
|
||||
|
||||
test_gui_listctrltest.obj : [.controls]listctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]listctrltest.cpp
|
||||
|
||||
test_gui_listviewtest.obj : [.controls]listviewtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]listviewtest.cpp
|
||||
|
||||
test_gui_notebooktest.obj : [.controls]notebooktest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]notebooktest.cpp
|
||||
|
||||
test_gui_pickerbasetest.obj : [.controls]pickerbasetest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]pickerbasetest.cpp
|
||||
|
||||
test_gui_pickertest.obj : [.controls]pickertest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]pickertest.cpp
|
||||
|
||||
test_gui_radioboxtest.obj : [.controls]radioboxtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]radioboxtest.cpp
|
||||
|
||||
test_gui_radiobuttontest.obj : [.controls]radiobuttontest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]radiobuttontest.cpp
|
||||
|
||||
test_gui_rearrangelisttest.obj : [.controls]rearrangelisttest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]rearrangelisttest.cpp
|
||||
|
||||
test_gui_richtextctrltest.obj : [.controls]richtextctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]richtextctrltest.cpp
|
||||
|
||||
test_gui_slidertest.obj : [.controls]slidertest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]slidertest.cpp
|
||||
|
||||
test_gui_spinctrldbltest.obj : [.controls]spinctrldbltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]spinctrldbltest.cpp
|
||||
|
||||
test_gui_spinctrltest.obj : [.controls]spinctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]spinctrltest.cpp
|
||||
|
||||
test_gui_styledtextctrltest.obj : [.controls]styledtextctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]styledtextctrltest.cpp
|
||||
|
||||
test_gui_textctrltest.obj : [.controls]textctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]textctrltest.cpp
|
||||
|
||||
test_gui_textentrytest.obj : [.controls]textentrytest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]textentrytest.cpp
|
||||
|
||||
test_gui_togglebuttontest.obj : [.controls]togglebuttontest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]togglebuttontest.cpp
|
||||
|
||||
test_gui_toolbooktest.obj : [.controls]toolbooktest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]toolbooktest.cpp
|
||||
|
||||
test_gui_treebooktest.obj : [.controls]treebooktest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]treebooktest.cpp
|
||||
|
||||
test_gui_treectrltest.obj : [.controls]treectrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]treectrltest.cpp
|
||||
|
||||
test_gui_virtlistctrltest.obj : [.controls]virtlistctrltest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]virtlistctrltest.cpp
|
||||
|
||||
test_gui_windowtest.obj : [.controls]windowtest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]windowtest.cpp
|
||||
|
||||
test_gui_clone.obj : [.events]clone.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.events]clone.cpp
|
||||
|
||||
test_gui_propagation.obj : [.events]propagation.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.events]propagation.cpp
|
||||
|
||||
test_gui_keyboard.obj : [.events]keyboard.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.events]keyboard.cpp
|
||||
|
||||
test_gui_fonttest.obj : [.font]fonttest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.font]fonttest.cpp
|
||||
|
||||
test_gui_image.obj : [.image]image.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.image]image.cpp
|
||||
|
||||
test_gui_rawbmp.obj : [.image]rawbmp.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.image]rawbmp.cpp
|
||||
|
||||
test_gui_htmlwindow.obj : [.html]htmlwindow.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.html]htmlwindow.cpp
|
||||
|
||||
test_gui_accelentry.obj : [.menu]accelentry.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.menu]accelentry.cpp
|
||||
|
||||
test_gui_menu.obj : [.menu]menu.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.menu]menu.cpp
|
||||
|
||||
test_gui_guifuncs.obj : [.misc]guifuncs.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.misc]guifuncs.cpp
|
||||
|
||||
test_gui_selstoretest.obj : [.misc]selstoretest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.misc]selstoretest.cpp
|
||||
|
||||
test_gui_garbage.obj : [.misc]garbage.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.misc]garbage.cpp
|
||||
|
||||
test_gui_settings.obj : [.misc]settings.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.misc]settings.cpp
|
||||
|
||||
test_gui_socket.obj : [.net]socket.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS)/warn=(disable=REFTEMPORARY)\
|
||||
[.net]socket.cpp
|
||||
|
||||
test_gui_boxsizer.obj : [.sizers]boxsizer.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.sizers]boxsizer.cpp
|
||||
|
||||
test_gui_clientsize.obj : [.window]clientsize.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.window]clientsize.cpp
|
||||
|
||||
test_gui_setsize.obj : [.window]setsize.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.window]setsize.cpp
|
||||
|
||||
test_gui_xrctest.obj : [.xml]xrctest.cpp
|
||||
$(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.xml]xrctest.cpp
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user