diff --git a/tests/graphics/coords.cpp b/tests/graphics/coords.cpp index bec0c53101..21f9e8f93e 100644 --- a/tests/graphics/coords.cpp +++ b/tests/graphics/coords.cpp @@ -26,503 +26,378 @@ static const wxSize s_dcSize(100, 100); static const wxPoint s_posDev(24, 57); static const wxSize s_dimDev(40, 15); -// ==================== -// wxDC / wxGCDC tests -// ==================== - -class CoordinatesDCTestCaseBase -{ -public: - CoordinatesDCTestCaseBase() - { - m_bmp.Create(s_dcSize); - m_dc = nullptr; - } - - virtual ~CoordinatesDCTestCaseBase() - { - m_bmp = wxNullBitmap; - } - -protected: - wxBitmap m_bmp; - wxDC* m_dc; -}; - -// =========== -// wxDC tests -// =========== - -class CoordinatesDCTestCase : public CoordinatesDCTestCaseBase -{ -public: - CoordinatesDCTestCase() - { - m_mdc.SelectObject(m_bmp); - m_dc = &m_mdc; - } - - virtual ~CoordinatesDCTestCase() - { - m_mdc.SelectObject(wxNullBitmap); - } - -protected: - wxMemoryDC m_mdc; -}; - -#if wxUSE_GRAPHICS_CONTEXT -// ============= -// wxGCDC tests -// ============= - -class CoordinatesGCDCTestCase : public CoordinatesDCTestCase -{ -public: - CoordinatesGCDCTestCase() - { - m_gcdc = new wxGCDC(m_mdc); - - wxGraphicsContext* ctx = m_gcdc->GetGraphicsContext(); - ctx->SetAntialiasMode(wxANTIALIAS_NONE); - ctx->DisableOffset(); - - m_dc = m_gcdc; - } - - virtual ~CoordinatesGCDCTestCase() - { - delete m_gcdc; - } - -protected: - wxGCDC* m_gcdc; -}; -#endif // wxUSE_GRAPHICS_CONTEXT - -// ===== Implementation ===== - -static void InitialState(wxDC* dc) +static void InitialState(wxDC& dc) { // Check initial state - wxPoint origin = dc->GetDeviceOrigin(); - CHECK(origin.x == 0); - CHECK(origin.y == 0); + wxPoint origin = dc.GetDeviceOrigin(); + CHECK(origin == wxPoint(0,0)); - origin = dc->GetLogicalOrigin(); - CHECK(origin.x == 0); - CHECK(origin.y == 0); + origin = dc.GetLogicalOrigin(); + CHECK(origin == wxPoint(0, 0)); double sx, sy; - dc->GetUserScale(&sx, &sy); + dc.GetUserScale(&sx, &sy); CHECK(sx == 1.0); CHECK(sy == 1.0); - dc->GetLogicalScale(&sx, &sy); + dc.GetLogicalScale(&sx, &sy); CHECK(sx == 1.0); CHECK(sy == 1.0); #if wxUSE_DC_TRANSFORM_MATRIX - if ( dc->CanUseTransformMatrix() ) + if ( dc.CanUseTransformMatrix() ) { - wxAffineMatrix2D m = dc->GetTransformMatrix(); + wxAffineMatrix2D m = dc.GetTransformMatrix(); CHECK(m.IsIdentity() == true); } #endif // wxUSE_DC_TRANSFORM_MATRIX } -static void NoTransform(wxDC *dc) +static void NoTransform(wxDC& dc) { // No transformations // First convert from device to logical coordinates wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK(posLog.x == s_posDev.x); - CHECK(posLog.y == s_posDev.y); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK(posLog == s_posDev); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } -static void NoTransformEx(wxDC * dc) +static void NoTransformEx(wxDC& dc) { // No transformations // First convert from device to logical coordinates wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == s_posDev.x); - CHECK(posLog.y == s_posDev.y); + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == s_posDev); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } -static void DeviceOriginChanged(wxDC* dc) +static void DeviceOriginChanged(wxDC& dc) { // Only device origin is changed const wxCoord dx = 10; const wxCoord dy = 15; - dc->SetDeviceOrigin(dx, dy); + dc.SetDeviceOrigin(dx, dy); // First convert from device to logical coordinates wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK(posLog.x == s_posDev.x - dx); - CHECK(posLog.y == s_posDev.y - dy); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK(posLog == wxPoint(s_posDev.x - dx, s_posDev.y - dy)); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } -static void DeviceOriginChangedEx(wxDC * dc) +static void DeviceOriginChangedEx(wxDC& dc) { // Only device origin is changed const wxCoord dx = 10; const wxCoord dy = 15; - dc->SetDeviceOrigin(dx, dy); + dc.SetDeviceOrigin(dx, dy); // First convert from device to logical coordinates wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == s_posDev.x - dx); - CHECK(posLog.y == s_posDev.y - dy); + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == wxPoint(s_posDev.x - dx, s_posDev.y - dy)); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } -static void LogicalOriginChanged(wxDC* dc) +static void LogicalOriginChanged(wxDC& dc) { // Only logical origin is changed const wxCoord dx = -15; const wxCoord dy = -20; - dc->SetLogicalOrigin(dx, dy); + dc.SetLogicalOrigin(dx, dy); // First convert from device to logical coordinates wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK(posLog.x == s_posDev.x + dx); - CHECK(posLog.y == s_posDev.y + dy); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK(posLog == wxPoint(s_posDev.x + dx, s_posDev.y + dy)); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } -static void LogicalOriginChangedEx(wxDC * dc) +static void LogicalOriginChangedEx(wxDC& dc) { // Only logical origin is changed const wxCoord dx = -15; const wxCoord dy = -20; - dc->SetLogicalOrigin(dx, dy); + dc.SetLogicalOrigin(dx, dy); // First convert from device to logical coordinates wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == s_posDev.x + dx); - CHECK(posLog.y == s_posDev.y + dy); + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == wxPoint(s_posDev.x + dx, s_posDev.y + dy)); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } -static void UserScaleChanged(wxDC* dc) +static void UserScaleChanged(wxDC& dc) { // Only user scale is changed const double sx = 2.0; const double sy = 3.0; - dc->SetUserScale(sx, sy); + dc.SetUserScale(sx, sy); // First convert from device to logical coordinates wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK(posLog.x == wxRound(s_posDev.x / sx)); - CHECK(posLog.y == wxRound(s_posDev.y / sy)); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK(posLog == wxPoint(wxRound(s_posDev.x / sx), wxRound(s_posDev.y / sy))); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK(dimLog.x == wxRound(s_dimDev.x / sx)); - CHECK(dimLog.y == wxRound(s_dimDev.y / sy)); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK(dimLog == wxSize(wxRound(s_dimDev.x / sx), wxRound(s_dimDev.y / sy))); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } -static void UserScaleChangedEx(wxDC * dc) +static void UserScaleChangedEx(wxDC& dc) { // Only user scale is changed const double sx = 2.0; const double sy = 3.0; - dc->SetUserScale(sx, sy); + dc.SetUserScale(sx, sy); // First convert from device to logical coordinates wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == wxRound(s_posDev.x / sx)); - CHECK(posLog.y == wxRound(s_posDev.y / sy)); + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == wxPoint(wxRound(s_posDev.x / sx), wxRound(s_posDev.y / sy))); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == wxRound(s_dimDev.x / sx)); - CHECK(dimLog.y == wxRound(s_dimDev.y / sy)); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == wxSize(wxRound(s_dimDev.x / sx), wxRound(s_dimDev.y / sy))); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } -static void LogicalScaleChanged(wxDC* dc) +static void LogicalScaleChanged(wxDC& dc) { // Only logical scale is changed const double sx = 2.0; const double sy = 3.0; - dc->SetLogicalScale(sx, sy); + dc.SetLogicalScale(sx, sy); // First convert from device to logical coordinates wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK(posLog.x == wxRound(s_posDev.x / sx)); - CHECK(posLog.y == wxRound(s_posDev.y / sy)); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK(posLog == wxPoint(wxRound(s_posDev.x / sx), wxRound(s_posDev.y / sy))); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK(dimLog.x == wxRound(s_dimDev.x / sx)); - CHECK(dimLog.y == wxRound(s_dimDev.y / sy)); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK(dimLog == wxSize(wxRound(s_dimDev.x / sx), wxRound(s_dimDev.y / sy))); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } -static void LogicalScaleChangedEx(wxDC * dc) +static void LogicalScaleChangedEx(wxDC& dc) { // Only logical scale is changed const double sx = 2.0; const double sy = 3.0; - dc->SetLogicalScale(sx, sy); + dc.SetLogicalScale(sx, sy); // First convert from device to logical coordinates wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == wxRound(s_posDev.x / sx)); - CHECK(posLog.y == wxRound(s_posDev.y / sy)); + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == wxPoint(wxRound(s_posDev.x / sx), wxRound(s_posDev.y / sy))); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == wxRound(s_dimDev.x / sx)); - CHECK(dimLog.y == wxRound(s_dimDev.y / sy)); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == wxSize(wxRound(s_dimDev.x / sx), wxRound(s_dimDev.y / sy))); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } -static void TransformedStd(wxDC* dc) +static void TransformedStd(wxDC& dc) { // Apply all standardd transformations - dc->SetDeviceOrigin(10, 15); - dc->SetUserScale(0.5, 2.0); - dc->SetLogicalScale(4.0, 1.5); - dc->SetLogicalOrigin(-15, -20); + dc.SetDeviceOrigin(10, 15); + dc.SetUserScale(0.5, 2.0); + dc.SetLogicalScale(4.0, 1.5); + dc.SetLogicalOrigin(-15, -20); // First convert from device to logical coordinates wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK(posLog.x == -8); - CHECK(posLog.y == -6); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK(posLog == wxPoint(-8, -6)); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK(dimLog.x == 20); - CHECK(dimLog.y == 5); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK(dimLog == wxSize(20, 5)); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } -static void TransformedStdEx(wxDC * dc) +static void TransformedStdEx(wxDC& dc) { // Apply all standardd transformations - dc->SetDeviceOrigin(10, 15); - dc->SetUserScale(0.5, 2.0); - dc->SetLogicalScale(4.0, 1.5); - dc->SetLogicalOrigin(-15, -20); + dc.SetDeviceOrigin(10, 15); + dc.SetUserScale(0.5, 2.0); + dc.SetLogicalScale(4.0, 1.5); + dc.SetLogicalOrigin(-15, -20); // First convert from device to logical coordinates wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == -8); - CHECK(posLog.y == -6); + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == wxPoint(-8, -6)); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == 20); - CHECK(dimLog.y == 5); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == wxSize(20, 5)); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); CHECK(posDev.y == s_posDev.y); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } -static void TransformedWithMatrix(wxDC* dc) +static void TransformedWithMatrix(wxDC& dc) { // Apply transformation matrix only #if wxUSE_DC_TRANSFORM_MATRIX - if ( dc->CanUseTransformMatrix() ) + if ( dc.CanUseTransformMatrix() ) { // Apply translation and scaling only - wxAffineMatrix2D m = dc->GetTransformMatrix(); + wxAffineMatrix2D m = dc.GetTransformMatrix(); m.Translate(10, 15); m.Scale(2.0, 3.0); - dc->SetTransformMatrix(m); + dc.SetTransformMatrix(m); // First convert from device to logical coordinates // Results should be nagative because legacy functions @@ -530,94 +405,84 @@ static void TransformedWithMatrix(wxDC* dc) m.Invert(); wxPoint2DDouble posLogRef = m.TransformPoint(wxPoint2DDouble(s_posDev)); wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK_FALSE(posLog.x == wxRound(posLogRef.m_x)); - CHECK_FALSE(posLog.y == wxRound(posLogRef.m_y)); - CHECK(posLog.x == s_posDev.x); - CHECK(posLog.y == s_posDev.y); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK_FALSE(posLog == wxPoint(wxRound(posLogRef.m_x), wxRound(posLogRef.m_y))); + CHECK(posLog == s_posDev); wxPoint2DDouble dimLogRef = m.TransformDistance(wxPoint2DDouble(s_dimDev.x, s_dimDev.y)); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK_FALSE(dimLog.x == wxRound(dimLogRef.m_x)); - CHECK_FALSE(dimLog.y == wxRound(dimLogRef.m_y)); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK_FALSE(dimLog == wxSize(wxRound(dimLogRef.m_x), wxRound(dimLogRef.m_y))); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } #endif // wxUSE_DC_TRANSFORM_MATRIX } -static void TransformedWithMatrixEx(wxDC * dc) +static void TransformedWithMatrixEx(wxDC& dc) { // Apply transformation matrix only #if wxUSE_DC_TRANSFORM_MATRIX - if ( dc->CanUseTransformMatrix() ) + if ( dc.CanUseTransformMatrix() ) { // Apply translation and scaling only - wxAffineMatrix2D m = dc->GetTransformMatrix(); + wxAffineMatrix2D m = dc.GetTransformMatrix(); m.Translate(10, 15); m.Scale(2.0, 3.0); - dc->SetTransformMatrix(m); + dc.SetTransformMatrix(m); // First convert from device to logical coordinates m.Invert(); wxPoint2DDouble posLogRef = m.TransformPoint(wxPoint2DDouble(s_posDev)); - wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == wxRound(posLogRef.m_x)); - CHECK(posLog.y == wxRound(posLogRef.m_y)); + wxPoint posLog; + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == wxPoint(wxRound(posLogRef.m_x), wxRound(posLogRef.m_y))); wxPoint2DDouble dimLogRef = m.TransformDistance(wxPoint2DDouble(s_dimDev.x, s_dimDev.y)); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == wxRound(dimLogRef.m_x)); - CHECK(dimLog.y == wxRound(dimLogRef.m_y)); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == wxSize(wxRound(dimLogRef.m_x), wxRound(dimLogRef.m_y))); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } #endif // wxUSE_DC_TRANSFORM_MATRIX } -static void TransformedWithMatrixAndStd(wxDC* dc) +static void TransformedWithMatrixAndStd(wxDC& dc) { // Apply combination of standard and matrix transformations #if wxUSE_DC_TRANSFORM_MATRIX - if ( dc->CanUseTransformMatrix() ) + if ( dc.CanUseTransformMatrix() ) { - dc->SetDeviceOrigin(10, 15); + dc.SetDeviceOrigin(10, 15); - dc->SetUserScale(0.5, 1.5); - dc->SetLogicalScale(4.0, 2.0); - dc->SetLogicalOrigin(-15, -20); + dc.SetUserScale(0.5, 1.5); + dc.SetLogicalScale(4.0, 2.0); + dc.SetLogicalOrigin(-15, -20); - wxAffineMatrix2D m = dc->GetTransformMatrix(); + wxAffineMatrix2D m = dc.GetTransformMatrix(); m.Translate(10, 18); m.Scale(2.0, 0.5); - dc->SetTransformMatrix(m); + dc.SetTransformMatrix(m); // First convert from device to logical coordinates // Results should be nagative because legacy functions @@ -630,50 +495,46 @@ static void TransformedWithMatrixAndStd(wxDC* dc) wxPoint2DDouble posLogRef = m1.TransformPoint(wxPoint2DDouble(s_posDev)); wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK_FALSE(posLog.x == wxRound(posLogRef.m_x)); - CHECK_FALSE(posLog.y == wxRound(posLogRef.m_y)); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK_FALSE(posLog == wxPoint(wxRound(posLogRef.m_x), wxRound(posLogRef.m_y))); wxPoint2DDouble dimLogRef = m1.TransformDistance(wxPoint2DDouble(s_dimDev.x, s_dimDev.y)); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK_FALSE(dimLog.x == wxRound(dimLogRef.m_x)); - CHECK_FALSE(dimLog.y == wxRound(dimLogRef.m_y)); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK_FALSE(dimLog == wxSize(wxRound(dimLogRef.m_x), wxRound(dimLogRef.m_y))); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } #endif // wxUSE_DC_TRANSFORM_MATRIX } -static void TransformedWithMatrixAndStdEx(wxDC * dc) +static void TransformedWithMatrixAndStdEx(wxDC& dc) { // Apply combination of standard and matrix transformations #if wxUSE_DC_TRANSFORM_MATRIX - if ( dc->CanUseTransformMatrix() ) + if ( dc.CanUseTransformMatrix() ) { - dc->SetDeviceOrigin(10, 15); + dc.SetDeviceOrigin(10, 15); - dc->SetUserScale(0.5, 1.5); - dc->SetLogicalScale(4.0, 2.0); - dc->SetLogicalOrigin(-15, -20); + dc.SetUserScale(0.5, 1.5); + dc.SetLogicalScale(4.0, 2.0); + dc.SetLogicalOrigin(-15, -20); - wxAffineMatrix2D m = dc->GetTransformMatrix(); + wxAffineMatrix2D m = dc.GetTransformMatrix(); m.Translate(10, 18); m.Scale(2.0, 0.5); - dc->SetTransformMatrix(m); + dc.SetTransformMatrix(m); // First convert from device to logical coordinates wxAffineMatrix2D m1; @@ -684,7 +545,7 @@ static void TransformedWithMatrixAndStdEx(wxDC * dc) wxPoint2DDouble posLogRef = m1.TransformPoint(wxPoint2DDouble(s_posDev)); wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); + posLog = dc.DeviceToLogical(s_posDev); if ( wxIsRunningUnderWine() ) { @@ -698,40 +559,36 @@ static void TransformedWithMatrixAndStdEx(wxDC * dc) WARN("Wine workaround might be not needed any longer"); } - CHECK(posLog.x == wxRound(posLogRef.m_x)); - CHECK(posLog.y == wxRound(posLogRef.m_y)); + CHECK(posLog == wxPoint(wxRound(posLogRef.m_x), wxRound(posLogRef.m_y))); wxPoint2DDouble dimLogRef = m1.TransformDistance(wxPoint2DDouble(s_dimDev.x, s_dimDev.y)); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == wxRound(dimLogRef.m_x)); - CHECK(dimLog.y == wxRound(dimLogRef.m_y)); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == wxSize(wxRound(dimLogRef.m_x), wxRound(dimLogRef.m_y))); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev = dc.LogicalToDevice(posLog); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev = dc.LogicalToDeviceRel(dimLog); + CHECK(dimDev == s_dimDev); } #endif // wxUSE_DC_TRANSFORM_MATRIX } -static void RotatedWithMatrix(wxDC* dc) +static void RotatedWithMatrix(wxDC& dc) { // Apply matrix transformations with rotation component #if wxUSE_DC_TRANSFORM_MATRIX - if ( dc->CanUseTransformMatrix() ) + if ( dc.CanUseTransformMatrix() ) { - wxAffineMatrix2D m = dc->GetTransformMatrix(); + wxAffineMatrix2D m = dc.GetTransformMatrix(); m.Rotate(6 * M_PI / 180.0); m.Translate(10, 15); m.Scale(2.0, 3.0); - dc->SetTransformMatrix(m); + dc.SetTransformMatrix(m); // First convert from device to logical coordinates // Results should be nagative because legacy functions @@ -739,702 +596,692 @@ static void RotatedWithMatrix(wxDC* dc) m.Invert(); wxPoint2DDouble posLogRef = m.TransformPoint(wxPoint2DDouble(s_posDev)); wxPoint posLog; - posLog.x = dc->DeviceToLogicalX(s_posDev.x); - posLog.y = dc->DeviceToLogicalY(s_posDev.y); - CHECK_FALSE(posLog.x == wxRound(posLogRef.m_x)); - CHECK_FALSE(posLog.y == wxRound(posLogRef.m_y)); - CHECK(posLog.x == s_posDev.x); - CHECK(posLog.y == s_posDev.y); + posLog.x = dc.DeviceToLogicalX(s_posDev.x); + posLog.y = dc.DeviceToLogicalY(s_posDev.y); + CHECK_FALSE(posLog == wxPoint(wxRound(posLogRef.m_x), wxRound(posLogRef.m_y))); + CHECK(posLog == s_posDev); wxPoint2DDouble dimLogRef = m.TransformDistance(wxPoint2DDouble(s_dimDev.x, s_dimDev.y)); wxSize dimLog; - dimLog.x = dc->DeviceToLogicalXRel(s_dimDev.x); - dimLog.y = dc->DeviceToLogicalYRel(s_dimDev.y); - CHECK_FALSE(dimLog.x == wxRound(dimLogRef.m_x)); - CHECK_FALSE(dimLog.y == wxRound(dimLogRef.m_y)); - CHECK(dimLog.x == s_dimDev.x); - CHECK(dimLog.y == s_dimDev.y); + dimLog.x = dc.DeviceToLogicalXRel(s_dimDev.x); + dimLog.y = dc.DeviceToLogicalYRel(s_dimDev.y); + CHECK_FALSE(dimLog == wxSize(wxRound(dimLogRef.m_x), wxRound(dimLogRef.m_y))); + CHECK(dimLog == s_dimDev); // And next back from logical to device coordinates wxPoint posDev; - posDev.x = dc->LogicalToDeviceX(posLog.x); - posDev.y = dc->LogicalToDeviceY(posLog.y); - CHECK(posDev.x == s_posDev.x); - CHECK(posDev.y == s_posDev.y); + posDev.x = dc.LogicalToDeviceX(posLog.x); + posDev.y = dc.LogicalToDeviceY(posLog.y); + CHECK(posDev == s_posDev); wxSize dimDev; - dimDev.x = dc->LogicalToDeviceXRel(dimLog.x); - dimDev.y = dc->LogicalToDeviceYRel(dimLog.y); - CHECK(dimDev.x == s_dimDev.x); - CHECK(dimDev.y == s_dimDev.y); + dimDev.x = dc.LogicalToDeviceXRel(dimLog.x); + dimDev.y = dc.LogicalToDeviceYRel(dimLog.y); + CHECK(dimDev == s_dimDev); } #endif // wxUSE_DC_TRANSFORM_MATRIX } -static void RotatedWithMatrixEx(wxDC * dc) +static void RotatedWithMatrixEx(wxDC& dc) { // Apply matrix transformations with rotation component #if wxUSE_DC_TRANSFORM_MATRIX - if ( dc->CanUseTransformMatrix() ) + if ( dc.CanUseTransformMatrix() ) { - wxAffineMatrix2D m = dc->GetTransformMatrix(); + wxAffineMatrix2D m = dc.GetTransformMatrix(); m.Rotate(6 * M_PI / 180.0); m.Translate(10, 15); m.Scale(2.0, 3.0); - dc->SetTransformMatrix(m); + dc.SetTransformMatrix(m); // First convert from device to logical coordinates m.Invert(); wxPoint2DDouble posLogRef = m.TransformPoint(wxPoint2DDouble(s_posDev)); wxPoint posLog; - posLog = dc->DeviceToLogical(s_posDev); - CHECK(posLog.x == wxRound(posLogRef.m_x)); - CHECK(posLog.y == wxRound(posLogRef.m_y)); + posLog = dc.DeviceToLogical(s_posDev); + CHECK(posLog == wxPoint(wxRound(posLogRef.m_x), wxRound(posLogRef.m_y)) ); wxPoint2DDouble dimLogRef = m.TransformDistance(wxPoint2DDouble(s_dimDev.x, s_dimDev.y)); wxSize dimLog; - dimLog = dc->DeviceToLogicalRel(s_dimDev); - CHECK(dimLog.x == wxRound(dimLogRef.m_x)); - CHECK(dimLog.y == wxRound(dimLogRef.m_y)); + dimLog = dc.DeviceToLogicalRel(s_dimDev); + CHECK(dimLog == wxSize(wxRound(dimLogRef.m_x), wxRound(dimLogRef.m_y))); // And next back from logical to device coordinates wxPoint posDev; - posDev = dc->LogicalToDevice(posLog); + posDev = dc.LogicalToDevice(posLog); CHECK(Approx(posDev.x).margin(1) == s_posDev.x); CHECK(Approx(posDev.y).margin(1) == s_posDev.y); wxSize dimDev; - dimDev = dc->LogicalToDeviceRel(dimLog); + dimDev = dc.LogicalToDeviceRel(dimLog); CHECK(Approx(dimDev.x).margin(1) == s_dimDev.x); CHECK(Approx(dimDev.y).margin(1) == s_dimDev.y); } #endif // wxUSE_DC_TRANSFORM_MATRIX } -// For GTK+ 3 and OSX wxDC is equivalent to wxGCDC -// so it doesn't need to be tested individually. -#if !defined(__WXGTK3__) && !defined(__WXOSX__) -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::InitialState", "[coordinates]") +TEST_CASE("CoordinatesTestCase::wxDC", "[coordinates][dc]") { - // Check initial state - InitialState(m_dc); -} + wxBitmap bmp(s_dcSize); + wxMemoryDC dc(bmp); -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::NoTransform", "[coordinates]") -{ - // No transformations - NoTransform(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::NoTransformEx", "[coordinates]") -{ - // No transformations - NoTransformEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::DeviceOriginChanged", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::DeviceOriginChangedEx", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::LogicalOriginChanged", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::LogicalOriginChangedEx", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::UserScaleChanged", "[coordinates]") -{ - // Only user scale is changed - UserScaleChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::UserScaleChangedEx", "[coordinates]") -{ - // Only user scale is changed - UserScaleChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::LogicalScaleChanged", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::LogicalScaleChangedEx", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::TransformedStd", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStd(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::TransformedStdEx", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStdEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::TransformedWithMatrix", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrix(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::TransformedWithMatrixEx", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrixEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::TransformedWithMatrixAndStd", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStd(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::TransformedWithMatrixAndStdEx", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStdEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::RotatedWithMatrix", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrix(m_dc); -} - -TEST_CASE_METHOD(CoordinatesDCTestCase, "CoordinatesDC::RotatedWithMatrixEx", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrixEx(m_dc); -} -#endif // !__WXGTK3__ && !_WXOSX__ - -#if wxUSE_GRAPHICS_CONTEXT -// For MSW we have individual test cases for each graphics renderer -// so we don't need to test wxGCDC with default renderer. -#ifndef __WXMSW__ -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::InitialState", "[coordinates]") -{ - // Check initial state - InitialState(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::NoTransform", "[coordinates]") -{ - // No transformations - NoTransform(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::NoTransformEx", "[coordinates]") -{ - // No transformations - NoTransformEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::DeviceOriginChanged", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::DeviceOriginChangedEx", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::LogicalOriginChanged", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::LogicalOriginChangedEx", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::UserScaleChanged", "[coordinates]") -{ - // Only user scale is changed - UserScaleChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::UserScaleChangedEx", "[coordinates]") -{ - // Only user scale is changed - UserScaleChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::LogicalScaleChanged", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChanged(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::LogicalScaleChangedEx", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChangedEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::TransformedStd", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStd(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::TransformedStdEx", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStdEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::TransformedWithMatrix", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrix(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::TransformedWithMatrixEx", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrixEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::TransformedWithMatrixAndStd", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStd(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::TransformedWithMatrixAndStdEx", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStdEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::RotatedWithMatrix", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrix(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCTestCase, "CoordinatesGCDC::RotatedWithMatrixEx", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrixEx(m_dc); -} -#else// GDI+ and Direct2D are available only under MSW. -#if wxUSE_GRAPHICS_GDIPLUS -class CoordinatesGCDCGDIPlusTestCase : public CoordinatesGCDCTestCase -{ -public: - CoordinatesGCDCGDIPlusTestCase() + SECTION("InitialState") { - wxGraphicsRenderer* rend = wxGraphicsRenderer::GetGDIPlusRenderer(); - wxGraphicsContext* ctx = rend->CreateContext(m_mdc); - REQUIRE(ctx != nullptr); - m_gcdc->SetGraphicsContext(ctx); + InitialState(dc); } - virtual ~CoordinatesGCDCGDIPlusTestCase() {} -}; + SECTION("NoTransform") + { + NoTransform(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::InitialState", "[coordinates]") -{ - // Check initial state - InitialState(m_dc); + SECTION("NoTransformEx") + { + NoTransformEx(dc); + } + + SECTION("DeviceOriginChanged") + { + // Only device origin is changed + DeviceOriginChanged(dc); + } + + SECTION("DeviceOriginChangedEx") + { + // Only device origin is changed + DeviceOriginChangedEx(dc); + } + + SECTION("LogicalOriginChanged") + { + // Only logical origin is changed + LogicalOriginChanged(dc); + } + + SECTION("LogicalOriginChangedEx") + { + // Only logical origin is changed + LogicalOriginChangedEx(dc); + } + + SECTION("UserScaleChanged") + { + // Only user scale is changed + UserScaleChanged(dc); + } + + SECTION("UserScaleChangedEx") + { + // Only user scale is changed + UserScaleChangedEx(dc); + } + + SECTION("LogicalScaleChanged") + { + // Only logical scale is changed + LogicalScaleChanged(dc); + } + + SECTION("LogicalScaleChangedEx") + { + // Only logical scale is changed + LogicalScaleChangedEx(dc); + } + + SECTION("TransformedStd") + { + // Apply all standardd transformations + TransformedStd(dc); + } + + SECTION("TransformedStdEx") + { + // Apply all standardd transformations + TransformedStdEx(dc); + } + + SECTION("TransformedWithMatrix") + { + // Apply transformation matrix only + TransformedWithMatrix(dc); + } + + SECTION("TransformedWithMatrixEx") + { + // Apply transformation matrix only + TransformedWithMatrixEx(dc); + } + + SECTION("TransformedWithMatrixAndStd") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStd(dc); + } + + SECTION("TransformedWithMatrixAndStdEx") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStdEx(dc); + } + + SECTION("RotatedWithMatrix") + { + // Apply matrix transformations with rotation component + RotatedWithMatrix(dc); + } + + SECTION("RotatedWithMatrixEx") + { + // Apply matrix transformations with rotation component + RotatedWithMatrixEx(dc); + } } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::NoTransform", "[coordinates]") +#if wxUSE_GRAPHICS_CONTEXT +TEST_CASE("CoordinatesTestCase::wxGCDC", "[coordinates][dc][gcdc]") { - // No transformations - NoTransform(m_dc); + wxBitmap bmp(s_dcSize); + wxMemoryDC mdc(bmp); + wxGCDC dc(mdc); + dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE); + dc.GetGraphicsContext()->DisableOffset(); + + SECTION("InitialState") + { + InitialState(dc); + } + + SECTION("NoTransform") + { + NoTransform(dc); + } + + SECTION("NoTransformEx") + { + NoTransformEx(dc); + } + + SECTION("DeviceOriginChanged") + { + // Only device origin is changed + DeviceOriginChanged(dc); + } + + SECTION("DeviceOriginChangedEx") + { + // Only device origin is changed + DeviceOriginChangedEx(dc); + } + + SECTION("LogicalOriginChanged") + { + // Only logical origin is changed + LogicalOriginChanged(dc); + } + + SECTION("LogicalOriginChangedEx") + { + // Only logical origin is changed + LogicalOriginChangedEx(dc); + } + + SECTION("UserScaleChanged") + { + // Only user scale is changed + UserScaleChanged(dc); + } + + SECTION("UserScaleChangedEx") + { + // Only user scale is changed + UserScaleChangedEx(dc); + } + + SECTION("LogicalScaleChanged") + { + // Only logical scale is changed + LogicalScaleChanged(dc); + } + + SECTION("LogicalScaleChangedEx") + { + // Only logical scale is changed + LogicalScaleChangedEx(dc); + } + + SECTION("TransformedStd") + { + // Apply all standardd transformations + TransformedStd(dc); + } + + SECTION("TransformedStdEx") + { + // Apply all standardd transformations + TransformedStdEx(dc); + } + + SECTION("TransformedWithMatrix") + { + // Apply transformation matrix only + TransformedWithMatrix(dc); + } + + SECTION("TransformedWithMatrixEx") + { + // Apply transformation matrix only + TransformedWithMatrixEx(dc); + } + + SECTION("TransformedWithMatrixAndStd") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStd(dc); + } + + SECTION("TransformedWithMatrixAndStdEx") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStdEx(dc); + } + + SECTION("RotatedWithMatrix") + { + // Apply matrix transformations with rotation component + RotatedWithMatrix(dc); + } + + SECTION("RotatedWithMatrixEx") + { + // Apply matrix transformations with rotation component + RotatedWithMatrixEx(dc); + } } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::NoTransformEx", "[coordinates]") +#ifdef __WXMSW__ +#if wxUSE_GRAPHICS_GDIPLUS +TEST_CASE("CoordinatesTestCase::wxGCDC(GDI+)", "[coordinates][dc][gcdc][gdiplus]") { - // No transformations - NoTransformEx(m_dc); -} + int depth = GENERATE(24, 32); -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::DeviceOriginChanged", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChanged(m_dc); -} + wxBitmap bmp(s_dcSize, depth); + wxMemoryDC mdc(bmp); + wxGraphicsRenderer* rend = wxGraphicsRenderer::GetGDIPlusRenderer(); + REQUIRE(rend); + wxGraphicsContext* ctx = rend->CreateContext(mdc); + ctx->SetAntialiasMode(wxANTIALIAS_NONE); + ctx->DisableOffset(); + wxGCDC dc(ctx); -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::DeviceOriginChangedEx", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChangedEx(m_dc); -} + SECTION("InitialState") + { + InitialState(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::LogicalOriginChanged", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChanged(m_dc); -} + SECTION("NoTransform") + { + NoTransform(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::LogicalOriginChangedEx", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChangedEx(m_dc); -} + SECTION("NoTransformEx") + { + NoTransformEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::UserScaleChanged", "[coordinates]") -{ - // Only user scale is changed - UserScaleChanged(m_dc); -} + SECTION("DeviceOriginChanged") + { + // Only device origin is changed + DeviceOriginChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::UserScaleChangedEx", "[coordinates]") -{ - // Only user scale is changed - UserScaleChangedEx(m_dc); -} + SECTION("DeviceOriginChangedEx") + { + // Only device origin is changed + DeviceOriginChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::LogicalScaleChanged", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChanged(m_dc); -} + SECTION("LogicalOriginChanged") + { + // Only logical origin is changed + LogicalOriginChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::LogicalScaleChangedex", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChangedEx(m_dc); -} + SECTION("LogicalOriginChangedEx") + { + // Only logical origin is changed + LogicalOriginChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::TransformedStd", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStd(m_dc); -} + SECTION("UserScaleChanged") + { + // Only user scale is changed + UserScaleChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::TransformedStdEx", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStdEx(m_dc); -} + SECTION("UserScaleChangedEx") + { + // Only user scale is changed + UserScaleChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::TransformedWithMatrix", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrix(m_dc); -} + SECTION("LogicalScaleChanged") + { + // Only logical scale is changed + LogicalScaleChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::TransformedWithMatrixEx", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrixEx(m_dc); -} + SECTION("LogicalScaleChangedEx") + { + // Only logical scale is changed + LogicalScaleChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::TransformedWithMatrixAndStd", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStd(m_dc); -} + SECTION("TransformedStd") + { + // Apply all standardd transformations + TransformedStd(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::TransformedWithMatrixAndStdEx", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStdEx(m_dc); -} + SECTION("TransformedStdEx") + { + // Apply all standardd transformations + TransformedStdEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::RotatedWithMatrix", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrix(m_dc); -} + SECTION("TransformedWithMatrix") + { + // Apply transformation matrix only + TransformedWithMatrix(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCGDIPlusTestCase, "CoordinatesGCDCGDIPlus::RotatedWithMatrixEx", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrixEx(m_dc); + SECTION("TransformedWithMatrixEx") + { + // Apply transformation matrix only + TransformedWithMatrixEx(dc); + } + + SECTION("TransformedWithMatrixAndStd") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStd(dc); + } + + SECTION("TransformedWithMatrixAndStdEx") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStdEx(dc); + } + + SECTION("RotatedWithMatrix") + { + // Apply matrix transformations with rotation component + RotatedWithMatrix(dc); + } + + SECTION("RotatedWithMatrixEx") + { + // Apply matrix transformations with rotation component + RotatedWithMatrixEx(dc); + } } #endif // wxUSE_GRAPHICS_GDIPLUS #if wxUSE_GRAPHICS_DIRECT2D -class CoordinatesGCDCDirect2DTestCase : public CoordinatesGCDCTestCase +TEST_CASE("CoordinatesTestCase::wxGCDC(Direct2D)", "[coordinates][dc][gcdc][direct2d]") { -public: - CoordinatesGCDCDirect2DTestCase() + int depth = GENERATE(24, 32); + + wxBitmap bmp(s_dcSize, depth); + wxMemoryDC mdc(bmp); + wxGraphicsRenderer* rend = wxGraphicsRenderer::GetDirect2DRenderer(); + REQUIRE(rend); + wxGraphicsContext* ctx = rend->CreateContext(mdc); + ctx->SetAntialiasMode(wxANTIALIAS_NONE); + ctx->DisableOffset(); + wxGCDC dc(ctx); + + SECTION("InitialState") { - wxGraphicsRenderer* rend = wxGraphicsRenderer::GetDirect2DRenderer(); - wxGraphicsContext* ctx = rend->CreateContext(m_mdc); - REQUIRE(ctx != nullptr); - m_gcdc->SetGraphicsContext(ctx); + InitialState(dc); } - virtual ~CoordinatesGCDCDirect2DTestCase() {} -}; + SECTION("NoTransform") + { + NoTransform(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::InitialState", "[coordinates]") -{ - // Check initial state - InitialState(m_dc); -} + SECTION("NoTransformEx") + { + NoTransformEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::NoTransform", "[coordinates]") -{ - // No transformations - NoTransform(m_dc); -} + SECTION("DeviceOriginChanged") + { + // Only device origin is changed + DeviceOriginChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::NoTransformEx", "[coordinates]") -{ - // No transformations - NoTransformEx(m_dc); -} + SECTION("DeviceOriginChangedEx") + { + // Only device origin is changed + DeviceOriginChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::DeviceOriginChanged", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChanged(m_dc); -} + SECTION("LogicalOriginChanged") + { + // Only logical origin is changed + LogicalOriginChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::DeviceOriginChangedEx", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChangedEx(m_dc); -} + SECTION("LogicalOriginChangedEx") + { + // Only logical origin is changed + LogicalOriginChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::LogicalOriginChanged", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChanged(m_dc); -} + SECTION("UserScaleChanged") + { + // Only user scale is changed + UserScaleChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::LogicalOriginChangedEx", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChangedEx(m_dc); -} + SECTION("UserScaleChangedEx") + { + // Only user scale is changed + UserScaleChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::UserScaleChanged", "[coordinates]") -{ - // Only user scale is changed - UserScaleChanged(m_dc); -} + SECTION("LogicalScaleChanged") + { + // Only logical scale is changed + LogicalScaleChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::UserScaleChangedEx", "[coordinates]") -{ - // Only user scale is changed - UserScaleChangedEx(m_dc); -} + SECTION("LogicalScaleChangedEx") + { + // Only logical scale is changed + LogicalScaleChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::LogicalScaleChanged", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChanged(m_dc); -} + SECTION("TransformedStd") + { + // Apply all standardd transformations + TransformedStd(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::LogicalScaleChangedEx", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChangedEx(m_dc); -} + SECTION("TransformedStdEx") + { + // Apply all standardd transformations + TransformedStdEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::TransformedStd", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStd(m_dc); -} + SECTION("TransformedWithMatrix") + { + // Apply transformation matrix only + TransformedWithMatrix(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::TransformedStdEx", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStdEx(m_dc); -} + SECTION("TransformedWithMatrixEx") + { + // Apply transformation matrix only + TransformedWithMatrixEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::TransformedWithMatrix", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrix(m_dc); -} + SECTION("TransformedWithMatrixAndStd") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStd(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::TransformedWithMatrixEx", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrixEx(m_dc); -} + SECTION("TransformedWithMatrixAndStdEx") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStdEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::TransformedWithMatrixAndStd", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStd(m_dc); -} + SECTION("RotatedWithMatrix") + { + // Apply matrix transformations with rotation component + RotatedWithMatrix(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::TransformedWithMatrixAndStdEx", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStdEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::RotatedWithMatrix", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrix(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCDirect2DTestCase, "CoordinatesGCDCDirect2D::RotatedWithMatrixEx", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrixEx(m_dc); + SECTION("RotatedWithMatrixEx") + { + // Apply matrix transformations with rotation component + RotatedWithMatrixEx(dc); + } } #endif // wxUSE_GRAPHICS_DIRECT2D -#endif // __WXMSW__/!__WXMSW__ +#endif // __WXMSW__ #if wxUSE_CAIRO -class CoordinatesGCDCCairoTestCase : public CoordinatesGCDCTestCase +TEST_CASE("CoordinatesTestCase::wxGCDC(Cairo)", "[coordinates][dc][gcdc][cairo]") { -public: - CoordinatesGCDCCairoTestCase() +#ifdef __WXMSW__ + int depth = GENERATE(24, 32); + + wxBitmap bmp(s_dcSize, depth); +#else + wxBitmap bmp(s_dcSize); +#endif + wxMemoryDC mdc(bmp); + wxGraphicsRenderer* rend = wxGraphicsRenderer::GetCairoRenderer(); + REQUIRE(rend); + wxGraphicsContext* ctx = rend->CreateContext(mdc); + ctx->SetAntialiasMode(wxANTIALIAS_NONE); + ctx->DisableOffset(); + wxGCDC dc(ctx); + + SECTION("InitialState") { - wxGraphicsRenderer* rend = wxGraphicsRenderer::GetCairoRenderer(); - wxGraphicsContext* ctx = rend->CreateContext(m_mdc); - REQUIRE(ctx != nullptr); - m_gcdc->SetGraphicsContext(ctx); + InitialState(dc); } - virtual ~CoordinatesGCDCCairoTestCase() {} -}; + SECTION("NoTransform") + { + NoTransform(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::InitialState", "[coordinates]") -{ - // Check initial state - InitialState(m_dc); -} + SECTION("NoTransformEx") + { + NoTransformEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::NoTransform", "[coordinates]") -{ - // No transformations - NoTransform(m_dc); -} + SECTION("DeviceOriginChanged") + { + // Only device origin is changed + DeviceOriginChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::NoTransformEx", "[coordinates]") -{ - // No transformations - NoTransformEx(m_dc); -} + SECTION("DeviceOriginChangedEx") + { + // Only device origin is changed + DeviceOriginChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::DeviceOriginChanged", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChanged(m_dc); -} + SECTION("LogicalOriginChanged") + { + // Only logical origin is changed + LogicalOriginChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::DeviceOriginChangedEx", "[coordinates]") -{ - // Only device origin is changed - DeviceOriginChangedEx(m_dc); -} + SECTION("LogicalOriginChangedEx") + { + // Only logical origin is changed + LogicalOriginChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::LogicalOriginChanged", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChanged(m_dc); -} + SECTION("UserScaleChanged") + { + // Only user scale is changed + UserScaleChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::LogicalOriginChangedEx", "[coordinates]") -{ - // Only logical origin is changed - LogicalOriginChangedEx(m_dc); -} + SECTION("UserScaleChangedEx") + { + // Only user scale is changed + UserScaleChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::UserScaleChanged", "[coordinates]") -{ - // Only user scale is changed - UserScaleChanged(m_dc); -} + SECTION("LogicalScaleChanged") + { + // Only logical scale is changed + LogicalScaleChanged(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::UserScaleChangedEx", "[coordinates]") -{ - // Only user scale is changed - UserScaleChangedEx(m_dc); -} + SECTION("LogicalScaleChangedEx") + { + // Only logical scale is changed + LogicalScaleChangedEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::LogicalScaleChanged", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChanged(m_dc); -} + SECTION("TransformedStd") + { + // Apply all standardd transformations + TransformedStd(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::LogicalScaleChangedEx", "[coordinates]") -{ - // Only logical scale is changed - LogicalScaleChangedEx(m_dc); -} + SECTION("TransformedStdEx") + { + // Apply all standardd transformations + TransformedStdEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::TransformedStd", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStd(m_dc); -} + SECTION("TransformedWithMatrix") + { + // Apply transformation matrix only + TransformedWithMatrix(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::TransformedStdEx", "[coordinates]") -{ - // Apply all standardd transformations - TransformedStdEx(m_dc); -} + SECTION("TransformedWithMatrixEx") + { + // Apply transformation matrix only + TransformedWithMatrixEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::TransformedWithMatrix", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrix(m_dc); -} + SECTION("TransformedWithMatrixAndStd") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStd(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::TransformedWithMatrixEx", "[coordinates]") -{ - // Apply transformation matrix only - TransformedWithMatrixEx(m_dc); -} + SECTION("TransformedWithMatrixAndStdEx") + { + // Apply combination of standard and matrix transformations + TransformedWithMatrixAndStdEx(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::TransformedWithMatrixAndStd", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStd(m_dc); -} + SECTION("RotatedWithMatrix") + { + // Apply matrix transformations with rotation component + RotatedWithMatrix(dc); + } -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::TransformedWithMatrixAndStdEx", "[coordinates]") -{ - // Apply combination of standard and matrix transformations - TransformedWithMatrixAndStdEx(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::RotatedWithMatrix", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrix(m_dc); -} - -TEST_CASE_METHOD(CoordinatesGCDCCairoTestCase, "CoordinatesGCDCCairo::RotatedWithMatrixEx", "[coordinates]") -{ - // Apply matrix transformations with rotation component - RotatedWithMatrixEx(m_dc); + SECTION("RotatedWithMatrixEx") + { + // Apply matrix transformations with rotation component + RotatedWithMatrixEx(dc); + } } #endif // wxUSE_CAIRO #endif // wxUSE_GRAPHICS_CONTEXT