File indexing completed on 2025-01-26 04:07:27
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #include "TestKoColorSpaceSanity.h" 0008 0009 #include <simpletest.h> 0010 #include <KoColorSpaceRegistry.h> 0011 #include <KoChannelInfo.h> 0012 0013 #include <testpigment.h> 0014 0015 void TestKoColorSpaceSanity::testChannelsInfo() 0016 { 0017 Q_FOREACH (const KoColorSpace* colorSpace, KoColorSpaceRegistry::instance()->allColorSpaces(KoColorSpaceRegistry::AllColorSpaces, KoColorSpaceRegistry::OnlyDefaultProfile)) 0018 { 0019 0020 QCOMPARE(colorSpace->channelCount(), quint32(colorSpace->channels().size())); 0021 QList<int> displayPositions; 0022 quint32 colorChannels = 0; 0023 quint32 size = 0; 0024 Q_FOREACH (KoChannelInfo* info, colorSpace->channels()) 0025 { 0026 if(info->channelType() == KoChannelInfo::COLOR ) { 0027 ++colorChannels; 0028 } 0029 // Check poses 0030 qint32 pos = info->pos(); 0031 QVERIFY(pos + info->size() <= (qint32)colorSpace->pixelSize()); 0032 Q_FOREACH (KoChannelInfo* info2, colorSpace->channels()) 0033 { 0034 if( info != info2 ) 0035 { 0036 QVERIFY( pos >= (info2->pos() + info2->size()) || pos + info->size() <= info2->pos()); 0037 } 0038 } 0039 0040 // Check displayPosition 0041 quint32 displayPosition = info->displayPosition(); 0042 QVERIFY(displayPosition < colorSpace->channelCount()); 0043 QVERIFY(displayPositions.indexOf(displayPosition) == -1); 0044 displayPositions.push_back(displayPosition); 0045 0046 size += info->size(); 0047 } 0048 QCOMPARE(size, colorSpace->pixelSize()); 0049 QCOMPARE(colorSpace->colorChannelCount(), colorChannels); 0050 } 0051 } 0052 0053 KISTEST_MAIN(TestKoColorSpaceSanity)