Commit b9c3cd66 authored by Kurt Hindenburg's avatar Kurt Hindenburg

More changes to QLatin1String, QLatin1Char and QStringLiteral

parent b4b4a502
......@@ -51,7 +51,7 @@ void DBusTest::initTestCase()
int pid = KProcess::startDetached(QStringLiteral("konsole"),
QStringList(QStringLiteral("--separate")));
if (pid == 0) {
QFAIL(QString("Unable to exec a new Konsole").toLatin1().data());
QFAIL(QStringLiteral("Unable to exec a new Konsole").toLatin1().data());
}
// Wait for above Konsole to finish starting
......@@ -97,7 +97,7 @@ void DBusTest::cleanupTestCase()
QDBusReply<void> instanceReply = iface.call(QStringLiteral("close"));
if (!instanceReply.isValid())
QFAIL(QString("Unable to close Konsole: %1").arg(instanceReply.error().message()).toLatin1().data());
QFAIL(QStringLiteral("Unable to close Konsole: %1").arg(instanceReply.error().message()).toLatin1().data());
}
void DBusTest::testSessions()
......
......@@ -34,8 +34,8 @@ void ProfileTest::testProfile()
{
// create a new profile
Profile* parent = new Profile;
parent->setProperty(Profile::Name, "Parent");
parent->setProperty(Profile::Path, "FakePath");
parent->setProperty(Profile::Name, QStringLiteral("Parent"));
parent->setProperty(Profile::Path, QStringLiteral("FakePath"));
parent->setProperty(Profile::AntiAliasFonts, false);
parent->setProperty(Profile::StartInCurrentSessionDir, false);
......@@ -65,9 +65,9 @@ void ProfileTest::testProfile()
QVERIFY(!child->isPropertySet(Profile::ColorScheme));
// read non-inheritable properties
QCOMPARE(parent->property<QString>(Profile::Name), QString("Parent"));
QCOMPARE(parent->property<QString>(Profile::Name), QStringLiteral("Parent"));
QCOMPARE(child->property<QVariant>(Profile::Name), QVariant());
QCOMPARE(parent->property<QString>(Profile::Path), QString("FakePath"));
QCOMPARE(parent->property<QString>(Profile::Path), QStringLiteral("FakePath"));
QCOMPARE(child->property<QVariant>(Profile::Path), QVariant());
// read inheritable properties
......@@ -83,22 +83,22 @@ void ProfileTest::testClone()
{
// create source profile and parent
Profile::Ptr parent(new Profile);
parent->setProperty(Profile::Command, "ps");
parent->setProperty(Profile::ColorScheme, "BlackOnWhite");
parent->setProperty(Profile::Command, QStringLiteral("ps"));
parent->setProperty(Profile::ColorScheme, QStringLiteral("BlackOnWhite"));
Profile::Ptr source(new Profile(parent));
source->setProperty(Profile::AntiAliasFonts, false);
source->setProperty(Profile::HistorySize, 4567);
source->setProperty(Profile::Name, "SourceProfile");
source->setProperty(Profile::Path, "SourcePath");
source->setProperty(Profile::Name, QStringLiteral("SourceProfile"));
source->setProperty(Profile::Path, QStringLiteral("SourcePath"));
// create target to clone source and parent
Profile::Ptr targetParent(new Profile);
// same value as source parent
targetParent->setProperty(Profile::Command, "ps");
targetParent->setProperty(Profile::Command, QStringLiteral("ps"));
// different value from source parent
targetParent->setProperty(Profile::ColorScheme, "BlackOnGrey");
targetParent->setProperty(Profile::ColorScheme, QStringLiteral("BlackOnGrey"));
Profile::Ptr target(new Profile(parent));
// clone source profile, setting only properties that differ
......@@ -161,18 +161,18 @@ void ProfileTest::testProfileGroup()
QCOMPARE(group_const->property<QVariant>(Profile::UseCustomCursorColor), QVariant());
// set and test shareable properties in the group
group->setProperty(Profile::Command, "ssh");
group->setProperty(Profile::Command, QStringLiteral("ssh"));
group->setProperty(Profile::AntiAliasFonts, false);
QCOMPARE(profile[0]->property<QString>(Profile::Command), QString("ssh"));
QCOMPARE(profile[0]->property<QString>(Profile::Command), QStringLiteral("ssh"));
QVERIFY(!profile[1]->property<bool>(Profile::AntiAliasFonts));
// set and test non-shareable properties in the group
// (should have no effect)
group->setProperty(Profile::Name, "NewName");
group->setProperty(Profile::Path, "NewPath");
QVERIFY(profile[1]->property<QString>(Profile::Name) != "NewName");
QVERIFY(profile[2]->property<QString>(Profile::Path) != "NewPath");
group->setProperty(Profile::Name, QStringLiteral("NewName"));
group->setProperty(Profile::Path, QStringLiteral("NewPath"));
QVERIFY(profile[1]->property<QString>(Profile::Name) != QLatin1String("NewName"));
QVERIFY(profile[2]->property<QString>(Profile::Path) != QLatin1String("NewPath"));
// remove a profile from the group
group->removeProfile(profile[0]);
......@@ -180,8 +180,8 @@ void ProfileTest::testProfileGroup()
group->updateValues();
// check that profile is no longer affected by group
group->setProperty(Profile::Command, "fish");
QVERIFY(profile[0]->property<QString>(Profile::Command) != "fish");
group->setProperty(Profile::Command, QStringLiteral("fish"));
QVERIFY(profile[0]->property<QString>(Profile::Command) != QLatin1String("fish"));
}
// Verify the correct file name is created from the untranslatedname
......@@ -191,13 +191,13 @@ void ProfileTest::testProfileFileNames()
QFileInfo fileInfo;
ProfileWriter* writer = new KDE4ProfileWriter;
profile->setProperty(Profile::UntranslatedName, "Indiana");
profile->setProperty(Profile::UntranslatedName, QStringLiteral("Indiana"));
fileInfo.setFile(writer->getPath(profile));
QCOMPARE(fileInfo.fileName(), QString("Indiana.profile"));
QCOMPARE(fileInfo.fileName(), QStringLiteral("Indiana.profile"));
profile->setProperty(Profile::UntranslatedName, "Old Paris");
profile->setProperty(Profile::UntranslatedName, QStringLiteral("Old Paris"));
fileInfo.setFile(writer->getPath(profile));
QCOMPARE(fileInfo.fileName(), QString("Old Paris.profile"));
QCOMPARE(fileInfo.fileName(), QStringLiteral("Old Paris.profile"));
/* FIXME: deal w/ file systems that are case-insensitive
This leads to confusion as both Test and test can appear in the Manager
......@@ -231,8 +231,8 @@ void ProfileTest::testFallbackProfile()
Profile* fallback = new Profile();
fallback->useFallback();
QCOMPARE(fallback->property<QString>(Profile::Name), QString("Default"));
QCOMPARE(fallback->property<QString>(Profile::Path), QString("FALLBACK/"));
QCOMPARE(fallback->property<QString>(Profile::Name), QStringLiteral("Default"));
QCOMPARE(fallback->property<QString>(Profile::Path), QStringLiteral("FALLBACK/"));
delete fallback;
}
......
......@@ -41,7 +41,7 @@ void ShellCommandTest::testConstructorWithOneArguemnt()
{
const QString fullCommand(QStringLiteral("sudo apt-get update"));
ShellCommand shellCommand(fullCommand);
QCOMPARE(shellCommand.command(), QString("sudo"));
QCOMPARE(shellCommand.command(), QStringLiteral("sudo"));
QCOMPARE(shellCommand.fullCommand(), fullCommand);
}
......@@ -55,7 +55,7 @@ void ShellCommandTest::testConstructorWithTwoArguments()
ShellCommand shellCommand(command, arguments);
QCOMPARE(shellCommand.command(), command);
QCOMPARE(shellCommand.arguments(), arguments);
QCOMPARE(shellCommand.fullCommand(), arguments.join(" "));
QCOMPARE(shellCommand.fullCommand(), arguments.join(QLatin1String(" ")));
}
void ShellCommandTest::testExpandEnvironmentVariable()
......@@ -66,13 +66,13 @@ void ShellCommandTest::testExpandEnvironmentVariable()
qputenv(env.toLocal8Bit().constData(), value.toLocal8Bit());
const QString result = ShellCommand::expand(text);
const QString expected = text.replace('$' + env, value);
const QString expected = text.replace(QLatin1Char('$') + env, value);
QCOMPARE(result, expected);
text = QStringLiteral("PATH=$PATH:\\$ESCAPED:~/bin");
qputenv(env.toLocal8Bit().constData(), value.toLocal8Bit());
const QString result2 = ShellCommand::expand(text);
const QString expected2 = text.replace('$' + env, value);
const QString expected2 = text.replace(QLatin1Char('$') + env, value);
QCOMPARE(result2, expected2);
text = QStringLiteral("$ABC \"$ABC\" '$ABC'");
......@@ -85,14 +85,14 @@ void ShellCommandTest::testExpandEnvironmentVariable()
void ShellCommandTest::testValidEnvCharacter()
{
QChar validChar('A');
QChar validChar(QLatin1Char('A'));
const bool result = ShellCommand::isValidEnvCharacter(validChar);
QCOMPARE(result, true);
}
void ShellCommandTest::testValidLeadingEnvCharacter()
{
QChar invalidChar('9');
QChar invalidChar(QLatin1Char('9'));
const bool result = ShellCommand::isValidLeadingEnvCharacter(invalidChar);
QCOMPARE(result, false);
}
......
......@@ -111,7 +111,7 @@ void TerminalInterfaceTest::testTerminalInterface()
// #1A - Test signal currentDirectoryChanged(QString)
currentDirectory = QStringLiteral("/tmp");
terminal->sendInput("cd " + currentDirectory + '\n');
terminal->sendInput(QStringLiteral("cd ") + currentDirectory + QLatin1Char('\n'));
sleep(2000);
QCOMPARE(stateSpy.count(), 1);
......@@ -136,7 +136,7 @@ void TerminalInterfaceTest::testTerminalInterface()
// Test starting a new program
QString command = QStringLiteral("top");
terminal->sendInput(command + '\n');
terminal->sendInput(command + QLatin1Char('\n'));
sleep(2000);
// FIXME: find a good way to validate process id of 'top'
foregroundProcessId = terminal->foregroundProcessId();
......
......@@ -59,8 +59,8 @@ void PartManualTest::testShortcutOverride()
// Create a main window with a menu and a test
// action with a shortcut set to Ctrl+S, which is also used by the terminal
auto mainWindow = new KMainWindow();
QMenu* fileMenu = mainWindow->menuBar()->addMenu("File");
QAction* testAction = fileMenu->addAction("Test");
QMenu* fileMenu = mainWindow->menuBar()->addMenu(QStringLiteral("File"));
QAction* testAction = fileMenu->addAction(QStringLiteral("Test"));
testAction->setShortcut(QKeySequence(Konsole::ACCEL + Qt::Key_S));
connect(testAction, &QAction::triggered, this, &Konsole::PartManualTest::shortcutTriggered);
......@@ -70,7 +70,7 @@ void PartManualTest::testShortcutOverride()
mainWindow->setCentralWidget(terminalPart->widget());
TerminalInterface* terminal = qobject_cast<TerminalInterface*>(terminalPart);
QVERIFY(terminal);
terminal->sendInput("Press Ctrl+S twice.\n");
terminal->sendInput(QStringLiteral("Press Ctrl+S twice.\n"));
mainWindow->show();
// Test shortcut with override disabled, so the shortcut will be triggered
......@@ -120,7 +120,7 @@ void PartManualTest::shortcutTriggered()
KParts::Part* PartManualTest::createPart()
{
KService::Ptr service = KService::serviceByDesktopName("konsolepart");
KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("konsolepart"));
Q_ASSERT(service);
KPluginFactory* factory = KPluginLoader(service->library()).factory();
Q_ASSERT(factory);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment