Commit 82401803 authored by Rafael Roquetto's avatar Rafael Roquetto

Implement BlackBerryConfigurationManager test

Change-Id: If7dba1fe1dae3a25aa2e991c85ed724101241a22
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
parent 3d78ae33
......@@ -74,6 +74,10 @@ const QLatin1String NDKVersionKey("NDKVersion");
const QLatin1String NDKAutoDetectionSourceKey("NDKAutoDetectionSource");
const QLatin1String NDKAutoDetectedKey("NDKAutoDetectedKey");
#ifdef WITH_TESTS
bool BlackBerryConfiguration::m_fakeConfig = false;
#endif
BlackBerryConfiguration::BlackBerryConfiguration(const NdkInstallInformation &ndkInstallInfo)
{
QString envFilePath = QnxUtils::envFilePath(ndkInstallInfo.path, ndkInstallInfo.version);
......@@ -215,6 +219,11 @@ bool BlackBerryConfiguration::isActive() const
bool BlackBerryConfiguration::isValid() const
{
#ifdef WITH_TESTS
if (BlackBerryConfiguration::fakeConfig())
return true;
#endif
return ((!m_qmake4BinaryFile.isEmpty() || !m_qmake5BinaryFile.isEmpty()) && !m_gccCompiler.isEmpty()
&& !m_deviceDebugger.isEmpty() && !m_simulatorDebugger.isEmpty()
&& m_ndkEnvFile.toFileInfo().exists() && (m_autoDetectionSource.isEmpty() ||
......@@ -449,5 +458,17 @@ void BlackBerryConfiguration::deactivate()
}
}
#ifdef WITH_TESTS
void BlackBerryConfiguration::setFakeConfig(bool fakeConfig)
{
m_fakeConfig = fakeConfig;
}
bool BlackBerryConfiguration::fakeConfig()
{
return m_fakeConfig;
}
#endif
} // namespace Internal
} // namespace Qnx
......@@ -86,6 +86,11 @@ public:
QList<Utils::EnvironmentItem> qnxEnv() const;
QVariantMap toMap() const;
#ifdef WITH_TESTS
static void setFakeConfig(bool fakeConfig);
static bool fakeConfig();
#endif
private:
QString m_displayName;
QString m_targetName;
......@@ -112,6 +117,10 @@ private:
ProjectExplorer::Kit* createKit(
QnxAbstractQtVersion* version, QnxToolChain* toolChain,
const QVariant &debuggerItemId);
#ifdef WITH_TESTS
static bool m_fakeConfig;
#endif
};
} // namespace Internal
......
......@@ -52,6 +52,7 @@
#include "blackberrycheckdebugtokenstepfactory.h"
#include "blackberrydeviceconnectionmanager.h"
#include "blackberryconfigurationmanager.h"
#include "blackberryconfiguration.h"
#include "cascadesimport/cascadesimportwizard.h"
#include "qnxtoolchain.h"
......@@ -392,6 +393,87 @@ void QNXPlugin::testBarDescriptorDocumentSetBannerComment()
QCOMPARE(doc.bannerComment(), comment);
}
void QNXPlugin::testConfigurationManager_data()
{
const QLatin1String NDKEnvFileKey("NDKEnvFile");
const QLatin1String NDKPathKey("NDKPath");
const QLatin1String NDKDisplayNameKey("NDKDisplayName");
const QLatin1String NDKTargetKey("NDKTarget");
const QLatin1String NDKHostKey("NDKHost");
const QLatin1String NDKVersionKey("NDKVersion");
const QLatin1String NDKAutoDetectionSourceKey("NDKAutoDetectionSource");
const QLatin1String NDKAutoDetectedKey("NDKAutoDetectedKey");
QTest::addColumn<QVariantMap>("newerConfiguration");
QTest::addColumn<QVariantMap>("olderConfiguration");
QVariantMap newerConfiguration;
newerConfiguration.insert(NDKEnvFileKey, QLatin1String("bbndk-env.sh"));
newerConfiguration.insert(NDKPathKey, QLatin1String("NDKPath"));
newerConfiguration.insert(NDKDisplayNameKey, QLatin1String("NDKDisplayName"));
newerConfiguration.insert(NDKTargetKey, QLatin1String("NDKTarget"));
newerConfiguration.insert(NDKHostKey, QLatin1String("NDKHost"));
newerConfiguration.insert(NDKVersionKey, QLatin1String("10.1.0.1008"));
newerConfiguration.insert(NDKAutoDetectionSourceKey, QLatin1String("NDKAutoDetectionSource"));
newerConfiguration.insert(NDKAutoDetectedKey, QLatin1String("NDKAutoDetectedKey"));
QVariantMap olderConfiguration;
olderConfiguration.insert(NDKEnvFileKey, QLatin1String("bbndk-env2.sh"));
olderConfiguration.insert(NDKPathKey, QLatin1String("NDKPath"));
olderConfiguration.insert(NDKDisplayNameKey, QLatin1String("NDKDisplayName"));
olderConfiguration.insert(NDKTargetKey, QLatin1String("NDKTarget"));
olderConfiguration.insert(NDKHostKey, QLatin1String("NDKHost"));
newerConfiguration.insert(NDKVersionKey, QLatin1String("10.2.0.1008"));
olderConfiguration.insert(NDKAutoDetectionSourceKey, QLatin1String("NDKAutoDetectionSource"));
olderConfiguration.insert(NDKAutoDetectedKey, QLatin1String("NDKAutoDetectedKey"));
QTest::newRow("configurations") << newerConfiguration << olderConfiguration;;
}
void QNXPlugin::testConfigurationManager()
{
BlackBerryConfigurationManager &manager = BlackBerryConfigurationManager::instance();
QCOMPARE(manager.configurations().count(), 0);
QCOMPARE(manager.activeConfigurations().count(), 0);
QCOMPARE(manager.defaultConfiguration(), static_cast<BlackBerryConfiguration*>(0));
QVERIFY(manager.newestConfigurationEnabled());
QFETCH(QVariantMap, newerConfiguration);
QFETCH(QVariantMap, olderConfiguration);
BlackBerryConfiguration::setFakeConfig(true);
BlackBerryConfiguration *newerConfig = new BlackBerryConfiguration(newerConfiguration);
BlackBerryConfiguration *oldConfig = new BlackBerryConfiguration(olderConfiguration);
QVERIFY(manager.addConfiguration(oldConfig));
QVERIFY(manager.newestConfigurationEnabled());
QCOMPARE(manager.defaultConfiguration(), oldConfig);
manager.setDefaultConfiguration(oldConfig);
QCOMPARE(manager.defaultConfiguration(), oldConfig);
QCOMPARE(manager.configurations().first(), oldConfig);
QVERIFY(!manager.newestConfigurationEnabled());
QVERIFY(manager.addConfiguration(newerConfig));
QCOMPARE(manager.configurations().first(), newerConfig);
QCOMPARE(manager.defaultConfiguration(), oldConfig);
manager.setDefaultConfiguration(0);
QVERIFY(manager.newestConfigurationEnabled());
QCOMPARE(manager.defaultConfiguration(), newerConfig);
manager.setDefaultConfiguration(oldConfig);
manager.removeConfiguration(oldConfig);
QCOMPARE(manager.defaultConfiguration(), newerConfig);
QVERIFY(manager.newestConfigurationEnabled());
manager.removeConfiguration(newerConfig);
QCOMPARE(manager.defaultConfiguration(), static_cast<BlackBerryConfiguration*>(0));
QVERIFY(manager.newestConfigurationEnabled());
}
#endif
Q_EXPORT_PLUGIN2(QNX, QNXPlugin)
......@@ -57,6 +57,9 @@ private slots:
void testBarDescriptorDocumentSetBannerComment_data();
void testBarDescriptorDocumentSetBannerComment();
void testConfigurationManager_data();
void testConfigurationManager();
#endif
};
......
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