1 /*
2 * Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "kis_datamanager_test.h"
20
21 #include <QTest>
22 #include "kis_datamanager.h"
23
testCreation()24 void KisDataManagerTest::testCreation()
25 {
26 quint8 c = 0;
27 KisDataManager test(1, &c);
28 }
29
30
testDefaultPixel()31 void KisDataManagerTest::testDefaultPixel()
32 {
33 {
34 quint8 c = 0;
35 KisDataManager dm(1, &c);
36 QVERIFY(dm.pixelSize() == 1);
37 QVERIFY(*dm.defaultPixel() == 0);
38 }
39 {
40 quint8 * p = new quint8[3];
41 memset(p, 0, 3);
42
43 // The default pixel is copied, we still own the pointer
44 KisDataManager dm(3, p);
45 QVERIFY(dm.pixelSize() == 3);
46
47 // A pointer, not a copy is returned. Changing it changes the
48 // default pixel in the data manager.
49 const quint8 * defaultPixelC = dm.defaultPixel();
50 QVERIFY(defaultPixelC[0] == 0);
51 QVERIFY(defaultPixelC[1] == 0);
52 QVERIFY(defaultPixelC[2] == 0);
53
54 // unconst it, so we can change it.
55 quint8 * defaultPixel = const_cast<quint8*>(defaultPixelC);
56 defaultPixel[0] = 50;
57 defaultPixel[1] = 150;
58 defaultPixel[2] = 200;
59
60 // Check that our original pixel isn't changed
61 QVERIFY(p[0] == 0);
62 QVERIFY(p[1] == 0);
63 QVERIFY(p[2] == 0);
64
65 // Reset the default pixel
66 dm.setDefaultPixel(p);
67 defaultPixelC = dm.defaultPixel();
68 QVERIFY(defaultPixelC[0] == 0);
69 QVERIFY(defaultPixelC[1] == 0);
70 QVERIFY(defaultPixelC[2] == 0);
71
72 delete[]p;
73
74 }
75 }
76
77 //void KisDataManagerTest::testMemento() {}
78 //
79 //void KisDataManagerTest::testReadWrite() {}
80 //
81 //void KisDataManagerTest::testExtent() {}
82 //
83 //void KisDataManagerTest::testClear() {}
84 //
85 //void KisDataManagerTest::testSetPixel() {}
86 //
87 //void KisDataManagerTest::testReadBytes() {}
88 //
89 //void KisDataManagerTest::testWriteBytes() {}
90 //
91 //void KisDataManagerTest::testPlanarBytes() {}
92 //
93 //void KisDataManagerTest::testContiguousColumns() {}
94 //
95 //void KisDataManagerTest::testRowStride() {}
96 //
97 //void KisDataManagerTest::testThreadedReadAccess() {}
98 //
99 //void KisDataManagerTest::testThreadedWriteAccess() {}
100 //
101 //void KisDataManagerTest::testThreadedReadWriteAccess() {}
102
103 QTEST_MAIN(KisDataManagerTest)
104