From 015dbba595082dd9de8483bb4b1fd19864a18c9c Mon Sep 17 00:00:00 2001 From: Blair McGlashan Date: Sun, 29 Dec 2024 09:57:55 +0000 Subject: [PATCH] Fix #1315: View Composer cannot save new view (#1316) --- .../Dolphin/Base/UI.ResourceIdentifier.cls | 2 +- .../Tests/UI.Tests.ResourceIdentifierTest.cls | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Core/Object Arts/Dolphin/Base/UI.ResourceIdentifier.cls b/Core/Object Arts/Dolphin/Base/UI.ResourceIdentifier.cls index a1a1dd3d3..eeb1ab864 100644 --- a/Core/Object Arts/Dolphin/Base/UI.ResourceIdentifier.cls +++ b/Core/Object Arts/Dolphin/Base/UI.ResourceIdentifier.cls @@ -191,7 +191,7 @@ class: aClass name: aString yourself! class: aClass selector: aSymbol - (aSymbol beginsWith: SelectorPrefix) + (aSymbol isNil or: [aSymbol beginsWith: SelectorPrefix]) ifFalse: [self error: 'Invalid resource selector ' , aSymbol printString]. ^self newClass: aClass selector: aSymbol! diff --git a/Core/Object Arts/Dolphin/MVP/Tests/UI.Tests.ResourceIdentifierTest.cls b/Core/Object Arts/Dolphin/MVP/Tests/UI.Tests.ResourceIdentifierTest.cls index 5c4246d4a..d51fe9728 100644 --- a/Core/Object Arts/Dolphin/MVP/Tests/UI.Tests.ResourceIdentifierTest.cls +++ b/Core/Object Arts/Dolphin/MVP/Tests/UI.Tests.ResourceIdentifierTest.cls @@ -51,6 +51,23 @@ testAssignResource [self class class removeSelector: #resource_Test_view ifAbsent: nil. self assert: (self class respondsTo: #resource_Test_view) not]! +testCopy + | subject copy | + subject := ResourceIdentifier class: Shell name: Shell defaultView. + copy := subject copy. + self assert: copy equals: subject. + self deny: copy identicalTo: subject. + self assert: copy owningClass identicalTo: subject owningClass. + self assert: copy selector identicalTo: subject selector. + subject name: nil. + self assertIsNil: subject selector. + self assert: subject printString equals: 'Shell.untitled'. + copy := subject copy. + self assert: copy equals: subject. + self deny: copy identicalTo: subject. + self assert: copy owningClass identicalTo: subject owningClass. + self assert: copy selector identicalTo: subject selector! + testDeserializeAll "Test's that all view resources are deserializable. The most common cause of breakage would be changing the layout of a class with serialized instances in resources without adding an @@ -119,6 +136,7 @@ createResourceNamed:for:on:!helpers!private! ! setUp!private!unit tests! ! tempViewResource!private!unit tests! ! testAssignResource!public!unit tests! ! +testCopy!public!unit tests! ! testDeserializeAll!public!unit tests! ! testReferenceToNonExistentView!public!unit tests! ! testResourceSelector!public!unit tests! !