1
0
Fork 0
gobject-generator/regression/tier3/PixbufSmoke.swift

36 lines
1.7 KiB
Swift

// PixbufSmoke.swift
// Tier-3-only runtime smoke test for GdkPixbuf (Phase E2). Proves against
// the REAL libgdk_pixbuf, linked at runtime that:
// 1. `Pixbuf(colorspace:hasAlpha:bitsPerSample:width:height:)` reaches the
// real `gdk_pixbuf_new` C call, correctly marshalling an enum param
// (`Colorspace`), a `Bool` param (`hasAlpha` `gboolean`), and `Int32`
// params (`bitsPerSample`/`width`/`height`), and wraps the returned
// `GdkPixbuf*` as a live GObject via `takingOwnership`.
// 2. `getWidth()`/`getHeight()` round-trip through `gdk_pixbuf_get_width`/
// `gdk_pixbuf_get_height`, returning the values passed to the
// constructor not stubbed/placeholder data.
//
// Not generated. `scripts/smoke-test.sh <tier>` copies tier 1 and the selected
// tier's fixtures for tiers 2 through 5. Tier 6/all copies every tier's fixtures
// into one full-stack SmokeTests target. Only installed for tier >= 3.
import Testing
import GLib
import GObject
import GdkPixbuf
@Suite("Tier 3 GdkPixbuf smoke tests")
struct PixbufSmokeTests {
@Test("Pixbuf(colorspace:hasAlpha:bitsPerSample:width:height:) constructs a real GdkPixbuf and getWidth()/getHeight() round-trip")
func pixbufConstructionAndDimensions() throws {
let pixbuf = Pixbuf(colorspace: .rgb, hasAlpha: true, bitsPerSample: 8, width: 4, height: 7)
// Dimension round-trip: these values only match if the constructor
// actually reached `gdk_pixbuf_new` with the right arguments and the
// getters call back into the real C object rather than returning
// stub data.
#expect(pixbuf.getWidth() == 4)
#expect(pixbuf.getHeight() == 7)
}
}