Skip to content

Automated Test Suite ​

Since version 4.3.0 the library ships an automated test suite, built with DUnitX, in the Test folder of the installation (and of the repository).

The suite is a console application for Delphi 13 (Win32 and Win64) and locks two kinds of behaviour:

  • Regression tests for the defects fixed by the code reviews: every fix has a test that failed on the previous sources and passes on the current ones.
  • Contract tests for the rendering and the style families: every Class/Appearance of every family assigns its colours, a solid border always has a colour, the Classic Disabled state visibly differs from Normal for every VCL style, btRounded buttons are real pills, the notification badge keeps its shape whatever the border width of the button.

Running the tests ​

Test\run_tests.cmd [Win32|Win64] [Debug|Release] [BDS path]
  • Defaults: Win64, Debug. The Debug configuration runs with range and overflow checking on, which is the point of running the tests at all.
  • The Delphi installation is taken from the BDS environment variable or from the registry (Delphi 13, 12, 11, 10.4, newest first); pass the path as third argument to force one.
  • The script builds Test\Projects\D13\StyledComponentsTests.dproj with MSBuild, runs the executable and writes a NUnit XML report in Test\Bin\<Platform>\<Config>\dunitx-results.xml. Exit code 0 means all tests passed.

The project can also be opened and run from the IDE like any DUnitX console project.

What is covered ​

UnitArea
StyledRenderTestsGDI+ shapes (pill radius), notification badge, style family registry and contracts (all families)
StyledButtonTestsAssign between styled buttons, StyleFamily change, dialog keys (Enter/Esc with KeyPreview)
StyledContainerTestsTStyledToolbar sizing inside BeginUpdate/EndUpdate, TStyledPanel ParentBackground with and without VCL styles, TStyledButtonGroup/TStyledCategoryButtons items shape
StyledDialogTestsTStyledTaskDialog radio buttons
StyledPerfTestsPerformance benchmarks (see below)

StyledTestUtils provides the shared helpers: off-screen painting of graphic and windowed controls, pixel probes with tolerance, a hidden host form, DFM streaming round-trip and the [AllFamilies] attribute that runs a test case once per registered style family.

Performance benchmarks ​

StyledPerfTests installs a pass-through memory manager that counts heap allocations and measures each scenario with TStopwatch: the numbers are reported in the test message and in the XML report, and a test fails only above an allocation ceiling (allocations are deterministic, times depend on the machine). Run them with the Release configuration for meaningful times.

Values measured on Delphi 13, Win32, per single paint, before and after the 4.3.0 optimizations:

Scenario4.2.44.3.0
TStyledButton real WM_PAINT, double buffered21 allocations7 allocations
Classic button paint (VCL style re-resolved per paint)19 allocations11 allocations
TStyledButtonGroup / TStyledCategoryButtons item with its own style27 allocations9 allocations
TStyledBitBtn Kind=bkOK (PNG decoded per paint)38 allocations, ~950 µs14 allocations, ~230 µs
TStyledBitBtn custom glyph (TImageList built per paint)37 allocations, ~560 µs11 allocations, ~150 µs
Command link button49 allocations, ~660 µs25 allocations, ~400 µs
SVG-Colors unknown class name (EConvertError)~40 µs~4 µs

For reference a plain VCL TButton painted the same way costs 0 allocations and about 30-45 µs; most of the remaining time of a styled button is the GDI+ drawing of the shape and of the text (about 20 µs each).

Notes ​

  • The test project links its resource with the comctl32 v6 manifest on purpose: without it StyleServices.Enabled is False and the whole VCL-style colour table of the Classic family is not registered, so those tests would pass vacuously.
  • The tests that need a custom VCL style load Carbon.vsf from the Delphi Redist\styles\vcl folder and restore the system style afterwards.
  • Test\Bin and Test\Lib are build outputs and are not part of the installer.

Released under Apache License, Version 2.0.