Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/connectivity/fixtures/load.qml

Raw
import QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/connectivity" as ConnectivityFeature

// `just load-test connectivity`: the registry entry's own panel, bound to the
// Network and Bluetooth doubles the load harness overlays. The panel renders the
// double's joined and secured networks and the powered-off adapter, expands the
// secured network,
// follows a live service refresh without losing the expanded SSID, then follows
// a live adapter refresh. Each refresh follows a user action, as in production,
// and reaches the panel only through its bindings to the services' typed state.
// No iwd, BlueZ, compositor, input, or pixels.
ShellRoot {
    id: root

    readonly property N.FeatureEntry feature: registry.popup("connectivity")
    property int step: 0
    // The overlaid doubles' fixture surface; production services have no externalUpdate.
    readonly property var networkDouble: registry.connectivity
    readonly property var bluetoothDouble: registry.bluetooth

    function finish(): void {
        const panel = loader.item as ConnectivityFeature.ConnectivityPanel;
        if (!panel)
            return;
        const networks = panel.networks;
        const secure = networks.find(row => row.ssid === "fixture-secure");
        if (root.step === 0 && root.feature.width === 620 && root.feature.height === 540 && root.feature.barLabel === "network" && !root.feature.barStrong && networks.length === 2 && networks[0].connected && secure && secure.signal === 2 && !panel.bluetoothPowered) {
            root.step = 1;
            panel.expandRow(secure);
            panel.scanWifi();
            root.networkDouble.externalUpdate();
        } else if (root.step === 1 && panel.expandedSsid === "fixture-secure" && secure && secure.signal === 4) {
            root.step = 2;
            panel.scanBluetooth();
            root.bluetoothDouble.externalUpdate();
        } else if (root.step === 2 && panel.bluetoothPowered) {
            console.log("load connectivity: PASS");
            Qt.quit();
        }
    }

    N.Theme {
        id: nuguTheme
    }

    N.Registry {
        id: registry

        theme: nuguTheme
    }

    // Plain Window: Quickshell windows set input masks the offscreen platform rejects.
    Window {
        width: 588
        height: 508
        visible: true
        color: "transparent"

        Loader {
            id: loader

            anchors.fill: parent
            sourceComponent: root.feature ? root.feature.panel : null
        }
    }

    Timer {
        interval: 25
        running: true
        repeat: true
        onTriggered: root.finish()
    }

    Timer {
        interval: 5000
        running: true
        onTriggered: {
            console.error("ERROR load connectivity: the panel never followed the doubles");
            Qt.quit();
        }
    }
}