30 #include <QLoggingCategory>
31 #include <QStandardPaths>
33 #include <QtCore/private/qloggingregistry_p.h>
54 qputenv(
"XDG_CONFIG_DIRS",
"/does/not/exist");
55 qunsetenv(
"QT_LOGGING_CONF");
56 qunsetenv(
"QT_LOGGING_RULES");
59 void QLoggingRule_parse_data()
61 QTest::addColumn<QString>(
"pattern");
62 QTest::addColumn<QString>(
"category");
63 QTest::addColumn<QtMsgType>(
"msgType");
64 QTest::addColumn<LoggingRuleState>(
"result");
155 void QLoggingRule_parse()
162 const auto categoryL1 =
category.toLatin1();
167 if (
rule.flags != 0) {
168 switch (
rule.pass(categoryL1S, msgType)) {
169 case -1:
QFAIL(
"Shoudn't happen, we set pattern to true");
break;
177 void QLoggingSettingsParser_iniStyle()
201 parser.setContent(
u"[OtherSection]\n"
206 void QLoggingRegistry_environment()
214 qputenv(
"QT_LOGGING_RULES",
"qt.foo.bar=true");
225 qunsetenv(
"QT_LOGGING_RULES");
226 qputenv(
"QT_LOGGING_CONF",
QFINDTESTDATA(
"qtlogging.ini").toLocal8Bit());
234 qputenv(
"QT_LOGGING_RULES",
"Digia.*=true");
237 QCOMPARE(
registry.ruleSets[QLoggingRegistry::EnvironmentRules].at(1).enabled,
true);
240 void QLoggingRegistry_config()
257 out <<
"Digia.*=false\n";
268 void QLoggingRegistry_rulePriorities()
284 registry->ruleSets[QLoggingRegistry::ApiRules].clear();
285 registry->ruleSets[QLoggingRegistry::ConfigRules].clear();
286 registry->ruleSets[QLoggingRegistry::EnvironmentRules].clear();
293 parser.setContent(
u"[Rules]\nDigia.*=false");
294 registry->ruleSets[QLoggingRegistry::ConfigRules] =
parser.rules();
305 parser.setContent(
u"Digia.*=false");
306 registry->ruleSets[QLoggingRegistry::EnvironmentRules] =
parser.rules();
313 void QLoggingRegistry_checkErrors()
329 #include "tst_qloggingregistry.moc"
small capitals from c petite p scientific f u
The QDir class provides access to directory structures and their contents.
The QFile class provides an interface for reading from and writing to files.
bool open(OpenMode flags) override
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QLoggingCategory class represents a category, or 'area' in the logging infrastructure.
static void setFilterRules(const QString &rules)
bool isWarningEnabled() const
bool isDebugEnabled() const
static QLoggingRegistry * instance()
The QObject class is the base class of all Qt objects.
static void setTestModeEnabled(bool testMode)
static QString writableLocation(StandardLocation type)
The QString class provides a Unicode character string.
The QTextStream class provides a convenient interface for reading and writing text.
const QLoggingCategory & category()
[1]
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message)
DBusConnection const char * rule
GLsizei const GLchar *const * path
#define QTEST_APPLESS_MAIN(TestObject)
#define QFETCH(Type, name)
#define QVERIFY(statement)
#define QFINDTESTDATA(basepath)
QTextStream out(stdout)
[7]
Q_DECLARE_METATYPE(LoggingRuleState)