KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_clipboard_export.cpp File Reference

Tests for multi-format clipboard export functionality in PCBnew. More...

#include <boost/test/unit_test.hpp>
#include <board.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_track.h>
#include <pcb_shape.h>
#include <pcb_text.h>
#include <pcb_field.h>
#include <zone.h>
#include <lset.h>
#include <plotters/plotters_pslike.h>
#include <pcb_painter.h>
#include <wx/ffile.h>
#include <wx/mstream.h>

Go to the source code of this file.

Classes

class  CLIPBOARD_EXPORT_FIXTURE
 

Functions

 BOOST_AUTO_TEST_CASE (SvgPlotter_LayerSupport)
 Test that SVG_PLOTTER supports the StartLayer and EndLayer methods for proper Inkscape-compatible layer grouping.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsTracks)
 Test that tracks are properly represented in SVG export.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsVias)
 Test that vias are properly represented in SVG export.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsFootprintPads)
 Test that footprints with pads are properly created for export testing.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsZones)
 Test that zones are properly created for export testing.
 
 BOOST_AUTO_TEST_CASE (PngExport_AlphaComputation_FullyOpaque)
 Test the dual-buffer alpha computation algorithm used for PNG transparency.
 
 BOOST_AUTO_TEST_CASE (PngExport_AlphaComputation_FullyTransparent)
 
 BOOST_AUTO_TEST_CASE (PngExport_AlphaComputation_SemiTransparent)
 
 BOOST_AUTO_TEST_CASE (PngExport_UnselectedColors)
 Test that selection state is cleared for proper unselected color rendering.
 
 BOOST_AUTO_TEST_CASE (PngExport_FootprintChildrenUnselected)
 Test that footprint children have selection cleared for proper rendering.
 
 BOOST_AUTO_TEST_CASE (PngExport_LayerOrder)
 Test layer ordering for proper hole rendering in PNG export.
 
 BOOST_AUTO_TEST_CASE (PngExport_BitmapSizeCalculation)
 Test bitmap size calculation from bounding box and view scale.
 
 BOOST_AUTO_TEST_CASE (PngExport_BitmapSizeClamping)
 Test bitmap size clamping to maximum size while preserving aspect ratio.
 
 BOOST_AUTO_TEST_CASE (SvgExport_LayerNames)
 Test that board layer names are retrievable for SVG export.
 
 BOOST_AUTO_TEST_CASE (SvgExport_CollectLayers)
 Test layer set collection from board items.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsArcs)
 Test that PCB arcs are properly created for export testing.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsPcbShapes)
 Test that PCB shapes on copper layers are properly created.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsPcbText)
 Test that PCB text is properly created for export testing.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsBlindVia)
 Test that blind vias are properly created.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsMicroVia)
 Test that micro vias are properly created.
 
 BOOST_AUTO_TEST_CASE (SvgExport_MultipleCopperLayers)
 Test that tracks on multiple copper layers can be created.
 
 BOOST_AUTO_TEST_CASE (SvgExport_FootprintGraphics)
 Test that footprint graphics (silkscreen items) are properly created.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ContainsSmdPads)
 Test that SMD pads are properly created.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ZoneWithNet)
 Test that zone fills can be created.
 
 BOOST_AUTO_TEST_CASE (BoundingBox_MultipleItems)
 Test bounding box computation for various item types.
 
 BOOST_AUTO_TEST_CASE (SvgExport_FillOpacity_MatchesColorAlpha)
 Test that SVG fill-opacity is set correctly when drawing shapes.
 
 BOOST_AUTO_TEST_CASE (SvgExport_FillOpacity_FullyOpaque)
 Test that SVG export with fully opaque colors has fill-opacity = 1.0.
 
 BOOST_AUTO_TEST_CASE (SvgExport_FootprintPads_IncludedInOutput)
 Test that footprint pads are included in SVG export.
 
 BOOST_AUTO_TEST_CASE (SvgExport_FootprintGraphics_IncludedInOutput)
 Test that footprint graphical items are included in SVG export.
 
 BOOST_AUTO_TEST_CASE (SvgExport_ColorAlpha_PreservedThroughSetColor)
 Test that verifies the COLOR4D alpha value is preserved through SetColor.
 

Detailed Description

Tests for multi-format clipboard export functionality in PCBnew.

These tests verify:

  1. SVG export includes all element types (tracks, arcs, vias, zones, pads, fields)
  2. SVG export uses proper layer structure with KiCad layer names
  3. PNG export uses unselected colors (no highlight)
  4. PNG export renders holes in foreground
  5. Footprint editor export includes pads and fields

Definition in file test_clipboard_export.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/30]

BOOST_AUTO_TEST_CASE ( BoundingBox_MultipleItems )

Test bounding box computation for various item types.

Definition at line 820 of file test_clipboard_export.cpp.

References BOX2< Vec >::Contains(), F_Cu, BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Merge(), and pcbIUScale.

◆ BOOST_AUTO_TEST_CASE() [2/30]

BOOST_AUTO_TEST_CASE ( PngExport_AlphaComputation_FullyOpaque )

Test the dual-buffer alpha computation algorithm used for PNG transparency.

This verifies the mathematical approach: α = 1 - (white - black) / 255

Definition at line 282 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [3/30]

BOOST_AUTO_TEST_CASE ( PngExport_AlphaComputation_FullyTransparent )

Definition at line 299 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [4/30]

BOOST_AUTO_TEST_CASE ( PngExport_AlphaComputation_SemiTransparent )

Definition at line 316 of file test_clipboard_export.cpp.

◆ BOOST_AUTO_TEST_CASE() [5/30]

BOOST_AUTO_TEST_CASE ( PngExport_BitmapSizeCalculation )

Test bitmap size calculation from bounding box and view scale.

Definition at line 438 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [6/30]

BOOST_AUTO_TEST_CASE ( PngExport_BitmapSizeClamping )

Test bitmap size clamping to maximum size while preserving aspect ratio.

Definition at line 463 of file test_clipboard_export.cpp.

◆ BOOST_AUTO_TEST_CASE() [7/30]

BOOST_AUTO_TEST_CASE ( PngExport_FootprintChildrenUnselected )

Test that footprint children have selection cleared for proper rendering.

Definition at line 361 of file test_clipboard_export.cpp.

References EDA_ITEM::ClearSelected(), FOOTPRINT::Clone(), EDA_ITEM::IsSelected(), pad, FOOTPRINT::Pads(), RECURSE, and EDA_ITEM::SetSelected().

◆ BOOST_AUTO_TEST_CASE() [8/30]

BOOST_AUTO_TEST_CASE ( PngExport_LayerOrder )

Test layer ordering for proper hole rendering in PNG export.

Higher order values are drawn later (on top).

Definition at line 402 of file test_clipboard_export.cpp.

References LSET::AllCuMask(), BOOST_CHECK_EQUAL(), and LSET::CuStack().

◆ BOOST_AUTO_TEST_CASE() [9/30]

BOOST_AUTO_TEST_CASE ( PngExport_UnselectedColors )

Test that selection state is cleared for proper unselected color rendering.

This verifies that ClearSelected() properly removes selection flag.

Definition at line 339 of file test_clipboard_export.cpp.

References PCB_TRACK::Clone(), F_Cu, EDA_ITEM::IsSelected(), and EDA_ITEM::SetSelected().

◆ BOOST_AUTO_TEST_CASE() [10/30]

BOOST_AUTO_TEST_CASE ( SvgExport_CollectLayers )

Test layer set collection from board items.

Definition at line 515 of file test_clipboard_export.cpp.

References B_Cu, F_Cu, and F_SilkS.

◆ BOOST_AUTO_TEST_CASE() [11/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ColorAlpha_PreservedThroughSetColor )

◆ BOOST_AUTO_TEST_CASE() [12/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsArcs )

◆ BOOST_AUTO_TEST_CASE() [13/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsBlindVia )

Test that blind vias are properly created.

Definition at line 636 of file test_clipboard_export.cpp.

References PADSTACK::ALL_LAYERS, BLIND, BOOST_REQUIRE(), F_Cu, PCB_VIA::GetViaType(), In1_Cu, PCB_VIA_T, pcbIUScale, and via.

◆ BOOST_AUTO_TEST_CASE() [14/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsFootprintPads )

Test that footprints with pads are properly created for export testing.

Definition at line 239 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL(), F_Cu, PAD::GetLayerSet(), PAD::GetNumber(), and FOOTPRINT::Pads().

◆ BOOST_AUTO_TEST_CASE() [15/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsMicroVia )

Test that micro vias are properly created.

Definition at line 667 of file test_clipboard_export.cpp.

References PADSTACK::ALL_LAYERS, BOOST_REQUIRE(), F_Cu, PCB_VIA::GetViaType(), In1_Cu, MICROVIA, PCB_VIA_T, pcbIUScale, and via.

◆ BOOST_AUTO_TEST_CASE() [16/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsPcbShapes )

Test that PCB shapes on copper layers are properly created.

Definition at line 562 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL(), CIRCLE, circle(), F_Cu, PCB_SHAPE_T, pcbIUScale, RECTANGLE, SEGMENT, EDA_SHAPE::SetEnd(), PCB_SHAPE::SetLayer(), EDA_SHAPE::SetStart(), PCB_SHAPE::SetStroke(), and SOLID.

◆ BOOST_AUTO_TEST_CASE() [17/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsPcbText )

Test that PCB text is properly created for export testing.

Definition at line 607 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL(), F_SilkS, PCB_TEXT_T, pcbIUScale, and text.

◆ BOOST_AUTO_TEST_CASE() [18/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsSmdPads )

◆ BOOST_AUTO_TEST_CASE() [19/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsTracks )

Test that tracks are properly represented in SVG export.

Definition at line 190 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL(), F_Cu, PCB_TRACK::GetEnd(), BOARD_CONNECTED_ITEM::GetLayer(), PCB_TRACK::GetStart(), pcbIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BOOST_AUTO_TEST_CASE() [20/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsVias )

Test that vias are properly represented in SVG export.

Definition at line 211 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), PCB_VIA_T, pcbIUScale, THROUGH, and via.

◆ BOOST_AUTO_TEST_CASE() [21/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ContainsZones )

Test that zones are properly created for export testing.

Definition at line 263 of file test_clipboard_export.cpp.

References BOOST_CHECK_EQUAL(), F_Cu, ZONE::GetFirstLayer(), and ZONE::GetNumCorners().

◆ BOOST_AUTO_TEST_CASE() [22/30]

BOOST_AUTO_TEST_CASE ( SvgExport_FillOpacity_FullyOpaque )

◆ BOOST_AUTO_TEST_CASE() [23/30]

BOOST_AUTO_TEST_CASE ( SvgExport_FillOpacity_MatchesColorAlpha )

Test that SVG fill-opacity is set correctly when drawing shapes.

This verifies that colors with alpha values produce correct fill-opacity.

Definition at line 849 of file test_clipboard_export.cpp.

References BOOST_REQUIRE(), SVG_PLOTTER::EndPlot(), FILLED_SHAPE, PLOTTER::OpenFile(), SVG_PLOTTER::Rect(), PSLIKE_PLOTTER::SetColor(), PLOTTER::SetColorMode(), PAGE_INFO::SetHeightMils(), PLOTTER::SetPageSettings(), SVG_PLOTTER::SetViewport(), PAGE_INFO::SetWidthMils(), and SVG_PLOTTER::StartPlot().

◆ BOOST_AUTO_TEST_CASE() [24/30]

BOOST_AUTO_TEST_CASE ( SvgExport_FootprintGraphics )

◆ BOOST_AUTO_TEST_CASE() [25/30]

◆ BOOST_AUTO_TEST_CASE() [26/30]

BOOST_AUTO_TEST_CASE ( SvgExport_FootprintPads_IncludedInOutput )

◆ BOOST_AUTO_TEST_CASE() [27/30]

BOOST_AUTO_TEST_CASE ( SvgExport_LayerNames )

Test that board layer names are retrievable for SVG export.

Definition at line 495 of file test_clipboard_export.cpp.

References B_Cu, F_Cu, and F_SilkS.

◆ BOOST_AUTO_TEST_CASE() [28/30]

BOOST_AUTO_TEST_CASE ( SvgExport_MultipleCopperLayers )

Test that tracks on multiple copper layers can be created.

Definition at line 698 of file test_clipboard_export.cpp.

References B_Cu, BOOST_CHECK_EQUAL(), F_Cu, In1_Cu, and In2_Cu.

◆ BOOST_AUTO_TEST_CASE() [29/30]

BOOST_AUTO_TEST_CASE ( SvgExport_ZoneWithNet )

◆ BOOST_AUTO_TEST_CASE() [30/30]