From 9b30d8830d2fcc9f9a2a7a4d6dc2b0b2617cb7b6 Mon Sep 17 00:00:00 2001 From: fabian Date: Wed, 9 Dec 2020 10:48:49 +0100 Subject: [PATCH] CATTY-446 Parse multiple scenes Revert "CATTY-446 Parse multiple scenes" Resolved Parsing Error CATTY-446 Parse multiple scenes Now it is building. CATTY-446 Parse multiple scenes Now moved files in right Directory. Now it should also work on the test System. CATTY-446 Parse multiple scenes Fixed non building testcases. CATTY-446 Parse multiple scenes Fixed some Testcases. CATTY-446 Parse multiple scenes Removed failing testcases because the functions needed were removed in a previous version. CATTY-446 Parse multiple scenes Also removed declarations of the removed functions. CATTY-446 Fixed some testcases CATTY-446 Parse multiple scenes Fixed remaining test cases. CATTY-446 Parse multiple scenes Package.resolved --- src/Catty.xcodeproj/project.pbxproj | 54 +++++++---- .../xcshareddata/swiftpm/Package.resolved | 4 +- src/Catty/DataModel/Project/Project.h | 4 +- src/Catty/DataModel/Project/Project.m | 53 +++++++---- .../UIViewControllerExtension.swift | 16 ++-- .../FormulaEditorViewController.h | 2 - src/Catty/IO/ProjectManager.swift | 16 ++-- .../PlayerEngine/Frontend/CBFrontend.swift | 4 +- .../Protocols/CBFrontendProtocol.swift | 3 - .../Sensors/Object/LayerSensor.swift | 4 +- .../Stage/Builder/StageBuilder.swift | 9 +- src/Catty/PlayerEngine/Stage/Stage.swift | 19 ++-- .../Stage/StagePresenterViewController.m | 15 +--- ...terViewControllerScreenshotExtension.swift | 4 +- ...resenterViewControllerShareExtension.swift | 4 +- src/Catty/XML/Old Parser/ProjectParser.m | 1 + .../XMLHandler/Project/Project+CBXMLHandler.m | 36 ++++---- src/CattyTests/Bricks/AskBrickTests.swift | 2 +- src/CattyTests/Bricks/BubbleBrickTests.swift | 4 +- .../ChangeBrightnessByNBrickTests.swift | 2 +- .../Bricks/ChangeColorByNBrickTests.swift | 2 +- .../Bricks/ChangeVariableBrickTests.swift | 2 +- .../Bricks/ChooseCameraBrickTests.swift | 2 +- .../Bricks/ClearGraphicEffectBrickTests.swift | 2 +- .../Bricks/ComeToFrontBrickTests.swift | 8 +- .../DeleteItemOfUserListBrickTests.swift | 2 +- .../Bricks/GoNStepsBackBrickTests.swift | 6 +- .../Bricks/HideTextBrickTests.swift | 2 +- .../InsertItemIntoUserListBrickTests.swift | 2 +- .../Bricks/NextLookBrickTests.swift | 9 +- .../Bricks/PreviousLookBrickTests.swift | 9 +- .../ReplaceItemInUserListBrickTests.swift | 2 +- .../SetBackgroundByIndexBrickTests.swift | 5 +- .../Bricks/SetBrightnessBrickTests.swift | 2 +- .../Bricks/SetColorBrickTests.swift | 2 +- src/CattyTests/Bricks/SetLookBrickTests.swift | 1 - .../Bricks/SetLookByIndexBrickTests.swift | 2 +- .../Bricks/SetVariableBrickTests.swift | 2 +- .../Bricks/ShowTextBrickTests.swift | 2 +- src/CattyTests/CBSpriteNodePhysicsTests.swift | 74 +++++++++------ src/CattyTests/DataModel/LookTest.swift | 33 ++++--- src/CattyTests/DataModel/SoundTest.swift | 2 +- .../DataModel/UserDataContainerTest.swift | 38 ++++---- .../UIViewControllerExtensionTests.swift | 2 +- .../FileManager/ProjectManagerTests.swift | 4 +- .../Object/CollisionFunctionTest.swift | 64 ++++++++----- .../PlayerEngine/CBBackendTests.swift | 2 +- .../FormulaManagerInterpreterTests.swift | 2 +- .../Frontend/CBFrontendTests.swift | 6 +- .../Sensors/Object/BrightnessSensorTest.swift | 2 +- .../Sensors/Object/LayerSensorTest.swift | 8 +- .../Object/TouchesEdgeSensorTest.swift | 28 +++--- .../Project/ProjectMigratorTest.swift | 4 +- src/CattyTests/Project/ProjectTests.swift | 48 +++++----- .../Project/RequiredResourcesTests.swift | 12 +-- .../Custom/MultipleScenes/MultipleScenes.xml | 78 ++++++++++++++++ .../WhenBackgroundChangesScriptTests.swift | 2 +- .../Scripts/WhenConditionScriptTests.swift | 2 +- .../SpriteObjectMutableCopyTests.swift | 4 +- src/CattyTests/Stage/StageTests.swift | 4 +- src/CattyTests/Utils/UtilTests.swift | 16 ++-- ...EditorDataSectionViewControllerTests.swift | 33 +++++-- ...esenterViewControllerScreenshotTests.swift | 10 +-- .../StagePresenterViewControllerTests.swift | 4 +- .../Data/BrickCellListDataTests.swift | 2 +- .../Data/BrickCellVariableDataTests.swift | 2 +- .../XML/Abstract/XMLAbstractTest.swift | 4 +- .../XML/Helper/CBXMLParserHelperTests.swift | 4 +- .../XMLParserTests092.swift | 12 +-- .../XMLParserBrickTests093.swift | 2 +- .../XMLParserTests098.swift | 24 ++--- .../XMLParserTests0991.swift | 90 +++++++++---------- .../XMLParserTests0992.swift | 52 +++++------ .../XMLParserTests0993.swift | 56 ++++++------ .../XMLParserTests0994.swift | 14 +-- .../XMLParserTests0995.swift | 4 +- .../XMLParserTests0996.swift | 14 +-- .../XMLParserTests0998.swift | 10 +-- .../XMLParserTests0999.swift | 8 +- .../XMLParserTests09993.swift | 50 +++++------ .../XMLSerializerBlackBoxTests.swift | 4 +- .../XML/Serializer/XMLSerializerTests.swift | 30 +++---- .../XML/XMLParseMultipleScenesTests.swift | 62 +++++++++++++ src/CattyUITests/MyFirstProjectTests.swift | 38 ++++---- 84 files changed, 764 insertions(+), 520 deletions(-) create mode 100644 src/CattyTests/Resources/ParserTests/Custom/MultipleScenes/MultipleScenes.xml create mode 100644 src/CattyTests/XML/XMLParseMultipleScenesTests.swift diff --git a/src/Catty.xcodeproj/project.pbxproj b/src/Catty.xcodeproj/project.pbxproj index a55b5f5c55..beb4d4fa11 100644 --- a/src/Catty.xcodeproj/project.pbxproj +++ b/src/Catty.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 0502CFA826754E570028CF53 /* RecentlyUsedBricksManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0502CFA726754E570028CF53 /* RecentlyUsedBricksManager.swift */; }; 0502CFAD26763BCC0028CF53 /* RecentlyUsedBricksManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0502CFAB26763B6B0028CF53 /* RecentlyUsedBricksManagerTests.swift */; }; 05501DE7255E106F00C64E58 /* color_change.dst in Resources */ = {isa = PBXBuildFile; fileRef = 05501DE4255E106F00C64E58 /* color_change.dst */; }; - 056677ED27DBD33E006B4477 /* ZigzagStitchPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056677EC27DBD33E006B4477 /* ZigzagStitchPattern.swift */; }; 056677F127DD39D8006B4477 /* ZigzagStitchPatternTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056677F027DD39D8006B4477 /* ZigzagStitchPatternTests.swift */; }; 056677F327DE9C6B006B4477 /* StartZigzagStitchBrick.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056677F227DE9C6B006B4477 /* StartZigzagStitchBrick.swift */; }; 056677F527DEA012006B4477 /* StartZigzagStitchBrickCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056677F427DEA012006B4477 /* StartZigzagStitchBrickCell.swift */; }; @@ -18,6 +17,8 @@ 056677F927DF4C00006B4477 /* StartZigzagStitchBrick+CBXMLHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056677F827DF4C00006B4477 /* StartZigzagStitchBrick+CBXMLHandler.swift */; }; 056677FB27DF8C4C006B4477 /* StartZigzagStitchBrickTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 056677FA27DF8C4C006B4477 /* StartZigzagStitchBrickTests.swift */; }; 0570883E2739CC6F00622D84 /* StartRunningStitchBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0570883D2739CC6F00622D84 /* StartRunningStitchBrick+Instruction.swift */; }; + 05744DF925C84328005455F9 /* XMLParseMultipleScenesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05744DF825C84328005455F9 /* XMLParseMultipleScenesTests.swift */; }; + 05744E0A25C8437C005455F9 /* MultipleScenes.xml in Resources */ = {isa = PBXBuildFile; fileRef = 05744E0925C8437C005455F9 /* MultipleScenes.xml */; }; 057B182826DC738D00C47E60 /* CGPointExtentions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 057B182726DC738D00C47E60 /* CGPointExtentions.swift */; }; 057B182A26DC8B6A00C47E60 /* StartRunningStitchBrick.swift in Sources */ = {isa = PBXBuildFile; fileRef = 057B182926DC8B6A00C47E60 /* StartRunningStitchBrick.swift */; }; 057B182C26DC903500C47E60 /* StartRunningStitchBrickCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 057B182B26DC903500C47E60 /* StartRunningStitchBrickCell.swift */; }; @@ -36,15 +37,12 @@ 0594CE66275E567E007DC3F9 /* SewUpBrickTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0594CE65275E567D007DC3F9 /* SewUpBrickTests.swift */; }; 05A3CE6D24F5164A0051DB39 /* CatrobatTableViewControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A3CE6A24F516490051DB39 /* CatrobatTableViewControllerExtension.swift */; }; 05A3D46824F517220051DB39 /* StoreProjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A3D46724F517220051DB39 /* StoreProjectTests.swift */; }; - 05CBC6BF286C5A4B007FBA61 /* TripleStitchPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CBC6BC286C5A4B007FBA61 /* TripleStitchPattern.swift */; }; 05CBC6C1286C5A75007FBA61 /* StartTripleStitchBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CBC6C0286C5A75007FBA61 /* StartTripleStitchBrick+Instruction.swift */; }; 05CBC6C3286C5A85007FBA61 /* StartTripleStitchBrick.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CBC6C2286C5A85007FBA61 /* StartTripleStitchBrick.swift */; }; 05CBC6C5286C5BBE007FBA61 /* StartTripleStitchBrickCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CBC6C4286C5BBE007FBA61 /* StartTripleStitchBrickCell.swift */; }; 05CBC6C7286C5C2E007FBA61 /* StartTripleStitchBrick+CBXMLHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CBC6C6286C5C2E007FBA61 /* StartTripleStitchBrick+CBXMLHandler.swift */; }; 05CBC6C9286C5C4D007FBA61 /* TripleStitchPatternTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CBC6C8286C5C4D007FBA61 /* TripleStitchPatternTests.swift */; }; 05CBC6CB286C5C65007FBA61 /* StartTripleStitchBrickTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CBC6CA286C5C65007FBA61 /* StartTripleStitchBrickTests.swift */; }; - 05CD095F26FA980600B25D72 /* StitchPatternProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CD095E26FA980600B25D72 /* StitchPatternProtocol.swift */; }; - 05CD096326FA989500B25D72 /* RunningStitchPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CD096226FA989500B25D72 /* RunningStitchPattern.swift */; }; 05CD096726FAA72700B25D72 /* RunningStitchPatternTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05CD096626FAA72700B25D72 /* RunningStitchPatternTests.swift */; }; 05E6801A255B5DAA00D1E295 /* EmbroideryStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05E68012255B5DAA00D1E295 /* EmbroideryStream.swift */; }; 05E6801B255B5DAA00D1E295 /* EmbroideryDefines.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05E68013255B5DAA00D1E295 /* EmbroideryDefines.swift */; }; @@ -1751,6 +1749,10 @@ AAF6D9DE1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DD1BC0C1F300686849 /* PlaceAtBrick+Instruction.swift */; }; AAF6D9E01BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */; }; AAF6D9E21BC0C48300686849 /* PointToBrick+Instruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */; }; + B0C080932A9CE61A008E31A4 /* RunningStitchPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C0808F2A9CE619008E31A4 /* RunningStitchPattern.swift */; }; + B0C080942A9CE61A008E31A4 /* ZigzagStitchPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C080902A9CE61A008E31A4 /* ZigzagStitchPattern.swift */; }; + B0C080952A9CE61A008E31A4 /* TripleStitchPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C080912A9CE61A008E31A4 /* TripleStitchPattern.swift */; }; + B0C080962A9CE61A008E31A4 /* StitchPatternProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C080922A9CE61A008E31A4 /* StitchPatternProtocol.swift */; }; BA1FA9981F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA9971F02AD770084184D /* InsertItemIntoUserListBrick+CBXMLHandler.m */; }; BA1FA99D1F02AEDC0084184D /* InsertItemIntoUserListBrick.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99C1F02AEDC0084184D /* InsertItemIntoUserListBrick.m */; }; BA1FA9A01F02B0020084184D /* InsertItemIntoUserListBrickCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BA1FA99F1F02B0020084184D /* InsertItemIntoUserListBrickCell.m */; }; @@ -2151,7 +2153,6 @@ 0502CFA726754E570028CF53 /* RecentlyUsedBricksManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentlyUsedBricksManager.swift; sourceTree = ""; }; 0502CFAB26763B6B0028CF53 /* RecentlyUsedBricksManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentlyUsedBricksManagerTests.swift; sourceTree = ""; }; 05501DE4255E106F00C64E58 /* color_change.dst */ = {isa = PBXFileReference; lastKnownFileType = file; path = color_change.dst; sourceTree = ""; }; - 056677EC27DBD33E006B4477 /* ZigzagStitchPattern.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZigzagStitchPattern.swift; sourceTree = ""; }; 056677F027DD39D8006B4477 /* ZigzagStitchPatternTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZigzagStitchPatternTests.swift; sourceTree = ""; }; 056677F227DE9C6B006B4477 /* StartZigzagStitchBrick.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartZigzagStitchBrick.swift; sourceTree = ""; }; 056677F427DEA012006B4477 /* StartZigzagStitchBrickCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartZigzagStitchBrickCell.swift; sourceTree = ""; }; @@ -2159,6 +2160,8 @@ 056677F827DF4C00006B4477 /* StartZigzagStitchBrick+CBXMLHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StartZigzagStitchBrick+CBXMLHandler.swift"; sourceTree = ""; }; 056677FA27DF8C4C006B4477 /* StartZigzagStitchBrickTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartZigzagStitchBrickTests.swift; sourceTree = ""; }; 0570883D2739CC6F00622D84 /* StartRunningStitchBrick+Instruction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StartRunningStitchBrick+Instruction.swift"; sourceTree = ""; }; + 05744DF825C84328005455F9 /* XMLParseMultipleScenesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLParseMultipleScenesTests.swift; sourceTree = ""; }; + 05744E0925C8437C005455F9 /* MultipleScenes.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = MultipleScenes.xml; sourceTree = ""; }; 057B182726DC738D00C47E60 /* CGPointExtentions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CGPointExtentions.swift; sourceTree = ""; }; 057B182926DC8B6A00C47E60 /* StartRunningStitchBrick.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartRunningStitchBrick.swift; sourceTree = ""; }; 057B182B26DC903500C47E60 /* StartRunningStitchBrickCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartRunningStitchBrickCell.swift; sourceTree = ""; }; @@ -2177,15 +2180,12 @@ 0594CE65275E567D007DC3F9 /* SewUpBrickTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SewUpBrickTests.swift; sourceTree = ""; }; 05A3CE6A24F516490051DB39 /* CatrobatTableViewControllerExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CatrobatTableViewControllerExtension.swift; sourceTree = ""; }; 05A3D46724F517220051DB39 /* StoreProjectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoreProjectTests.swift; sourceTree = ""; }; - 05CBC6BC286C5A4B007FBA61 /* TripleStitchPattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TripleStitchPattern.swift; sourceTree = ""; }; 05CBC6C0286C5A75007FBA61 /* StartTripleStitchBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StartTripleStitchBrick+Instruction.swift"; sourceTree = ""; }; 05CBC6C2286C5A85007FBA61 /* StartTripleStitchBrick.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartTripleStitchBrick.swift; sourceTree = ""; }; 05CBC6C4286C5BBE007FBA61 /* StartTripleStitchBrickCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartTripleStitchBrickCell.swift; sourceTree = ""; }; 05CBC6C6286C5C2E007FBA61 /* StartTripleStitchBrick+CBXMLHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StartTripleStitchBrick+CBXMLHandler.swift"; sourceTree = ""; }; 05CBC6C8286C5C4D007FBA61 /* TripleStitchPatternTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TripleStitchPatternTests.swift; sourceTree = ""; }; 05CBC6CA286C5C65007FBA61 /* StartTripleStitchBrickTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StartTripleStitchBrickTests.swift; sourceTree = ""; }; - 05CD095E26FA980600B25D72 /* StitchPatternProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StitchPatternProtocol.swift; sourceTree = ""; }; - 05CD096226FA989500B25D72 /* RunningStitchPattern.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningStitchPattern.swift; sourceTree = ""; }; 05CD096626FAA72700B25D72 /* RunningStitchPatternTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunningStitchPatternTests.swift; sourceTree = ""; }; 05E68012255B5DAA00D1E295 /* EmbroideryStream.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmbroideryStream.swift; sourceTree = ""; }; 05E68013255B5DAA00D1E295 /* EmbroideryDefines.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmbroideryDefines.swift; sourceTree = ""; }; @@ -4395,6 +4395,10 @@ AAF6D9DF1BC0C2AA00686849 /* PointInDirectionBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointInDirectionBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointInDirectionBrick+Instruction.swift"; sourceTree = ""; }; AAF6D9E11BC0C48300686849 /* PointToBrick+Instruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "PointToBrick+Instruction.swift"; path = "PlayerEngine/Instructions/Motion/PointToBrick+Instruction.swift"; sourceTree = ""; }; ABD74577198FBC2984BDDE56 /* hu */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = ""; }; + B0C0808F2A9CE619008E31A4 /* RunningStitchPattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RunningStitchPattern.swift; sourceTree = ""; }; + B0C080902A9CE61A008E31A4 /* ZigzagStitchPattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZigzagStitchPattern.swift; sourceTree = ""; }; + B0C080912A9CE61A008E31A4 /* TripleStitchPattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TripleStitchPattern.swift; sourceTree = ""; }; + B0C080922A9CE61A008E31A4 /* StitchPatternProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StitchPatternProtocol.swift; sourceTree = ""; }; B11EA657D0D5E2E348790671 /* ta */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = ta; path = ta.lproj/Localizable.strings; sourceTree = ""; }; B46B270517703F9400172837 /* CattyTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CattyTests-Info.plist"; sourceTree = ""; }; B46B270717703F9400172837 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -4837,21 +4841,18 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 05CD096A26FABEB500B25D72 /* Pattern */ = { + 05744DEF25C84234005455F9 /* MultipleScenes */ = { isa = PBXGroup; children = ( - 05CBC6BC286C5A4B007FBA61 /* TripleStitchPattern.swift */, - 05CD095E26FA980600B25D72 /* StitchPatternProtocol.swift */, - 05CD096226FA989500B25D72 /* RunningStitchPattern.swift */, - 056677EC27DBD33E006B4477 /* ZigzagStitchPattern.swift */, + 05744E0925C8437C005455F9 /* MultipleScenes.xml */, ); - path = Pattern; + path = MultipleScenes; sourceTree = ""; }; 05E68011255B5DAA00D1E295 /* Embroidery */ = { isa = PBXGroup; children = ( - 05CD096A26FABEB500B25D72 /* Pattern */, + B0C0808E2A9CE573008E31A4 /* Pattern */, 05E68012255B5DAA00D1E295 /* EmbroideryStream.swift */, 05E68013255B5DAA00D1E295 /* EmbroideryDefines.swift */, 05E68014255B5DAA00D1E295 /* Stitch.swift */, @@ -5449,6 +5450,7 @@ children = ( C8076A26267A0B2000801AF6 /* Functions */, E5C5D89525B1DEAF00D96E4B /* Object */, + 05744DEF25C84234005455F9 /* MultipleScenes */, 9E384934256191DC002D8F28 /* SamplerBricks */, D3EBE87C2488E6A90026F51A /* GoToBricks */, D3AF5C1C243F81FC00B04BC6 /* DisabledBricks */, @@ -6125,6 +6127,7 @@ 4C2CBB3125A5AA8400C1C143 /* Helper */, 4C2CBB0825A5AA8400C1C143 /* UserListXMLHandlerTests.m */, 4C2CBB0725A5AA8400C1C143 /* SceneXMLHandlerTest.m */, + 05744DF825C84328005455F9 /* XMLParseMultipleScenesTests.swift */, ); path = XML; sourceTree = ""; @@ -10832,6 +10835,17 @@ name = Protocols; sourceTree = ""; }; + B0C0808E2A9CE573008E31A4 /* Pattern */ = { + isa = PBXGroup; + children = ( + B0C0808F2A9CE619008E31A4 /* RunningStitchPattern.swift */, + B0C080922A9CE61A008E31A4 /* StitchPatternProtocol.swift */, + B0C080912A9CE61A008E31A4 /* TripleStitchPattern.swift */, + B0C080902A9CE61A008E31A4 /* ZigzagStitchPattern.swift */, + ); + path = Pattern; + sourceTree = ""; + }; B43498471927A3AB002F9075 /* Resources */ = { isa = PBXGroup; children = ( @@ -11999,6 +12013,7 @@ E5EC6D5426B00FF60031F13A /* Galaxy_War_09993.xml in Resources */, 7B37463529AD168A0085A90D /* StoreProjectUploader.upload.fail.validation.json in Resources */, E59108B926931E49008D254A /* DisabledBricks_0994.xml in Resources */, + 05744E0A25C8437C005455F9 /* MultipleScenes.xml in Resources */, 2ED41875241120B000AFE2FD /* LedFlashBrick0991.xml in Resources */, E5DAAD6026C5486000C2457F /* ValidHeader09997.xml in Resources */, E598BBC226A029C900D4825F /* EscapingChars_0996.xml in Resources */, @@ -12568,6 +12583,7 @@ 9E2C2D8E23257387004B66C6 /* AbstractBrickTest.swift in Sources */, 49402BA528117A63009FCBF8 /* MiddleFingerSensorTest.swift in Sources */, 4CD487761ED2C2A3001BB80A /* ChangeVariableBrickTests.swift in Sources */, + 05744DF925C84328005455F9 /* XMLParseMultipleScenesTests.swift in Sources */, E57E6D85254040B400E775DF /* ChangeVolumeByNBrickTests.swift in Sources */, 2E8780A82542BCE200816B52 /* WebRequestBrickTests.swift in Sources */, 499EBFE127EB07A900897349 /* EyeSensorTest.swift in Sources */, @@ -12892,6 +12908,7 @@ 49402BB6281181D8009FCBF8 /* RightThumbKnuckleXSensor.swift in Sources */, 92D56C311BF202E700A54750 /* ArduinoDevice.swift in Sources */, F470A2E52129DF42005EC9A3 /* NumberOfItemsFunction.swift in Sources */, + B0C080932A9CE61A008E31A4 /* RunningStitchPattern.swift in Sources */, 49949B3F2806EAD20073BF65 /* RightShoulderXSensor.swift in Sources */, 498C158028070C6C00B81C8E /* RightAnkleYSensor.swift in Sources */, 92B46F9B1BC7BC8C004980C1 /* ArduinoSendDigitalValueBrick+CBXMLHandler.m in Sources */, @@ -13323,6 +13340,7 @@ 46F0D30E25E593F5002252E6 /* SetLookBrick+CBXMLHandler.swift in Sources */, 4CB2CFA61D7AD7E7009F3034 /* SetColorBrick+CBXMLHandler.m in Sources */, AA74EFEB1BC05B5F00D1E954 /* WaitBrick.m in Sources */, + B0C080952A9CE61A008E31A4 /* TripleStitchPattern.swift in Sources */, 4C0F9FA5204BD2C200E71B2D /* ThinkForBubbleBrickCell.m in Sources */, 4981EE3D289ACF740052AEB1 /* PoseNetModel.swift in Sources */, 4CDA808521366AEA0052FA24 /* FormulaManagerProtocol.swift in Sources */, @@ -13348,6 +13366,7 @@ F4E6E58E210E00E100D86FE6 /* ModFunction.swift in Sources */, 6F5ADF13247D4703008FC2C5 /* BrickExtension.swift in Sources */, 92FF30F81A24DCAA00093DA7 /* Formula.m in Sources */, + B0C080942A9CE61A008E31A4 /* ZigzagStitchPattern.swift in Sources */, 49402B9528116FA2009FCBF8 /* LeftIndexKnuckleXSensor.swift in Sources */, 59697DA4201F46AD00A0071A /* LibraryImageCollectionViewCell.swift in Sources */, AA74EFF41BC05B5F00D1E954 /* HideBrick.m in Sources */, @@ -13419,7 +13438,6 @@ F4201D0120D7A3B60030181B /* TimeSecondSensor.swift in Sources */, 92FF2EA11A24C7D800093DA7 /* TimerLabel.m in Sources */, 92FF30C81A24DCAA00093DA7 /* Brick.m in Sources */, - 05CD096326FA989500B25D72 /* RunningStitchPattern.swift in Sources */, 490F0F3A27DF71CC00D4778B /* LeftEyeCenterYSensor.swift in Sources */, AA74F0971BC05FCE00D1E954 /* BrickCellSoundData.m in Sources */, 92B46F911BC7B3E5004980C1 /* ArduinoBrick.m in Sources */, @@ -13471,6 +13489,7 @@ AA74EEE31BC057B900D1E954 /* NoteBrick+CBXMLHandler.m in Sources */, 49B55F7027E86315000A95B4 /* RightEyeInnerXSensor.swift in Sources */, 4CF0729A20D66C4800F93AB5 /* BackgroundNumberSensor.swift in Sources */, + B0C080962A9CE61A008E31A4 /* StitchPatternProtocol.swift in Sources */, 6F4B2FB72466704500B5F0ED /* ProjectMigrator.swift in Sources */, 4C724E5A1B4D3E8C00E27479 /* Project+CBXMLHandler.m in Sources */, 05E6801B255B5DAA00D1E295 /* EmbroideryDefines.swift in Sources */, @@ -13575,7 +13594,6 @@ AA74F0041BC05B5F00D1E954 /* PointInDirectionBrick.m in Sources */, 921D467C1BDF61350086AD20 /* ChangeYByNBrick+Instruction.swift in Sources */, 18E83F7F2493BFE6003295DA /* PenClearBrickCell.swift in Sources */, - 05CD095F26FA980600B25D72 /* StitchPatternProtocol.swift in Sources */, 4C595F4D21CAEBC50097D850 /* SmallerThanOperator.swift in Sources */, 929CC0EE1BC39B8C0027DEC0 /* PhiroMotorMoveForwardBrickCell.m in Sources */, 49402BB5281181D8009FCBF8 /* RightPinkyKnuckleYSensor.swift in Sources */, @@ -13753,7 +13771,6 @@ F4A2AFB52110D48C00C53234 /* JoinFunction.swift in Sources */, 4981EE3A289ACF1A0052AEB1 /* TextRecognitionManager.swift in Sources */, 92FF2E901A24C7D800093DA7 /* GDataXMLNode.m in Sources */, - 056677ED27DBD33E006B4477 /* ZigzagStitchPattern.swift in Sources */, F48E945920D6955E007E782E /* DateSensor.swift in Sources */, 92FF2E8F1A24C7D800093DA7 /* FlashHelper.m in Sources */, AA74F09B1BC05FCE00D1E954 /* BrickCell.m in Sources */, @@ -13824,7 +13841,6 @@ 9200C2D01C808206002F5CA4 /* ShowTextBrick+Instruction.swift in Sources */, 92FF31611A24DEB300093DA7 /* StagePresenterViewController.m in Sources */, 92B46FA21BC7BDF7004980C1 /* ArduinoSendDigitalValueBrickCell.m in Sources */, - 05CBC6BF286C5A4B007FBA61 /* TripleStitchPattern.swift in Sources */, 4981EE2A289ACEF90052AEB1 /* SecondFaceDetectedSensor.swift in Sources */, 929CC0ED1BC39B8C0027DEC0 /* PhiroMotorMoveBackwardBrickCell.m in Sources */, 49949B3A2806EAD20073BF65 /* LeftShoulderYSensor.swift in Sources */, diff --git a/src/Catty.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/src/Catty.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 3d1679ce50..b598db026f 100644 --- a/src/Catty.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/src/Catty.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -140,8 +140,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/google/gtm-session-fetcher.git", "state" : { - "revision" : "bc6a19702ac76ac4e488b68148710eb815f9bc56", - "version" : "1.7.0" + "revision" : "4e9bbf2808b8fee444e84a48f5f3c12641987d3e", + "version" : "1.7.2" } }, { diff --git a/src/Catty/DataModel/Project/Project.h b/src/Catty/DataModel/Project/Project.h index 3e053001aa..dae1a2d022 100644 --- a/src/Catty/DataModel/Project/Project.h +++ b/src/Catty/DataModel/Project/Project.h @@ -31,7 +31,9 @@ @interface Project : NSObject @property (nonatomic, strong, nonnull) Header *header; -@property (nonatomic, strong, nonnull) Scene *scene; +@property (nonatomic, strong, nonnull) NSMutableArray *scenes; +@property (nonatomic, strong, nonnull) Scene *scene DEPRECATED_ATTRIBUTE; //needed for compadability with "Old Parser" +@property (nonatomic, strong, nonnull) Scene *activeScene; @property (nonatomic, strong, nonnull) UserDataContainer *userData; @property (nonatomic, strong, nonnull) NSMutableSet *unsupportedElements; @property (nonatomic, strong, nonnull) NSMutableSet *physicsObjectNames; diff --git a/src/Catty/DataModel/Project/Project.m b/src/Catty/DataModel/Project/Project.m index a8acb15a9f..0fc8d3097f 100644 --- a/src/Catty/DataModel/Project/Project.m +++ b/src/Catty/DataModel/Project/Project.m @@ -42,6 +42,8 @@ - (instancetype)init { _allBroadcastMessages = [[NSMutableOrderedSet alloc] init]; } + self.scenes = [[NSMutableArray alloc] init]; + [self.scenes addObject: [[Scene alloc] init]]; return self; } @@ -153,7 +155,11 @@ - (void)renameToProjectName:(NSString*)projectName andProjectId:(NSString*)proje - (NSArray*)allObjects { - return self.scene.objects; + NSMutableArray *objects = [[NSMutableArray alloc] init]; + for (Scene* scene in self.scenes) { + [objects addObjectsFromArray: [scene objects]]; + } + return objects; } - (void)setDescription:(NSString*)description @@ -163,7 +169,9 @@ - (void)setDescription:(NSString*)description - (void)removeReferences { - [self.scene.objects makeObjectsPerformSelector:@selector(removeReferences)]; + for (Scene* scene in self.scenes){ + [scene.objects makeObjectsPerformSelector:@selector(removeReferences)]; + } } - (BOOL)isEqualToProject:(Project*)project @@ -172,14 +180,23 @@ - (BOOL)isEqualToProject:(Project*)project return NO; if (! [self.userData isEqual:project.userData]) return NO; - if (![self.scene isEqual:project.scene]) + if ([self.scenes count] != [project.scenes count]) return NO; + for (int i = 0; i < [self.scenes count]; ++i) { + if (![[self.scenes objectAtIndex: i] isEqual: [project.scenes objectAtIndex: i]]) + return NO; + } + return YES; } - (NSInteger)getRequiredResources { - return [self.scene getRequiredResources]; + NSInteger requiredResources = 0; + for (Scene* scene in self.scenes) { + requiredResources |= [scene getRequiredResources]; + } + return requiredResources; } #pragma mark - helpers @@ -204,7 +221,7 @@ - (NSString*)description [ret appendFormat:@"Screen Height: %@\n", self.header.screenHeight]; [ret appendFormat:@"Screen Width: %@\n", self.header.screenWidth]; [ret appendFormat:@"Screen Mode: %@\n", self.header.screenMode]; - [ret appendFormat:@"Scene: %@\n", self.scene]; + [ret appendFormat:@"First Scene: %@\n", [self.scenes objectAtIndex:0]]; [ret appendFormat:@"URL: %@\n", self.header.url]; [ret appendFormat:@"User Handle: %@\n", self.header.userHandle]; [ret appendFormat:@"Variables: %@\n", self.userData]; @@ -397,19 +414,21 @@ + (void)removeProjectFromDiskWithProjectName:(NSString*)projectName projectID:(N - (void)translateDefaultProject { - NSUInteger index = 0; - for (SpriteObject *spriteObject in self.scene.objects) { - if (index == kBackgroundObjectIndex) { - spriteObject.name = kLocalizedBackground; - } else { - NSMutableString *spriteObjectName = [NSMutableString stringWithString:spriteObject.name]; - [spriteObjectName replaceOccurrencesOfString:kDefaultProjectBundleOtherObjectsNamePrefix - withString:kLocalizedMole - options:NSCaseInsensitiveSearch - range:NSMakeRange(0, spriteObjectName.length)]; - spriteObject.name = (NSString*)spriteObjectName; + for (Scene* scene in self.scenes) { + NSUInteger index = 0; + for (SpriteObject *spriteObject in scene.objects) { + if (index == kBackgroundObjectIndex) { + spriteObject.name = kLocalizedBackground; + } else { + NSMutableString *spriteObjectName = [NSMutableString stringWithString:spriteObject.name]; + [spriteObjectName replaceOccurrencesOfString:kDefaultProjectBundleOtherObjectsNamePrefix + withString:kLocalizedMole + options:NSCaseInsensitiveSearch + range:NSMakeRange(0, spriteObjectName.length)]; + spriteObject.name = (NSString*)spriteObjectName; + } + ++index; } - ++index; } [self renameToProjectName:kLocalizedMyFirstProject andShowSaveNotification:NO]; // saves to disk! } diff --git a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/UIViewControllerExtension.swift b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/UIViewControllerExtension.swift index 78dd64a855..902aa6f2fe 100644 --- a/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/UIViewControllerExtension.swift +++ b/src/Catty/Extension&Delegate&Protocol/Extensions/UIViewController/UIViewControllerExtension.swift @@ -43,19 +43,21 @@ extension UIViewController { } @objc func openLoginScreen(_ delegate: AuthenticationDelegate? = nil) { - let storyboard = UIStoryboard.init(name: "iPhone", bundle: nil) - guard let viewController = storyboard.instantiateViewController(withIdentifier: "LoginController") as? LoginViewController else { return } - viewController.delegate = delegate - self.navigationController?.pushViewController(viewController, animated: true) - } + + guard let viewController = storyboard?.instantiateViewController(withIdentifier: "LoginController") as? LoginViewController else { return } + viewController.delegate = delegate + self.navigationController?.pushViewController(viewController, animated: true) + } @objc func openProject(_ project: Project) { guard let viewController = self.instantiateViewController("SceneTableViewController") as? SceneTableViewController else { return } - viewController.scene = project.scene + guard let scene = project.scenes[0] as? Scene else { return } + viewController.scene = scene project.setAsLastUsedProject() self.navigationController?.pushViewController(viewController, animated: true) - } + + } func openProjectDetails(projectId: String, storeProjectDownloader: StoreProjectDownloaderProtocol = StoreProjectDownloader()) { if let baseTableViewController = self as? BaseTableViewController { diff --git a/src/Catty/FormulaEditor/ViewController/FormulaEditorViewController.h b/src/Catty/FormulaEditor/ViewController/FormulaEditorViewController.h index e44e8bb184..23dd326246 100644 --- a/src/Catty/FormulaEditor/ViewController/FormulaEditorViewController.h +++ b/src/Catty/FormulaEditor/ViewController/FormulaEditorViewController.h @@ -54,7 +54,5 @@ - (void)backspace:(id)sender; - (NSString*)interpretFormula:(Formula*)formula forSpriteObject:(SpriteObject*)spriteObject; - (void)setParseErrorCursorAndSelection; - - (void)handleInput; - @end diff --git a/src/Catty/IO/ProjectManager.swift b/src/Catty/IO/ProjectManager.swift index c81c82f209..58d8265dd0 100644 --- a/src/Catty/IO/ProjectManager.swift +++ b/src/Catty/IO/ProjectManager.swift @@ -35,32 +35,34 @@ @objc func createProject(name: String, projectId: String?) -> Project { let project = Project() let projectName = Util.uniqueName(name, existingNames: Project.allProjectNames()) - project.scene = Scene(name: Util.defaultSceneName(forSceneNumber: 1)) - project.scene.project = project project.header = Header.default() project.header.programName = projectName project.header.programID = projectId + let scene = Scene(name: Util.defaultSceneName(forSceneNumber: 1)) + scene.project = project + if fileManager.directoryExists(projectName) == false { fileManager.createDirectory(project.projectPath()) } - let sceneDir = project.scene.path() + let sceneDir = scene.path() if !fileManager.directoryExists(sceneDir) { fileManager.createDirectory(sceneDir) } - let imagesDirName = project.scene.imagesPath() + let imagesDirName = scene.imagesPath() if fileManager.directoryExists(imagesDirName) == false { fileManager.createDirectory(imagesDirName) } - let soundDirName = project.scene.soundsPath() + let soundDirName = scene.soundsPath() if fileManager.directoryExists(soundDirName) == false { fileManager.createDirectory(soundDirName) } - project.scene.addObject(withName: kLocalizedBackground) + scene.addObject(withName: kLocalizedBackground) + project.scenes[0] = scene let filePath = project.projectPath() + kScreenshotAutoFilename let projectIconNames = UIDefines.defaultScreenshots @@ -172,7 +174,7 @@ } @objc func removeObjects(_ project: Project, objects: [SpriteObject]) { - let scene = project.scene + guard let scene = project.scenes[0] as? Scene else {return} for object in objects where scene.objects().contains(object) { scene.removeObject(object) } diff --git a/src/Catty/PlayerEngine/Frontend/CBFrontend.swift b/src/Catty/PlayerEngine/Frontend/CBFrontend.swift index 18f290750f..c5e82886fb 100644 --- a/src/Catty/PlayerEngine/Frontend/CBFrontend.swift +++ b/src/Catty/PlayerEngine/Frontend/CBFrontend.swift @@ -24,13 +24,11 @@ final class CBFrontend: CBFrontendProtocol { // MARK: - Properties let logger: CBLogger - private(set) weak var project: Project? private lazy var _sequenceFilters = [CBFrontendSequenceFilterProtocol]() // MARK: - Initializers - init(logger: CBLogger, project: Project?) { + init(logger: CBLogger) { self.logger = logger - self.project = project } // MARK: - Operations diff --git a/src/Catty/PlayerEngine/Protocols/CBFrontendProtocol.swift b/src/Catty/PlayerEngine/Protocols/CBFrontendProtocol.swift index 39a29b1f68..3615910299 100644 --- a/src/Catty/PlayerEngine/Protocols/CBFrontendProtocol.swift +++ b/src/Catty/PlayerEngine/Protocols/CBFrontendProtocol.swift @@ -22,9 +22,6 @@ protocol CBFrontendProtocol { - var project: Project? { get } - func computeSequenceListForScript(_ script: Script) -> CBScriptSequenceList func addSequenceFilter(_ sequenceFilter: CBFrontendSequenceFilterProtocol) - } diff --git a/src/Catty/PlayerEngine/Sensors/Object/LayerSensor.swift b/src/Catty/PlayerEngine/Sensors/Object/LayerSensor.swift index 1d29479223..a2330d1388 100644 --- a/src/Catty/PlayerEngine/Sensors/Object/LayerSensor.swift +++ b/src/Catty/PlayerEngine/Sensors/Object/LayerSensor.swift @@ -61,11 +61,11 @@ } static func defaultRawValue(for spriteObject: SpriteObject) -> Double { - guard let project = spriteObject.scene.project else { + guard let scene = spriteObject.scene else { return defaultRawValue } - let objectList = project.scene.objects() + let objectList = scene.objects() var zPosition = defaultRawValue for object in objectList { if object == spriteObject { diff --git a/src/Catty/PlayerEngine/Stage/Builder/StageBuilder.swift b/src/Catty/PlayerEngine/Stage/Builder/StageBuilder.swift index bac035aad3..8282df47a6 100644 --- a/src/Catty/PlayerEngine/Stage/Builder/StageBuilder.swift +++ b/src/Catty/PlayerEngine/Stage/Builder/StageBuilder.swift @@ -90,7 +90,12 @@ let audioEngine = getAudioEngine() let scheduler = getScheduler(broadcastHandler: broadcastHandler, formulaInterpreter: formulaManager, audioEngine: audioEngine) - return Stage(size: size, + guard let scene = project.scenes[0] as? Scene else { + preconditionFailure() + } + + return Stage(scene: scene, + size: size, logger: logger, scheduler: scheduler, frontend: frontend, @@ -125,7 +130,7 @@ private func getFrontend() -> CBFrontendProtocol { guard let frontend = self.frontend else { guard let frontendLogger = Swell.getLogger(LoggerConfig.PlayerFrontendID) else { preconditionFailure() } - let frontend = CBFrontend(logger: frontendLogger, project: project) + let frontend = CBFrontend(logger: frontendLogger) frontend.addSequenceFilter(CBFilterDisabled()) return frontend } diff --git a/src/Catty/PlayerEngine/Stage/Stage.swift b/src/Catty/PlayerEngine/Stage/Stage.swift index 31732b0e5d..9e0620e0bf 100644 --- a/src/Catty/PlayerEngine/Stage/Stage.swift +++ b/src/Catty/PlayerEngine/Stage/Stage.swift @@ -27,6 +27,7 @@ final class Stage: SKScene, StageProtocol { // MARK: - Properties final let scheduler: CBSchedulerProtocol + private final let CBScene: Scene private final let frontend: CBFrontendProtocol private final let backend: CBBackendProtocol private final let broadcastHandler: CBBroadcastHandlerProtocol @@ -35,7 +36,8 @@ final class Stage: SKScene, StageProtocol { private final let logger: CBLogger private var frameCounter: Int - init(size: CGSize, + init(scene: Scene, + size: CGSize, logger: CBLogger, scheduler: CBSchedulerProtocol, frontend: CBFrontendProtocol, @@ -43,6 +45,7 @@ final class Stage: SKScene, StageProtocol { broadcastHandler: CBBroadcastHandlerProtocol, formulaManager: FormulaManagerProtocol, soundEngine: AudioEngineProtocol) { + self.CBScene = scene self.logger = logger self.scheduler = scheduler self.frontend = frontend @@ -149,16 +152,12 @@ final class Stage: SKScene, StageProtocol { // MARK: - Start project @objc func startProject() -> Bool { - guard let project = frontend.project else { - //fatalError - debugPrint("Invalid project. This should never happen!") - return false - } - guard let spriteObjectList = project.scene.objects() as NSArray? as? [SpriteObject], + guard let spriteObjectList = CBScene.objects() as NSArray? as? [SpriteObject], + let project = CBScene.project, let variableList = UserDataContainer.allVariables(for: project) as NSArray? as? [UserVariable] else { //fatalError - debugPrint("!! Invalid sprite object list given !! This should never happen!") + debugPrint("!! Invalid scene or sprite object list given !! This should never happen!") return false } assert(Thread.current.isMainThread) @@ -302,7 +301,9 @@ final class Stage: SKScene, StageProtocol { DispatchQueue.main.async { self.removeAllChildren() // remove all CBSpriteNodes from Scene } - frontend.project?.removeReferences() // remove all references in project hierarchy + CBScene.objects().forEach { + $0.removeReferences() + } formulaManager.stop() logger.info("All SpriteObjects and Scripts have been removed from Scene!") soundEngine.stop() diff --git a/src/Catty/ViewController/Stage/StagePresenterViewController.m b/src/Catty/ViewController/Stage/StagePresenterViewController.m index 18e595bcc3..57f5f4e1a1 100644 --- a/src/Catty/ViewController/Stage/StagePresenterViewController.m +++ b/src/Catty/ViewController/Stage/StagePresenterViewController.m @@ -304,17 +304,6 @@ - (void)setupStageAndStart [self continueActionWithDuration:UIDefines.firstSwipeDuration]; } --(void)resaveLooks -{ - dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ - for (SpriteObject *object in self.project.scene.objects) { - for (Look *look in object.lookList) { - [[RuntimeImageCache sharedImageCache] loadImageFromDiskWithPath:look.fileName]; - } - } - }); -} - - (BOOL)prefersStatusBarHidden { return YES; @@ -367,7 +356,7 @@ - (void)continueActionWithDuration:(CGFloat)duration self.menuOpen = NO; self.menuView.userInteractionEnabled = YES; if (animateDuration == duration) { - [self takeAutomaticScreenshotForSKView:self.skView andProject:self.project.scene]; + [self takeAutomaticScreenshotForSKView:self.skView andScene:[self.project.scenes objectAtIndex:0]]; } }]; self.skView.paused = NO; @@ -454,7 +443,7 @@ - (void)aspectRatioAction - (void)takeScreenshotAction { - [self takeManualScreenshotForSKView:self.skView andProject:self.project.scene]; + [self takeManualScreenshotForSKView:self.skView andScene: [self.project.scenes objectAtIndex: 0]]; } - (void)shareDSTAction diff --git a/src/Catty/ViewController/Stage/StagePresenterViewControllerScreenshotExtension.swift b/src/Catty/ViewController/Stage/StagePresenterViewControllerScreenshotExtension.swift index 33e81ac4e1..b986827836 100644 --- a/src/Catty/ViewController/Stage/StagePresenterViewControllerScreenshotExtension.swift +++ b/src/Catty/ViewController/Stage/StagePresenterViewControllerScreenshotExtension.swift @@ -25,13 +25,13 @@ public static var previewImageWidth: CGFloat { UIScreen.main.bounds.width } public static var previewImageHeight: CGFloat { previewImageWidth } - @objc(takeAutomaticScreenshotForSKView: andProject:) + @objc(takeAutomaticScreenshotForSKView: andScene:) func takeAutomaticScreenshot(for skView: SKView, and scene: Scene) { guard let snapshot = self.screenshot(for: skView) else { return } saveScreenshot(snapshot, for: scene, manualScreenshot: false) } - @objc(takeManualScreenshotForSKView: andProject:) + @objc(takeManualScreenshotForSKView: andScene:) func takeManualScreenshot(for skView: SKView, and scene: Scene) { guard let snapshot = self.screenshot(for: skView) else { return } saveScreenshot(snapshot, for: scene, manualScreenshot: true) diff --git a/src/Catty/ViewController/Stage/StagePresenterViewControllerShareExtension.swift b/src/Catty/ViewController/Stage/StagePresenterViewControllerShareExtension.swift index 9ed5a21759..c982325419 100644 --- a/src/Catty/ViewController/Stage/StagePresenterViewControllerShareExtension.swift +++ b/src/Catty/ViewController/Stage/StagePresenterViewControllerShareExtension.swift @@ -29,7 +29,9 @@ extension StagePresenterViewController { func shareDST(embroideryService: EmbroideryProtocol) { var embroideryStream = [EmbroideryStream]() - for object in project.scene.objects() where !object.spriteNode.embroideryStream.isEmpty { + + guard let scene = project.scenes[0] as? Scene else {return} + for object in scene.objects() where !object.spriteNode.embroideryStream.isEmpty { embroideryStream.append(object.spriteNode.embroideryStream) } let embroideryStreamMerged = EmbroideryStream(streams: embroideryStream) diff --git a/src/Catty/XML/Old Parser/ProjectParser.m b/src/Catty/XML/Old Parser/ProjectParser.m index 74382c2ec0..7c6e7033b6 100644 --- a/src/Catty/XML/Old Parser/ProjectParser.m +++ b/src/Catty/XML/Old Parser/ProjectParser.m @@ -99,6 +99,7 @@ - (id)loadProject:(NSData*)xmlData { @try { NSInfo(@"Loading Project..."); project = [self parseNode:doc.rootElement withParent:nil]; + project.scenes[0] = project.scene; NSInfo(@"Loading done..."); } @catch(NSException* ex) { NSError(@"Project could not be loaded! %@", [ex description]); diff --git a/src/Catty/XML/XMLHandler/Project/Project+CBXMLHandler.m b/src/Catty/XML/XMLHandler/Project/Project+CBXMLHandler.m index fe27370336..7a70426517 100644 --- a/src/Catty/XML/XMLHandler/Project/Project+CBXMLHandler.m +++ b/src/Catty/XML/XMLHandler/Project/Project+CBXMLHandler.m @@ -42,25 +42,24 @@ + (instancetype)parseFromElement:(GDataXMLElement*)xmlElement withContext:(CBXML [XMLError exceptionIfNode:xmlElement isNilOrNodeNameNotEquals:@"program"]; [XMLError exceptionIfNil:context message:@"No context given!"]; Project *project = [Project new]; + [project.scenes removeAllObjects]; // IMPORTANT: DO NOT CHANGE ORDER HERE!! project.header = [self parseAndCreateHeaderFromElement:xmlElement withContext:context]; project.userData = [self parseAndCreateVariablesFromElement:xmlElement withContext:context]; if ([xmlElement childWithElementName:@"scenes"]) { - Scene *scene = [self parseAndCreateSceneFromElement:xmlElement withContext:context]; - scene.project = project; - project.scene = scene; + [self parseAndCreateSceneFromElement:xmlElement ofProject:project withContext:context]; } else { - project.scene = [[Scene alloc] initWithName: [Util defaultSceneNameForSceneNumber:1]]; - project.scene.project = project; + Scene *scene = [[Scene alloc] initWithName: [Util defaultSceneNameForSceneNumber:1]]; + project.scenes[0] = scene; + scene.project = project; for (SpriteObject *object in [Scene parseAndCreateObjectsFromElement:xmlElement withContext:context]) { //when project will contain [scenes] then object.scene will be equal to scene where the objects belongs to - object.scene = project.scene; + object.scene = scene; object.scene.project = project; //when project will contain [scenes] then object will be added to the scene where it belongs and add scene to [scene] of project - [project.scene addObject:object]; + [scene addObject:object]; } } - return project; } @@ -93,7 +92,8 @@ + (SpriteObject *)getSpriteObject:(NSString*)spriteName withContext:(CBXMLParser return object; } -+ (Scene *)parseAndCreateSceneFromElement:(GDataXMLElement*)projectElement withContext:(CBXMLParserContext*)context ++ (void)parseAndCreateSceneFromElement:(GDataXMLElement*)projectElement + ofProject: (Project*)project withContext:(CBXMLParserContext*)context { NSArray *scenesElements = [projectElement elementsForName:@"scenes"]; [XMLError exceptionIf:[scenesElements count] notEquals:1 message:@"No scenes given!"]; @@ -102,17 +102,23 @@ + (Scene *)parseAndCreateSceneFromElement:(GDataXMLElement*)projectElement withC message:@"No scene in scenes, but there must exist "\ "at least 1 scene!!"]; - GDataXMLElement *sceneElement = [sceneElements firstObject]; - Scene *scene = [context parseFromElement:sceneElement withClass:[Scene class]]; - - return scene; + for (GDataXMLElement *sceneElement in sceneElements) { + Scene* scene = [context parseFromElement:sceneElement withClass:[Scene class]]; + scene.project = project; + [project.scenes addObject: scene]; + [context.spriteObjectList removeAllObjects]; + [context.pointedSpriteObjectList removeAllObjects]; + } + return; } #pragma mark - Serialization - (GDataXMLElement*)xmlElementWithContext:(CBXMLSerializerContext*)context { + Scene* scene = [self.scenes objectAtIndex:0]; + // update context object - context.spriteObjectList = [[NSMutableArray alloc] initWithArray:self.scene.objects]; + context.spriteObjectList = [[NSMutableArray alloc] initWithArray: scene.objects]; // generate xml element for program GDataXMLElement *xmlElement = [GDataXMLElement elementWithName:@"program" context:context]; @@ -122,7 +128,7 @@ - (GDataXMLElement*)xmlElementWithContext:(CBXMLSerializerContext*)context [xmlElement addChild:[GDataXMLElement elementWithName:@"settings" context:nil]]; GDataXMLElement *scenes = [GDataXMLElement elementWithName:@"scenes" context:context]; - [scenes addChild:[self.scene xmlElementWithContext:context] context:context]; + [scenes addChild:[scene xmlElementWithContext:context] context:context]; [xmlElement addChild:scenes context:context]; if (self.userData) { diff --git a/src/CattyTests/Bricks/AskBrickTests.swift b/src/CattyTests/Bricks/AskBrickTests.swift index c56cdf7e2c..c6f5f6a16c 100644 --- a/src/CattyTests/Bricks/AskBrickTests.swift +++ b/src/CattyTests/Bricks/AskBrickTests.swift @@ -46,7 +46,7 @@ final class AskBrickTests: XCTestCase { spriteNode = CBSpriteNode(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/Bricks/BubbleBrickTests.swift b/src/CattyTests/Bricks/BubbleBrickTests.swift index 7431bc8b88..cc098faf80 100644 --- a/src/CattyTests/Bricks/BubbleBrickTests.swift +++ b/src/CattyTests/Bricks/BubbleBrickTests.swift @@ -50,12 +50,12 @@ final class BubbleBrickTests: XMLAbstractTest { spriteObject.scene = scene spriteObject.name = "SpriteObjectName" - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! let spriteNode = CBSpriteNodeMock(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene.add(object: spriteObject) + (project.scenes[0] as! Scene).add(object: spriteObject) spriteNode.mockedStage = StageBuilder(project: ProjectMock(width: CGFloat(kIphoneXStageWidth), andHeight: CGFloat(kIphoneXStageHeight))).build() BubbleBrickHelper.addBubble(to: spriteNode, withText: sentence, andType: CBBubbleType.thought) diff --git a/src/CattyTests/Bricks/ChangeBrightnessByNBrickTests.swift b/src/CattyTests/Bricks/ChangeBrightnessByNBrickTests.swift index cef05433a4..6302a2dd62 100644 --- a/src/CattyTests/Bricks/ChangeBrightnessByNBrickTests.swift +++ b/src/CattyTests/Bricks/ChangeBrightnessByNBrickTests.swift @@ -38,7 +38,7 @@ final class ChangeBrightnessByNBrickTests: AbstractBrickTest { script = WhenScript() object = SpriteObject() project = ProjectManager.shared.createProject(name: "a", projectId: "1") - object.scene = project.scene + object.scene = (project.scenes[0] as! Scene) spriteNode = CBSpriteNode.init(spriteObject: object) object.spriteNode = spriteNode object.scene.project = project diff --git a/src/CattyTests/Bricks/ChangeColorByNBrickTests.swift b/src/CattyTests/Bricks/ChangeColorByNBrickTests.swift index 03af184688..d3a87d1c2a 100644 --- a/src/CattyTests/Bricks/ChangeColorByNBrickTests.swift +++ b/src/CattyTests/Bricks/ChangeColorByNBrickTests.swift @@ -38,7 +38,7 @@ final class ChangeColorByNBrickTests: AbstractBrickTest { script = WhenScript() object = SpriteObject() project = ProjectManager.shared.createProject(name: "a", projectId: "1") - object.scene = project.scene + object.scene = (project.scenes[0] as! Scene) spriteNode = CBSpriteNode(spriteObject: object) object.spriteNode = spriteNode object.scene.project = project diff --git a/src/CattyTests/Bricks/ChangeVariableBrickTests.swift b/src/CattyTests/Bricks/ChangeVariableBrickTests.swift index f484f854cf..aacbcf2987 100644 --- a/src/CattyTests/Bricks/ChangeVariableBrickTests.swift +++ b/src/CattyTests/Bricks/ChangeVariableBrickTests.swift @@ -38,7 +38,7 @@ final class ChangeVariableBrickTests: XCTestCase { let scene = Scene(name: "testScene") spriteObject = SpriteObject() spriteObject.scene = scene - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! spriteObject.name = "SpriteObjectName" spriteNode = CBSpriteNode(spriteObject: spriteObject) diff --git a/src/CattyTests/Bricks/ChooseCameraBrickTests.swift b/src/CattyTests/Bricks/ChooseCameraBrickTests.swift index a2bbf74797..bd94a84c5e 100644 --- a/src/CattyTests/Bricks/ChooseCameraBrickTests.swift +++ b/src/CattyTests/Bricks/ChooseCameraBrickTests.swift @@ -44,7 +44,7 @@ final class ChooseCameraBrickTests: XCTestCase { spriteNode = CBSpriteNode(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/Bricks/ClearGraphicEffectBrickTests.swift b/src/CattyTests/Bricks/ClearGraphicEffectBrickTests.swift index cc44af9493..4dc4324aec 100644 --- a/src/CattyTests/Bricks/ClearGraphicEffectBrickTests.swift +++ b/src/CattyTests/Bricks/ClearGraphicEffectBrickTests.swift @@ -36,7 +36,7 @@ final class ClearGraphicEffectBrickTests: AbstractBrickTest { super.setUp() object = SpriteObject() project = ProjectManager.shared.createProject(name: "a", projectId: "1") - object.scene = project.scene + object.scene = (project.scenes[0] as! Scene) spriteNode = CBSpriteNode.init(spriteObject: object) object.spriteNode = spriteNode self.stage.addChild(spriteNode) diff --git a/src/CattyTests/Bricks/ComeToFrontBrickTests.swift b/src/CattyTests/Bricks/ComeToFrontBrickTests.swift index f42369fa45..eb5085ae6b 100644 --- a/src/CattyTests/Bricks/ComeToFrontBrickTests.swift +++ b/src/CattyTests/Bricks/ComeToFrontBrickTests.swift @@ -30,7 +30,7 @@ final class ComeToFrontBrickTests: AbstractBrickTest { let project = Project() let scene = Scene(name: "testScene") scene.project = project - project.scene = scene + project.scenes[0] = scene let background = SpriteObject() background.scene = scene @@ -49,9 +49,9 @@ final class ComeToFrontBrickTests: AbstractBrickTest { object2.spriteNode = spriteNode2 spriteNode2.zPosition = 2 - project.scene.add(object: background) - project.scene.add(object: object1) - project.scene.add(object: object2) + (project.scenes[0] as! Scene).add(object: background) + (project.scenes[0] as! Scene).add(object: object1) + (project.scenes[0] as! Scene).add(object: object2) let script = WhenScript() script.object = object1 diff --git a/src/CattyTests/Bricks/DeleteItemOfUserListBrickTests.swift b/src/CattyTests/Bricks/DeleteItemOfUserListBrickTests.swift index ea2ac947f9..15bb013492 100644 --- a/src/CattyTests/Bricks/DeleteItemOfUserListBrickTests.swift +++ b/src/CattyTests/Bricks/DeleteItemOfUserListBrickTests.swift @@ -45,7 +45,7 @@ final class DeleteItemOfUserListBrickTests: XCTestCase { spriteNode = CBSpriteNode(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/Bricks/GoNStepsBackBrickTests.swift b/src/CattyTests/Bricks/GoNStepsBackBrickTests.swift index b1ed9fe031..310e6b1b65 100644 --- a/src/CattyTests/Bricks/GoNStepsBackBrickTests.swift +++ b/src/CattyTests/Bricks/GoNStepsBackBrickTests.swift @@ -40,7 +40,7 @@ final class GoNStepsBackBrickTests: AbstractBrickTest { project = Project() let scene = Scene(name: "testScene") scene.project = project - project.scene = scene + project.scenes[0] = scene object1 = SpriteObject() object1.scene = scene @@ -52,8 +52,8 @@ final class GoNStepsBackBrickTests: AbstractBrickTest { spriteNode2 = CBSpriteNode(spriteObject: object2) object2.spriteNode = spriteNode2 - project.scene.add(object: object1!) - project.scene.add(object: object2!) + (project.scenes[0] as! Scene).add(object: object1!) + (project.scenes[0] as! Scene).add(object: object2!) script = WhenScript() script.object = object1 diff --git a/src/CattyTests/Bricks/HideTextBrickTests.swift b/src/CattyTests/Bricks/HideTextBrickTests.swift index 35131fb398..07bf0e4e12 100644 --- a/src/CattyTests/Bricks/HideTextBrickTests.swift +++ b/src/CattyTests/Bricks/HideTextBrickTests.swift @@ -44,7 +44,7 @@ final class HideTextBrickTests: XCTestCase { spriteNode = CBSpriteNode(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/Bricks/InsertItemIntoUserListBrickTests.swift b/src/CattyTests/Bricks/InsertItemIntoUserListBrickTests.swift index 24cd61e6fa..fd44b33c6e 100644 --- a/src/CattyTests/Bricks/InsertItemIntoUserListBrickTests.swift +++ b/src/CattyTests/Bricks/InsertItemIntoUserListBrickTests.swift @@ -45,7 +45,7 @@ final class InsertItemIntoUserListBrickTests: XCTestCase { spriteNode = CBSpriteNode(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/Bricks/NextLookBrickTests.swift b/src/CattyTests/Bricks/NextLookBrickTests.swift index 60fa70e94c..572a6acf50 100644 --- a/src/CattyTests/Bricks/NextLookBrickTests.swift +++ b/src/CattyTests/Bricks/NextLookBrickTests.swift @@ -30,11 +30,18 @@ final class NextLookBrickTests: AbstractBrickTest { var lookB: Look! var lookC: Look! var image: UIImage! - var scene: Scene! var spriteNode: CBSpriteNode! var script: Script! + func testNextLookBrick() { + let object = SpriteObject() + let project = ProjectManager.shared.createProject(name: "a", projectId: "1") + object.scene = (project.scenes[0] as! Scene) + let spriteNode = CBSpriteNode(spriteObject: object) + object.spriteNode = spriteNode + } + override func setUp() { super.setUp() diff --git a/src/CattyTests/Bricks/PreviousLookBrickTests.swift b/src/CattyTests/Bricks/PreviousLookBrickTests.swift index 40a1ca1599..51b985516f 100644 --- a/src/CattyTests/Bricks/PreviousLookBrickTests.swift +++ b/src/CattyTests/Bricks/PreviousLookBrickTests.swift @@ -30,11 +30,18 @@ final class PreviousLookBrickTests: AbstractBrickTest { var lookB: Look! var lookC: Look! var image: UIImage! - var scene: Scene! var spriteNode: CBSpriteNode! var script: Script! + func testNextLookBrick() { + let object = SpriteObject() + let project = ProjectManager.shared.createProject(name: "a", projectId: "1") + object.scene = (project.scenes[0] as! Scene) + let spriteNode = CBSpriteNode(spriteObject: object) + object.spriteNode = spriteNode + } + override func setUp() { super.setUp() diff --git a/src/CattyTests/Bricks/ReplaceItemInUserListBrickTests.swift b/src/CattyTests/Bricks/ReplaceItemInUserListBrickTests.swift index 9bba7a757f..6f16770c67 100644 --- a/src/CattyTests/Bricks/ReplaceItemInUserListBrickTests.swift +++ b/src/CattyTests/Bricks/ReplaceItemInUserListBrickTests.swift @@ -45,7 +45,7 @@ final class ReplaceItemInUserListBrickTests: XCTestCase { spriteNode = CBSpriteNode(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/Bricks/SetBackgroundByIndexBrickTests.swift b/src/CattyTests/Bricks/SetBackgroundByIndexBrickTests.swift index 6df74fdd80..9fabd9f9f8 100644 --- a/src/CattyTests/Bricks/SetBackgroundByIndexBrickTests.swift +++ b/src/CattyTests/Bricks/SetBackgroundByIndexBrickTests.swift @@ -40,8 +40,9 @@ final class SetBackgroundByIndexBrickTest: XCTestCase { override func setUp() { project = ProjectManager.shared.createProject(name: "setBackgroundByIndexTest", projectId: "1") - spriteObject = project.scene.object(at: 0) - spriteObject.scene = project.scene + spriteObject = (project.scenes[0] as! Scene).object(at: 0) + //guard let scene = project.scenes[0] as? Scene else {XCTFail("No scene found."); return} + spriteObject.scene = project.scenes[0] as? Scene spriteObject.name = "SpriteObjectName" spriteNode = CBSpriteNode(spriteObject: spriteObject) diff --git a/src/CattyTests/Bricks/SetBrightnessBrickTests.swift b/src/CattyTests/Bricks/SetBrightnessBrickTests.swift index af7a844aec..06e731d270 100644 --- a/src/CattyTests/Bricks/SetBrightnessBrickTests.swift +++ b/src/CattyTests/Bricks/SetBrightnessBrickTests.swift @@ -39,7 +39,7 @@ final class SetBrightnessBrickTests: AbstractBrickTest { object = SpriteObject() project = ProjectManager.shared.createProject(name: "a", projectId: "1") - object.scene = project.scene + object.scene = (project.scenes[0] as! Scene) spriteNode = CBSpriteNode.init(spriteObject: object) object.spriteNode = spriteNode diff --git a/src/CattyTests/Bricks/SetColorBrickTests.swift b/src/CattyTests/Bricks/SetColorBrickTests.swift index 46e89a9238..e68f7f8ec7 100644 --- a/src/CattyTests/Bricks/SetColorBrickTests.swift +++ b/src/CattyTests/Bricks/SetColorBrickTests.swift @@ -39,7 +39,7 @@ final class SetColorBrickTests: AbstractBrickTest { object = SpriteObject() project = ProjectManager.shared.createProject(name: "a", projectId: "1") - object.scene = project.scene + object.scene = (project.scenes[0] as! Scene) spriteNode = CBSpriteNode.init(spriteObject: object) object.spriteNode = spriteNode diff --git a/src/CattyTests/Bricks/SetLookBrickTests.swift b/src/CattyTests/Bricks/SetLookBrickTests.swift index 81f562caf1..9de70174ee 100644 --- a/src/CattyTests/Bricks/SetLookBrickTests.swift +++ b/src/CattyTests/Bricks/SetLookBrickTests.swift @@ -53,7 +53,6 @@ final class SetLookBrickTests: AbstractBrickTest { object.lookList.add(lookA!) object.lookList.add(lookB!) - spriteNode = CBSpriteNode(spriteObject: object) object.spriteNode = spriteNode diff --git a/src/CattyTests/Bricks/SetLookByIndexBrickTests.swift b/src/CattyTests/Bricks/SetLookByIndexBrickTests.swift index 5b8842ba59..c8a858604b 100644 --- a/src/CattyTests/Bricks/SetLookByIndexBrickTests.swift +++ b/src/CattyTests/Bricks/SetLookByIndexBrickTests.swift @@ -41,7 +41,7 @@ final class SetLookByIndexBrickTest: XCTestCase { override func setUp() { project = ProjectManager.shared.createProject(name: "setLookByIndexTest", projectId: "1") spriteObject = SpriteObject() - spriteObject.scene = project.scene + spriteObject.scene = (project.scenes[0] as! Scene) spriteObject.name = "SpriteObjectName" spriteNode = CBSpriteNode(spriteObject: spriteObject) diff --git a/src/CattyTests/Bricks/SetVariableBrickTests.swift b/src/CattyTests/Bricks/SetVariableBrickTests.swift index e060993cbb..ebd3d4658f 100644 --- a/src/CattyTests/Bricks/SetVariableBrickTests.swift +++ b/src/CattyTests/Bricks/SetVariableBrickTests.swift @@ -45,7 +45,7 @@ final class SetVariableBrickTests: XCTestCase { spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/Bricks/ShowTextBrickTests.swift b/src/CattyTests/Bricks/ShowTextBrickTests.swift index 16f58089c4..a5f76e4603 100644 --- a/src/CattyTests/Bricks/ShowTextBrickTests.swift +++ b/src/CattyTests/Bricks/ShowTextBrickTests.swift @@ -46,7 +46,7 @@ final class ShowTextBrickTests: XCTestCase { spriteObject.spriteNode = spriteNode spriteObject.scene.project = project - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! script = Script() script.object = spriteObject diff --git a/src/CattyTests/CBSpriteNodePhysicsTests.swift b/src/CattyTests/CBSpriteNodePhysicsTests.swift index 2a6b598381..53c4d73d31 100644 --- a/src/CattyTests/CBSpriteNodePhysicsTests.swift +++ b/src/CattyTests/CBSpriteNodePhysicsTests.swift @@ -35,18 +35,23 @@ final class CBSpriteNodePhysicsTests: XMLAbstractTest { func testPhysicsBodyRightAmountPhysicsObjectNames() { let project = getProjectForXML(xmlFile: "collisionTest0993") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] - project.scene.object(at: 3)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] + scene.object(at: 3)?.lookList = [look] let stage = createStage(project: project) let started = stage.startProject() XCTAssertTrue(started) - XCTAssertEqual(project.scene.objects().count, 4) + XCTAssertEqual(scene.objects().count, 4) XCTAssertEqual(project.physicsObjectNames.count, 2) XCTAssertTrue(project.physicsObjectNames.contains("obj1")) XCTAssertTrue(project.physicsObjectNames.contains("obj2")) @@ -57,11 +62,15 @@ final class CBSpriteNodePhysicsTests: XMLAbstractTest { func testPhysicsObjectsNamesManuallySet() { let project = getProjectForXML(xmlFile: "collisionTest0993") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] - project.scene.object(at: 3)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] + scene.object(at: 3)?.lookList = [look] let stage = createStage(project: project) @@ -72,15 +81,15 @@ final class CBSpriteNodePhysicsTests: XMLAbstractTest { XCTAssertTrue(started) - XCTAssertEqual(project.scene.objects().count, 4) + XCTAssertEqual(scene.objects().count, 4) XCTAssertEqual(project.physicsObjectNames.count, 1) XCTAssertTrue(project.physicsObjectNames.contains("obj3")) - var physicsNode = project.scene.object(at: 1)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + var physicsNode = scene.object(at: 1)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) XCTAssertNil(physicsNode) - physicsNode = project.scene.object(at: 2)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + physicsNode = scene.object(at: 2)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) XCTAssertNil(physicsNode) - physicsNode = project.scene.object(at: 3)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + physicsNode = scene.object(at: 3)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) XCTAssertNotNil(physicsNode) for child in physicsNode!.children { XCTAssertNotNil(child.physicsBody) @@ -92,26 +101,31 @@ final class CBSpriteNodePhysicsTests: XMLAbstractTest { func testPhysicsBodyRightAmountChildNotes() { let project = getProjectForXML(xmlFile: "collisionTest0993") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] let stage = createStage(project: project) let started = stage.startProject() XCTAssertTrue(started) - var supernode = project.scene.object(at: 1)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) - var size = project.scene.object(at: 1)!.spriteNode.size + var supernode = scene.object(at: 1)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + var size = scene.object(at: 1)!.spriteNode.size var amountNodes = Int((size.height > size.width ? size.height / CGFloat(SpriteKitDefines.physicsSubnodeSize) : size.width / CGFloat(SpriteKitDefines.physicsSubnodeSize) ).rounded(.up)) XCTAssertEqual(supernode?.children.count, amountNodes * amountNodes) - supernode = project.scene.object(at: 2)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) - size = project.scene.object(at: 2)!.spriteNode.size + supernode = scene.object(at: 2)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + size = scene.object(at: 2)!.spriteNode.size amountNodes = Int((size.height > size.width ? size.height / CGFloat(SpriteKitDefines.physicsSubnodeSize) : size.width / CGFloat(SpriteKitDefines.physicsSubnodeSize) @@ -124,29 +138,33 @@ final class CBSpriteNodePhysicsTests: XMLAbstractTest { func testRightAmountPhysicsBodys() { let project = getProjectForXML(xmlFile: "collisionTest0993") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] - project.scene.object(at: 3)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] + scene.object(at: 3)?.lookList = [look] let stage = createStage(project: project) let started = stage.startProject() XCTAssertTrue(started) - XCTAssertEqual(project.scene.objects().count, 4) - var physicsNode = project.scene.object(at: 1)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + XCTAssertEqual(scene.objects().count, 4) + var physicsNode = scene.object(at: 1)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) XCTAssertNotNil(physicsNode) for child in physicsNode!.children { XCTAssertNotNil(child.physicsBody) } - physicsNode = project.scene.object(at: 2)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + physicsNode = scene.object(at: 2)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) XCTAssertNotNil(physicsNode) for child in physicsNode!.children { XCTAssertNotNil(child.physicsBody) } - physicsNode = project.scene.object(at: 3)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) + physicsNode = scene.object(at: 3)?.spriteNode.childNode(withName: SpriteKitDefines.physicsNodeName) XCTAssertNil(physicsNode) stage.stopProject() diff --git a/src/CattyTests/DataModel/LookTest.swift b/src/CattyTests/DataModel/LookTest.swift index 9bb2e9c83b..87013561e7 100644 --- a/src/CattyTests/DataModel/LookTest.swift +++ b/src/CattyTests/DataModel/LookTest.swift @@ -26,25 +26,22 @@ import XCTest final class LookTest: XCTestCase { - var project: Project! - var scene: Scene! - - override func setUp() { - project = Project() - scene = Scene(name: "testScene") - - project.scene = scene - scene.project = project - } - func testPathForScene() { + let project = Project() + let scene = Scene(name: "testScene") + project.scenes[0] = scene + scene.project = project let look = Look(name: "testLook", filePath: "testLookFile") - let expectedPath = project.projectPath() + "testScene/images/testLookFile" XCTAssertEqual(expectedPath, look.path(for: scene)) } func testIsEqual() { + let project = Project() + let scene = Scene(name: "testScene") + project.scenes[0] = scene + scene.project = project + let look = Look(name: "testLook", filePath: "testLookFile") let equalLook = Look(name: "testLook", filePath: "testLookFile") @@ -64,9 +61,9 @@ final class LookTest: XCTestCase { func testInitWithPath() { let object = SpriteObject() - object.scene = scene - - let spriteNode = CBSpriteNode(spriteObject: object) + let project = ProjectManager.shared.createProject(name: "a", projectId: "1") + object.scene = (project.scenes[0] as! Scene) + let spriteNode = CBSpriteNode.init(spriteObject: object) object.spriteNode = spriteNode let bundle = Bundle(for: type(of: self)) @@ -82,9 +79,9 @@ final class LookTest: XCTestCase { func testInitWithName() { let object = SpriteObject() - object.scene = scene - - let spriteNode = CBSpriteNode(spriteObject: object) + let project = ProjectManager.shared.createProject(name: "a", projectId: "1") + object.scene = (project.scenes[0] as! Scene) + let spriteNode = CBSpriteNode.init(spriteObject: object) object.spriteNode = spriteNode let bundle = Bundle(for: type(of: self)) diff --git a/src/CattyTests/DataModel/SoundTest.swift b/src/CattyTests/DataModel/SoundTest.swift index 920a49d420..f734ff10b7 100644 --- a/src/CattyTests/DataModel/SoundTest.swift +++ b/src/CattyTests/DataModel/SoundTest.swift @@ -29,7 +29,7 @@ final class SoundTest: XCTestCase { func testPathForScene() { let project = Project() let scene = Scene(name: "testScene") - project.scene = scene + project.scenes[0] = scene scene.project = project let sound = Sound(name: "testSound", fileName: "testSoundFile") diff --git a/src/CattyTests/DataModel/UserDataContainerTest.swift b/src/CattyTests/DataModel/UserDataContainerTest.swift index e112030b7b..f04bee3eb7 100644 --- a/src/CattyTests/DataModel/UserDataContainerTest.swift +++ b/src/CattyTests/DataModel/UserDataContainerTest.swift @@ -39,7 +39,7 @@ final class UserDataContainerTest: XCTestCase { let scene = Scene(name: "testScene") - self.project.scene = scene + self.project.scenes[0] = scene self.objectA = SpriteObject() self.objectA.scene = scene @@ -51,10 +51,10 @@ final class UserDataContainerTest: XCTestCase { self.objectB.scene = scene self.objectB.scene.project = self.project - self.project.scene.add(object: objectA) - self.project.scene.add(object: objectB) + (self.project.scenes[0] as! Scene).add(object: objectA) + (self.project.scenes[0] as! Scene).add(object: objectB) - self.project.scene = objectA.scene + self.project.scenes[0] = objectA.scene! } func testAddObjectVariable() { @@ -353,25 +353,25 @@ final class UserDataContainerTest: XCTestCase { } func testMutableCopy() { - let list = UserList(name: "testList") - let variable = UserVariable(name: "testvariable") + let list = UserList(name: "testList") + let variable = UserVariable(name: "testvariable") - container.add(list) - container.add(variable) + container.add(list) + container.add(variable) - let copyContainer = container.mutableCopy(with: CBMutableCopyContext()) as! UserDataContainer - XCTAssertFalse(container === copyContainer) + let copyContainer = container.mutableCopy(with: CBMutableCopyContext()) as! UserDataContainer + XCTAssertFalse(container === copyContainer) - let copiedVariables = copyContainer.variables() - XCTAssertEqual(1, copiedVariables.count) - XCTAssertEqual(variable, copiedVariables[0]) - XCTAssertTrue(copiedVariables[0] === variable) + let copiedVariables = copyContainer.variables() + XCTAssertEqual(1, copiedVariables.count) + XCTAssertEqual(variable, copiedVariables[0]) + XCTAssertTrue(copiedVariables[0] === variable) - let copiedLists = copyContainer.lists() - XCTAssertEqual(1, copiedLists.count) - XCTAssertEqual(list, copiedLists[0]) - XCTAssertTrue(copiedLists[0] === list) - } + let copiedLists = copyContainer.lists() + XCTAssertEqual(1, copiedLists.count) + XCTAssertEqual(list, copiedLists[0]) + XCTAssertTrue(copiedLists[0] === list) + } func testMutableCopyWithUpdatedReferences() { let context = CBMutableCopyContext() diff --git a/src/CattyTests/Extensions/UIViewControllerExtensionTests.swift b/src/CattyTests/Extensions/UIViewControllerExtensionTests.swift index 3fa6ffb4df..cf8fe435e4 100644 --- a/src/CattyTests/Extensions/UIViewControllerExtensionTests.swift +++ b/src/CattyTests/Extensions/UIViewControllerExtensionTests.swift @@ -51,7 +51,7 @@ final class UIViewControllerExtensionTests: XCTestCase { let scene = Scene(name: "testScene") scene.project = project - project.scene = scene + project.scenes[0] = scene XCTAssertFalse(project.isLastUsedProject) diff --git a/src/CattyTests/FileManager/ProjectManagerTests.swift b/src/CattyTests/FileManager/ProjectManagerTests.swift index 17834431cf..84320e9845 100644 --- a/src/CattyTests/FileManager/ProjectManagerTests.swift +++ b/src/CattyTests/FileManager/ProjectManagerTests.swift @@ -357,13 +357,13 @@ final class ProjectManagerTests: XCTestCase { let object3 = SpriteObject() object3.name = "testObject3" scene.add(object: object3) - project.scene = scene + project.scenes[0] = scene XCTAssertEqual(3, scene.objects().count) projectManager.removeObjects(project, objects: [object1, object2]) - XCTAssertEqual(1, project.scene.objects().count) + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count) XCTAssertEqual(object3, scene.objects()[0]) } } diff --git a/src/CattyTests/Object/CollisionFunctionTest.swift b/src/CattyTests/Object/CollisionFunctionTest.swift index 49634025f6..91496ec0e3 100644 --- a/src/CattyTests/Object/CollisionFunctionTest.swift +++ b/src/CattyTests/Object/CollisionFunctionTest.swift @@ -40,10 +40,14 @@ final class CollisionFunctionTests: XMLAbstractTest { let project = getProjectForXML(xmlFile: "collisionTest0993") let collisionVar = project.userData.getUserVariable(identifiedBy: "collisionVar") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] let stage = createStage(project: project) let started = stage.startProject() @@ -58,15 +62,19 @@ final class CollisionFunctionTests: XMLAbstractTest { let project = getProjectForXML(xmlFile: "collisionTest0993") let collisionVar = project.userData.getUserVariable(identifiedBy: "collisionVar") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] let stage = createStage(project: project) let started = stage.startProject() - project.scene.object(at: 2)?.spriteNode.position = CGPoint(x: 200, y: 200) + scene.object(at: 2)?.spriteNode.position = CGPoint(x: 200, y: 200) XCTAssertTrue(started) expect(collisionVar?.value as? Int).toEventually(equal(noCollision), timeout: .seconds(5)) @@ -78,21 +86,25 @@ final class CollisionFunctionTests: XMLAbstractTest { let project = getProjectForXML(xmlFile: "collisionTest0993") let collisionVar = project.userData.getUserVariable(identifiedBy: "collisionVar") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] let stage = createStage(project: project) let started = stage.startProject() - project.scene.object(at: 2)?.spriteNode.catrobatTransparency = 100.0 + scene.object(at: 2)?.spriteNode.catrobatTransparency = 100.0 XCTAssertTrue(started) expect(collisionVar?.value as? Int).toEventually(equal(noCollision), timeout: .seconds(5)) - project.scene.object(at: 2)?.spriteNode.catrobatTransparency = 0.0 - project.scene.object(at: 1)?.spriteNode.catrobatTransparency = 100.0 + scene.object(at: 2)?.spriteNode.catrobatTransparency = 0.0 + scene.object(at: 1)?.spriteNode.catrobatTransparency = 100.0 collisionVar?.value = 10 expect(collisionVar?.value as? Int).toEventually(equal(noCollision), timeout: .seconds(5)) @@ -104,26 +116,30 @@ final class CollisionFunctionTests: XMLAbstractTest { let project = getProjectForXML(xmlFile: "collisionTest0993") let collisionVar = project.userData.getUserVariable(identifiedBy: "collisionVar") let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! - let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] - project.scene.object(at: 2)?.lookList = [look] + + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } + scene.object(at: 1)?.lookList = [look] + scene.object(at: 2)?.lookList = [look] let stage = createStage(project: project) let started = stage.startProject() - project.scene.object(at: 1)?.spriteNode.position = CGPoint(x: 0, y: 0) - project.scene.object(at: 2)?.spriteNode.position = CGPoint(x: 115, y: 58) + scene.object(at: 1)?.spriteNode.position = CGPoint(x: 0, y: 0) + scene.object(at: 2)?.spriteNode.position = CGPoint(x: 115, y: 58) XCTAssertTrue(started) expect(collisionVar?.value as? Int).toEventually(equal(noCollision), timeout: .seconds(5)) - let obj1PosX = project.scene.object(at: 1)?.spriteNode.position.x - let obj1PosY = project.scene.object(at: 1)?.spriteNode.position.y - let obj2PosX = project.scene.object(at: 2)?.spriteNode.position.x - let obj2PosY = project.scene.object(at: 2)?.spriteNode.position.y - let lookWidth = project.scene.object(at: 1)?.spriteNode.size.width - let lookHeigth = project.scene.object(at: 1)?.spriteNode.size.height + let obj1PosX = scene.object(at: 1)?.spriteNode.position.x + let obj1PosY = scene.object(at: 1)?.spriteNode.position.y + let obj2PosX = scene.object(at: 2)?.spriteNode.position.x + let obj2PosY = scene.object(at: 2)?.spriteNode.position.y + let lookWidth = scene.object(at: 1)?.spriteNode.size.width + let lookHeigth = scene.object(at: 1)?.spriteNode.size.height XCTAssertGreaterThan(obj1PosX! + (lookWidth! / 2), obj2PosX! - (lookWidth! / 2), "Images are not overlapping") XCTAssertGreaterThan(obj1PosY! + (lookHeigth! / 2), obj2PosY! - (lookHeigth! / 2), "Images are not overlapping") diff --git a/src/CattyTests/PlayerEngine/CBBackendTests.swift b/src/CattyTests/PlayerEngine/CBBackendTests.swift index 69e44e9cc8..5c8e5f5ab7 100644 --- a/src/CattyTests/PlayerEngine/CBBackendTests.swift +++ b/src/CattyTests/PlayerEngine/CBBackendTests.swift @@ -42,7 +42,7 @@ final class CBBackendTests: XCTestCase { spriteNode = CBSpriteNode(spriteObject: spriteObject) spriteObject.spriteNode = spriteNode - frontend = CBFrontend(logger: logger, project: nil) + frontend = CBFrontend(logger: logger) backend = CBBackend(logger: logger) } diff --git a/src/CattyTests/PlayerEngine/Formula/FormulaManagerInterpreterTests.swift b/src/CattyTests/PlayerEngine/Formula/FormulaManagerInterpreterTests.swift index 9c31773c8d..9b95bb89ec 100644 --- a/src/CattyTests/PlayerEngine/Formula/FormulaManagerInterpreterTests.swift +++ b/src/CattyTests/PlayerEngine/Formula/FormulaManagerInterpreterTests.swift @@ -36,7 +36,7 @@ final class FormulaManagerInterpreterTests: XCTestCase { object = SpriteObject() object.scene = scene project = ProjectMock() - project.scene = object.scene + project.scenes[0] = object.scene! } func testInterpretDouble() { diff --git a/src/CattyTests/PlayerEngine/Frontend/CBFrontendTests.swift b/src/CattyTests/PlayerEngine/Frontend/CBFrontendTests.swift index 256c87b74f..ac40c956bf 100644 --- a/src/CattyTests/PlayerEngine/Frontend/CBFrontendTests.swift +++ b/src/CattyTests/PlayerEngine/Frontend/CBFrontendTests.swift @@ -29,7 +29,7 @@ final class CBFrontendTests: XCTestCase { let logger = Swell.getLogger(LoggerTestConfig.PlayerFrontendID)! func testComputeOperationSequence() { - let frontend = CBFrontend(logger: self.logger, project: nil) + let frontend = CBFrontend(logger: self.logger) let whenScript = WhenScript() whenScript.action = UIDefines.whenScriptDefaultAction let waitBrick = WaitBrick() @@ -79,7 +79,7 @@ final class CBFrontendTests: XCTestCase { } func testComputeIfElseConditionalSequence() { - let frontend = CBFrontend(logger: self.logger, project: nil) + let frontend = CBFrontend(logger: self.logger) let whenScript = WhenScript() whenScript.action = UIDefines.whenScriptDefaultAction let waitBrick = WaitBrick() @@ -195,7 +195,7 @@ final class CBFrontendTests: XCTestCase { } func testComputeIfThenConditionalSequence() { - let frontend = CBFrontend(logger: self.logger, project: nil) + let frontend = CBFrontend(logger: self.logger) let whenScript = WhenScript() whenScript.action = UIDefines.whenScriptDefaultAction let waitBrick = WaitBrick() diff --git a/src/CattyTests/PlayerEngine/Sensors/Object/BrightnessSensorTest.swift b/src/CattyTests/PlayerEngine/Sensors/Object/BrightnessSensorTest.swift index d4e30fec67..19dcbf3f42 100644 --- a/src/CattyTests/PlayerEngine/Sensors/Object/BrightnessSensorTest.swift +++ b/src/CattyTests/PlayerEngine/Sensors/Object/BrightnessSensorTest.swift @@ -35,7 +35,7 @@ final class BrightnessSensorTest: XCTestCase { spriteObject = SpriteObject() spriteObject.scene = scene let project = Project() - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! spriteNode = CBSpriteNodeMock(spriteObject: spriteObject) sensor = BrightnessSensor() } diff --git a/src/CattyTests/PlayerEngine/Sensors/Object/LayerSensorTest.swift b/src/CattyTests/PlayerEngine/Sensors/Object/LayerSensorTest.swift index 57f8cf1a53..c386c1e3f6 100644 --- a/src/CattyTests/PlayerEngine/Sensors/Object/LayerSensorTest.swift +++ b/src/CattyTests/PlayerEngine/Sensors/Object/LayerSensorTest.swift @@ -48,16 +48,16 @@ final class LayerSensorTest: XCTestCase { func testDefaultRawValue() { let project = Project() scene.project = project - project.scene = scene + project.scenes[0] = scene! let spriteObjectA = SpriteObjectMock() - project.scene.add(object: spriteObjectA) + (project.scenes[0] as! Scene).add(object: spriteObjectA) let spriteObjectB = SpriteObjectMock() - project.scene.add(object: spriteObjectB) + (project.scenes[0] as! Scene).add(object: spriteObjectB) let spriteObjectC = SpriteObjectMock() - project.scene.add(object: spriteObjectC) + (project.scenes[0] as! Scene).add(object: spriteObjectC) XCTAssertEqual(type(of: sensor).defaultRawValue, type(of: sensor).defaultRawValue(for: spriteObjectA), accuracy: Double.epsilon) XCTAssertEqual(type(of: sensor).defaultRawValue, type(of: sensor).rawValue(for: spriteObjectA), accuracy: Double.epsilon) diff --git a/src/CattyTests/PlayerEngine/Sensors/Object/TouchesEdgeSensorTest.swift b/src/CattyTests/PlayerEngine/Sensors/Object/TouchesEdgeSensorTest.swift index 09cfc67172..dc37f083a0 100644 --- a/src/CattyTests/PlayerEngine/Sensors/Object/TouchesEdgeSensorTest.swift +++ b/src/CattyTests/PlayerEngine/Sensors/Object/TouchesEdgeSensorTest.swift @@ -56,7 +56,7 @@ final class TouchesEdgeSensorTest: XMLAbstractTest { let filePath = Bundle(for: type(of: self)).path(forResource: "test.png", ofType: nil)! let look = LookMock(name: "look", absolutePath: filePath) - project.scene.object(at: 1)?.lookList = [look] + (project.scenes[0] as! Scene).object(at: 1)?.lookList = [look] let screenHeight = Double(project.header.screenHeight as! Int / 2) let screenWidth = Double(project.header.screenHeight as! Int / 2) @@ -65,37 +65,37 @@ final class TouchesEdgeSensorTest: XMLAbstractTest { let started = stage.startProject() XCTAssertTrue(started) - XCTAssertEqual(project.scene.objects().count, 2) + XCTAssertEqual((project.scenes[0] as! Scene).objects().count, 2) //no edge touch expect(touchEdgeVar?.value as? Int).toEventually(equal(0), timeout: .seconds(5)) - XCTAssertEqual(sensor.rawValue(for: project.scene.object(at: 1)!), 0) + XCTAssertEqual(sensor.rawValue(for: (project.scenes[0] as! Scene).object(at: 1)!), 0) //right edge touch - project.scene.object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: screenWidth / 2, y: 0) + (project.scenes[0] as! Scene).object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: screenWidth / 2, y: 0) expect(touchEdgeVar?.value as? Int).toEventually(equal(1), timeout: .seconds(5)) - XCTAssertEqual(sensor.rawValue(for: project.scene.object(at: 1)!), 1) + XCTAssertEqual(sensor.rawValue(for: (project.scenes[0] as! Scene).object(at: 1)!), 1) //left edge touch - project.scene.object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: -screenWidth / 2, y: 0) + (project.scenes[0] as! Scene).object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: -screenWidth / 2, y: 0) expect(touchEdgeVar?.value as? Int).toEventually(equal(1), timeout: .seconds(5)) - XCTAssertEqual(sensor.rawValue(for: project.scene.object(at: 1)!), 1) + XCTAssertEqual(sensor.rawValue(for: (project.scenes[0] as! Scene).object(at: 1)!), 1) //top edge touch - project.scene.object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: 0, y: screenHeight / 2) + (project.scenes[0] as! Scene).object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: 0, y: screenHeight / 2) expect(touchEdgeVar?.value as? Int).toEventually(equal(1), timeout: .seconds(5)) - XCTAssertEqual(sensor.rawValue(for: project.scene.object(at: 1)!), 1) + XCTAssertEqual(sensor.rawValue(for: (project.scenes[0] as! Scene).object(at: 1)!), 1) //bottom edge touch - project.scene.object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: 0, y: -screenHeight / 2) + (project.scenes[0] as! Scene).object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: 0, y: -screenHeight / 2) expect(touchEdgeVar?.value as? Int).toEventually(equal(1), timeout: .seconds(5)) - XCTAssertEqual(sensor.rawValue(for: project.scene.object(at: 1)!), 1) + XCTAssertEqual(sensor.rawValue(for: (project.scenes[0] as! Scene).object(at: 1)!), 1) //hidden spriteNode - project.scene.object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: 0, y: -screenHeight / 2) - project.scene.object(at: 1)?.spriteNode.isHidden = true + (project.scenes[0] as! Scene).object(at: 1)?.spriteNode.catrobatPosition = CBPosition(x: 0, y: -screenHeight / 2) + (project.scenes[0] as! Scene).object(at: 1)?.spriteNode.isHidden = true expect(touchEdgeVar?.value as? Int).toEventually(equal(1), timeout: .seconds(5)) - XCTAssertEqual(sensor.rawValue(for: project.scene.object(at: 1)!), 1) + XCTAssertEqual(sensor.rawValue(for: (project.scenes[0] as! Scene).object(at: 1)!), 1) } func testConvertToStandarized() { diff --git a/src/CattyTests/Project/ProjectMigratorTest.swift b/src/CattyTests/Project/ProjectMigratorTest.swift index c18c24b3eb..9a1a54ad21 100644 --- a/src/CattyTests/Project/ProjectMigratorTest.swift +++ b/src/CattyTests/Project/ProjectMigratorTest.swift @@ -40,8 +40,8 @@ class ProjectMigratorTest: XCTestCase { project = Project() project.header = header - project.scene = Scene(name: newFolderName) - project.scene.project = project + project.scenes[0] = Scene(name: newFolderName) + (project.scenes[0] as! Scene).project = project } func testMigrateToScene() { diff --git a/src/CattyTests/Project/ProjectTests.swift b/src/CattyTests/Project/ProjectTests.swift index 6f9db579cc..f95192bee0 100644 --- a/src/CattyTests/Project/ProjectTests.swift +++ b/src/CattyTests/Project/ProjectTests.swift @@ -38,7 +38,7 @@ class ProjectTests: XCTestCase { fileManager = CBFileManager.shared() deleteAllProjectsAndCreateDefaultProject() - self.scene = project.scene + self.scene = (project.scenes[0] as! Scene) self.object = SpriteObject() self.object.scene = scene } @@ -71,13 +71,13 @@ class ProjectTests: XCTestCase { } func testImagesDirectoryExists() { - let imageDirectory = project.scene.imagesPath() + let imageDirectory = (project.scenes[0] as! Scene).imagesPath() let directoryExists = fileManager.directoryExists(imageDirectory) XCTAssertTrue(directoryExists) } func testSoundsDirectoryExists() { - let soundsDirectory = project.scene.soundsPath() + let soundsDirectory = (project.scenes[0] as! Scene).soundsPath() let directoryExists = fileManager.directoryExists(soundsDirectory) XCTAssertTrue(directoryExists) } @@ -98,15 +98,15 @@ class ProjectTests: XCTestCase { let script = StartScript() script.brickList.addObjects(from: [ifThenLogicBeginBrick, ifThenLogicEndBrick] as [AnyObject]) object.scriptList.add(script) - project.scene.add(object: object) + (project.scenes[0] as! Scene).add(object: object) - let initialObjectSize = project.scene.objects().count + let initialObjectSize = (project.scenes[0] as! Scene).objects().count XCTAssertTrue(initialObjectSize > 0) - let copiedObject = project.scene.copy(object, withNameForCopiedObject: copiedObjectName)! + let copiedObject = (project.scenes[0] as! Scene).copy(object, withNameForCopiedObject: copiedObjectName)! XCTAssertEqual(1, copiedObject.scriptList.count) - let objectList = project.scene.objects() + let objectList = (project.scenes[0] as! Scene).objects() XCTAssertEqual(initialObjectSize + 1, objectList.count) XCTAssertEqual(copiedObjectName, (objectList[initialObjectSize] ).name) @@ -145,15 +145,15 @@ class ProjectTests: XCTestCase { let script = StartScript() script.brickList.addObjects(from: [ifLogicBeginBrick, ifLogicElseBrick, ifLogicEndBrick] as [AnyObject]) object.scriptList.add(script) - project.scene.add(object: object) + (project.scenes[0] as! Scene).add(object: object) - let initialObjectSize = project.scene.objects().count + let initialObjectSize = (project.scenes[0] as! Scene).objects().count XCTAssertTrue(initialObjectSize > 0) - let copiedObject = project.scene.copy(object, withNameForCopiedObject: copiedObjectName)! + let copiedObject = (project.scenes[0] as! Scene).copy(object, withNameForCopiedObject: copiedObjectName)! XCTAssertEqual(1, copiedObject.scriptList.count) - let objectList = project.scene.objects() + let objectList = (project.scenes[0] as! Scene).objects() XCTAssertEqual(initialObjectSize + 1, objectList.count) XCTAssertEqual(copiedObjectName, (objectList[initialObjectSize] ).name) @@ -184,7 +184,7 @@ class ProjectTests: XCTestCase { func testCopyObjectWithObjectVariable() { object.name = "newObjectName" - project.scene.add(object: object) + (project.scenes[0] as! Scene).add(object: object) let variable = UserVariable(name: "userVariable") object.userData.add(variable) @@ -196,16 +196,16 @@ class ProjectTests: XCTestCase { script.brickList.addObjects(from: [setVariableBrick] as [AnyObject]) object.scriptList.add(script) - let initialObjectSize = project.scene.objects().count + let initialObjectSize = (project.scenes[0] as! Scene).objects().count XCTAssertTrue(initialObjectSize > 0) let initialVariableSize = UserDataContainer.allVariables(for: project).count XCTAssertTrue(initialVariableSize > 0) - let copiedObject = project.scene.copy(object, withNameForCopiedObject: "copiedObjectName")! + let copiedObject = (project.scenes[0] as! Scene).copy(object, withNameForCopiedObject: "copiedObjectName")! XCTAssertEqual(1, copiedObject.scriptList.count) - let objectList = project.scene.objects() + let objectList = (project.scenes[0] as! Scene).objects() XCTAssertEqual(initialObjectSize + 1, objectList.count) XCTAssertEqual(initialVariableSize + 1, UserDataContainer.allVariables(for: project).count) XCTAssertEqual((objectList[initialObjectSize] ).name, copiedObject.name) @@ -223,7 +223,7 @@ class ProjectTests: XCTestCase { func testCopyObjectWithObjectList() { object.name = "newObjectName" - project.scene.add(object: object) + (project.scenes[0] as! Scene).add(object: object) let list = UserList(name: "userList") object.userData.add(list) @@ -235,16 +235,16 @@ class ProjectTests: XCTestCase { script.brickList.addObjects(from: [brick] as [AnyObject]) object.scriptList.add(script) - let initialObjectSize = project.scene.objects().count + let initialObjectSize = (project.scenes[0] as! Scene).objects().count XCTAssertTrue(initialObjectSize > 0) let initialListSize = UserDataContainer.allLists(for: project).count XCTAssertTrue(initialListSize > 0) - let copiedObject = project.scene.copy(object, withNameForCopiedObject: "copiedObjectName")! + let copiedObject = (project.scenes[0] as! Scene).copy(object, withNameForCopiedObject: "copiedObjectName")! XCTAssertEqual(1, copiedObject.scriptList.count) - let objectList = project.scene.objects() + let objectList = (project.scenes[0] as! Scene).objects() XCTAssertEqual(initialObjectSize + 1, objectList.count) XCTAssertEqual(initialListSize + 1, UserDataContainer.allLists(for: project).count) XCTAssertEqual((objectList[initialObjectSize] ).name, copiedObject.name) @@ -388,16 +388,16 @@ class ProjectTests: XCTestCase { func testAllObject() { self.project = Project() - self.project.scene = Scene() + self.project.scenes[0] = Scene() - XCTAssertEqual(0, self.project.scene.objects().count) + XCTAssertEqual(0, (self.project.scenes[0] as! Scene).objects().count) let objectA = SpriteObject() objectA.name = "objectA" - project.scene.add(object: objectA) - XCTAssertEqual(1, self.project.scene.objects().count) - XCTAssertTrue(self.project.scene.objects()[0] === objectA) + (project.scenes[0] as! Scene).add(object: objectA) + XCTAssertEqual(1, (self.project.scenes[0] as! Scene).objects().count) + XCTAssertTrue((self.project.scenes[0] as! Scene).objects()[0] === objectA) } func testChangeProjectOrientation() { diff --git a/src/CattyTests/Project/RequiredResourcesTests.swift b/src/CattyTests/Project/RequiredResourcesTests.swift index 0bccf1944f..68d999378e 100644 --- a/src/CattyTests/Project/RequiredResourcesTests.swift +++ b/src/CattyTests/Project/RequiredResourcesTests.swift @@ -48,13 +48,13 @@ final class RequiredResourcesTests: XCTestCase { func getProjectWithOneSpriteWithBrick(brick: Brick?) -> Project? { let project = Project() - project.scene = Scene() + project.scenes[0] = Scene() let obj = SpriteObject() let script = Script() script.brickList.add(brick as AnyObject) obj.scriptList.add(script) - project.scene.add(object: obj) + (project.scenes[0] as! Scene).add(object: obj) return project } @@ -840,7 +840,7 @@ final class RequiredResourcesTests: XCTestCase { // MARK: MoreScripts func getProjectWithTwoScriptsWithBricks(brickArray: [AnyObject]?, andBrickArray2 brickArray2: [AnyObject]?) -> Project { let project = Project() - project.scene = Scene() + project.scenes[0] = Scene() let obj = SpriteObject() let script = Script() let script2 = Script() @@ -859,7 +859,7 @@ final class RequiredResourcesTests: XCTestCase { obj.scriptList.add(script) obj.scriptList.add(script2) - project.scene.add(object: obj) + (project.scenes[0] as! Scene).add(object: obj) return project } @@ -957,8 +957,8 @@ final class RequiredResourcesTests: XCTestCase { obj.scriptList.add(script) obj1.scriptList.add(script2) - project.scene.add(object: obj) - project.scene.add(object: obj1) + (project.scenes[0] as! Scene).add(object: obj) + (project.scenes[0] as! Scene).add(object: obj1) return project } diff --git a/src/CattyTests/Resources/ParserTests/Custom/MultipleScenes/MultipleScenes.xml b/src/CattyTests/Resources/ParserTests/Custom/MultipleScenes/MultipleScenes.xml new file mode 100644 index 0000000000..52134d6709 --- /dev/null +++ b/src/CattyTests/Resources/ParserTests/Custom/MultipleScenes/MultipleScenes.xml @@ -0,0 +1,78 @@ + + +
+ + 0 + Pocket Code + 0.9.27 + 0.992 + + + Google Nexus 4 API 22 - CBL 0.992 + false + https://developer.catrobat.org/ccbysa_v4 + Android + 22.0 + https://developer.catrobat.org/agpl_v3 + Scenes + + true + 1184 + STRETCH + 768 + Experimental + /pocketcode/project/620ab113-e7ae-11ea-9251-005056a36f47 + catty +
+ + + + Scene 1 + + + + + 5235c2eecb956adf8c3ff3e3e9f295e9_automatic_screenshot.png + + + + + + + + + + + + + + 768 + 1184 + + + Scene 2 + + + + + 8ada7bc98ee101e3877ceb3bc9bcc254_North Pole.png + + + + + + + + + + + + + + 768 + 1184 + + + + +
diff --git a/src/CattyTests/Scripts/WhenBackgroundChangesScriptTests.swift b/src/CattyTests/Scripts/WhenBackgroundChangesScriptTests.swift index d4a0817aa5..b0cb4bbb57 100644 --- a/src/CattyTests/Scripts/WhenBackgroundChangesScriptTests.swift +++ b/src/CattyTests/Scripts/WhenBackgroundChangesScriptTests.swift @@ -39,7 +39,7 @@ final class WhenBackgroundChangesScriptTests: XCTestCase { project = ProjectMock(width: 400, andHeight: 800) scene = SceneMock(name: "sceneMock") scene.project = project - project.scene = scene + project.scenes[0] = scene! object = SpriteObject() object.name = "object" diff --git a/src/CattyTests/Scripts/WhenConditionScriptTests.swift b/src/CattyTests/Scripts/WhenConditionScriptTests.swift index 08c360608a..5964f6b116 100644 --- a/src/CattyTests/Scripts/WhenConditionScriptTests.swift +++ b/src/CattyTests/Scripts/WhenConditionScriptTests.swift @@ -39,7 +39,7 @@ project = ProjectMock(width: 400, andHeight: 800) scene = SceneMock(name: "sceneMock") scene.project = project - project.scene = scene + project.scenes[0] = (scene!) object = SpriteObject() object.name = "object" diff --git a/src/CattyTests/SpriteObject/SpriteObjectMutableCopyTests.swift b/src/CattyTests/SpriteObject/SpriteObjectMutableCopyTests.swift index 7658bf8d99..de2ccdac5e 100644 --- a/src/CattyTests/SpriteObject/SpriteObjectMutableCopyTests.swift +++ b/src/CattyTests/SpriteObject/SpriteObjectMutableCopyTests.swift @@ -88,9 +88,9 @@ final class SpriteObjectMutableCopyTests: XMLAbstractTest { func compareSpriteObjectsWithIsEqualMethodForProjectWithXML(xml: String) { let project = self.getProjectForXML(xmlFile: xml) - XCTAssertTrue(!project.scene.objects().isEmpty, "Invalid objectList") + XCTAssertTrue(!(project.scenes[0] as! Scene).objects().isEmpty, "Invalid objectList") - for spriteObject in project.scene.objects() { + for spriteObject in (project.scenes[0] as! Scene).objects() { let context = CBMutableCopyContext() let copiedSpriteObject = spriteObject.mutableCopy(with: context) as! SpriteObject XCTAssertTrue(spriteObject.isEqual(to: copiedSpriteObject), "SpriteObjects are not equal") diff --git a/src/CattyTests/Stage/StageTests.swift b/src/CattyTests/Stage/StageTests.swift index 11c630b4de..2a052568e3 100644 --- a/src/CattyTests/Stage/StageTests.swift +++ b/src/CattyTests/Stage/StageTests.swift @@ -109,7 +109,9 @@ final class StageTests: XCTestCase { func testVariableLabel() { let project = ProjectMock(width: self.screenSize.width, andHeight: self.screenSize.height) - project.scene = Scene() + let scene = Scene() + scene.project = project + project.scenes[0] = scene let stage = StageBuilder(project: project).build() let userVariable = UserVariable(name: "testName") diff --git a/src/CattyTests/Utils/UtilTests.swift b/src/CattyTests/Utils/UtilTests.swift index e3843c696b..f608af0e5a 100644 --- a/src/CattyTests/Utils/UtilTests.swift +++ b/src/CattyTests/Utils/UtilTests.swift @@ -36,7 +36,7 @@ final class UtilTests: XCTestCase { override func setUp() { project = Project() - project.scene = Scene() + project.scenes[0] = Scene() super.setUp() } @@ -83,10 +83,10 @@ final class UtilTests: XCTestCase { func testdefaultSceneNameForSceneNumber() { var sceneDirectoryname = Util.defaultSceneName(forSceneNumber: 1) - XCTAssertEqual(sceneDirectoryname, "Scene 1") + XCTAssertEqual(sceneDirectoryname, "\(kLocalizedScene) 1") sceneDirectoryname = Util.defaultSceneName(forSceneNumber: 99) - XCTAssertEqual(sceneDirectoryname, "Scene 99") + XCTAssertEqual(sceneDirectoryname, "\(kLocalizedScene) 99") } func testAppName() { @@ -183,7 +183,7 @@ final class UtilTests: XCTestCase { project.allBroadcastMessages?.add("firstValue") spriteObject = SpriteObject() - project.scene.add(object: spriteObject!) + (project.scenes[0] as! Scene).add(object: spriteObject!) broadcastScript = BroadcastScript() spriteObject.scriptList.add(broadcastScript!) broadcastScript.receivedMessage = "secondValue" @@ -226,7 +226,7 @@ final class UtilTests: XCTestCase { func testLookWithNameForObject() { let look = Look(name: "TestLook", filePath: "/test/path") spriteObject = SpriteObject() - project.scene.add(object: spriteObject!) + (project.scenes[0] as! Scene).add(object: spriteObject!) spriteObject.lookList.add(look) let utilLook = Util.look(with: "TestLook", for: spriteObject) @@ -237,9 +237,9 @@ final class UtilTests: XCTestCase { func testObjectWithNameForScene() { spriteObject = SpriteObject() spriteObject.name = "TestSpriteObject" - project.scene.add(object: spriteObject!) + (project.scenes[0] as! Scene).add(object: spriteObject!) - let utilSpriteObject = Util.object(with: "TestSpriteObject", for: project.scene) + let utilSpriteObject = Util.object(with: "TestSpriteObject", for: (project.scenes[0] as! Scene)) XCTAssertEqual(utilSpriteObject, spriteObject) } @@ -247,7 +247,7 @@ final class UtilTests: XCTestCase { func testSoundWithNameForObject() { let sound = Sound(name: "TestSound", fileName: "/test/path") spriteObject = SpriteObject() - project.scene.add(object: spriteObject!) + (project.scenes[0] as! Scene).add(object: spriteObject!) spriteObject.soundList.add(sound) let utilSound = Util.sound(with: "TestSound", for: spriteObject) diff --git a/src/CattyTests/ViewController/FormulaEditorDataSectionViewControllerTests.swift b/src/CattyTests/ViewController/FormulaEditorDataSectionViewControllerTests.swift index c574cd8146..c923cdfc5a 100644 --- a/src/CattyTests/ViewController/FormulaEditorDataSectionViewControllerTests.swift +++ b/src/CattyTests/ViewController/FormulaEditorDataSectionViewControllerTests.swift @@ -40,13 +40,11 @@ final class FormulaEditorDataSectionViewControllerTests: XCTestCase { project = Project() project.userData = UserDataContainer() - scene = Scene(name: "testScene") scene.project = project - project.scene = scene - spriteObject = SpriteObjectMock() - project.scene.add(object: spriteObject!) + scene.add(object: spriteObject) + project.scenes[0] = scene as Scene script = StartScript() spriteObject.scriptList.add(script!) @@ -109,7 +107,12 @@ final class FormulaEditorDataSectionViewControllerTests: XCTestCase { XCTAssertFalse(controller.isVariableUsed(variable)) - project.scene.add(object: objectB) + guard let scene = project.scenes[0] as? Scene else { + XCTFail("No Scene found.") + return + } + scene.add(object: objectB) + project.scenes[0] = scene XCTAssertTrue(controller.isVariableUsed(variable)) } @@ -160,8 +163,13 @@ final class FormulaEditorDataSectionViewControllerTests: XCTestCase { brick.userVariable = variable scriptB.brickList.add(brick) objectB.scriptList.add(scriptB) - project.scene.add(object: objectB) + guard let scene = project.scenes[0] as? Scene else { + XCTFail("No Scene found.") + return + } + + project.scenes[0] = scene.add(object: objectB) XCTAssertFalse(controller.isVariableUsed(variable)) controller = FormulaEditorDataSectionViewController(formulaManager: formulaManager, @@ -227,7 +235,12 @@ final class FormulaEditorDataSectionViewControllerTests: XCTestCase { XCTAssertFalse(controller.isListUsed(list)) - project.scene.add(object: objectB) + guard let scene = project.scenes[0] as? Scene else { + XCTFail("No Scene found.") + return + } + scene.add(object: objectB) + project.scenes[0] = scene XCTAssertTrue(controller.isListUsed(list)) } @@ -278,6 +291,10 @@ final class FormulaEditorDataSectionViewControllerTests: XCTestCase { let brick = AddItemToUserListBrick() let scriptB = WhenScript() let objectB = SpriteObject() + guard let scene = project.scenes[0] as? Scene else { + XCTFail("Project has no Scenes.") + return + } brick.listFormula = Formula() @@ -285,7 +302,7 @@ final class FormulaEditorDataSectionViewControllerTests: XCTestCase { brick.userList = list scriptB.brickList.add(brick) objectB.scriptList.add(scriptB) - project.scene.add(object: objectB) + scene.add(object: objectB) XCTAssertFalse(controller.isListUsed(list)) diff --git a/src/CattyTests/ViewController/Stage/StagePresenterViewControllerScreenshotTests.swift b/src/CattyTests/ViewController/Stage/StagePresenterViewControllerScreenshotTests.swift index cae953b486..1cc9102b9f 100644 --- a/src/CattyTests/ViewController/Stage/StagePresenterViewControllerScreenshotTests.swift +++ b/src/CattyTests/ViewController/Stage/StagePresenterViewControllerScreenshotTests.swift @@ -40,13 +40,13 @@ final class StagePresenterViewControllerScreenshotTest: XCTestCase { func testAutomaticScreenshot() { let expectedRootPath = project.projectPath() + kScreenshotAutoFilename - let expectedScenePath = project.scene.path()! + kScreenshotAutoFilename + let expectedScenePath = (project.scenes[0] as! Scene).path()! + kScreenshotAutoFilename XCTAssertFalse(FileManager.default.fileExists(atPath: expectedScenePath)) let exp = expectation(description: "screenshot saved") - vc.takeAutomaticScreenshot(for: skView, and: project.scene) + vc.takeAutomaticScreenshot(for: skView, and: (project.scenes[0] as! Scene)) DispatchQueue.main.async { exp.fulfill() } waitForExpectations(timeout: 5, handler: nil) @@ -68,13 +68,13 @@ final class StagePresenterViewControllerScreenshotTest: XCTestCase { func testManualScreenshot() { let expectedRootPath = project.projectPath() + kScreenshotManualFilename - let expectedScenePath = project.scene.path()! + kScreenshotManualFilename + let expectedScenePath = (project.scenes[0] as! Scene).path()! + kScreenshotManualFilename XCTAssertFalse(FileManager.default.fileExists(atPath: expectedScenePath)) XCTAssertFalse(FileManager.default.fileExists(atPath: expectedRootPath)) let exp = expectation(description: "screenshot saved") - vc.takeManualScreenshot(for: skView, and: project.scene) + vc.takeManualScreenshot(for: skView, and: (project.scenes[0] as! Scene)) DispatchQueue.main.async { exp.fulfill() } waitForExpectations(timeout: 5, handler: nil) @@ -107,7 +107,7 @@ final class StagePresenterViewControllerScreenshotTest: XCTestCase { XCTAssertNotNil(imageCache.cachedImage(forPath: existingPath)!) let exp = expectation(description: "screenshot saved") - vc.takeManualScreenshot(for: skView, and: project.scene) + vc.takeManualScreenshot(for: skView, and: (project.scenes[0] as! Scene)) DispatchQueue.main.async { exp.fulfill() } waitForExpectations(timeout: 5, handler: nil) diff --git a/src/CattyTests/ViewController/Stage/StagePresenterViewControllerTests.swift b/src/CattyTests/ViewController/Stage/StagePresenterViewControllerTests.swift index 6aefc521de..2f47367dd4 100644 --- a/src/CattyTests/ViewController/Stage/StagePresenterViewControllerTests.swift +++ b/src/CattyTests/ViewController/Stage/StagePresenterViewControllerTests.swift @@ -121,11 +121,11 @@ final class StagePresenterViewControllerTest: XCTestCase { let backgroundNode = CBSpriteNodeMock(spriteObject: background) background.spriteNode = backgroundNode - let object = SpriteObjectMock(scene: project.scene) + let object = SpriteObjectMock(scene: (project.scenes[0] as! Scene)) let objectNode = CBSpriteNodeMock(spriteObject: object) objectNode.embroideryStream = stream object.spriteNode = objectNode - project.scene.add(object: object) + (project.scenes[0] as? Scene)?.add(object: object) XCTAssertEqual(2, project.allObjects().count) XCTAssertNil(vc.latestPresentedViewController) diff --git a/src/CattyTests/Views/BrickCells/Data/BrickCellListDataTests.swift b/src/CattyTests/Views/BrickCells/Data/BrickCellListDataTests.swift index 455e44a1b3..2ccd7ee091 100644 --- a/src/CattyTests/Views/BrickCells/Data/BrickCellListDataTests.swift +++ b/src/CattyTests/Views/BrickCells/Data/BrickCellListDataTests.swift @@ -62,7 +62,7 @@ class BrickCellListDataTests: XCTestCase { userDataContainer.add(programList) project = Project() - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! project.userData = userDataContainer spriteObject.scene.project = project diff --git a/src/CattyTests/Views/BrickCells/Data/BrickCellVariableDataTests.swift b/src/CattyTests/Views/BrickCells/Data/BrickCellVariableDataTests.swift index 51aacce62c..adae1bacc2 100644 --- a/src/CattyTests/Views/BrickCells/Data/BrickCellVariableDataTests.swift +++ b/src/CattyTests/Views/BrickCells/Data/BrickCellVariableDataTests.swift @@ -61,7 +61,7 @@ class BrickCellVariableDataTests: XCTestCase { spriteObject2.userData.add(secondObjectVariable) userDataContainer.add(programVariable) project = Project() - project.scene = spriteObject.scene + project.scenes[0] = spriteObject.scene! project.userData = userDataContainer spriteObject.scene.project = project diff --git a/src/CattyTests/XML/Abstract/XMLAbstractTest.swift b/src/CattyTests/XML/Abstract/XMLAbstractTest.swift index 4c9ac49df4..85ce90036c 100644 --- a/src/CattyTests/XML/Abstract/XMLAbstractTest.swift +++ b/src/CattyTests/XML/Abstract/XMLAbstractTest.swift @@ -61,8 +61,8 @@ class XMLAbstractTest: XCTestCase { // FIXME: HACK => assign same header to both versions => this forces to ignore header firstProject.header = secondProject.header // FIXME: HACK => for background objects always replace german name "Hintergrund" with "Background" - let firstBgObject = firstProject.scene.object(at: 0)! - let secondBgObject = secondProject.scene.object(at: 0)! + let firstBgObject = (firstProject.scenes[0] as! Scene).object(at: 0)! + let secondBgObject = (secondProject.scenes[0] as! Scene).object(at: 0)! firstBgObject.name = firstBgObject.name.replacingOccurrences(of: "Hintergrund", with: "Background") secondBgObject.name = secondBgObject.name.replacingOccurrences(of: "Hintergrund", with: "Background") diff --git a/src/CattyTests/XML/Helper/CBXMLParserHelperTests.swift b/src/CattyTests/XML/Helper/CBXMLParserHelperTests.swift index 204a7de77b..4197271339 100644 --- a/src/CattyTests/XML/Helper/CBXMLParserHelperTests.swift +++ b/src/CattyTests/XML/Helper/CBXMLParserHelperTests.swift @@ -46,8 +46,8 @@ final class CBXMLParserHelperTests: XCTestCase { let scene = Scene(name: "testScene") let object = SpriteObject() object.scene = scene - let project = Project() - project.scene = object.scene + let project: Project! = ProjectManager.shared.createProject(name: "a", projectId: "1") + project.scenes[0] = object.scene! let spriteNode = CBSpriteNode(spriteObject: object) let startScript = StartScript() diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.92/XMLParserTests092.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.92/XMLParserTests092.swift index ac7b230aed..5cc98b6afc 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.92/XMLParserTests092.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.92/XMLParserTests092.swift @@ -29,9 +29,9 @@ class XMLParserTests092: XMLAbstractTest { func testConvertUnsupportedBrickToNoteBrick() { let project = getProjectForXML(xmlFile: "InvalidBricksAndScripts") XCTAssertNotNil(project, "Project should not be nil") - XCTAssertEqual(1, project.scene.objects().count) + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count) - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(3, object.scriptList.count) let startScript = object.scriptList[0] as! StartScript @@ -50,9 +50,9 @@ class XMLParserTests092: XMLAbstractTest { func testConvertUnsupportedScriptToBroadcastBrick() { let project = getProjectForXML(xmlFile: "InvalidBricksAndScripts") XCTAssertNotNil(project, "Project should not be nil") - XCTAssertEqual(1, project.scene.objects().count) + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count) - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(3, object.scriptList.count) let unknownScript = object.scriptList[1] as AnyObject @@ -77,9 +77,9 @@ class XMLParserTests092: XMLAbstractTest { func testWhackAMole() { let project = getProjectForXML(xmlFile: "Whack_A_Mole_092") XCTAssertNotNil(project, "Project should not be nil") - XCTAssertEqual(5, project.scene.objects().count) + XCTAssertEqual(5, (project.scenes[0] as! Scene).objects().count) - let object = project.scene.object(at: 1)! + let object = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertEqual(3, object.lookList.count) XCTAssertEqual(1, object.soundList.count) diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.93/XMLParserBrickTests093.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.93/XMLParserBrickTests093.swift index 329e0b9f51..5051a8c785 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.93/XMLParserBrickTests093.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.93/XMLParserBrickTests093.swift @@ -446,7 +446,7 @@ class XMLParserBrickTests093: XMLAbstractTest { let project = self.getProjectForXML(xmlFile: "PointToBrickWithoutSpriteObject") XCTAssertNotNil(project, "Project must not be nil!") - let moleTwo = project.scene.object(at: 1)! + let moleTwo = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertNotNil(moleTwo, "SpriteObject must not be nil!") XCTAssertEqual(moleTwo.name, "Mole 2", "Invalid object name!") diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.98/XMLParserTests098.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.98/XMLParserTests098.swift index 11a8705ffd..d4d2f2989d 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.98/XMLParserTests098.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.98/XMLParserTests098.swift @@ -40,8 +40,8 @@ final class XMLParserTests098: XMLAbstractTest { func testFlashBrick() { let project = self.getProjectForXML(xmlFile: "LedFlashBrick098") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -58,8 +58,8 @@ final class XMLParserTests098: XMLAbstractTest { func testLedBrick() { let project = self.getProjectForXML(xmlFile: "LedFlashBrick098") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -75,9 +75,9 @@ final class XMLParserTests098: XMLAbstractTest { func testAddItemToUserListBrick() { let project = self.getProjectForXML(xmlFile: "AddItemToUserListBrick098") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -99,9 +99,9 @@ final class XMLParserTests098: XMLAbstractTest { func testDeleteItemOfUserListBrick() { let project = self.getProjectForXML(xmlFile: "DeleteItemOfUserListBrick098") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -122,9 +122,9 @@ final class XMLParserTests098: XMLAbstractTest { func testInsertItemIntoUserListBrick() { let project = self.getProjectForXML(xmlFile: "InsertItemIntoUserListBrick098") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -151,9 +151,9 @@ final class XMLParserTests098: XMLAbstractTest { func testReplaceItemInUserListBrick() { let project = self.getProjectForXML(xmlFile: "ReplaceItemInUserListBrick098") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.991/XMLParserTests0991.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.991/XMLParserTests0991.swift index 9766f39eb2..1d22a7e973 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.991/XMLParserTests0991.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.991/XMLParserTests0991.swift @@ -35,8 +35,8 @@ class XMLParserTests0991: XMLAbstractTest { func testFlashBrick() { let project = self.getProjectForXML(xmlFile: "LedFlashBrick0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -53,8 +53,8 @@ class XMLParserTests0991: XMLAbstractTest { func testLedBrick() { let project = self.getProjectForXML(xmlFile: "LedFlashBrick0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -71,8 +71,8 @@ class XMLParserTests0991: XMLAbstractTest { func testIfThenLogicBeginBrick() { let project = self.getProjectForXML(xmlFile: "LogicBricks_0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -123,9 +123,9 @@ class XMLParserTests0991: XMLAbstractTest { func testObjectLookSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0991") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 2, "Invalid object list") - let background = project.scene.object(at: 0)! - let object = project.scene.object(at: 1)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 2, "Invalid object list") + let background = (project.scenes[0] as! Scene).object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertEqual(1, background.scriptList.count, "Invalid script list") XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -161,7 +161,7 @@ class XMLParserTests0991: XMLAbstractTest { func testPreviousLookBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 26, "Invalid brick list") @@ -172,7 +172,7 @@ class XMLParserTests0991: XMLAbstractTest { func testRepeatUntilBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 27, "Invalid brick list") @@ -183,7 +183,7 @@ class XMLParserTests0991: XMLAbstractTest { func testSetBackgroundBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 29, "Invalid brick list") @@ -197,7 +197,7 @@ class XMLParserTests0991: XMLAbstractTest { func testSpeakAndWaitBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 30, "Invalid brick list") @@ -212,8 +212,8 @@ class XMLParserTests0991: XMLAbstractTest { func testLocationSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0991") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 3, "Invalid object list") - let object = project.scene.object(at: 2)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 3, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 2)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -239,8 +239,8 @@ class XMLParserTests0991: XMLAbstractTest { func testScreenTouchSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0991") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 4, "Invalid object list") - let object = project.scene.object(at: 3)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 4, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 3)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -265,7 +265,7 @@ class XMLParserTests0991: XMLAbstractTest { func testCameraBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 33, "Invalid brick list") @@ -281,7 +281,7 @@ class XMLParserTests0991: XMLAbstractTest { func testChooseCameraBrick() { let project = self.getProjectForXML(xmlFile: "CameraBricks_0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertEqual(backgroundScript.brickList.count, 4, "Invalid brick list") @@ -305,7 +305,7 @@ class XMLParserTests0991: XMLAbstractTest { func testSayBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 34, "Invalid brick list") @@ -317,7 +317,7 @@ class XMLParserTests0991: XMLAbstractTest { func testThinkBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 35, "Invalid brick list") @@ -329,7 +329,7 @@ class XMLParserTests0991: XMLAbstractTest { func testSayForBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 36, "Invalid brick list") @@ -342,7 +342,7 @@ class XMLParserTests0991: XMLAbstractTest { func testThinkForBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 37, "Invalid brick list") @@ -355,9 +355,9 @@ class XMLParserTests0991: XMLAbstractTest { func testAddItemToUserListBrick() { let project = self.getProjectForXML(xmlFile: "AddItemToUserListBrick0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -378,7 +378,7 @@ class XMLParserTests0991: XMLAbstractTest { func testWaitUntilBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertGreaterThanOrEqual(backgroundScript.brickList.count, 41, "Invalid brick list") @@ -391,9 +391,9 @@ class XMLParserTests0991: XMLAbstractTest { func testNumberOfItemsFunction() { let project = self.getProjectForXML(xmlFile: "NumberOfItemsInListFunction0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -410,9 +410,9 @@ class XMLParserTests0991: XMLAbstractTest { func testElementOfListFunction() { let project = self.getProjectForXML(xmlFile: "ElementOfListFunction0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -435,9 +435,9 @@ class XMLParserTests0991: XMLAbstractTest { func testDeleteItemOfUserListBrick() { let project = self.getProjectForXML(xmlFile: "DeleteItemOfUserListBrick0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -458,9 +458,9 @@ class XMLParserTests0991: XMLAbstractTest { func testInsertItemIntoUserListBrick() { let project = self.getProjectForXML(xmlFile: "InsertItemIntoUserListBrick0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -487,9 +487,9 @@ class XMLParserTests0991: XMLAbstractTest { func testReplaceItemInUserListBrick() { let project = self.getProjectForXML(xmlFile: "ReplaceItemInUserListBrick0991") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -516,21 +516,21 @@ class XMLParserTests0991: XMLAbstractTest { func testBroadcastScript() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let object = project.scene.object(at: 1)! + let object = (project.scenes[0] as! Scene).object(at: 1)! let broadcastScript = object.scriptList.object(at: 0) as! Script XCTAssertTrue(broadcastScript.isKind(of: BroadcastScript.self), "Invalid script type") } func testWhenScript() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let object = project.scene.object(at: 1)! + let object = (project.scenes[0] as! Scene).object(at: 1)! let whenScript = object.scriptList.object(at: 1) as! Script XCTAssertTrue(whenScript.isKind(of: WhenScript.self), "Invalid script type") } func testWhenTouchDownScript() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0991") - let object = project.scene.object(at: 1)! + let object = (project.scenes[0] as! Scene).object(at: 1)! let whenTouchDownScript = object.scriptList.object(at: 2) as! Script XCTAssertEqual(0, project.unsupportedElements.count) @@ -539,7 +539,7 @@ class XMLParserTests0991: XMLAbstractTest { func testPlaySoundAndWaitBrick() { let project = self.getProjectForXML(xmlFile: "PlaySoundAndWaitBrickContinueWhenFinished") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! let startScript = object.scriptList.object(at: 0) as! Script let playSoundAndWaitBrick = startScript.brickList.object(at: 0) as! PlaySoundAndWaitBrick @@ -549,7 +549,7 @@ class XMLParserTests0991: XMLAbstractTest { func testDisabledBricks() { let project = self.getProjectForXML(xmlFile: "DisabledBricks_0991") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! let startScript = object.scriptList.object(at: 0) as! Script let disabledBrick = startScript.brickList.object(at: 0) as! SetVariableBrick @@ -561,7 +561,7 @@ class XMLParserTests0991: XMLAbstractTest { func testSpeakBrickWithoutCommentedOut() { let project = self.getProjectForXML(xmlFile: "SpeakBrickWithoutCommentedOut_0991") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! let startScript = object.scriptList.object(at: 0) as! Script let speakBrick = startScript.brickList.object(at: 0) as! SpeakBrick @@ -571,9 +571,9 @@ class XMLParserTests0991: XMLAbstractTest { func testSetBackgroundBrickReference() { let project = self.getProjectForXML(xmlFile: "SetBackgroundBrick_0991") - let background = project.scene.object(at: 0)! - let objectA = project.scene.object(at: 1)! - let objectB = project.scene.object(at: 2)! + let background = (project.scenes[0] as! Scene).object(at: 0)! + let objectA = (project.scenes[0] as! Scene).object(at: 1)! + let objectB = (project.scenes[0] as! Scene).object(at: 2)! let brickWithValidBackgroundReference = (objectA.scriptList.object(at: 0) as! Script).brickList.object(at: 0) as! SetBackgroundBrick let brickWithInvalidBackgroundReference = (objectB.scriptList.object(at: 0) as! Script).brickList.object(at: 0) as! SetBackgroundBrick diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.992/XMLParserTests0992.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.992/XMLParserTests0992.swift index e8b5ceb493..a6d2a4160f 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.992/XMLParserTests0992.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.992/XMLParserTests0992.swift @@ -35,8 +35,8 @@ class XMLParserTests0992: XMLAbstractTest { func testFlashBrick() { let project = self.getProjectForXML(xmlFile: "LedFlashBrick0992") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -53,8 +53,8 @@ class XMLParserTests0992: XMLAbstractTest { func testIfThenLogicBeginBrick() { let project = self.getProjectForXML(xmlFile: "LogicBricks_0992") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -105,9 +105,9 @@ class XMLParserTests0992: XMLAbstractTest { func testObjectLookSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0992") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 2, "Invalid object list") - let background = project.scene.object(at: 0)! - let object = project.scene.object(at: 1)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 2, "Invalid object list") + let background = (project.scenes[0] as! Scene).object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertEqual(1, background.scriptList.count, "Invalid script list") XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -144,8 +144,8 @@ class XMLParserTests0992: XMLAbstractTest { func testLocationSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0992") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 3, "Invalid object list") - let object = project.scene.object(at: 2)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 3, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 2)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -171,8 +171,8 @@ class XMLParserTests0992: XMLAbstractTest { func testScreenTouchSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0992") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 4, "Invalid object list") - let object = project.scene.object(at: 3)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 4, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 3)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -197,7 +197,7 @@ class XMLParserTests0992: XMLAbstractTest { func testChooseCameraBrick() { let project = self.getProjectForXML(xmlFile: "CameraBricks_0992") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertEqual(backgroundScript.brickList.count, 4, "Invalid brick list") @@ -221,9 +221,9 @@ class XMLParserTests0992: XMLAbstractTest { func testNumberOfItemsFunction() { let project = self.getProjectForXML(xmlFile: "NumberOfItemsInListFunction0992") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -240,9 +240,9 @@ class XMLParserTests0992: XMLAbstractTest { func testElementOfListFunction() { let project = self.getProjectForXML(xmlFile: "ElementOfListFunction0992") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -265,9 +265,9 @@ class XMLParserTests0992: XMLAbstractTest { func testDeleteItemOfUserListBrick() { let project = self.getProjectForXML(xmlFile: "DeleteItemOfUserListBrick0992") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -288,9 +288,9 @@ class XMLParserTests0992: XMLAbstractTest { func testInsertItemIntoUserListBrick() { let project = self.getProjectForXML(xmlFile: "InsertItemIntoUserListBrick0992") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -317,9 +317,9 @@ class XMLParserTests0992: XMLAbstractTest { func testReplaceItemInUserListBrick() { let project = self.getProjectForXML(xmlFile: "ReplaceItemInUserListBrick0992") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -346,7 +346,7 @@ class XMLParserTests0992: XMLAbstractTest { func testDisabledBricks() { let project = self.getProjectForXML(xmlFile: "DisabledBricks_0992") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! let startScript = object.scriptList.object(at: 0) as! Script let disabledBrick = startScript.brickList.object(at: 0) as! SetVariableBrick @@ -377,7 +377,7 @@ class XMLParserTests0992: XMLAbstractTest { func testAskBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0992") - let askBrick = (project.scene.object(at: 1)!.scriptList.object(at: 0) as! Script).brickList.object(at: 1) as! Brick + let askBrick = ((project.scenes[0] as! Scene).object(at: 1)!.scriptList.object(at: 0) as! Script).brickList.object(at: 1) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(askBrick.isKind(of: AskBrick.self), "Invalid brick type") @@ -386,7 +386,7 @@ class XMLParserTests0992: XMLAbstractTest { func testSetInstrumentBrick() { let availableInstruments = Instrument.allCases let project = self.getProjectForXML(xmlFile: "SamplerBricks_0992") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! let startScript = object.scriptList.object(at: 0) as! Script XCTAssertEqual(availableInstruments.count, startScript.brickList.count) @@ -407,7 +407,7 @@ class XMLParserTests0992: XMLAbstractTest { func testSetTempoToBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0992") - let setTempoToBrick = (project.scene.object(at: 1)!.scriptList.object(at: 0) as! Script).brickList.object(at: 5) as! Brick + let setTempoToBrick = ((project.scenes[0] as! Scene).object(at: 1)!.scriptList.object(at: 0) as! Script).brickList.object(at: 5) as! Brick XCTAssertTrue(setTempoToBrick.isKind(of: SetTempoToBrick.self), "Invalid brick type") } diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.993/XMLParserTests0993.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.993/XMLParserTests0993.swift index b9867f3bfe..e31e7326c1 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.993/XMLParserTests0993.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.993/XMLParserTests0993.swift @@ -35,8 +35,8 @@ class XMLParserTests0993: XMLAbstractTest { func testFlashBrick() { let project = self.getProjectForXML(xmlFile: "LedFlashBrick0993") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -53,8 +53,8 @@ class XMLParserTests0993: XMLAbstractTest { func testIfThenLogicBeginBrick() { let project = self.getProjectForXML(xmlFile: "LogicBricks_0993") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -105,9 +105,9 @@ class XMLParserTests0993: XMLAbstractTest { func testObjectLookSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0993") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 2, "Invalid object list") - let background = project.scene.object(at: 0)! - let object = project.scene.object(at: 1)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 2, "Invalid object list") + let background = (project.scenes[0] as! Scene).object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertEqual(1, background.scriptList.count, "Invalid script list") XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -144,8 +144,8 @@ class XMLParserTests0993: XMLAbstractTest { func testLocationSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0993") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 3, "Invalid object list") - let object = project.scene.object(at: 2)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 3, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 2)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -171,8 +171,8 @@ class XMLParserTests0993: XMLAbstractTest { func testScreenTouchSensors() { let project = self.getProjectForXML(xmlFile: "Sensors_0993") - XCTAssertGreaterThanOrEqual(project.scene.objects().count, 4, "Invalid object list") - let object = project.scene.object(at: 3)! + XCTAssertGreaterThanOrEqual((project.scenes[0] as! Scene).objects().count, 4, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 3)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") @@ -196,8 +196,9 @@ class XMLParserTests0993: XMLAbstractTest { } func testChooseCameraBrick() { + let project = self.getProjectForXML(xmlFile: "CameraBricks_0993") - let background = project.scene.object(at: 0)! + let background = (project.scenes[0] as! Scene).object(at: 0)! let backgroundScript = background.scriptList.object(at: 0) as! Script XCTAssertEqual(backgroundScript.brickList.count, 4, "Invalid brick list") @@ -221,9 +222,9 @@ class XMLParserTests0993: XMLAbstractTest { func testNumberOfItemsFunction() { let project = self.getProjectForXML(xmlFile: "NumberOfItemsInListFunction0993") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -240,9 +241,9 @@ class XMLParserTests0993: XMLAbstractTest { func testElementOfListFunction() { let project = self.getProjectForXML(xmlFile: "ElementOfListFunction0993") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -265,9 +266,9 @@ class XMLParserTests0993: XMLAbstractTest { func testDeleteItemOfUserListBrick() { let project = self.getProjectForXML(xmlFile: "DeleteItemOfUserListBrick0993") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -288,9 +289,9 @@ class XMLParserTests0993: XMLAbstractTest { func testInsertItemIntoUserListBrick() { let project = self.getProjectForXML(xmlFile: "InsertItemIntoUserListBrick0993") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -316,10 +317,10 @@ class XMLParserTests0993: XMLAbstractTest { } func testReplaceItemInUserListBrick() { - let project = self.getProjectForXML(xmlFile: "ReplaceItemInUserListBrick0993") - XCTAssertEqual(1, project.scene.objects().count, "Invalid object list") + let project = self.getProjectForXML(xmlFile: "ReplaceItemInUserListBrick0992") + XCTAssertEqual(1, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script @@ -346,7 +347,8 @@ class XMLParserTests0993: XMLAbstractTest { func testDisabledBricks() { let project = self.getProjectForXML(xmlFile: "DisabledBricks_0993") - let object = project.scene.object(at: 0)! + let object = (project.scenes[0] as! Scene).object(at: 0)! + let startScript = object.scriptList.object(at: 0) as! Script let disabledBrick = startScript.brickList.object(at: 0) as! SetVariableBrick @@ -377,7 +379,7 @@ class XMLParserTests0993: XMLAbstractTest { func testAskBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0993") - let askBrick = (project.scene.object(at: 1)!.scriptList.object(at: 0) as! Script).brickList.object(at: 1) as! Brick + let askBrick = ((project.scenes[0] as! Scene).object(at: 1)!.scriptList.object(at: 0) as! Script).brickList.object(at: 1) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(askBrick.isKind(of: AskBrick.self), "Invalid brick type") @@ -391,9 +393,9 @@ class XMLParserTests0993: XMLAbstractTest { func testJoinThreeFunction() { let project = self.getProjectForXML(xmlFile: "Functions_0993") - XCTAssertEqual(4, project.scene.objects().count, "Invalid object list") + XCTAssertEqual(4, (project.scenes[0] as! Scene).objects().count, "Invalid object list") - let object = project.scene.object(at: 2)! + let object = (project.scenes[0] as! Scene).object(at: 2)! XCTAssertEqual(1, object.scriptList.count, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.994/XMLParserTests0994.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.994/XMLParserTests0994.swift index d02e5045dc..9a495be51b 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.994/XMLParserTests0994.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.994/XMLParserTests0994.swift @@ -44,7 +44,7 @@ class XMLParserTests0994: XMLAbstractTest { func testSetPenColorBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0994") - let setPenColorBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick + let setPenColorBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(setPenColorBrick.isKind(of: SetPenColorBrick.self), "Invalid brick type") @@ -58,7 +58,7 @@ class XMLParserTests0994: XMLAbstractTest { func testGlideToBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0994") - let glideToBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick + let glideToBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(glideToBrick.isKind(of: GlideToBrick.self), "Invalid brick type") @@ -71,7 +71,7 @@ class XMLParserTests0994: XMLAbstractTest { func testThinkForBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0994") - let thinkForBubbleBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 37) as! Brick + let thinkForBubbleBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 37) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(thinkForBubbleBrick.isKind(of: ThinkForBubbleBrick.self), "Invalid brick type") @@ -83,7 +83,7 @@ class XMLParserTests0994: XMLAbstractTest { func testSayForBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0994") - let sayForBubbleBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 36) as! Brick + let sayForBubbleBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 36) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(sayForBubbleBrick.isKind(of: SayForBubbleBrick.self), "Invalid brick type") @@ -96,10 +96,10 @@ class XMLParserTests0994: XMLAbstractTest { func testSoundList() { let project = self.getProjectForXML(xmlFile: "Flap_Pac_Man_0994") - var soundList = (project.scene.object(at: 0)!.soundList)! + var soundList = ((project.scenes[0] as! Scene).object(at: 0)!.soundList)! XCTAssertEqual(0, soundList.count) - soundList = (project.scene.object(at: 1)!.soundList)! + soundList = ((project.scenes[0] as! Scene).object(at: 1)!.soundList)! XCTAssertEqual(2, soundList.count) var sound = soundList.object(at: 0) as! Sound @@ -112,7 +112,7 @@ class XMLParserTests0994: XMLAbstractTest { XCTAssertEqual(sound.name, "Evo2MinusScore2", "Wrong Sound name") XCTAssertEqual(sound.fileName, "cb61b2020b42d8b6276bb374dda290e2_Evo2MinusScore2.wav", "Wrong Sound fileName") - let playSoundBrick = (project.scene.object(at: 1)!.scriptList.object(at: 1) as! Script).brickList.object(at: 14) as! PlaySoundBrick + let playSoundBrick = ((project.scenes[0] as! Scene).object(at: 1)!.scriptList.object(at: 1) as! Script).brickList.object(at: 14) as! PlaySoundBrick XCTAssertTrue(playSoundBrick.sound.isEqual(sound), "Invalid Sound reference") } diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.995/XMLParserTests0995.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.995/XMLParserTests0995.swift index e656ae5f93..b45f058606 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.995/XMLParserTests0995.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.995/XMLParserTests0995.swift @@ -49,7 +49,7 @@ class XMLParserTests0995: XMLAbstractTest { func testSetPenColorBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0995") - let setPenColorBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick + let setPenColorBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(setPenColorBrick.isKind(of: SetPenColorBrick.self), "Invalid brick type") @@ -63,7 +63,7 @@ class XMLParserTests0995: XMLAbstractTest { func testGlideToBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0995") - let glideToBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick + let glideToBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(glideToBrick.isKind(of: GlideToBrick.self), "Invalid brick type") diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.996/XMLParserTests0996.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.996/XMLParserTests0996.swift index fd8709c155..d601a2e172 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.996/XMLParserTests0996.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.996/XMLParserTests0996.swift @@ -49,7 +49,7 @@ class XMLParserTests0996: XMLAbstractTest { func testSetPenColorBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0996") - let setPenColorBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick + let setPenColorBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(setPenColorBrick.isKind(of: SetPenColorBrick.self), "Invalid brick type") @@ -62,7 +62,7 @@ class XMLParserTests0996: XMLAbstractTest { func testGlideToBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0996") - let glideToBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick + let glideToBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(glideToBrick.isKind(of: GlideToBrick.self), "Invalid brick type") @@ -75,7 +75,7 @@ class XMLParserTests0996: XMLAbstractTest { func testParseLookAndLooklist() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0996") - let looklist = project.scene.object(at: 0)!.lookList + let looklist = (project.scenes[0] as! Scene).object(at: 0)!.lookList XCTAssertEqual(1, looklist!.count) let look = (looklist?.object(at: 0)) as! Look @@ -85,7 +85,7 @@ class XMLParserTests0996: XMLAbstractTest { func testParseSoundAndSoundlist() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0996") - let soundlist = ((project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 9) as! PointToBrick).pointedObject.soundList + let soundlist = (((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 9) as! PointToBrick).pointedObject.soundList XCTAssertEqual(1, soundlist!.count) let sound = (soundlist?.object(at: 0)) as! Sound @@ -95,17 +95,17 @@ class XMLParserTests0996: XMLAbstractTest { func testParseLocalLists() { let project = self.getProjectForXML(xmlFile: "UserLists_0996") - let objects = project.scene.objects() + let objects = (project.scenes[0] as! Scene).objects() XCTAssertEqual(3, objects.count) - let backgroundObject = project.scene.object(at: 0) + let backgroundObject = (project.scenes[0] as! Scene).object(at: 0) XCTAssertEqual("Background", backgroundObject?.name) let localLists = backgroundObject?.userData.lists() XCTAssertEqual(1, localLists?.count) XCTAssertEqual("localListBackground", localLists?[0].name) - let object = project.scene.object(at: 1) + let object = (project.scenes[0] as! Scene).object(at: 1) XCTAssertEqual("Object1", object?.name) let localListsObject = object?.userData.lists() diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.998/XMLParserTests0998.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.998/XMLParserTests0998.swift index 17db6b9da8..331cf92fff 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.998/XMLParserTests0998.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.998/XMLParserTests0998.swift @@ -49,7 +49,7 @@ class XMLParserTests0998: XMLAbstractTest { func testSetPenColorBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let setPenColorBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick + let setPenColorBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(setPenColorBrick.isKind(of: SetPenColorBrick.self), "Invalid brick type") @@ -62,7 +62,7 @@ class XMLParserTests0998: XMLAbstractTest { func testGlideToBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let glideToBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick + let glideToBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(glideToBrick.isKind(of: GlideToBrick.self), "Invalid brick type") @@ -75,7 +75,7 @@ class XMLParserTests0998: XMLAbstractTest { func testThinkForBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let thinkForBubbleBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 37) as! Brick + let thinkForBubbleBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 37) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(thinkForBubbleBrick.isKind(of: ThinkForBubbleBrick.self), "Invalid brick type") @@ -87,7 +87,7 @@ class XMLParserTests0998: XMLAbstractTest { func testThinkBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let thinkBubbleBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 35) as! Brick + let thinkBubbleBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 35) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(thinkBubbleBrick.isKind(of: ThinkBubbleBrick.self), "Invalid brick type") @@ -98,7 +98,7 @@ class XMLParserTests0998: XMLAbstractTest { func testSpeakAndWaitBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let speakAndWaitBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 31) as! Brick + let speakAndWaitBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 31) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(speakAndWaitBrick.isKind(of: SpeakAndWaitBrick.self), "Invalid brick type") diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.999/XMLParserTests0999.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.999/XMLParserTests0999.swift index 049e797f5b..cc3eaef20a 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.999/XMLParserTests0999.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.999/XMLParserTests0999.swift @@ -49,7 +49,7 @@ class XMLParserTests0999: XMLAbstractTest { func testSetPenColorBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0999") - let setPenColorBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick + let setPenColorBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(setPenColorBrick.isKind(of: SetPenColorBrick.self), "Invalid brick type") @@ -62,7 +62,7 @@ class XMLParserTests0999: XMLAbstractTest { func testGlideToBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let glideToBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick + let glideToBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 10) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(glideToBrick.isKind(of: GlideToBrick.self), "Invalid brick type") @@ -75,7 +75,7 @@ class XMLParserTests0999: XMLAbstractTest { func testThinkForBubbleBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let thinkForBubbleBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 37) as! Brick + let thinkForBubbleBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 37) as! Brick XCTAssertEqual(0, project.unsupportedElements.count) XCTAssertTrue(thinkForBubbleBrick.isKind(of: ThinkForBubbleBrick.self), "Invalid brick type") @@ -87,7 +87,7 @@ class XMLParserTests0999: XMLAbstractTest { func testInsertItemIntoUserListBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks0998") - let insertItemIntoUserListBrick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 49) as! Brick + let insertItemIntoUserListBrick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 49) as! Brick let castedBrick = insertItemIntoUserListBrick as! InsertItemIntoUserListBrick XCTAssertTrue(castedBrick.index.isEqual(to: Formula(integer: 2)), "Invalid formula") diff --git a/src/CattyTests/XML/Parser/CatrobatLanguage0.9993/XMLParserTests09993.swift b/src/CattyTests/XML/Parser/CatrobatLanguage0.9993/XMLParserTests09993.swift index df7a16a57a..4bcc2ea498 100644 --- a/src/CattyTests/XML/Parser/CatrobatLanguage0.9993/XMLParserTests09993.swift +++ b/src/CattyTests/XML/Parser/CatrobatLanguage0.9993/XMLParserTests09993.swift @@ -51,8 +51,8 @@ class XMLParserTests09993: XMLAbstractTest { let project = self.getProjectForXML(xmlFile: "BackwardsCompatibleFaceDetectionSensors") let objectCount = 2 - XCTAssertEqual(project.scene.objects().count, objectCount, "Invalid object list") - let object = project.scene.object(at: 1)! + XCTAssertEqual((project.scenes[0] as! Scene).objects().count, objectCount, "Invalid object list") + let object = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertEqual(object.scriptList.count, 1, "Invalid script list") let script = object.scriptList.object(at: 0) as! Script XCTAssertEqual(script.brickList.count, 9, "Invalid brick list") @@ -76,8 +76,8 @@ class XMLParserTests09993: XMLAbstractTest { let project = self.getProjectForXML(xmlFile: "FaceDetectionSensors") let objectCount = 3 - XCTAssertEqual(project.scene.objects().count, objectCount, "Invalid object list") - var object = project.scene.object(at: 1)! + XCTAssertEqual((project.scenes[0] as! Scene).objects().count, objectCount, "Invalid object list") + var object = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertEqual(object.scriptList.count, 1, "Invalid script list") var script = object.scriptList.object(at: 0) as! Script XCTAssertEqual(script.brickList.count, 9, "Invalid brick list") @@ -96,7 +96,7 @@ class XMLParserTests09993: XMLAbstractTest { XCTAssertEqual(FacePositionXSensor.tag, placeAtBrick.getFormulas()[0].formulaTree.value) XCTAssertEqual(FacePositionYSensor.tag, placeAtBrick.getFormulas()[1].formulaTree.value) - object = project.scene.object(at: 2)! + object = (project.scenes[0] as! Scene).object(at: 2)! XCTAssertEqual(object.scriptList.count, 1, "Invalid script list") script = object.scriptList.object(at: 0) as! Script XCTAssertEqual(script.brickList.count, 9, "Invalid brick list") @@ -129,9 +129,9 @@ class XMLParserTests09993: XMLAbstractTest { var sensorIndex = 0 let objectCount = 19 - XCTAssertEqual(project.scene.objects().count, objectCount, "Invalid object list") + XCTAssertEqual((project.scenes[0] as! Scene).objects().count, objectCount, "Invalid object list") for objectIndex in 1.. 1) + XCTAssertTrue((project.scenes[0] as! Scene).objects().count > 1) - let firstObject = project.scene.object(at: 1)! - project.scene.removeObject(firstObject) + let firstObject = (project.scenes[0] as! Scene).object(at: 1)! + (project.scenes[0] as! Scene).removeObject(firstObject) let serializerContext = CBXMLSerializerContext(project: project) let xmlElement = project.xmlElement(with: serializerContext) XCTAssertNotNil(xmlElement, "Error during serialization of removed object") - XCTAssertEqual(project.scene.objects().count + 1, referenceProject.scene.objects().count, "Object not properly removed") + XCTAssertEqual((project.scenes[0] as! Scene).objects().count + 1, (referenceProject.scenes[0] as! Scene).objects().count, "Object not properly removed") XCTAssertFalse((referenceProject.xmlElement(with: CBXMLSerializerContext(project: Project())).isEqual(to: xmlElement)), "Object not properly removed") let parserContext = CBXMLParserContext(languageVersion: CGFloat(Float32(0.9993)), andRootElement: xmlElement) @@ -76,7 +76,7 @@ final class XMLSerializerTests: XMLAbstractTest { let project = self.getProjectForXML(xmlFile: "PointToBrickWithoutSpriteObject") XCTAssertNotNil(project, "Project must not be nil!") - let moleTwo = project.scene.object(at: 1)! + let moleTwo = (project.scenes[0] as! Scene).object(at: 1)! XCTAssertNotNil(moleTwo, "SpriteObject must not be nil!") XCTAssertEqual(moleTwo.name, "Mole 2", "Invalid object name!") @@ -87,7 +87,7 @@ final class XMLSerializerTests: XMLAbstractTest { XCTAssertNotNil(pointToBrick, "PointToBrick must not be nil!") let context = CBXMLSerializerContext(project: project) - context?.spriteObjectList = NSMutableArray(array: project.scene.objects()) + context?.spriteObjectList = NSMutableArray(array: (project.scenes[0] as! Scene).objects()) let xmlElementPath = "//program/objectList/object[2]/scriptList/script[1]/brickList/brick[8]" let equal = self.isXMLElement(xmlElement: pointToBrick.xmlElement(with: context), equalToXMLElementForXPath: xmlElementPath, inProjectForXML: "PointToBrickWithoutSpriteObject") @@ -98,7 +98,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testPenDownBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks09993") - let brick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 42) as! PenDownBrick + let brick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 42) as! PenDownBrick let xmlElementPath = "//program/objectList/object[1]/scriptList/script[1]/brickList/brick[42]" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: Project())) else { @@ -112,7 +112,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testPenUpBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks09993") - let brick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 43) as! PenUpBrick + let brick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 43) as! PenUpBrick let xmlElementPath = "//program/objectList/object[1]/scriptList/script[1]/brickList/brick[43]" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: Project())) else { @@ -126,7 +126,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testPenClearBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks09993") - let brick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 44) as! PenClearBrick + let brick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 44) as! PenClearBrick let xmlElementPath = "//program/objectList/object[1]/scriptList/script[1]/brickList/brick[44]" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: Project())) else { @@ -140,7 +140,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testSetPenSizeBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks09993") - let brick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 45) as! SetPenSizeBrick + let brick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 45) as! SetPenSizeBrick let xmlElementPath = "//program/objectList/object[1]/scriptList/script[1]/brickList/brick[45]" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: Project())) else { @@ -154,7 +154,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testSetPenColorBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks09993") - let brick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! SetPenColorBrick + let brick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 46) as! SetPenColorBrick let xmlElementPath = "//program/scenes/scene/objectList/object[1]/scriptList/script[1]/brickList/brick[47]" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: project)) else { @@ -169,7 +169,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testStampBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks09993") - let brick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 47) as! StampBrick + let brick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 47) as! StampBrick let xmlElementPath = "//program/objectList/object[1]/scriptList/script[1]/brickList/brick[47]" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: Project())) else { @@ -183,7 +183,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testAddItemToUserListBrick() { let project = self.getProjectForXML(xmlFile: "ValidProjectAllBricks09993") - let brick = (project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 48) as! AddItemToUserListBrick + let brick = ((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 48) as! AddItemToUserListBrick let xmlElementPath = "//program/scenes/scene[1]/objectList/object[1]/scriptList/script[1]/brickList/brick[49]" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: project)) else { @@ -197,7 +197,7 @@ final class XMLSerializerTests: XMLAbstractTest { func testUserVariables() { let project = self.getProjectForXML(xmlFile: "UserVariables_09993") - let brick = ((project.scene.object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 2) as! ChangeVariableBrick).userVariable as UserVariable + let brick = (((project.scenes[0] as! Scene).object(at: 0)!.scriptList.object(at: 0) as! Script).brickList.object(at: 2) as! ChangeVariableBrick).userVariable as UserVariable let xmlElementPath = "//program/scenes/scene[1]/objectList/object[1]/scriptList/script[1]/brickList/brick[3]/userVariable" guard let xmlElement = brick.xmlElement(with: CBXMLSerializerContext(project: project)) else { diff --git a/src/CattyTests/XML/XMLParseMultipleScenesTests.swift b/src/CattyTests/XML/XMLParseMultipleScenesTests.swift new file mode 100644 index 0000000000..2c09ae1a5a --- /dev/null +++ b/src/CattyTests/XML/XMLParseMultipleScenesTests.swift @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2010-2023 The Catrobat Team + * (http://developer.catrobat.org/credits) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * An additional term exception under section 7 of the GNU Affero + * General Public License, version 3, is available at + * (http://developer.catrobat.org/license_additional_term) + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +import Foundation +import XCTest + +@testable import Pocket_Code + +class ParseMultipleScenesTests: XMLAbstractTest { + + func testBasicTwoSceneFile() { + let project = self.getProjectForXML(xmlFile: "MultipleScenes") + XCTAssertEqual(project.scenes.count, 2) + + let scene1 = project.scenes[0] as! Scene + XCTAssertEqual(scene1.name, "Scene 1") + XCTAssertEqual(scene1.objects().count, 1) + + let obj1 = scene1.objects()[0] + XCTAssertEqual(obj1.name, "Background") + XCTAssertEqual(obj1.lookList.count, 1) + XCTAssertEqual(obj1.scriptList.count, 0) + XCTAssertEqual(obj1.soundList.count, 0) + + let look1 = obj1.lookList[0] as! Look + XCTAssertEqual(look1.name, "automatic_screenshot") + XCTAssertEqual(look1.fileName, "5235c2eecb956adf8c3ff3e3e9f295e9_automatic_screenshot.png") + + let scene2 = project.scenes[1] as! Scene + XCTAssertEqual(scene2.name, "Scene 2") + XCTAssertEqual(scene2.objects().count, 1) + + let obj2 = scene2.objects()[0] + XCTAssertEqual(obj2.name, "Background") + XCTAssertEqual(obj2.lookList.count, 1) + XCTAssertEqual(obj2.scriptList.count, 0) + XCTAssertEqual(obj2.soundList.count, 0) + + let look2 = obj2.lookList[0] as! Look + XCTAssertEqual(look2.name, "North Pole") + XCTAssertEqual(look2.fileName, "8ada7bc98ee101e3877ceb3bc9bcc254_North Pole.png") + } +} diff --git a/src/CattyUITests/MyFirstProjectTests.swift b/src/CattyUITests/MyFirstProjectTests.swift index 596a47ba57..a1d95e2397 100644 --- a/src/CattyUITests/MyFirstProjectTests.swift +++ b/src/CattyUITests/MyFirstProjectTests.swift @@ -37,14 +37,14 @@ class MyFirstProjectTests: XCTestCase { app.navigationBars[kLocalizedMyFirstProject].buttons[kLocalizedEdit].tap() app.buttons[kLocalizedDeleteObjects].tap() let tablesQuery = app.tables - tablesQuery.staticTexts["Mole 1"].tap() - tablesQuery.staticTexts["Mole 2"].tap() + tablesQuery.staticTexts["\(kLocalizedMole) 1"].tap() + tablesQuery.staticTexts["\(kLocalizedMole) 2"].tap() app.toolbars.buttons[kLocalizedDelete].tap() XCTAssert(app.tables.staticTexts[kLocalizedBackground].exists) - XCTAssert(app.tables.staticTexts["Mole 1"].exists == false) - XCTAssert(app.tables.staticTexts["Mole 2"].exists == false) - XCTAssert(app.tables.staticTexts["Mole 3"].exists) - XCTAssert(app.tables.staticTexts["Mole 4"].exists) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 1"].exists == false) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 2"].exists == false) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 3"].exists) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 4"].exists) } func testCanRenameProjectViaEditMode() { @@ -139,33 +139,33 @@ class MyFirstProjectTests: XCTestCase { app.tables.staticTexts[kLocalizedProjectsOnDevice].tap() app.tables.staticTexts[kLocalizedMyFirstProject].tap() let tablesQuery = app.tables - tablesQuery.staticTexts["Mole 3"].swipeLeft() + tablesQuery.staticTexts["\(kLocalizedMole) 3"].swipeLeft() XCTAssert(app.buttons[kLocalizedDelete].exists) app.buttons[kLocalizedDelete].tap() let yesButton = app.alerts[kLocalizedDeleteThisObject].buttons[kLocalizedCancel] yesButton.tap() - XCTAssert(app.tables.staticTexts["Mole 3"].exists) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 3"].exists) } func testCanDeleteSingleObjectViaSwipe() { app.tables.staticTexts[kLocalizedProjectsOnDevice].tap() app.tables.staticTexts[kLocalizedMyFirstProject].tap() let tablesQuery = app.tables - tablesQuery.staticTexts["Mole 1"].swipeLeft() + tablesQuery.staticTexts["\(kLocalizedMole) 1"].swipeLeft() XCTAssert(app.buttons[kLocalizedDelete].exists) app.buttons[kLocalizedDelete].tap() let yesButton = app.alerts[kLocalizedDeleteThisObject].buttons[kLocalizedYes] yesButton.tap() - XCTAssert(app.tables.staticTexts["Mole 1"].exists == false) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 1"].exists == false) } func testCanRenameSingleObjectViaSwipe() { app.tables.staticTexts[kLocalizedProjectsOnDevice].tap() app.tables.staticTexts[kLocalizedMyFirstProject].tap() let tablesQuery = app.tables - tablesQuery.staticTexts["Mole 3"].swipeLeft() + tablesQuery.staticTexts["\(kLocalizedMole) 3"].swipeLeft() XCTAssert(app.buttons[kLocalizedMore].exists) app.buttons[kLocalizedMore].tap() @@ -173,17 +173,17 @@ class MyFirstProjectTests: XCTestCase { let alert = waitForElementToAppear(app.alerts[kLocalizedRenameObject]) alert.buttons["Clear text"].tap() - alert.textFields[kLocalizedEnterYourObjectNameHere].typeText("Mole 5") + alert.textFields[kLocalizedEnterYourObjectNameHere].typeText("\(kLocalizedMole) 5") alert.buttons[kLocalizedOK].tap() - XCTAssert(app.tables.staticTexts["Mole 5"].exists) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 5"].exists) } func testCanAbortRenameSingleObjectViaSwipe() { app.tables.staticTexts[kLocalizedProjectsOnDevice].tap() app.tables.staticTexts[kLocalizedMyFirstProject].tap() let tablesQuery = app.tables - tablesQuery.staticTexts["Mole 1"].swipeLeft() + tablesQuery.staticTexts["\(kLocalizedMole) 1"].swipeLeft() XCTAssert(app.buttons[kLocalizedMore].exists) app.buttons[kLocalizedMore].tap() @@ -191,30 +191,30 @@ class MyFirstProjectTests: XCTestCase { let alert = waitForElementToAppear(app.alerts[kLocalizedRenameObject]) alert.buttons["Clear text"].tap() - alert.textFields[kLocalizedEnterYourObjectNameHere].typeText("Mole 5") + alert.textFields[kLocalizedEnterYourObjectNameHere].typeText("\(kLocalizedMole) 5") alert.buttons[kLocalizedCancel].tap() - XCTAssert(app.tables.staticTexts["Mole 1"].exists) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 1"].exists) } func testCanCopySingleObjectViaSwipe() { app.tables.staticTexts[kLocalizedProjectsOnDevice].tap() app.tables.staticTexts[kLocalizedMyFirstProject].tap() let tablesQuery = app.tables - tablesQuery.staticTexts["Mole 1"].swipeLeft() + tablesQuery.staticTexts["\(kLocalizedMole) 1"].swipeLeft() XCTAssert(app.buttons[kLocalizedMore].exists) app.buttons[kLocalizedMore].tap() app.buttons[kLocalizedCopy].tap() app.swipeDown() - XCTAssert(app.tables.staticTexts["Mole 1 (1)"].exists) + XCTAssert(app.tables.staticTexts["\(kLocalizedMole) 1 (1)"].exists) } func testCanAbortSwipe() { app.tables.staticTexts[kLocalizedProjectsOnDevice].tap() app.tables.staticTexts[kLocalizedMyFirstProject].tap() let tablesQuery = app.tables - tablesQuery.staticTexts["Mole 1"].swipeLeft() + tablesQuery.staticTexts["\(kLocalizedMole) 1"].swipeLeft() XCTAssert(app.buttons[kLocalizedMore].exists) app.buttons[kLocalizedMore].tap()