Warning, file /graphics/krita/plugins/impex/psd/tests/psd_header_test.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2009 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "psd_header_test.h" 0008 0009 #include <simpletest.h> 0010 #include <QCoreApplication> 0011 #include <klocalizedstring.h> 0012 #include <psd_header.h> 0013 #ifndef FILES_DATA_DIR 0014 #error "FILES_DATA_DIR not set. A directory with the data used for testing the importing of files in krita" 0015 #endif 0016 0017 void PSDHeaderTest::testCreation() 0018 { 0019 PSDHeader header; 0020 Q_ASSERT(!header.valid()); 0021 } 0022 0023 void PSDHeaderTest::testLoading() 0024 { 0025 QString filename = QString(FILES_DATA_DIR) + "/sources/2.psd"; 0026 QFile f(filename); 0027 f.open(QIODevice::ReadOnly); 0028 PSDHeader header; 0029 header.read(f); 0030 0031 QVERIFY(header.signature == QString("8BPS")); 0032 QVERIFY(header.version == 1); 0033 QVERIFY(header.nChannels == 3); 0034 QVERIFY(header.width == 100 ); 0035 QVERIFY(header.height == 100); 0036 QVERIFY(header.channelDepth == 8); 0037 QVERIFY(header.colormode == RGB); 0038 0039 } 0040 0041 void PSDHeaderTest::testRoundTripping() 0042 { 0043 QString filename = "test.psd"; 0044 QFile f(filename); 0045 f.open(QIODevice::ReadWrite); 0046 PSDHeader header; 0047 Q_ASSERT(!header.valid()); 0048 header.signature = "8BPS"; 0049 header.version = 1; 0050 header.nChannels = 3; 0051 header.width = 1000; 0052 header.height = 1000; 0053 header.channelDepth = 8; 0054 header.colormode = RGB; 0055 Q_ASSERT(header.valid()); 0056 bool retval = header.write(f); 0057 Q_ASSERT(retval); Q_UNUSED(retval); 0058 0059 f.close(); 0060 f.open(QIODevice::ReadOnly); 0061 PSDHeader header2; 0062 retval = header2.read(f); 0063 Q_ASSERT(retval); 0064 0065 QCOMPARE(header.signature, header2.signature); 0066 QVERIFY(header.version == header2.version); 0067 QVERIFY(header.nChannels == header2.nChannels); 0068 QVERIFY(header.width == header2.width); 0069 QVERIFY(header.height == header2.height); 0070 QVERIFY(header.channelDepth == header2.channelDepth); 0071 QVERIFY(header.colormode == header2.colormode); 0072 } 0073 0074 0075 0076 SIMPLE_TEST_MAIN(PSDHeaderTest) 0077