update tests
This commit is contained in:
parent
e28c32bbf4
commit
9992974049
@ -573,8 +573,11 @@ void JsonRPCServer::sendNotification(const QVariantMap ¶ms)
|
||||
notification.insert("notification", handler->name() + "." + method.name());
|
||||
notification.insert("params", params);
|
||||
|
||||
QByteArray data = QJsonDocument::fromVariant(notification).toJson(QJsonDocument::Compact);
|
||||
qCDebug(dcJsonRpcTraffic()) << "Sending notification:" << data;
|
||||
|
||||
foreach (const QUuid &clientId, m_clientNotifications.keys(true)) {
|
||||
m_clientTransports.value(clientId)->sendData(clientId, QJsonDocument::fromVariant(notification).toJson(QJsonDocument::Compact));
|
||||
m_clientTransports.value(clientId)->sendData(clientId, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -168,8 +168,12 @@ QString NymeaSettings::settingsPath()
|
||||
/*! Returns the default system translation path \tt{/usr/share/nymea/translations}. */
|
||||
QString NymeaSettings::translationsPath()
|
||||
{
|
||||
QString organisationName = QCoreApplication::instance()->organizationName();
|
||||
|
||||
if (!qgetenv("SNAP").isEmpty()) {
|
||||
return QString(qgetenv("SNAP") + "/usr/share/nymea/translations");
|
||||
} else if (organisationName == "nymea-test") {
|
||||
return "/tmp/" + organisationName;
|
||||
} else {
|
||||
return QString("/usr/share/nymea/translations");
|
||||
}
|
||||
|
||||
@ -38,6 +38,9 @@ class TestConfigurations: public NymeaTestBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected slots:
|
||||
void initTestCase();
|
||||
|
||||
private slots:
|
||||
void getConfigurations();
|
||||
|
||||
@ -52,6 +55,21 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void TestConfigurations::initTestCase()
|
||||
{
|
||||
QDir dir(NymeaSettings::translationsPath());
|
||||
dir.mkpath(NymeaSettings::translationsPath());
|
||||
QStringList languages = {"de", "en_US"};
|
||||
foreach (const QString &language, languages) {
|
||||
QFile f(NymeaSettings::translationsPath().append("/nymead-" + language + ".qm"));
|
||||
QVERIFY2(f.open(QFile::WriteOnly), "Could not create translation file.");
|
||||
f.write(" ");
|
||||
f.close();
|
||||
}
|
||||
|
||||
NymeaTestBase::initTestCase();
|
||||
}
|
||||
|
||||
void TestConfigurations::getConfigurations()
|
||||
{
|
||||
QVariant response = injectAndWait("Configuration.GetConfigurations");
|
||||
@ -250,18 +268,21 @@ void TestConfigurations::testLanguages()
|
||||
|
||||
QVariantList languageVariantList = responseMap.value("languages").toList();
|
||||
foreach (const QVariant &languageVariant, languageVariantList) {
|
||||
// create a new spy for each run as we restart the server and kill the old one in this loop
|
||||
QSignalSpy notificationSpy2 (m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
|
||||
|
||||
// Get current configurations
|
||||
basicConfigurationMap = loadBasicConfiguration();
|
||||
|
||||
// Set language
|
||||
params.clear(); response.clear(); notificationSpy.clear();
|
||||
params.clear(); response.clear();
|
||||
params.insert("language", languageVariant);
|
||||
QVariant response = injectAndWait("Configuration.SetLanguage", params);
|
||||
verifyConfigurationError(response);
|
||||
|
||||
// Check notification
|
||||
notificationSpy.wait(500);
|
||||
QVariantList languageChangedNotifications = checkNotifications(notificationSpy, "Configuration.LanguageChanged");
|
||||
notificationSpy2.wait(500);
|
||||
QVariantList languageChangedNotifications = checkNotifications(notificationSpy2, "Configuration.LanguageChanged");
|
||||
|
||||
// If the language did not change no notification should be emitted
|
||||
if (basicConfigurationMap.value("language").toString() == languageVariant.toString()) {
|
||||
@ -274,6 +295,8 @@ void TestConfigurations::testLanguages()
|
||||
|
||||
// Restart the server and check if the language will be loaded correctly
|
||||
restartServer();
|
||||
enableNotifications();
|
||||
|
||||
|
||||
// Get configuration
|
||||
basicConfigurationMap = loadBasicConfiguration();
|
||||
|
||||
Reference in New Issue
Block a user