diff --git a/tests/core/ApplicationInfoTest.cpp b/tests/core/ApplicationInfoTest.cpp index 117711734..903a8885f 100644 --- a/tests/core/ApplicationInfoTest.cpp +++ b/tests/core/ApplicationInfoTest.cpp @@ -1,178 +1,178 @@ /* GCompris - ApplicationInfoTest.cpp * * Copyright (C) 2018 Billy Laws * GCompris (C) 2018 GCompris Developers * * Authors: * Billy Laws * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ #include #include #include "src/core/ApplicationInfo.h" class ApplicationInfoTest : public QObject { public: Q_OBJECT private slots: void LocaleTest_data(); void LocaleTest(); void WindowTest_data(); void WindowTest(); void getVoicesLocaleTest_data(); void getVoicesLocaleTest(); void getAudioFilePathForLocaleTest_data(); void getAudioFilePathForLocaleTest(); }; void ApplicationInfoTest::LocaleTest_data() { QTest::addColumn("localeFull"); QTest::addColumn("localeShort"); QTest::addColumn("higherWord"); QTest::addColumn("lowerWord"); QTest::newRow("British English") << QStringLiteral("en_GB") << QStringLiteral("en") << QStringLiteral("apple") << QStringLiteral("banana"); } void ApplicationInfoTest::LocaleTest() { ApplicationInfo appInfo; ApplicationInfo::getInstance(); QFETCH(QString, localeFull); QFETCH(QString, localeShort); QFETCH(QString, higherWord); QFETCH(QString, lowerWord); QVERIFY(appInfo.localeShort(localeFull) == localeShort); QVERIFY(appInfo.localeCompare(higherWord, lowerWord, localeFull) == -1); QVERIFY(appInfo.localeCompare(lowerWord, higherWord, localeFull) == 1); QVERIFY(appInfo.localeCompare(higherWord, higherWord, localeFull) == 0); QVariantList sortList; sortList.append(QVariant(higherWord)); sortList.append(QVariant(lowerWord)); sortList.append(QVariant(higherWord)); sortList.append(QVariant(lowerWord)); sortList = appInfo.localeSort(sortList, localeFull); QVERIFY(sortList[0] == higherWord); QVERIFY(sortList[1] == higherWord); QVERIFY(sortList[2] == lowerWord); QVERIFY(sortList[3] == lowerWord); } void ApplicationInfoTest::WindowTest_data() { QTest::addColumn("useOpenGL"); QTest::addColumn("applicationWidth"); QTest::addColumn("portraitMode"); QTest::newRow("dummy1") << true << 1920 << true; } void ApplicationInfoTest::WindowTest() { ApplicationInfo appInfo; ApplicationInfo::getInstance(); QFETCH(bool, useOpenGL); QFETCH(int, applicationWidth); QFETCH(bool, portraitMode); appInfo.setApplicationWidth(applicationWidth); appInfo.setIsPortraitMode(portraitMode); appInfo.setUseOpenGL(useOpenGL); QVERIFY(appInfo.useOpenGL() == useOpenGL); QVERIFY(appInfo.applicationWidth() == applicationWidth); QVERIFY(appInfo.isPortraitMode() == portraitMode); } void ApplicationInfoTest::getVoicesLocaleTest_data() { QTest::addColumn("actual"); QTest::addColumn("expected"); QTest::newRow("default") << GC_DEFAULT_LOCALE - << "en"; + << "en_US"; QTest::newRow("en_US") << "en_US" << "en_US"; QTest::newRow("pt_BR") << "pt_BR" << "pt_BR"; QTest::newRow("pt_PT") << "pt_PT" << "pt"; QTest::newRow("fr_FR") << "fr_FR" << "fr"; } void ApplicationInfoTest::getVoicesLocaleTest() { // Set default locale to "C". ALlows to test GC_DEFAULT_LOCALE QLocale defaultLocale = QLocale::system(); QLocale::setDefault(QLocale::c()); ApplicationInfo appInfo; ApplicationInfo::getInstance(); QFETCH(QString, actual); QFETCH(QString, expected); QCOMPARE(appInfo.getVoicesLocale(actual), expected); QLocale::setDefault(defaultLocale); } void ApplicationInfoTest::getAudioFilePathForLocaleTest_data() { QTest::addColumn("file"); QTest::addColumn("locale"); QTest::addColumn("expected"); QTest::newRow("absolutePath_en") << "/$LOCALE/$CA" << "en" << QString("/en/%1").arg(COMPRESSED_AUDIO); QTest::newRow("absolutePath_pt_BR") << "qrc:/$LOCALE/test" << "pt_BR" << "qrc:/pt_BR/test"; QTest::newRow("absolute_fr") << ":/test/test2" << "unused" << ":/test/test2"; QTest::newRow("relative_fr") << "$LOCALE/$CA" << "fr" << QString("qrc:/gcompris/data/fr/%1").arg(COMPRESSED_AUDIO); } void ApplicationInfoTest::getAudioFilePathForLocaleTest() { ApplicationInfo appInfo; ApplicationInfo::getInstance(); QFETCH(QString, file); QFETCH(QString, locale); QFETCH(QString, expected); QCOMPARE(appInfo.getAudioFilePathForLocale(file, locale), expected); } QTEST_MAIN(ApplicationInfoTest) #include "ApplicationInfoTest.moc"