Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QFakeXdgPortalFixture Class Reference

#include <qfakexdgportalfixture_p.h>

Collaboration diagram for QFakeXdgPortalFixture:

Classes

class  Private

Public Member Functions

 QFakeXdgPortalFixture ()
 ~QFakeXdgPortalFixture ()
q23::expected< void, QString > start (const SyntheticVideoScene &initialScene)
void stop ()
bool isActive () const
quint32 nodeId () const
 The node id the fake portal reports from Start(). Mostly useful for diagnostics.
q23::expected< void, QString > setScene (const SyntheticVideoScene &scene)
 Replaces the content published by the synthetic source.
q23::expected< void, QString > closeSessions ()
 Revokes the portal session mid-stream, as a compositor would.

Static Public Member Functions

static bool isHelperProcess (int argc, char **argv)
 True when this process was started as the fake portal helper.
static int runHelperProcess (int argc, char **argv)
static bool isRequested ()
 Whether the fixture should be used at all.
static bool prerequisitesAvailable (QString *unavailableReason=nullptr)
 Whether the external pieces (pipewire, dbus-run-session) are present.
static void reexecUnderPrivateBusIfRequested (int argc, char **argv)
 Re-executes the test binary under dbus-run-session when isRequested() and the prerequisites hold, so the whole test runs against a private session bus.
static bool isRunningOnPrivateBus ()
 True if the current process is already running on the fixture's private bus.

Detailed Description

Runs an unattended stand-in for xdg-desktop-portal, so that tests can exercise the portal-backed PipeWire code paths end to end without a human approving a consent dialog. Today it implements the ScreenCast interface; the intent is that every portal interface qtmultimedia talks to is faked here.

It brings up, and tears down: \list

  • a private pipewire daemon, with no session manager and no access to any real hardware;
  • a helper process (this test binary, re-executed with QtFakeXdgPortal::HelperArgument) which owns org.freedesktop.portal.Desktop on a private D-Bus session bus and publishes a synthetic video source rendering a SyntheticVideoScene. \endlist

Usage from a test's main():

#define main testlib_main
QTEST_MAIN(tst_Foo)
#undef main
int main(int argc, char *argv[])
{
return testlib_main(argc, argv);
}
static int runHelperProcess(int argc, char **argv)
static bool isHelperProcess(int argc, char **argv)
True when this process was started as the fake portal helper.
static void reexecUnderPrivateBusIfRequested(int argc, char **argv)
Re-executes the test binary under dbus-run-session when isRequested() and the prerequisites hold,...
int main()
[open]
#define QTEST_MAIN(TestObject)
Definition qtest.h:296

The re-exec must happen before QApplication is constructed: QApplication opens the session bus, and QDBusConnection caches it for the lifetime of the process.

Definition at line 64 of file qfakexdgportalfixture_p.h.

Constructor & Destructor Documentation

◆ QFakeXdgPortalFixture()

QFakeXdgPortalFixture::QFakeXdgPortalFixture ( )

Definition at line 167 of file qfakexdgportalfixture.cpp.

◆ ~QFakeXdgPortalFixture()

QFakeXdgPortalFixture::~QFakeXdgPortalFixture ( )

Definition at line 169 of file qfakexdgportalfixture.cpp.

Member Function Documentation

◆ closeSessions()

q23::expected< void, QString > QFakeXdgPortalFixture::closeSessions ( )

Revokes the portal session mid-stream, as a compositor would.

Definition at line 472 of file qfakexdgportalfixture.cpp.

◆ isActive()

bool QFakeXdgPortalFixture::isActive ( ) const
nodiscard

Definition at line 443 of file qfakexdgportalfixture.cpp.

◆ isHelperProcess()

bool QFakeXdgPortalFixture::isHelperProcess ( int argc,
char ** argv )
static

True when this process was started as the fake portal helper.

Definition at line 174 of file qfakexdgportalfixture.cpp.

◆ isRequested()

bool QFakeXdgPortalFixture::isRequested ( )
static

Whether the fixture should be used at all.

Controlled by QT_MULTIMEDIA_TEST_XDG_PORTAL_FIXTURE: "fake" forces it on, "none" forces it off, and the default "auto" enables it on Linux for non-X11 sessions, where the real portal would otherwise block on a consent dialog.

Definition at line 186 of file qfakexdgportalfixture.cpp.

◆ isRunningOnPrivateBus()

bool QFakeXdgPortalFixture::isRunningOnPrivateBus ( )
static

True if the current process is already running on the fixture's private bus.

Definition at line 219 of file qfakexdgportalfixture.cpp.

◆ nodeId()

quint32 QFakeXdgPortalFixture::nodeId ( ) const
nodiscard

The node id the fake portal reports from Start(). Mostly useful for diagnostics.

Definition at line 448 of file qfakexdgportalfixture.cpp.

◆ prerequisitesAvailable()

bool QFakeXdgPortalFixture::prerequisitesAvailable ( QString * unavailableReason = nullptr)
static

Whether the external pieces (pipewire, dbus-run-session) are present.

Definition at line 204 of file qfakexdgportalfixture.cpp.

◆ reexecUnderPrivateBusIfRequested()

void QFakeXdgPortalFixture::reexecUnderPrivateBusIfRequested ( int argc,
char ** argv )
static

Re-executes the test binary under dbus-run-session when isRequested() and the prerequisites hold, so the whole test runs against a private session bus.

Returns normally when no re-exec is needed or possible.

Definition at line 224 of file qfakexdgportalfixture.cpp.

◆ runHelperProcess()

int QFakeXdgPortalFixture::runHelperProcess ( int argc,
char ** argv )
static

Definition at line 181 of file qfakexdgportalfixture.cpp.

◆ setScene()

q23::expected< void, QString > QFakeXdgPortalFixture::setScene ( const SyntheticVideoScene & scene)

Replaces the content published by the synthetic source.

Definition at line 453 of file qfakexdgportalfixture.cpp.

◆ start()

q23::expected< void, QString > QFakeXdgPortalFixture::start ( const SyntheticVideoScene & initialScene)

Definition at line 357 of file qfakexdgportalfixture.cpp.

◆ stop()

void QFakeXdgPortalFixture::stop ( )

Definition at line 422 of file qfakexdgportalfixture.cpp.


The documentation for this class was generated from the following files: