Cleaned out the tests folder. Added simple test gerber. Added simple unit test using the GUI.
This commit is contained in:
parent
45c7f8efab
commit
95f51b2870
|
@ -89,7 +89,7 @@ class App(QtCore.QObject):
|
|||
new_object_available = QtCore.pyqtSignal(object)
|
||||
message = QtCore.pyqtSignal(str, str, str)
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, post_gui=None):
|
||||
"""
|
||||
Starts the application. Takes no parameters.
|
||||
|
||||
|
@ -512,6 +512,11 @@ class App(QtCore.QObject):
|
|||
print "ERROR: ", ext
|
||||
sys.exit(2)
|
||||
|
||||
# Post-GUI initialization: Experimental attempt
|
||||
# to perform unit tests on the GUI.
|
||||
if post_gui is not None:
|
||||
post_gui(self)
|
||||
|
||||
App.log.debug("END of constructor. Releasing control.")
|
||||
|
||||
def defaults_read_form(self):
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
G04 MADE WITH FRITZING*
|
||||
G04 WWW.FRITZING.ORG*
|
||||
G04 DOUBLE SIDED*
|
||||
G04 HOLES PLATED*
|
||||
G04 CONTOUR ON CENTER OF CONTOUR VECTOR*
|
||||
%ASAXBY*%
|
||||
%FSLAX23Y23*%
|
||||
%MOIN*%
|
||||
%OFA0B0*%
|
||||
%SFA1.0B1.0*%
|
||||
%ADD10R,0.047244X0.078740*%
|
||||
%ADD11C,0.024000*%
|
||||
%LNCOPPER1*%
|
||||
G90*
|
||||
G70*
|
||||
G54D10*
|
||||
X2940Y1051D03*
|
||||
X2940Y941D03*
|
||||
G54D11*
|
||||
X2438Y839D02*
|
||||
X2440Y1023D01*
|
||||
D02*
|
||||
X2940Y907D02*
|
||||
X2941Y839D01*
|
||||
D02*
|
||||
X2941Y839D02*
|
||||
X2438Y839D01*
|
||||
D02*
|
||||
X2941Y1239D02*
|
||||
X2940Y1085D01*
|
||||
D02*
|
||||
X2438Y1239D02*
|
||||
X2941Y1239D01*
|
||||
D02*
|
||||
X2440Y1126D02*
|
||||
X2438Y1239D01*
|
||||
G36*
|
||||
X2418Y1064D02*
|
||||
X2461Y1064D01*
|
||||
X2461Y1017D01*
|
||||
X2418Y1017D01*
|
||||
X2418Y1064D01*
|
||||
G37*
|
||||
D02*
|
||||
G36*
|
||||
X2418Y1131D02*
|
||||
X2461Y1131D01*
|
||||
X2461Y1084D01*
|
||||
X2418Y1084D01*
|
||||
X2418Y1131D01*
|
||||
G37*
|
||||
D02*
|
||||
G04 End of Copper1*
|
||||
M02*
|
|
@ -3,6 +3,7 @@ from shapely.ops import cascaded_union, unary_union
|
|||
from matplotlib.pyplot import plot, subplot, show
|
||||
from camlib import *
|
||||
|
||||
|
||||
def plotg2(geo, solid_poly=False, color="black", linestyle='solid'):
|
||||
|
||||
try:
|
|
@ -1,6 +1,5 @@
|
|||
from rtree import index as rtindex
|
||||
|
||||
|
||||
def pt2rect(pt):
|
||||
return pt[0], pt[1], pt[0], pt[1]
|
||||
|
|
@ -1,30 +1,20 @@
|
|||
import unittest
|
||||
import camlib
|
||||
from shapely.geometry import Polygon, LineString, Point, LinearRing
|
||||
from shapely.geometry import MultiPoint, MultiPolygon
|
||||
from shapely.geometry import box as shply_box
|
||||
from shapely.ops import cascaded_union
|
||||
import shapely.affinity as affinity
|
||||
from shapely.wkt import loads as sloads
|
||||
from shapely.wkt import dumps as sdumps
|
||||
from shapely.geometry.base import BaseGeometry
|
||||
|
||||
class GerberBuffer(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.gerber1 = camlib.Gerber()
|
||||
self.gerber1.use_buffer_for_union = True
|
||||
self.gerber1.parse_file ("./gerber_files/STM32F4-spindle.cmp")
|
||||
self.gerber1.parse_file("./gerber_files/STM32F4-spindle.cmp")
|
||||
geometry1 = self.gerber1.solid_geometry
|
||||
self.geometry1_area = self.compute_area (geometry1)
|
||||
self.geometry1_area = self.compute_area(geometry1)
|
||||
self.gerber2 = camlib.Gerber()
|
||||
self.gerber2.use_buffer_for_union = False
|
||||
self.gerber2.parse_file ("./gerber_files/STM32F4-spindle.cmp")
|
||||
self.gerber2.parse_file("./gerber_files/STM32F4-spindle.cmp")
|
||||
geometry2 = self.gerber2.solid_geometry
|
||||
self.geometry2_area = self.compute_area (geometry2)
|
||||
|
||||
|
||||
|
||||
def compute_area (self, geometry):
|
||||
def compute_area(self, geometry):
|
||||
area = 0
|
||||
try:
|
||||
for geo in geometry:
|
||||
|
@ -35,10 +25,9 @@ class GerberBuffer(unittest.TestCase):
|
|||
area = geometry.area
|
||||
return area
|
||||
|
||||
|
||||
def test_buffer(self):
|
||||
self.assertLessEqual (abs(self.geometry2_area - self.geometry1_area), 0.000001)
|
||||
self.assertLessEqual(abs(self.geometry2_area - self.geometry1_area), 0.000001)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import sys
|
||||
import unittest
|
||||
from PyQt4 import QtGui
|
||||
from FlatCAMApp import App
|
||||
|
||||
|
||||
class BaseGUITestCase(unittest.TestCase):
|
||||
|
||||
filename = 'simple1.gbr'
|
||||
|
||||
def setUp(self):
|
||||
self.app = QtGui.QApplication(sys.argv)
|
||||
self.fc = App()
|
||||
|
||||
self.fc.open_gerber('tests/gerber_files/' + self.filename)
|
||||
|
||||
def tearDown(self):
|
||||
del self.fc
|
||||
del self.app
|
||||
|
||||
def test_available(self):
|
||||
names = self.fc.collection.get_names()
|
||||
self.assertEquals(len(names), 1,
|
||||
"Expected 1 object, found %d" % len(names))
|
||||
self.assertEquals(names[0], self.filename,
|
||||
"Expected name == %s, got %s" % (self.filename, names[0]))
|
||||
print names[0]
|
|
@ -6,6 +6,7 @@ from matplotlib.pyplot import plot, subplot, show, cla, clf, xlim, ylim, title
|
|||
from camlib import *
|
||||
from copy import deepcopy
|
||||
|
||||
|
||||
def mkstorage(paths):
|
||||
def get_pts(o):
|
||||
return [o.coords[0], o.coords[-1]]
|
||||
|
@ -208,4 +209,4 @@ class PaintConnectTest3(PaintTestCase):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue