mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-05 23:27:31 +08:00
Simple serialization entities fixes and tests
This commit is contained in:
11
tests/fixtures/BlueprintFixture.js
vendored
11
tests/fixtures/BlueprintFixture.js
vendored
@@ -117,4 +117,15 @@ export default class BlueprintFixture {
|
||||
|
||||
async cleanup() {
|
||||
}
|
||||
|
||||
blur() {
|
||||
return this.page.evaluate(() => /** @type {HTMLElement} */(document.activeElement).blur())
|
||||
}
|
||||
|
||||
getSerializedNodes() {
|
||||
return this.blueprintLocator.evaluate(blueprint => {
|
||||
blueprint.selectAll()
|
||||
return blueprint.template.getCopyInputObject().getSerializedText()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ test.describe.configure({ mode: "parallel" })
|
||||
for (const nodeTest of nodeTests) {
|
||||
test.describe(nodeTest.name, () => {
|
||||
|
||||
test.describe.configure({ mode: "serial" })
|
||||
test.beforeAll(async ({ blueprintPage }) => {
|
||||
await blueprintPage.removeNodes()
|
||||
await blueprintPage.paste(nodeTest.value)
|
||||
@@ -142,15 +143,12 @@ for (const nodeTest of nodeTests) {
|
||||
test(
|
||||
`${nodeTest.name}: Maintains the order of attributes`,
|
||||
async ({ blueprintPage }) => {
|
||||
const serialized = await blueprintPage.blueprintLocator.evaluate(blueprint => {
|
||||
blueprint.selectAll()
|
||||
return blueprint.template.getCopyInputObject().getSerializedText()
|
||||
})
|
||||
const words = nodeTest.value
|
||||
const actualSerialization = await blueprintPage.getSerializedNodes()
|
||||
const expectedWords = nodeTest.value
|
||||
.split("\n")
|
||||
.map(row => row.match(/\s*("?\w+(\s+\w+)*).+/)?.[1])
|
||||
.filter(v => v?.length > 0)
|
||||
expect(serialized).toMatch(Utility.getFirstWordOrder(words))
|
||||
expect(actualSerialization).toMatch(Utility.getFirstWordOrder(expectedWords))
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -6,8 +6,12 @@ import IntegerEntity from "../js/entity/IntegerEntity.js"
|
||||
import KeyBindingEntity from "../js/entity/KeyBindingEntity.js"
|
||||
import LinearColorEntity from "../js/entity/LinearColorEntity.js"
|
||||
import ObjectReferenceEntity from "../js/entity/ObjectReferenceEntity.js"
|
||||
import PinEntity from "../js/entity/PinEntity.js"
|
||||
import PinTypeEntity from "../js/entity/PinTypeEntity.js"
|
||||
import RotatorEntity from "../js/entity/RotatorEntity.js"
|
||||
import SimpleSerializationRotatorEntity from "../js/entity/SimpleSerializationRotatorEntity.js"
|
||||
import SimpleSerializationVector2DEntity from "../js/entity/SimpleSerializationVector2DEntity.js"
|
||||
import SimpleSerializationVectorEntity from "../js/entity/SimpleSerializationVectorEntity.js"
|
||||
import SymbolEntity from "../js/entity/SymbolEntity.js"
|
||||
import UnknownKeysEntity from "../js/entity/UnknownKeysEntity.js"
|
||||
import Vector2DEntity from "../js/entity/Vector2DEntity.js"
|
||||
@@ -15,7 +19,6 @@ import VectorEntity from "../js/entity/VectorEntity.js"
|
||||
import Grammar from "../js/serialization/Grammar.js"
|
||||
import SerializerFactory from "../js/serialization/SerializerFactory.js"
|
||||
import initializeSerializerFactory from "../js/serialization/initializeSerializerFactory.js"
|
||||
import PinEntity from "../js/entity/PinEntity.js"
|
||||
|
||||
test.beforeAll(() => initializeSerializerFactory())
|
||||
|
||||
@@ -299,6 +302,63 @@ test("PinEntity", () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("SimpleSerializationRotatorEntity", () => {
|
||||
const serializer = SerializerFactory.getSerializer(SimpleSerializationRotatorEntity)
|
||||
|
||||
expect(serializer.read("0, 0, 0")).toEqual(new SimpleSerializationRotatorEntity({
|
||||
R: 0,
|
||||
P: 0,
|
||||
Y: 0,
|
||||
}))
|
||||
expect(serializer.read("0.65, 1.0, 0.99")).toEqual(new SimpleSerializationRotatorEntity({
|
||||
P: 0.65,
|
||||
Y: 1.0,
|
||||
R: 0.99,
|
||||
}))
|
||||
expect(serializer.read("7,6,5")).toEqual(new SimpleSerializationRotatorEntity({
|
||||
P: 7,
|
||||
Y: 6,
|
||||
R: 5,
|
||||
}))
|
||||
})
|
||||
|
||||
test("SimpleSerializationVector2DEntity", () => {
|
||||
const serializer = SerializerFactory.getSerializer(SimpleSerializationVector2DEntity)
|
||||
|
||||
expect(serializer.read("0, 0")).toEqual(new SimpleSerializationVector2DEntity({
|
||||
X: 0,
|
||||
Y: 0,
|
||||
}))
|
||||
expect(serializer.read("127.8, 13.3")).toEqual(new SimpleSerializationVector2DEntity({
|
||||
X: 127.8,
|
||||
Y: 13.3,
|
||||
}))
|
||||
expect(serializer.read("5,0")).toEqual(new SimpleSerializationVector2DEntity({
|
||||
X: 5,
|
||||
Y: 0,
|
||||
}))
|
||||
})
|
||||
|
||||
test("SimpleSerializationVectorEntity", () => {
|
||||
const serializer = SerializerFactory.getSerializer(SimpleSerializationVectorEntity)
|
||||
|
||||
expect(serializer.read("0, 0, 0")).toEqual(new SimpleSerializationVectorEntity({
|
||||
X: 0,
|
||||
Y: 0,
|
||||
Z: 0,
|
||||
}))
|
||||
expect(serializer.read("1001, 56.4, 0.5")).toEqual(new SimpleSerializationVectorEntity({
|
||||
X: 1001,
|
||||
Y: 56.4,
|
||||
Z: 0.5,
|
||||
}))
|
||||
expect(serializer.read("-1,-2,-3")).toEqual(new SimpleSerializationVectorEntity({
|
||||
X: -1,
|
||||
Y: -2,
|
||||
Z: -3,
|
||||
}))
|
||||
})
|
||||
|
||||
test("String", () => {
|
||||
const serializer = SerializerFactory.getSerializer(String)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Configuration from "../../js/Configuration.js"
|
||||
import SVGIcon from "../../js/SVGIcon.js"
|
||||
import { expect } from "../fixtures/test.js"
|
||||
import NodeTests from "./NodeTests.js"
|
||||
|
||||
export default class OtherNodes extends NodeTests {
|
||||
@@ -522,6 +523,84 @@ export default class OtherNodes extends NodeTests {
|
||||
delegate: false,
|
||||
development: false,
|
||||
},
|
||||
{
|
||||
name: "Add Local Navigation Grid For Box",
|
||||
value: String.raw`
|
||||
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_0" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Temp/Untitled_1.Untitled_1:PersistentLevel.Untitled.EventGraph.K2Node_CallFunction_0'"
|
||||
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/AIModule.NavLocalGridManager'",MemberName="AddLocalNavigationGridForBox")
|
||||
NodePosX=304
|
||||
NodePosY=-496
|
||||
NodeGuid=C15FC9905D6D4BF5AF19CB81BAB598DE
|
||||
CustomProperties Pin (PinId=4A315083206E46F38782139225D1CBDB,PinName="execute",PinToolTip="\nExec",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=0E0D6F8DD32C430D9F727D4B16A6CA85,PinName="then",PinToolTip="\nExec",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=3A0F065EA4444A6BBD9DB667859A2139,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nNav Local Grid Manager Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/AIModule.NavLocalGridManager'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultObject="/Script/AIModule.Default__NavLocalGridManager",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=3FBC998EDAF84DC48EF01354ED460934,PinName="WorldContextObject",PinToolTip="World Context Object\nObject Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/CoreUObject.Object'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=44559846BCBA449395FE1552F1ECE478,PinName="Location",PinToolTip="Location\nVector (by ref)",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Vector'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=True,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0, 0, 0",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=C5C95F7DF3A74AF990B3093D85D70478,PinName="Extent",PinToolTip="Extent\nVector",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Vector'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="15.000000,30.000000,45.000000",AutogeneratedDefaultValue="1.000000,1.000000,1.000000",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=EE0E7856A7B54B5CBE67E4F589E82B4C,PinName="Rotation",PinToolTip="Rotation\nRotator",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Rotator'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="20.000000,30.000000,10.000000",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=960A2A37701047D5B28353189B7199A5,PinName="Radius2D",PinToolTip="Radius 2D\nInteger",PinType.PinCategory="int",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="8",AutogeneratedDefaultValue="5",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=DE5301DC038D43969F9DB9F41949AFD0,PinName="Height",PinToolTip="Height\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="200.500000",AutogeneratedDefaultValue="100.000000",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=5E42C9BD542E413E9CEF9D5A98A4C5EB,PinName="bRebuildGrids",PinToolTip="Rebuild Grids\nBoolean",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="false",AutogeneratedDefaultValue="true",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
CustomProperties Pin (PinId=5A398222D44740A98F9742B5BDDB3580,PinName="ReturnValue",PinToolTip="Return Value\nInteger\n\nAdd Local Navigation Grid for Box",Direction="EGPD_Output",PinType.PinCategory="int",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0",AutogeneratedDefaultValue="0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
|
||||
End Object
|
||||
`,
|
||||
size: [20.5, 19],
|
||||
color: Configuration.nodeColors.blue,
|
||||
icon: SVGIcon.functionSymbol,
|
||||
pins: 9,
|
||||
pinNames: [
|
||||
"Location",
|
||||
"Extent",
|
||||
"Rotation",
|
||||
"Radius 2D",
|
||||
"Height",
|
||||
"Rebuild Grids",
|
||||
"Return Value",
|
||||
],
|
||||
delegate: false,
|
||||
development: false,
|
||||
additionalTest: async (node, pins, blueprintPage) => {
|
||||
await expect(pins[2].locator("ueb-input")).toHaveText(["15.0", "30.0", "45.0"])
|
||||
await expect(pins[3].locator("ueb-input")).toHaveText(["10.0", "20.0", "30.0"])
|
||||
await expect(pins[4].locator("ueb-input")).toHaveText(["8"])
|
||||
await expect(pins[5].locator("ueb-input")).toHaveText(["200.5"])
|
||||
await expect(pins[6].locator("input")).toBeChecked({ checked: false })
|
||||
let inputs = await pins[2].locator("ueb-input").all()
|
||||
await inputs[0].fill("-11.11")
|
||||
await inputs[1].fill("-22.22")
|
||||
await inputs[2].fill("-33.33")
|
||||
await blueprintPage.blur()
|
||||
expect(await pins[2].evaluate(pin => pin.entity.DefaultValue.constructor.name))
|
||||
.toBe("SimpleSerializationVectorEntity")
|
||||
await expect(pins[2].locator("ueb-input")).toHaveText(["-11.11", "-22.22", "-33.33"])
|
||||
inputs = await pins[3].locator("ueb-input").all()
|
||||
await inputs[0].fill("88")
|
||||
await inputs[1].fill("77")
|
||||
await inputs[2].fill("66")
|
||||
await blueprintPage.blur()
|
||||
expect(await pins[3].evaluate(pin => pin.entity.DefaultValue.constructor.name))
|
||||
.toBe("SimpleSerializationRotatorEntity")
|
||||
await expect(pins[3].locator("ueb-input")).toHaveText(["88.0", "77.0", "66.0"])
|
||||
await pins[4].locator("ueb-input").fill("35.814")
|
||||
await blueprintPage.blur()
|
||||
expect(await pins[4].evaluate(pin => pin.entity.DefaultValue.constructor.name))
|
||||
.toBe("IntegerEntity")
|
||||
await expect(pins[4].locator("ueb-input")).toHaveText("35")
|
||||
await pins[6].locator("input").check()
|
||||
await expect(pins[6].locator("input")).toBeChecked()
|
||||
expect(await pins[6].evaluate(pin => pin.entity.DefaultValue.constructor.name))
|
||||
.toBe("Boolean")
|
||||
const serialization = await blueprintPage.getSerializedNodes()
|
||||
await blueprintPage.removeNodes()
|
||||
await blueprintPage.paste(serialization)
|
||||
pins = await blueprintPage.blueprintLocator.locator("ueb-pin").all()
|
||||
await expect(pins[2].locator("ueb-input")).toHaveText(["-11.11", "-22.22", "-33.33"])
|
||||
await expect(pins[3].locator("ueb-input")).toHaveText(["88.0", "77.0", "66.0"])
|
||||
await expect(pins[4].locator("ueb-input")).toHaveText(["35"])
|
||||
await expect(pins[5].locator("ueb-input")).toHaveText(["200.5"])
|
||||
await expect(pins[6].locator("input")).toBeChecked()
|
||||
}
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user