File indexing completed on 2024-12-22 04:10:15
0001 /* 0002 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt boud @valdyas.org 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kis_datamanager_test.h" 0008 0009 #include <simpletest.h> 0010 #include "kis_datamanager.h" 0011 0012 void KisDataManagerTest::testCreation() 0013 { 0014 quint8 c = 0; 0015 KisDataManager test(1, &c); 0016 } 0017 0018 0019 void KisDataManagerTest::testDefaultPixel() 0020 { 0021 { 0022 quint8 c = 0; 0023 KisDataManager dm(1, &c); 0024 QVERIFY(dm.pixelSize() == 1); 0025 QVERIFY(*dm.defaultPixel() == 0); 0026 } 0027 { 0028 quint8 * p = new quint8[3]; 0029 memset(p, 0, 3); 0030 0031 // The default pixel is copied, we still own the pointer 0032 KisDataManager dm(3, p); 0033 QVERIFY(dm.pixelSize() == 3); 0034 0035 // A pointer, not a copy is returned. Changing it changes the 0036 // default pixel in the data manager. 0037 const quint8 * defaultPixelC = dm.defaultPixel(); 0038 QVERIFY(defaultPixelC[0] == 0); 0039 QVERIFY(defaultPixelC[1] == 0); 0040 QVERIFY(defaultPixelC[2] == 0); 0041 0042 // unconst it, so we can change it. 0043 quint8 * defaultPixel = const_cast<quint8*>(defaultPixelC); 0044 defaultPixel[0] = 50; 0045 defaultPixel[1] = 150; 0046 defaultPixel[2] = 200; 0047 0048 // Check that our original pixel isn't changed 0049 QVERIFY(p[0] == 0); 0050 QVERIFY(p[1] == 0); 0051 QVERIFY(p[2] == 0); 0052 0053 // Reset the default pixel 0054 dm.setDefaultPixel(p); 0055 defaultPixelC = dm.defaultPixel(); 0056 QVERIFY(defaultPixelC[0] == 0); 0057 QVERIFY(defaultPixelC[1] == 0); 0058 QVERIFY(defaultPixelC[2] == 0); 0059 0060 delete[]p; 0061 0062 } 0063 } 0064 0065 //void KisDataManagerTest::testMemento() {} 0066 // 0067 //void KisDataManagerTest::testReadWrite() {} 0068 // 0069 //void KisDataManagerTest::testExtent() {} 0070 // 0071 //void KisDataManagerTest::testClear() {} 0072 // 0073 //void KisDataManagerTest::testSetPixel() {} 0074 // 0075 //void KisDataManagerTest::testReadBytes() {} 0076 // 0077 //void KisDataManagerTest::testWriteBytes() {} 0078 // 0079 //void KisDataManagerTest::testPlanarBytes() {} 0080 // 0081 //void KisDataManagerTest::testContiguousColumns() {} 0082 // 0083 //void KisDataManagerTest::testRowStride() {} 0084 // 0085 //void KisDataManagerTest::testThreadedReadAccess() {} 0086 // 0087 //void KisDataManagerTest::testThreadedWriteAccess() {} 0088 // 0089 //void KisDataManagerTest::testThreadedReadWriteAccess() {} 0090 0091 SIMPLE_TEST_MAIN(KisDataManagerTest)