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
mediabackendutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
6#include <QtCore/qbytearray.h>
7#include <QtCore/qlist.h>
8
9namespace BackendUtilsImpl {
10
11void addMediaBackendToTestEnvironment(const QString &backend)
12{
13 const QByteArray backendName = backend.toLower().toUtf8();
14 const QByteArray backendKey = backendName + "-mediabackend";
15 QByteArray testEnvironment = qgetenv("QTEST_ENVIRONMENT");
16 bool hasBackendKey = false;
17 const QList<QByteArray> keys = testEnvironment.split(' ');
18 for (const QByteArray &key : keys) {
19 if (!key.endsWith("-mediabackend"))
20 continue;
21 if (key != backendKey) {
22 qFatal(
23 "QTEST_ENVIRONMENT contains '%s', but the media backend in use is '%s'",
24 key.constData(),
25 backendName.constData());
26 }
27 hasBackendKey = true;
28 }
29 if (!hasBackendKey) {
30 if (!testEnvironment.isEmpty())
31 testEnvironment += ' ';
32 testEnvironment += backendKey;
33 qputenv("QTEST_ENVIRONMENT", testEnvironment);
34 }
35}
36
37} // namespace BackendUtilsImpl
void addMediaBackendToTestEnvironment(const QString &backend)