-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved compatibility with older project files
- Loading branch information
1 parent
d81f0de
commit ab0eb38
Showing
5 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
Class { | ||
#name : 'OPLegacyProjectLoadTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'workbench' | ||
], | ||
#category : 'OpenPonk-Spec-Tests', | ||
#package : 'OpenPonk-Spec', | ||
#tag : 'Tests' | ||
} | ||
|
||
{ #category : 'generating' } | ||
OPLegacyProjectLoadTest class >> generateFromDesktopProjects [ | ||
|
||
<script> | ||
FileLocator desktop asFileReference files | ||
select: [ :each | each extension = 'opp' ] | ||
thenDo: [ :file | self generateFromProjectFile: file ] | ||
] | ||
|
||
{ #category : 'generating' } | ||
OPLegacyProjectLoadTest class >> generateFromProjectFile: file [ | ||
|
||
| pluginName version modelName base64 className | | ||
pluginName := (file basename copyUpToLast: $-) capitalized. | ||
version := (file basename copyAfterLast: $-) reject: [ :each | | ||
each = $. ]. | ||
modelName := pluginName , version. | ||
|
||
file binaryReadStreamDo: [ :s | base64 := s upToEnd base64Encoded ]. | ||
base64 ifNil: [ self error ]. | ||
|
||
className := ('OP' , modelName , 'ProjectLoadTest') asSymbol. | ||
|
||
(OPLegacyProjectLoadTest << className) | ||
tag: 'Tests'; | ||
package: 'OpenPonk-Spec'; | ||
install. | ||
|
||
(Smalltalk at: className) compile: 'base64ProjectZip | ||
^''' , base64 , ''' | ||
' | ||
] | ||
|
||
{ #category : 'testing' } | ||
OPLegacyProjectLoadTest class >> isAbstract [ | ||
|
||
^ self = OPLegacyProjectLoadTest | ||
] | ||
|
||
{ #category : 'files' } | ||
OPLegacyProjectLoadTest >> base64ProjectZip [ | ||
|
||
^ self subclassResponsibility | ||
] | ||
|
||
{ #category : 'files' } | ||
OPLegacyProjectLoadTest >> file [ | ||
|
||
^ FileSystem memory root / 'testLegacyProject.opp' | ||
] | ||
|
||
{ #category : 'files' } | ||
OPLegacyProjectLoadTest >> projectZip [ | ||
|
||
| file | | ||
file := self file. | ||
file ensureDelete. | ||
file binaryWriteStreamDo: [ :s | | ||
s nextPutAll: self base64ProjectZip base64Decoded ]. | ||
file exists ifFalse: [ | ||
self error: 'Failed to save the base64 as file in memory' ]. | ||
file size isZero ifTrue: [ | ||
self error: 'File with base64 content is empty' ]. | ||
^ file | ||
] | ||
|
||
{ #category : 'running' } | ||
OPLegacyProjectLoadTest >> tearDown [ | ||
|
||
self file ensureDelete. | ||
workbench ifNotNil: [ workbench delete ]. | ||
super tearDown | ||
] | ||
|
||
{ #category : 'tests' } | ||
OPLegacyProjectLoadTest >> testLoad [ | ||
|
||
| project | | ||
project := OPProjectController fromFile: self projectZip. | ||
workbench := project open. | ||
self assert: workbench focusedEditor isNotNil. | ||
self assert: | ||
workbench focusedEditor canvasPresenter canvas shapes isNotEmpty | ||
] |