@@ -145,11 +145,18 @@ interface ISerializedTestInput {
145145
146146class TestEditorInputFactory implements IEditorInputFactory {
147147
148+ static disableSerialize = false ;
149+ static disableDeserialize = false ;
150+
148151 canSerialize ( editorInput : EditorInput ) : boolean {
149152 return true ;
150153 }
151154
152- serialize ( editorInput : EditorInput ) : string {
155+ serialize ( editorInput : EditorInput ) : string | undefined {
156+ if ( TestEditorInputFactory . disableSerialize ) {
157+ return undefined ;
158+ }
159+
153160 let testEditorInput = < TestEditorInput > editorInput ;
154161 let testInput : ISerializedTestInput = {
155162 id : testEditorInput . id
@@ -158,7 +165,11 @@ class TestEditorInputFactory implements IEditorInputFactory {
158165 return JSON . stringify ( testInput ) ;
159166 }
160167
161- deserialize ( instantiationService : IInstantiationService , serializedEditorInput : string ) : EditorInput {
168+ deserialize ( instantiationService : IInstantiationService , serializedEditorInput : string ) : EditorInput | undefined {
169+ if ( TestEditorInputFactory . disableDeserialize ) {
170+ return undefined ;
171+ }
172+
162173 let testInput : ISerializedTestInput = JSON . parse ( serializedEditorInput ) ;
163174
164175 return new TestEditorInput ( testInput . id ) ;
@@ -170,6 +181,9 @@ suite('Workbench editor groups', () => {
170181 let disposables : IDisposable [ ] = [ ] ;
171182
172183 setup ( ( ) => {
184+ TestEditorInputFactory . disableSerialize = false ;
185+ TestEditorInputFactory . disableDeserialize = false ;
186+
173187 disposables . push ( Registry . as < IEditorInputFactoryRegistry > ( EditorExtensions . EditorInputFactories ) . registerEditorInputFactory ( 'testEditorInputForGroups' , TestEditorInputFactory ) ) ;
174188 } ) ;
175189
@@ -296,18 +310,40 @@ suite('Workbench editor groups', () => {
296310 const input2 = input ( ) ;
297311 const input3 = input ( ) ;
298312
299- // Pinned and Active
313+ // Case 1: inputs can be serialized and deserialized
314+
300315 group . openEditor ( input1 , { pinned : true , active : true } ) ;
301316 group . openEditor ( input2 , { pinned : true , active : true } ) ;
302317 group . openEditor ( input3 , { pinned : false , active : true } ) ;
303318
304- const deserialized = createGroup ( group . serialize ( ) ) ;
319+ let deserialized = createGroup ( group . serialize ( ) ) ;
305320 assert . equal ( group . id , deserialized . id ) ;
306321 assert . equal ( deserialized . count , 3 ) ;
322+ assert . equal ( deserialized . getEditors ( EditorsOrder . SEQUENTIAL ) . length , 3 ) ;
323+ assert . equal ( deserialized . getEditors ( EditorsOrder . MOST_RECENTLY_ACTIVE ) . length , 3 ) ;
307324 assert . equal ( deserialized . isPinned ( input1 ) , true ) ;
308325 assert . equal ( deserialized . isPinned ( input2 ) , true ) ;
309326 assert . equal ( deserialized . isPinned ( input3 ) , false ) ;
310327 assert . equal ( deserialized . isActive ( input3 ) , true ) ;
328+
329+ // Case 2: inputs cannot be serialized
330+ TestEditorInputFactory . disableSerialize = true ;
331+
332+ deserialized = createGroup ( group . serialize ( ) ) ;
333+ assert . equal ( group . id , deserialized . id ) ;
334+ assert . equal ( deserialized . count , 0 ) ;
335+ assert . equal ( deserialized . getEditors ( EditorsOrder . SEQUENTIAL ) . length , 0 ) ;
336+ assert . equal ( deserialized . getEditors ( EditorsOrder . MOST_RECENTLY_ACTIVE ) . length , 0 ) ;
337+
338+ // Case 3: inputs cannot be deserialized
339+ TestEditorInputFactory . disableSerialize = false ;
340+ TestEditorInputFactory . disableDeserialize = true ;
341+
342+ deserialized = createGroup ( group . serialize ( ) ) ;
343+ assert . equal ( group . id , deserialized . id ) ;
344+ assert . equal ( deserialized . count , 0 ) ;
345+ assert . equal ( deserialized . getEditors ( EditorsOrder . SEQUENTIAL ) . length , 0 ) ;
346+ assert . equal ( deserialized . getEditors ( EditorsOrder . MOST_RECENTLY_ACTIVE ) . length , 0 ) ;
311347 } ) ;
312348
313349 test ( 'One Editor' , function ( ) {
0 commit comments