~zsombi/ubuntu-ui-toolkit/05-palettechanges

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_subtheming/tst_subtheming.cpp

  • Committer: Zsombor Egri
  • Date: 2015-03-16 12:03:54 UTC
  • Revision ID: zsombor.egri@canonical.com-20150316120354-79zmgfryecqieya9
API complete

Show diffs side-by-side

added added

removed removed

Lines of Context:
597
597
        QColor paletteColor = theme->getPaletteColor("normal", "background");
598
598
        QCOMPARE(paletteColor, expected);
599
599
    }
600
 
 
601
 
    void test_switch_values_palettechanges_data()
602
 
    {
603
 
        QTest::addColumn<QString>("test");
604
 
        QTest::addColumn<QString>("properties");
605
 
 
606
 
        QTest::newRow("Switch background") << "SwitchOnePaletteValue.qml" << "background";
607
 
        QTest::newRow("Switch background, overlay")  << "SwitchFewPaletteValues.qml" << "background,overlay";
608
 
        QTest::newRow("Switch all")  << "SwitchFewPaletteValues.qml" << "*";
609
 
        // error detection
610
 
    }
611
 
    void test_switch_values_palettechanges()
612
 
    {
613
 
        QFETCH(QString, test);
614
 
        QFETCH(QString, properties);
615
 
        QStringList propertyList = properties.split(',', QString::SkipEmptyParts);
616
 
 
617
 
        qputenv("UBUNTU_UI_TOOLKIT_THEMES_PATH", "");
618
 
        qputenv("XDG_DATA_DIRS", "./themes");
619
 
 
620
 
        QScopedPointer<ThemeTestCase> view(new ThemeTestCase(test));
621
 
        UCTheme *theme = view->findItem<UCTheme*>("testSet");
622
 
        UCTheme *mainTheme = UCStyledItemBasePrivate::get(qobject_cast<UCStyledItemBase*>(view->rootObject()))->getTheme();
623
 
        if (properties == "*") {
624
 
            // test all properties
625
 
            propertyList.clear();
626
 
            const QMetaObject *mo = theme->palette()->property("normal").value<QObject*>()->metaObject();
627
 
            for (int i = mo->propertyOffset(); i < mo->propertyCount(); i++) {
628
 
                propertyList << mo->property(i).name();
629
 
            }
630
 
        }
631
 
 
632
 
        // compare mainTheme.normal with mainTheme.selected values
633
 
        Q_FOREACH(const QString &property, propertyList) {
634
 
            QColor mainColor = mainTheme->getPaletteColor("normal", property.toLocal8Bit());
635
 
            QColor testColor = theme->getPaletteColor("selected", property.toLocal8Bit());
636
 
            QVERIFY2(mainColor == testColor, (QString("%1 color value differs").arg(property)).toLocal8Bit());
637
 
        }
638
 
    }
639
 
 
640
600
};
641
601
 
642
602
QTEST_MAIN(tst_Subtheming)