Skip to content

Commit

Permalink
Add test for viewController.createLines()
Browse files Browse the repository at this point in the history
Lines can be successfully created. They are added to a, during runtime, created group called "BCF-X" where X is some random number between 0 and 5000.
  • Loading branch information
podestplatz committed Jul 25, 2019
1 parent 64d381c commit 1910afd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
6 changes: 4 additions & 2 deletions bcfplugin/frontend/viewController.py
@@ -1,8 +1,10 @@
import re
import copy
from typing import List
from pivy import coin
from enum import Enum
from math import pi
from random import randrange

import rdwr.threedvector as vector
import util
Expand All @@ -29,7 +31,7 @@
doc = FreeCAD.ActiveDocument
""" Reference to the document the model to the BCF file is open in """

bcfGroupName = "BCF"
bcfGroupName = "BCF-{}".format(randrange(5000))
bcfGroup = None
""" Reference to the document object group all elements will be assigned to,
that get created by functions inside this file """
Expand Down Expand Up @@ -211,7 +213,7 @@ def drawLine(start: FreeCAD.Vector, end: FreeCAD.Vector):

if start is None or end is None:
return None
if not (isinstance(start, FreeCAD.Vector) and is instance(end,
if not (isinstance(start, FreeCAD.Vector) and isinstance(end,
FreeCAD.Vector)):
return None

Expand Down
41 changes: 36 additions & 5 deletions bcfplugin/tests/viewController_tests.py
@@ -1,15 +1,46 @@
def setupBCFFile(fileName, testFileDir, topicDir, testBCFName):
import sys
import os
if __name__ == "__main__":
sys.path.insert(0, "../")
sys.path.append("../../env/lib/python3.7/site-packages")
FreeCAD.open(u"../../bcf-examples/clippingPlane_bernd/bcfexample1.FCStd")

import util

import programmaticInterface as pI
import frontend.viewController as vC


def setupBCFFile(testFile, testFileDir, topicDir, testBCFName):

cmd = "cp {}/{} {}/{}/viewpoint.bcfv".format(testFileDir, testFile,
testFileDir, testTopicDir)
project.debug("Executing: {}".format(cmd))
testFileDir, topicDir)
print("Executing: {}".format(cmd))
os.system(cmd)

cmd = "cd ./viewController-tests && zip -q {} {}/markup.bcf".format(testBCFName,
cmd = "cd ./{} && zip -q {} {}/viewpoint.bcfv".format(testFileDir, testBCFName,
topicDir)
project.debug("Executing: {}".format(cmd))
print("Executing: {}".format(cmd))
os.system(cmd)

return os.path.join(testFileDir, testBCFName)


def test_letLinesDraw():

topics = [ topic[1] for topic in pI.getTopics() ]
viewpoints = [ vp[1] for vp in pI.getViewpoints(topics[0]) ]
vC.createLines(viewpoints[0].lines)



#if __name__ == "__main__":
testFileDir = "viewController-tests"
testBCFFile = "bcfexmple_bernd.bcf"

setupBCFFile("viewpoint_with_lines.bcfv", "viewController-tests",
"d7301aa6-3533-4031-b209-9e1c701802f5", "bcfexmple_bernd.bcf")
pI.openProject("./{}/{}".format(testFileDir, testBCFFile))

test_letLinesDraw()

6 changes: 3 additions & 3 deletions bcfplugin/tests/viewpoint_tests.py
Expand Up @@ -18,13 +18,13 @@ def setCameraSettings(project, vC):


import sys
sys.path.append("/home/patrick/projects/freecad/plugin/env/lib/python3.7/site-packages")
sys.path.append("../../env/lib/python3.7/site-packages")
import bcfplugin
import bcfplugin.programmaticInterface
import bcfplugin.frontend.viewController as vC
FreeCAD.open(u"/home/patrick/projects/freecad/plugin/bcf-examples/clippingPlane_bernd/bcfexample1.FCStd")
FreeCAD.open(u"../../bcf-examples/clippingPlane_bernd/bcfexample1.FCStd")

bcfplugin.programmaticInterface.openProject("/home/patrick/projects/freecad/plugin/bcf-examples/bcfexmple_bernd.bcf")
bcfplugin.programmaticInterface.openProject("../../bcf-examples/bcfexmple_bernd.bcf")
project = bcfplugin.programmaticInterface.curProject

setCameraSettings(project, vC)

0 comments on commit 1910afd

Please sign in to comment.