File indexing completed on 2025-01-05 04:59:55
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 0007 #include <testlib/qtest_zanshin.h> 0008 0009 #include "domain/context.h" 0010 0011 using namespace Domain; 0012 0013 class ContextTest : public QObject 0014 { 0015 Q_OBJECT 0016 private slots: 0017 void shouldHaveEmptyPropertiesByDefault() 0018 { 0019 Context c; 0020 QCOMPARE(c.name(), QString()); 0021 } 0022 0023 void shouldNotifyNameChanges() 0024 { 0025 Context c; 0026 QSignalSpy spy(&c, &Context::nameChanged); 0027 c.setName(QStringLiteral("foo")); 0028 QCOMPARE(spy.count(), 1); 0029 QCOMPARE(spy.first().first().toString(), QStringLiteral("foo")); 0030 } 0031 0032 void shouldNotNotifyIdenticalNameChanges() 0033 { 0034 Context c; 0035 c.setName(QStringLiteral("foo")); 0036 QSignalSpy spy(&c, &Context::nameChanged); 0037 c.setName(QStringLiteral("foo")); 0038 QCOMPARE(spy.count(), 0); 0039 } 0040 }; 0041 0042 ZANSHIN_TEST_MAIN(ContextTest) 0043 0044 #include "contexttest.moc"