245 lines
7.1 KiB
Plaintext
245 lines
7.1 KiB
Plaintext
Option Explicit
|
|
|
|
Const epcbFabAll = 0
|
|
Const epcbSelectAll = 0
|
|
Const epcbSideTopOrBottom = 2
|
|
Const epcbFabAssembly = 4
|
|
Const epcbJustifyVCenter = 1
|
|
Const epcbJustifyHCenter = 1
|
|
Const epcbUnitMM = 2
|
|
Const epcbAngleUnitDegrees = 1
|
|
Dim fso, root, stream, docObj, fabtxt, request, Scripting, tempRoot, fixturePath, parsed, Application, ScriptEngine, targetText
|
|
Set fso = CreateObject("Scripting.FileSystemObject")
|
|
root = fso.GetAbsolutePathName(fso.BuildPath( _
|
|
fso.GetParentFolderName(WScript.ScriptFullName), "..\.."))
|
|
Set stream = fso.OpenTextFile(root & _
|
|
"\integration\dxdesigner795\expedition\ExpeditionBridge.vbs", 1, False, 0)
|
|
ExecuteGlobal stream.ReadAll
|
|
stream.Close
|
|
|
|
Set docObj = New TestDocument
|
|
Set fabtxt = New TestFabText
|
|
Set fabtxt.Component = Nothing
|
|
fabtxt.TextType = 1
|
|
fabtxt.Side = 1
|
|
fabtxt.FabType = epcbFabAssembly
|
|
fabtxt.TextString = "BOARD NOTE"
|
|
docObj.Texts.Add fabtxt
|
|
request = DxEpExportRequest(docObj)
|
|
If request <> "T|0|1|1|1|BOARD NOTE||" & vbCrLf & vbCrLf Then
|
|
WScript.Echo "FAIL exported assembly classification: " & request
|
|
WScript.Quit 1
|
|
End If
|
|
WScript.Echo "Expedition request assertions passed"
|
|
If DxEpQuote("C:\PCB Tool\tools.exe") <> Chr(34) & _
|
|
"C:\PCB Tool\tools.exe" & Chr(34) Then
|
|
WScript.Echo "FAIL standalone command quoting"
|
|
WScript.Quit 1
|
|
End If
|
|
If DxEpQuote("C:\PCB Tool\") <> Chr(34) & _
|
|
"C:\PCB Tool\\" & Chr(34) Then
|
|
WScript.Echo "FAIL trailing command backslash quoting"
|
|
WScript.Quit 1
|
|
End If
|
|
WScript.Echo "Expedition standalone quoting assertions passed"
|
|
Set targetText = New TestMoveText
|
|
Call DxEpApplyLine("MOVE|0|10|20|90||Arial", targetText)
|
|
If targetText.MoveCount <> 0 Then
|
|
WScript.Echo "FAIL nonassembly cardinal text position must be preserved"
|
|
WScript.Quit 1
|
|
End If
|
|
If targetText.Format.Rotation <> 90 Or targetText.Format.Font <> "Arial" Then
|
|
WScript.Echo "FAIL format-only refdes update"
|
|
WScript.Quit 1
|
|
End If
|
|
Call DxEpApplyLine("MOVE|0|10|20|90|0.4|Arial", targetText)
|
|
If targetText.MoveCount <> 1 Or targetText.X <> 10 Or targetText.Y <> 20 Then
|
|
WScript.Echo "FAIL assembly refdes movement"
|
|
WScript.Quit 1
|
|
End If
|
|
WScript.Echo "Expedition legacy position parity assertions passed"
|
|
tempRoot = fso.BuildPath(fso.GetSpecialFolder(2), fso.GetTempName)
|
|
fso.CreateFolder tempRoot
|
|
fso.CreateFolder tempRoot & "\expedition"
|
|
Set stream = fso.CreateTextFile(tempRoot & "\DxDesignerTools.exe", True)
|
|
stream.Close
|
|
Set stream = fso.CreateTextFile(tempRoot & "\expedition\ExpeditionBridge.vbs", True)
|
|
stream.Close
|
|
Set Scripting = New TestScripting
|
|
Scripting.CurrentScriptFullName = tempRoot & "\expedition\ExpeditionBridge.vbs"
|
|
If DxEpResolveRoot() <> tempRoot Then
|
|
WScript.Echo "FAIL native CurrentScriptFullName root fallback"
|
|
WScript.Quit 1
|
|
End If
|
|
fixturePath = tempRoot & "\startup.json"
|
|
Set stream = fso.CreateTextFile(fixturePath, True)
|
|
stream.Write "{""tool_root"":""" & Replace(tempRoot, Chr(92), _
|
|
Chr(92) & Chr(92)) & """}"
|
|
stream.Close
|
|
If DxEpStartupRootFromFile(fixturePath) <> tempRoot Then
|
|
WScript.Echo "FAIL persisted Start registration root"
|
|
WScript.Quit 1
|
|
End If
|
|
If Not DxEpJsonString("{""tool_root"":""C:\\" & _
|
|
"\u5DE5\u5177\\a\""b""}", "tool_root", parsed) Then
|
|
WScript.Echo "FAIL escaped registration JSON"
|
|
WScript.Quit 1
|
|
End If
|
|
If parsed <> "C:\" & ChrW(&H5DE5) & ChrW(&H5177) & "\a" & Chr(34) & "b" Then
|
|
WScript.Echo "FAIL escaped registration value"
|
|
WScript.Quit 1
|
|
End If
|
|
Set Application = New TestApplication
|
|
ScriptEngine = "fixture-script-engine"
|
|
Call DxEpInitialize()
|
|
If Application.Gui.Bar.Controls.Count <> 1 Then
|
|
WScript.Echo "FAIL native menu installation"
|
|
WScript.Quit 1
|
|
End If
|
|
If Scripting.DontExit <> True Then
|
|
WScript.Echo "FAIL native callback script lifetime"
|
|
WScript.Quit 1
|
|
End If
|
|
If Application.Gui.Bar.Controls.Item(1).Controls.Button.ExecuteMethod <> _
|
|
"DxEpAssemblyMenuCommand" Then
|
|
WScript.Echo "FAIL assembly callback registration"
|
|
WScript.Quit 1
|
|
End If
|
|
If Application.Gui.Bar.Controls.Item(1).Controls.Button.Target <> ScriptEngine Then
|
|
WScript.Echo "FAIL callback target must be the native script engine"
|
|
WScript.Quit 1
|
|
End If
|
|
fso.DeleteFile tempRoot & "\expedition\ExpeditionBridge.vbs"
|
|
If DxEpStartupRootFromFile(fixturePath) <> "" Then
|
|
WScript.Echo "FAIL stale registration without Expedition script"
|
|
WScript.Quit 1
|
|
End If
|
|
fso.DeleteFile fixturePath
|
|
fso.DeleteFile tempRoot & "\DxDesignerTools.exe"
|
|
fso.DeleteFolder tempRoot & "\expedition"
|
|
fso.DeleteFolder tempRoot
|
|
WScript.Echo "Expedition native root assertions passed"
|
|
WScript.Echo "Expedition persisted registration assertions passed"
|
|
WScript.Echo "Expedition native menu assertions passed"
|
|
|
|
Class TestFabText
|
|
Public Component
|
|
Public TextType
|
|
Public Side
|
|
Public FabType
|
|
Public Property Get [Type]()
|
|
[Type] = FabType
|
|
End Property
|
|
Public TextString
|
|
End Class
|
|
|
|
Class TestDocument
|
|
Public Texts
|
|
Private Sub Class_Initialize()
|
|
Set Texts = CreateObject("System.Collections.ArrayList")
|
|
End Sub
|
|
Public Function FabricationLayerTexts(fabType, selection, side, selected)
|
|
Set FabricationLayerTexts = Texts
|
|
End Function
|
|
End Class
|
|
|
|
Class TestScripting
|
|
Public CurrentScriptFullName
|
|
Public DontExit
|
|
End Class
|
|
|
|
Class TestApplication
|
|
Public Gui
|
|
Private Sub Class_Initialize()
|
|
Set Gui = New TestGui
|
|
End Sub
|
|
End Class
|
|
|
|
Class TestGui
|
|
Public Bar
|
|
Private Sub Class_Initialize()
|
|
Set Bar = New TestMenuBar
|
|
End Sub
|
|
Public Property Get CommandBars(name)
|
|
If name <> "Document Menu Bar" Then Err.Raise 5
|
|
Set CommandBars = Bar
|
|
End Property
|
|
End Class
|
|
|
|
Class TestMenuBar
|
|
Public Controls
|
|
Private Sub Class_Initialize()
|
|
Set Controls = New TestPopupControls
|
|
End Sub
|
|
End Class
|
|
|
|
Class TestPopupControls
|
|
Public Count
|
|
Private Popup
|
|
Private Sub Class_Initialize()
|
|
Count = 0
|
|
End Sub
|
|
Public Function Add(kind)
|
|
If kind <> 1 Then Err.Raise 5, "Fixture", "cmdControlPopup must be 1"
|
|
Set Popup = New TestPopup
|
|
Count = Count + 1
|
|
Set Add = Popup
|
|
End Function
|
|
Public Property Get Item(index)
|
|
Set Item = Popup
|
|
End Property
|
|
End Class
|
|
|
|
Class TestPopup
|
|
Public Caption
|
|
Public Controls
|
|
Private Sub Class_Initialize()
|
|
Set Controls = New TestButtonControls
|
|
End Sub
|
|
End Class
|
|
|
|
Class TestButtonControls
|
|
Public Button
|
|
Public Function Add()
|
|
Set Button = New TestButton
|
|
Set Add = Button
|
|
End Function
|
|
End Class
|
|
|
|
Class TestButton
|
|
Public Caption
|
|
Public OnAction
|
|
Public Target
|
|
Public ExecuteMethod
|
|
End Class
|
|
|
|
Class TestMoveText
|
|
Public Format
|
|
Public MoveCount
|
|
Public X
|
|
Public Y
|
|
Private Sub Class_Initialize()
|
|
Set Format = New TestTextFormat
|
|
MoveCount = 0
|
|
End Sub
|
|
Public Sub Move(newX, newY)
|
|
MoveCount = MoveCount + 1
|
|
X = newX
|
|
Y = newY
|
|
End Sub
|
|
End Class
|
|
|
|
Class TestTextFormat
|
|
Public VerticalJust
|
|
Public HorizontalJust
|
|
Public Font
|
|
Public Rotation
|
|
Public Size
|
|
Public Property Let Orientation(unit, value)
|
|
Rotation = value
|
|
End Property
|
|
Public Property Let Height(unit, value)
|
|
Size = value
|
|
End Property
|
|
End Class
|