Krita Source Code Documentation
Loading...
Searching...
No Matches
documents_gridsconfig_test_script.TestDocument Class Reference

Public Member Functions

 __init__ (self)
 
 checkResult (self, name, value, ref)
 
 checkTestValues01 (self, doc)
 
 checkTestValues02 (self, doc)
 
 checkTestValues03 (self, doc)
 
 setTestValues01 (self, doc)
 
 setTestValues02 (self, doc)
 
 setTestValues03 (self, doc)
 

Public Attributes

 newDoc
 

Detailed Description

Definition at line 21 of file documents_gridsconfig_test_script.py.

Constructor & Destructor Documentation

◆ __init__()

documents_gridsconfig_test_script.TestDocument.__init__ ( self)

Definition at line 22 of file documents_gridsconfig_test_script.py.

22 def __init__(self):
23 self.newDoc = Krita.instance().createDocument(500, 500, "Test autosave", "RGBA", "U8", "", 300)
24
25 with tempfile.TemporaryDirectory() as tmpDirname:
26 tmpFileName = os.path.join(tmpDirname, 'testing_document.kra')
27
28 qDebug("-- Test 01 --")
29 self.setTestValues01(self.newDoc)
30 self.checkTestValues01(self.newDoc)
31 self.newDoc.saveAs(tmpFileName)
32 self.newDoc.close()
33 qDebug("-- Test 01 (loaded) --")
34 self.newDoc = Krita.instance().openDocument(tmpFileName)
35 self.checkTestValues01(self.newDoc)
36
37 qDebug("-- Test 02 --")
38 self.setTestValues02(self.newDoc)
39 self.checkTestValues02(self.newDoc)
40 self.newDoc.save()
41 self.newDoc.close()
42 qDebug("-- Test 02 (loaded) --")
43 self.newDoc = Krita.instance().openDocument(tmpFileName)
44 self.checkTestValues02(self.newDoc)
45
46 qDebug("-- Test 03 --")
47 self.setTestValues03(self.newDoc)
48 self.checkTestValues03(self.newDoc)
49 self.newDoc.save()
50 self.newDoc.close()
51 qDebug("-- Test 03 (loaded) --")
52 self.newDoc = Krita.instance().openDocument(tmpFileName)
53 self.checkTestValues03(self.newDoc)
54 self.newDoc.close()
55
static Krita * instance()
instance retrieve the singleton instance of the Application object.
Definition Krita.cpp:390
KisDocument * createDocument(QList< KisNodeSP > nodes, KisImageSP srcImage, const QRect &copiedBounds)

Member Function Documentation

◆ checkResult()

documents_gridsconfig_test_script.TestDocument.checkResult ( self,
name,
value,
ref )

Definition at line 215 of file documents_gridsconfig_test_script.py.

215 def checkResult(self, name, value, ref):
216 returned = None
217
218 if isinstance(value, float) and isinstance(ref, float):
219 returned = qFuzzyCompare(value, ref)
220 elif isinstance(value, list) and isinstance(ref, list) and len(value) == len(ref):
221 returned = True
222 for index in range(len(value)):
223 if not qFuzzyCompare(value[index], ref[index]):
224 returned = False
225 break
226
227 if returned or value == ref:
228 returned = True
229 isOk = "OK"
230 qDebug(f"Check {name}: '{value}' == '{ref}' --> {isOk}")
231 else:
232 returned = False
233 isOk = "INVALID"
234 qWarning(f"Check {name}: '{value}' == '{ref}' --> {isOk}")
235
236 return returned
237
238

◆ checkTestValues01()

documents_gridsconfig_test_script.TestDocument.checkTestValues01 ( self,
doc )

Definition at line 83 of file documents_gridsconfig_test_script.py.

83 def checkTestValues01(self, doc):
84 grid = doc.gridConfig()
85 self.checkResult('grid type', grid.type(), "rectangular")
86 self.checkResult('grid visible', grid.visible(), True)
87 self.checkResult('grid snap', grid.snap(), True)
88 self.checkResult('grid offset', grid.offset(), QPoint(5, 10))
89 self.checkResult('grid spacing', grid.spacing(), QPoint(15, 20))
90 self.checkResult('grid spacing active H', grid.spacingActiveHorizontal(), True)
91 self.checkResult('grid spacing active V', grid.spacingActiveVertical(), True)
92 self.checkResult('grid subdivision', grid.subdivision(), 2)
93 self.checkResult('grid angle left', grid.angleLeft(), 0)
94 self.checkResult('grid angle right', grid.angleRight(), 0)
95 self.checkResult('grid angle left active', grid.angleLeftActive(), True)
96 self.checkResult('grid angle right active', grid.angleRightActive(), True)
97 self.checkResult('grid cell spacing', grid.cellSpacing(), 10)
98 self.checkResult('grid cell size', grid.cellSize(), 10)
99 self.checkResult('grid offset aspect locked', grid.offsetAspectLocked(), False)
100 self.checkResult('grid spacing aspect locked', grid.spacingAspectLocked(), False)
101 self.checkResult('grid angle aspect locked', grid.angleAspectLocked(), False)
102 self.checkResult('grid line type main', grid.lineTypeMain(), "solid")
103 self.checkResult('grid line type subdivision', grid.lineTypeSubdivision(), "dashed")
104 self.checkResult('grid line type verical', grid.lineTypeVertical(), "dotted")
105 self.checkResult('grid color main', grid.colorMain().name(), "#ff0000")
106 self.checkResult('grid color subdivision', grid.colorSubdivision().name(), "#00ff00")
107 self.checkResult('grid color vertical', grid.colorVertical().name(), "#0000ff")
108

References documents_gridsconfig_test_script.TestDocument.checkResult(), and documents_guidesconfig_test_script.TestDocument.checkResult().

◆ checkTestValues02()

documents_gridsconfig_test_script.TestDocument.checkTestValues02 ( self,
doc )

Definition at line 136 of file documents_gridsconfig_test_script.py.

136 def checkTestValues02(self, doc):
137 grid = doc.gridConfig()
138 self.checkResult('grid type', grid.type(), "isometric_legacy")
139 self.checkResult('grid visible', grid.visible(), False)
140 self.checkResult('grid snap', grid.snap(), False)
141 self.checkResult('grid offset', grid.offset(), QPoint(10, 5))
142 self.checkResult('grid spacing', grid.spacing(), QPoint(20, 15))
143 self.checkResult('grid spacing active H', grid.spacingActiveHorizontal(), False)
144 self.checkResult('grid spacing active V', grid.spacingActiveVertical(), False)
145 self.checkResult('grid subdivision', grid.subdivision(), 3)
146 self.checkResult('grid angle left', grid.angleLeft(), 15)
147 self.checkResult('grid angle right', grid.angleRight(), 30)
148 self.checkResult('grid angle left active', grid.angleLeftActive(), False)
149 self.checkResult('grid angle right active', grid.angleRightActive(), False)
150 self.checkResult('grid cell spacing', grid.cellSpacing(), 10)
151 self.checkResult('grid cell size', grid.cellSize(), 15)
152 self.checkResult('grid offset aspect locked', grid.offsetAspectLocked(), True)
153 self.checkResult('grid spacing aspect locked', grid.spacingAspectLocked(), True)
154 self.checkResult('grid angle aspect locked', grid.angleAspectLocked(), True)
155 self.checkResult('grid line type main', grid.lineTypeMain(), "dashed")
156 self.checkResult('grid line type subdivision', grid.lineTypeSubdivision(), "dotted")
157 self.checkResult('grid line type verical', grid.lineTypeVertical(), "none")
158 self.checkResult('grid color main', grid.colorMain().name(), "#00ff00")
159 self.checkResult('grid color subdivision', grid.colorSubdivision().name(), "#0000ff")
160 self.checkResult('grid color vertical', grid.colorVertical().name(), "#ff0000")
161

References documents_gridsconfig_test_script.TestDocument.checkResult(), and documents_guidesconfig_test_script.TestDocument.checkResult().

◆ checkTestValues03()

documents_gridsconfig_test_script.TestDocument.checkTestValues03 ( self,
doc )

Definition at line 189 of file documents_gridsconfig_test_script.py.

189 def checkTestValues03(self, doc):
190 grid = doc.gridConfig()
191 self.checkResult('grid type', grid.type(), "isometric")
192 self.checkResult('grid visible', grid.visible(), False)
193 self.checkResult('grid snap', grid.snap(), False)
194 self.checkResult('grid offset', grid.offset(), QPoint())
195 self.checkResult('grid spacing', grid.spacing(), QPoint(1, 1))
196 self.checkResult('grid spacing active H', grid.spacingActiveHorizontal(), False)
197 self.checkResult('grid spacing active V', grid.spacingActiveVertical(), False)
198 self.checkResult('grid subdivision', grid.subdivision(), 1)
199 self.checkResult('grid angle left', grid.angleLeft(), 0.0)
200 self.checkResult('grid angle right', grid.angleRight(), 0.0)
201 self.checkResult('grid angle left active', grid.angleLeftActive(), False)
202 self.checkResult('grid angle right active', grid.angleRightActive(), False)
203 self.checkResult('grid cell spacing', grid.cellSpacing(), 10)
204 self.checkResult('grid cell size', grid.cellSize(), 10)
205 self.checkResult('grid offset aspect locked', grid.offsetAspectLocked(), True)
206 self.checkResult('grid spacing aspect locked', grid.spacingAspectLocked(), True)
207 self.checkResult('grid angle aspect locked', grid.angleAspectLocked(), True)
208 self.checkResult('grid line type main', grid.lineTypeMain(), "solid")
209 self.checkResult('grid line type subdivision', grid.lineTypeSubdivision(), "solid")
210 self.checkResult('grid line type verical', grid.lineTypeVertical(), "none")
211 self.checkResult('grid color main', grid.colorMain().name(), "#00ff00")
212 self.checkResult('grid color subdivision', grid.colorSubdivision().name(), "#0000ff")
213 self.checkResult('grid color vertical', grid.colorVertical().name(), "#ff0000")
214

References documents_gridsconfig_test_script.TestDocument.checkResult(), and documents_guidesconfig_test_script.TestDocument.checkResult().

◆ setTestValues01()

documents_gridsconfig_test_script.TestDocument.setTestValues01 ( self,
doc )

Definition at line 56 of file documents_gridsconfig_test_script.py.

56 def setTestValues01(self, doc):
57 grid = GridConfig()
58 grid.setType("rectangular")
59 grid.setVisible(True)
60 grid.setSnap(True)
61 grid.setOffset(QPoint(5, 10))
62 grid.setSpacing(QPoint(15, 20))
63 grid.setSpacingActiveHorizontal(True)
64 grid.setSpacingActiveVertical(True)
65 grid.setSubdivision(2)
66 grid.setAngleLeft(0)
67 grid.setAngleRight(0)
68 grid.setAngleLeftActive(True)
69 grid.setAngleRightActive(True)
70 grid.setCellSpacing(10)
71 grid.setCellSize(10)
72 grid.setOffsetAspectLocked(False)
73 grid.setSpacingAspectLocked(False)
74 grid.setAngleAspectLocked(False)
75 grid.setLineTypeMain("solid")
76 grid.setLineTypeSubdivision("dashed")
77 grid.setLineTypeVertical("dotted")
78 grid.setColorMain(QColor("#ff0000"))
79 grid.setColorSubdivision(QColor("#00ff00"))
80 grid.setColorVertical(QColor("#0000ff"))
81 doc.setGridConfig(grid)
82

◆ setTestValues02()

documents_gridsconfig_test_script.TestDocument.setTestValues02 ( self,
doc )

Definition at line 109 of file documents_gridsconfig_test_script.py.

109 def setTestValues02(self, doc):
110 grid = GridConfig()
111 grid.setType("isometric_legacy")
112 grid.setVisible(False)
113 grid.setSnap(False)
114 grid.setOffset(QPoint(10, 5))
115 grid.setSpacing(QPoint(20, 15))
116 grid.setSpacingActiveHorizontal(False)
117 grid.setSpacingActiveVertical(False)
118 grid.setSubdivision(3)
119 grid.setAngleLeft(15)
120 grid.setAngleRight(30)
121 grid.setAngleLeftActive(False)
122 grid.setAngleRightActive(False)
123 grid.setCellSpacing(10)
124 grid.setCellSize(15)
125 grid.setOffsetAspectLocked(True)
126 grid.setSpacingAspectLocked(True)
127 grid.setAngleAspectLocked(True)
128 grid.setLineTypeMain("dashed")
129 grid.setLineTypeSubdivision("dotted")
130 grid.setLineTypeVertical("none")
131 grid.setColorMain(QColor("#00ff00"))
132 grid.setColorSubdivision(QColor("#0000ff"))
133 grid.setColorVertical(QColor("#ff0000"))
134 doc.setGridConfig(grid)
135

◆ setTestValues03()

documents_gridsconfig_test_script.TestDocument.setTestValues03 ( self,
doc )

Definition at line 162 of file documents_gridsconfig_test_script.py.

162 def setTestValues03(self, doc):
163 grid = GridConfig()
164 grid.setType("isometric")
165 grid.setVisible(False)
166 grid.setSnap(False)
167 grid.setOffset(QPoint(-10, -10))
168 grid.setSpacing(QPoint(-20, -20))
169 grid.setSpacingActiveHorizontal(False)
170 grid.setSpacingActiveVertical(False)
171 grid.setSubdivision(-3)
172 grid.setAngleLeft(-15)
173 grid.setAngleRight(-30)
174 grid.setAngleLeftActive(False)
175 grid.setAngleRightActive(False)
176 grid.setCellSpacing(-10)
177 grid.setCellSize(-15)
178 grid.setOffsetAspectLocked(True)
179 grid.setSpacingAspectLocked(True)
180 grid.setAngleAspectLocked(True)
181 grid.setLineTypeMain("none")
182 grid.setLineTypeSubdivision("none")
183 grid.setLineTypeVertical("none")
184 grid.setColorMain(QColor("#00ff00"))
185 grid.setColorSubdivision(QColor("#0000ff"))
186 grid.setColorVertical(QColor("#ff0000"))
187 doc.setGridConfig(grid)
188

Member Data Documentation

◆ newDoc

documents_gridsconfig_test_script.TestDocument.newDoc

Definition at line 23 of file documents_gridsconfig_test_script.py.


The documentation for this class was generated from the following file: