Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
8df3326d
Commit
8df3326d
authored
Feb 08, 2014
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More BOARD unit tests
parent
a2483d48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
11 deletions
+58
-11
test_002_board_class.py
qa/testcases/test_002_board_class.py
+58
-11
No files found.
qa/testcases/test_002_board_class.py
View file @
8df3326d
...
@@ -3,29 +3,76 @@ import unittest
...
@@ -3,29 +3,76 @@ import unittest
import
pcbnew
import
pcbnew
import
pdb
import
pdb
from
pcbnew
import
ToMM
from
pcbnew
import
*
class
TestBoardClass
(
unittest
.
TestCase
):
class
TestBoardClass
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
pcb
=
pcbnew
.
LoadBoard
(
"data/complex_hierarchy.kicad_pcb"
)
self
.
pcb
=
LoadBoard
(
"data/complex_hierarchy.kicad_pcb"
)
def
test_pcb_find_module
(
self
):
def
test_pcb_find_module
(
self
):
module
=
self
.
pcb
.
FindModule
(
'P1'
)
module
=
self
.
pcb
.
FindModule
(
'P1'
)
self
.
assertEqual
(
module
.
GetReference
(),
'P1'
)
self
.
assertEqual
(
module
.
GetReference
(),
'P1'
)
def
test_pcb_get_track_count
(
self
):
pcb
=
BOARD
()
self
.
assertEqual
(
pcb
.
GetNumSegmTrack
(),
0
)
track0
=
TRACK
(
pcb
)
pcb
.
Add
(
track0
)
self
.
assertEqual
(
pcb
.
GetNumSegmTrack
(),
1
)
track1
=
TRACK
(
pcb
)
pcb
.
Add
(
track1
)
self
.
assertEqual
(
pcb
.
GetNumSegmTrack
(),
2
)
def
test_pcb_bounding_box
(
self
):
def
test_pcb_bounding_box
(
self
):
bounding_box
=
self
.
pcb
.
ComputeBoundingBox
()
pcb
=
BOARD
()
track
=
TRACK
(
pcb
)
pcb
.
Add
(
track
)
#track.SetStartEnd(wxPointMM(10.0, 10.0),
# wxPointMM(20.0, 30.0))
height
=
ToMM
(
bounding_box
.
GetHeight
()
)
track
.
SetStart
(
wxPointMM
(
10.0
,
10.0
))
width
=
ToMM
(
bounding_box
.
GetWidth
()
)
track
.
SetEnd
(
wxPointMM
(
20.0
,
30.0
))
track
.
SetWidth
(
FromMM
(
0.5
))
#!!! THIS FAILS? == 0.0 x 0.0 ??
#height, width = ToMM(pcb.ComputeBoundingBox().GetSize())
bounding_box
=
pcb
.
ComputeBoundingBox
()
height
,
width
=
ToMM
(
bounding_box
.
GetSize
())
self
.
assertAlmostEqual
(
width
,
(
30
-
10
)
+
0.5
,
2
)
self
.
assertAlmostEqual
(
height
,
(
20
-
10
)
+
0.5
,
2
)
def
test_pcb_get_pad
(
self
):
pcb
=
BOARD
()
module
=
MODULE
(
pcb
)
pcb
.
Add
(
module
)
pad
=
D_PAD
(
module
)
module
.
Add
(
pad
)
pad
.
SetShape
(
PAD_OVAL
)
pad
.
SetSize
(
wxSizeMM
(
2.0
,
3.0
))
pad
.
SetPosition
(
wxPointMM
(
0
,
0
))
# easy case
p1
=
pcb
.
GetPad
(
wxPointMM
(
0
,
0
))
# top side
p2
=
pcb
.
GetPad
(
wxPointMM
(
0.9
,
0.0
))
# probably it's a cleaner test to generate a board with
# bottom side
# a couple of things, that we can know the exact size,
p3
=
pcb
.
GetPad
(
wxPointMM
(
0
,
1.4
))
# and then compute the bounding box,
self
.
assertAlmostEqual
(
height
,
89.52
,
2
)
# TODO: get pad == p1 evaluated as true instead
self
.
assertAlmostEqual
(
width
,
108.44
,
2
)
# of relying in the internal C++ object pointer
self
.
assertEqual
(
pad
.
this
,
p1
.
this
)
self
.
assertEqual
(
pad
.
this
,
p2
.
this
)
self
.
assertEqual
(
pad
.
this
,
p3
.
this
)
#def test_interactive(self):
#def test_interactive(self):
# code.interact(local=locals())
# code.interact(local=locals())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment