Commit Graph

73 Commits

Author SHA1 Message Date
Graham Dawes
db15e99884 Fix wxBitmap::GetRawData() in wxQt
This method used to return a dangling pointer to a temporary buffer,
which resulted in a crash when using it, e.g. in the unit test.

Fix this by keeping a QImage as a member in wxBitmapRefData, so that the
pointer to its data remain valid until UngetRawData() is called.

Also check that GetRawData() returns a non-null pointer in the test.

Closes https://github.com/wxWidgets/wxWidgets/pull/1067
2018-12-13 15:24:54 +01:00
Maarten Bent
3bab07edcf Fix some build warnings
private field 'm_dwCookie' is not used
'return' will never be executed
result of comparison of unsigned enum expression < 0 is always false
'FlushDC' overrides a member function but is not marked 'override'
potentially uninitialized local variable 'bound' used
2018-11-25 21:29:38 +01:00
Maarten Bent
7bf952165f Test success in BitmapTestCase::Mask() 2018-09-19 22:01:17 +02:00
Maarten Bent
a914478f60 Add guards around test cases 2018-09-19 22:01:17 +02:00
Maarten Bent
da9b4bc0a0 Remove unused variable in graphpath test 2018-07-29 16:29:36 +02:00
Maarten Bent
57180d68c8 Add wxOVERRIDE to test files
And cleanup some tailing spaces and tabs.
2018-07-29 12:08:53 +02:00
Artur Wieczorek
e732da462f Add tests for the bounds of wxGraphicsPath
Check if bounding box of wxGraphicsPath is properly determined.
2018-07-28 11:36:44 +02:00
Artur Wieczorek
fc53007ab4 Add unit test for current point of wxGraphicsPath
Verify that last point is properly positioned after the operations
on wxGraphicsPath.

See #18111.
2018-07-02 20:08:30 +02:00
Vadim Zeitlin
070336470f Make wxSVGFileDC::GetClippingBox() actually work
wxSVGFileDCImpl class uses the default, i.e. inherited from wxDCImpl,
implementation of this method, but for it to work, the clipping box
coordinates stored in wxDCImpl need to be updated when the clipping
region changes or is destroyed and this wasn't done before.

Fix this now and add a unit test verifying that this indeed works.
2018-06-18 17:11:16 +02:00
Vadim Zeitlin
e13904308f Add convenient tags for clipping box unit tests
No real changes, just replace the old CppUnit test registration macros
with wxREGISTER_UNIT_TEST_WITH_TAGS() which allows to specify the tags
explicitly and use "clip" as the tag for all the tests here to allow
running all of them (and just them) by specifying "[clip]" on the test
program command line.
2018-06-18 10:54:26 +02:00
Vadim Zeitlin
f3b5cc32fa Fix recently introduced crash in ClippingBoxTestCase
Commit fc7f20c419 did fix a memory leak in
this test case, but at the price of introducing a crash due to deleting
the same pointer twice.

The real fix would be to change the code here to avoid returning a
pointer which sometimes needs to be deleted and sometimes must not, but
for now just add a crude check to avoid crashing.
2017-11-14 00:41:31 +01:00
Paul Cornett
74282d9aed Fix DrawPoint() test
The result now matches non-GC wxDC, after 5ba7a1d1
2017-11-05 09:35:43 -08:00
Vadim Zeitlin
e70fc11ef1 Replace CppUnit with Catch for unit tests
Drop the legacy CppUnit testing framework used for the unit tests.
Replacing it with Catch has the advantage of not requiring CppUnit
libraries to be installed on the system in order to be able to run
tests (Catch is header-only and a copy of it is now included in the
main repository itself) and, in the future, of being able to write
the tests in a much more natural way.

For now, however, avoid changing the existing tests code as much as
[reasonably] possible to avoid introducing bugs in them and provide
the CppUnit compatibility macros in the new wx/catch_cppunit.h header
which allow to preserve the 99% of the existing code unchanged. Some
of the required changes are:

 - Decompose asserts using "a && b" conditions into multiple asserts
   checking "a" and "b" independently. This would have been better
   even with CppUnit (to know which part of condition exactly failed)
   and is required with Catch.

 - Use extra parentheses around such conditions when they can't be
   easily decomposed in the arrays test, due to the use of macros.
   This is not ideal from the point of view of messages given when
   the tests fail but will do for now.

 - Rewrite asserts using "a || b" as a combination of condition
   checks and assert macros. Again, this is better anyhow, and is
   required with Catch. Incidentally, this allowed to fix a bug in
   the "exec" unit test which didn't leave enough time for the new
   process to be launched before trying to kill it.

 - Remove multiple CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() macros,
   our emulation of this macro can be used only once.

 - Provide string conversions using Catch-specific StringMaker for
   a couple of types.

 - Replace custom wxImage comparison with a Catch-specific matcher
   class.

 - Remove most of test running logic from test.cpp, in particular don't
   parse command line ourselves any longer but use Catch built-in
   command line parser. This is a source of a minor regression:
   previously, both "Foo" and "FooTestCase" could be used as the name of
   the test to run, but now only the latter is accepted.
2017-11-02 01:53:16 +01:00
Vadim Zeitlin
aa4c270d73 Fix warning about local variable shadowing in clipping unit test
Use "col" for the "wxColour" variable to avoid clash with "c" one used
for the corner index.

Also just construct the colour directly from the RGB values instead of
default-initializing it and then using Set(), which also allows to make
it "const".
2017-10-22 23:39:47 +02:00
Paul Cornett
fc7f20c419 Fix some memory leaks in the tests 2017-10-01 09:41:49 -07:00
Artur Wieczorek
f171d48be4 Disable antialiasing in unit test
In order to examine real colors of pixels we need to have unmodified (aliased) edges between regions drawn with different colors.
For for wxDCs backed by wxGraphicsContext (e.g. under wxGTK3) antialiasing is enabled by default and to prevent falsifying pixel colors we have to disable it prior to drawing operations.

See #17666.
2017-04-14 09:15:04 +02:00
Artur Wieczorek
34e19a7449 Prevent unit test from crashing under wxGTK3
Under wxGTK3 default color depth for wxBitmap is 24 bpp and therefore wxAlphaPixelData cannot be used to get access to wxBitmap's internal data in this case.

See #17666.
2017-04-14 09:13:36 +02:00
Artur Wieczorek
ee4ab34686 Fix building tests with wxUSE_GRAPHICS_CONTEXT==0
Don't execute code which depends on graphics context functions if wxUSE_GRAPHICS_CONTEXT==0.
2017-04-09 21:29:14 +02:00
Vadim Zeitlin
092e772848 Use wxAlphaPixelData for default native bitmaps in the unit test
The unit test added in 607b800444 didn't work on
the systems using 32 bpp screens, i.e. almost all of them, because it tried to
use 24 bpp wxNativePixelData with them.

Fix this by using wxAlphaPixelData, which won't work on non 32 bpp systems,
and so is still not ideal, but at least makes the test work on most systems by
default.

See #17666.
2017-01-03 02:51:55 +01:00
Vadim Zeitlin
e3c245c226 Select the bitmap out of wxDC before using it in the unit test
The unit test added in 607b800444 had a bug as
it tried to use the bitmap directly while it was still selected into a
wxMemoryDC, which wasn't guaranteed to work and resulted in an assert.

Fix this by destroying wxMemoryDC earlier.

See #17666.
2017-01-03 02:50:26 +01:00
Tim Roberts
607b800444 Fix wxMemoryDC::Blit() with itself as source in wxMSW
Don't use StretchDIBits() native function as it doesn't seem to handle the
case when its source and destination are the same correctly.

Closes #17666.
2016-09-21 23:00:03 +02:00
Artur Wieczorek
c916845aaa Add new test of affine transformation matrix
Add test of concatenating two wxAffineMatrix2D.
2016-09-18 23:10:26 +02:00
Artur Wieczorek
fb9cbc0879 Add test suite to check wxGraphicsMatrix operations
Implemented tests of some basic operations like Invert() and Concat().

See #17670.
2016-09-18 23:09:44 +02:00
Artur Wieczorek
ecaeceb878 Add few tests of retrieving bounding box
New tests of retrieving bounding box coordinates after two consecutive drawing operations, for the case when wxDC coordinates have been changed between the operations and for resetting the bounding box.

See #17667.
2016-09-16 22:29:34 +02:00
Artur Wieczorek
83527e93d1 Extend affine transformation matrix tests
Add tests of affine transformation matrix for wxGCDC with various renderers.
2016-09-08 19:34:44 +02:00
Artur Wieczorek
a37ed9a2b5 Add tests of setting clipping region and retrieving clipping box
These new tests are about setting clipping region and retrieving clipping box for wxDC and wxGCDC with applied transformations.

See #17646
2016-09-01 20:35:09 +02:00
Artur Wieczorek
d66ff48fb4 Add new tests to check clipping region with rotated wxDC/wxGCDC
See #17636.
2016-08-21 21:23:01 +02:00
Artur Wieczorek
6ca5c894cd Add tests of setting clipping regions with wxGraphicsContext
The scope of tests corresponds to the scope of existing wxDC/wxGCDC tests. Additionally, newly introduced wxGraphicsContext::GetClipBox() function is tested too.
2016-08-21 21:00:13 +02:00
Artur Wieczorek
c9a8dbedc8 Add a test of storing/restoring clipping regions with wxGraphicsContext.
See #17626.
2016-08-12 23:22:34 +02:00
Artur Wieczorek
e3be67a756 Add test of setting clipping region for transformed (rotated) wxGraphicsContext
See #17622
2016-08-09 20:49:58 +02:00
Artur Wieczorek
0f31e05cb8 Adopt clipping box tests for GTK+ 3 environment
1. Under GTK+ 3 wxDC is implemented as wxGCDC (with underlying Cairo renderer) and hence there is no need to test wxDC individually.
2. wxRegion is implemented under GTK+ 2 using GdkRegion but under GTK+ 3 it is implemented using cairo_region_t so some region attributes can be slightly different in some circumstances for both ports. This happens e.g. for non-rectangular regions which can have slightly different clip extents for GTK+ 2 and 3. We have to take this into account in the tests of non-rectangular clipping region and accept that actual clipping box position can differ of few pixels from expected position (so comparing clipping box positions shouldn't be exact but with some error tolerance).
2016-08-09 20:48:43 +02:00
Artur Wieczorek
0fc246176a Add to the test suite a test of setting non-rectangular clipping region
Added a test of creating triangular clipping region (with wxDC::SetDeviceClippingRegion).

See #17609
2016-07-31 23:57:03 +02:00
Artur Wieczorek
874da289ef Modified parameters in clipping box tests.
Some coordinates of clipping regions given in device coordinates has to be slightly modified to avoid rounding errors in conversions from device to logical coordinates.
2016-07-17 18:19:32 +02:00
Artur Wieczorek
9ecea7dc74 Added tests to check setting of clipping region using device coordinates.
Tests of setting clipping region(s) with wxDC::SetDeviceClippingRegion() for transformed wxDC/wxGCDC (with changed device origin, logical origin and scale and with various renderers for wxGCDC) to check if all transformations are taken into account in the clipping box calculations.

See #17596
2016-07-15 20:57:21 +02:00
Artur Wieczorek
2b7aab70ff Added tests to check setting of clipping region for transformed wxDC/wxGCDC.
In these tests clipping region is set for transformed wxDC/wxGCDC (with changed device origin, logical origin and scale) to check if all these transformations are taken into account in the clipping box calculations.
2016-07-09 23:38:33 +02:00
Artur Wieczorek
2d096311c5 Fixed clipping box tests for Direct2D
Flushing native Direct2D renderer (invoking wxGCDC::Flush() -> wxGraphicsContext::Flush() -> ID2D1RenderTarget::Flush()) is apparently not enough to update underlying DC (with selected in bitmap) and therefore we have to destroy the renderer (which in turn invokes ID2D1RenderTarget::EndDraw()) to do so.
2016-07-05 21:58:48 +02:00
Artur Wieczorek
e953447ae9 Include GDI+ and Direct2D clipping box test cases only for MSW build. 2016-07-03 10:40:02 +02:00
Artur Wieczorek
4d91d6d2ff Enhance clipping box test cases
1. Added checking if actual drawing output is really clipped at the edge of the clipping box.
2. Added tests for wxGCDC with GDI+, Direct2D, Cairo renderers under wxMSW.
3. Added new test to check calculations for bounding box set entirely outside DC area.
2016-07-02 23:14:37 +02:00
Artur Wieczorek
9bf97bd607 Use wxMemoryDC with selected wxBitmap to create wxGraphicsContext in the graphics test.
If there is no wxBitmap selected into wxMemoryDC which is passed to wxGraphicsContext then there is raised an assertion warning (harmless in this context but caught and reported by CppUnit). To suppress this message we need to select any bitmap into wxMemoryDC prior to creating a wxGraphicsContext.
2016-06-29 21:01:53 +02:00
Artur Wieczorek
eb7a9f85c5 Added new tests to check clipping box calculations for wxDC and wxGCDC.
See #17013
2016-06-29 21:01:36 +02:00
Vadim Zeitlin
fde8f93a49 Fix ellipsization unit test when using pixel scaling
When pixel doubling is in use, e.g. when using GTK+ 2 on high DPI displays,
the width of a single TAB can be greater than the hardcoded 50 width in the
test, which resulted in test failures.

Base the widths on the average character width to make sure we can always
ellipsize.
2016-02-26 15:09:39 +01:00
Dimitri Schoolwerth
8f8d58d193 Use wx-prefixed macros throughout the repository.
Change {DECLARE,IMPLEMENT}_*CLASS and {DECLARE,BEGIN,END}_EVENT_TABLE
occurrences to use the wx-prefixed version of the macros.
2015-04-23 22:00:35 +04:00
Dimitri Schoolwerth
66cfa40643 Deal with remaining cvs/svn keywords.
A few $Id$ references remained after commit
3f66f6a5b3 or appeared in newly added files.
Remove the lines containing svn keywords except when it concerns
third-party files. In that case keep the line as-is or collapse it to the
keyword if it had been expanded to contain wx commit information (only
occurs with src/zlib/ChangeLog).
2015-04-09 03:32:23 +04:00
Vadim Zeitlin
2bfd94d59c wxX11 use XColor directly, so wxX11 does not support alpha at all currently
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77775 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-09-23 17:39:41 +00:00
Vadim Zeitlin
c3c0ae03fe No changes, just update the file name in the header.
Update the name in the header to match the actual file name.

See #12904.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76956 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-07-26 10:50:38 +00:00
Vadim Zeitlin
2098cafcad Implement bounding box computations for wxGDDC.
Update the bounding box in all the methods drawing something. This wasn't
done before in many of them, resulting in the bounding box remaining empty,
but it is updated now and a new test checking that it is was added.

Closes #12904.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76953 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-07-26 01:34:50 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
0646084eb2 Allow retrieving the descent and external leading of empty strings.
This used to work before wxTextMeasure changes so make it work again instead
of optimizing the case of empty string away and not returning anything in the
descent and externalLeading output parameters in this case.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-10 01:28:18 +00:00
Vadim Zeitlin
c7619cf139 Replace a template function with template class to fix VC6 build.
VC6 doesn't like template methods, so use a helper template class instead,
hopefully this will finally allow it to compile the test suite again.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-11-12 15:50:13 +00:00
Vadim Zeitlin
1bce253a23 Allow wxTextMeasure to work with non-native wxDC objects too.
Just forward back to wxDC itself in this case instead of using the
platform-specific code in wxTextMeasure that only works with native DCs.

See #14781.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72801 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-27 12:27:56 +00:00