File indexing completed on 2025-05-04 04:59:01
0001 /* 0002 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "messagedisplayformatattributetest.h" 0008 #include "../src/viewer/messagedisplayformatattribute.h" 0009 #include <QTest> 0010 0011 MessageDisplayFormatAttributeTest::MessageDisplayFormatAttributeTest(QObject *parent) 0012 : QObject(parent) 0013 { 0014 } 0015 0016 MessageDisplayFormatAttributeTest::~MessageDisplayFormatAttributeTest() = default; 0017 0018 void MessageDisplayFormatAttributeTest::shouldHaveDefaultValue() 0019 { 0020 MessageViewer::MessageDisplayFormatAttribute attr; 0021 QVERIFY(!attr.remoteContent()); 0022 QCOMPARE(attr.messageFormat(), MessageViewer::Viewer::UseGlobalSetting); 0023 } 0024 0025 void MessageDisplayFormatAttributeTest::shouldChangeRemoteValue() 0026 { 0027 MessageViewer::MessageDisplayFormatAttribute attr; 0028 attr.setRemoteContent(true); 0029 QVERIFY(attr.remoteContent()); 0030 } 0031 0032 void MessageDisplayFormatAttributeTest::shouldChangeMessageFormat() 0033 { 0034 MessageViewer::Viewer::DisplayFormatMessage format = MessageViewer::Viewer::Html; 0035 MessageViewer::MessageDisplayFormatAttribute attr; 0036 attr.setMessageFormat(format); 0037 QCOMPARE(attr.messageFormat(), format); 0038 0039 format = MessageViewer::Viewer::Text; 0040 attr.setMessageFormat(format); 0041 QCOMPARE(attr.messageFormat(), format); 0042 0043 format = MessageViewer::Viewer::UseGlobalSetting; 0044 attr.setMessageFormat(format); 0045 QCOMPARE(attr.messageFormat(), format); 0046 } 0047 0048 void MessageDisplayFormatAttributeTest::shouldDeserializeValue() 0049 { 0050 MessageViewer::Viewer::DisplayFormatMessage format = MessageViewer::Viewer::Html; 0051 MessageViewer::MessageDisplayFormatAttribute attr; 0052 attr.setMessageFormat(format); 0053 attr.setRemoteContent(true); 0054 const QByteArray ba = attr.serialized(); 0055 MessageViewer::MessageDisplayFormatAttribute result; 0056 result.deserialize(ba); 0057 QVERIFY(attr == result); 0058 } 0059 0060 void MessageDisplayFormatAttributeTest::shouldCloneAttribute() 0061 { 0062 MessageViewer::Viewer::DisplayFormatMessage format = MessageViewer::Viewer::Html; 0063 MessageViewer::MessageDisplayFormatAttribute attr; 0064 attr.setMessageFormat(format); 0065 attr.setRemoteContent(true); 0066 MessageViewer::MessageDisplayFormatAttribute *result = attr.clone(); 0067 QVERIFY(attr == *result); 0068 delete result; 0069 } 0070 0071 void MessageDisplayFormatAttributeTest::shouldDefineType() 0072 { 0073 MessageViewer::MessageDisplayFormatAttribute attr; 0074 QCOMPARE(attr.type(), QByteArrayLiteral("MessageDisplayFormatAttribute")); 0075 } 0076 0077 QTEST_MAIN(MessageDisplayFormatAttributeTest) 0078 0079 #include "moc_messagedisplayformatattributetest.cpp"