@@ -38,6 +38,7 @@ const instanceFactory = jest.fn(() => ({
3838 getGuiTree : jest . fn < ScvdGuiInterface [ ] | undefined , [ ] > ( ( ) => [ ] ) ,
3939 updateActiveSession : jest . fn ( ) ,
4040 cancelExecution : jest . fn ( ) ,
41+ setSvdPath : jest . fn ( ) ,
4142} ) ) ;
4243
4344jest . mock ( '../../component-viewer-instance' , ( ) => ( {
@@ -157,12 +158,12 @@ describe('ComponentViewerBase', () => {
157158 expect ( vscode . commands . registerCommand ) . toHaveBeenCalledWith ( 'vscode-cmsis-debugger.testClass.lockComponent' , expect . any ( Function ) ) ;
158159 expect ( vscode . commands . registerCommand ) . toHaveBeenCalledWith ( 'vscode-cmsis-debugger.testClass.unlockComponent' , expect . any ( Function ) ) ;
159160 expect ( vscode . commands . registerCommand ) . toHaveBeenCalledWith ( 'vscode-cmsis-debugger.testClass.expandAll' , expect . any ( Function ) ) ;
160- // 1 tree view + 2 event listeners + 7 commands + 6 tracker disposables
161- expect ( context . subscriptions . length ) . toBe ( 16 ) ;
161+ // 1 tree view + 2 event listeners + 7 commands + 7 tracker disposables
162+ expect ( context . subscriptions . length ) . toBe ( 17 ) ;
162163 expect ( vscode . commands . registerCommand ) . toHaveBeenCalledWith ( 'vscode-cmsis-debugger.testClass.filterTree' , expect . any ( Function ) ) ;
163164 expect ( vscode . commands . registerCommand ) . toHaveBeenCalledWith ( 'vscode-cmsis-debugger.testClass.clearFilter' , expect . any ( Function ) ) ;
164- // 1 tree view + 2 event listeners + 7 commands + 6 tracker disposables
165- expect ( context . subscriptions . length ) . toBe ( 16 ) ;
165+ // 1 tree view + 2 event listeners + 7 commands + 7 tracker disposables
166+ expect ( context . subscriptions . length ) . toBe ( 17 ) ;
166167 } ) ;
167168
168169 it ( 'should fail to activate the test class tree data provider if view is not correctly loaded' , async ( ) => {
@@ -213,6 +214,22 @@ describe('ComponentViewerBase', () => {
213214 expect ( instanceFactory ) . toHaveBeenCalledTimes ( 2 ) ;
214215 } ) ;
215216
217+ it ( 'sets svd path from debug configuration when reading scvd files' , async ( ) => {
218+ const session = debugSessionFactory ( 's1' , [ 'a.scvd' ] ) ;
219+ ( session . session as unknown as { configuration : { definitionPath : string } } ) . configuration = {
220+ definitionPath : '/device.svd' ,
221+ } ;
222+ ( controller as unknown as { _activeSession ?: Session } ) . _activeSession = session ;
223+
224+ const instance = instanceFactory ( ) ;
225+ instanceFactory . mockImplementationOnce ( ( ) => instance ) ;
226+
227+ const readScvdFiles = getReadScvdFiles ( controller ) ;
228+ await readScvdFiles ( tracker , session ) ;
229+
230+ expect ( instance . setSvdPath ) . toHaveBeenCalledWith ( '/device.svd' ) ;
231+ } ) ;
232+
216233 it ( 'skips reading scvd files when no active session is set' , async ( ) => {
217234 const session = debugSessionFactory ( 's1' , [ 'a.scvd' ] ) ;
218235 const readScvdFiles = getReadScvdFiles ( controller ) ;
@@ -235,6 +252,7 @@ describe('ComponentViewerBase', () => {
235252 getGuiTree : jest . fn ( ( ) => [ ] ) ,
236253 updateActiveSession : jest . fn ( ) ,
237254 cancelExecution : jest . fn ( ) ,
255+ setSvdPath : jest . fn ( ) ,
238256 } ) ) ;
239257 const showErrorSpy = jest . spyOn ( vscode . window , 'showErrorMessage' ) . mockResolvedValue ( undefined ) ;
240258 const errorSpy = jest . spyOn ( componentViewerLogger , 'error' ) ;
@@ -292,6 +310,8 @@ describe('ComponentViewerBase', () => {
292310 await tracker . callbacks . stackTrace ?.( { session } ) ;
293311 expect ( ( controller as unknown as { _activeSession ?: Session } ) . _activeSession ) . toBe ( session ) ;
294312
313+ await tracker . callbacks . memory ?.( { session } ) ;
314+
295315
296316 ( controller as unknown as { _activeSession ?: Session } ) . _activeSession = session ;
297317 await tracker . callbacks . willStop ?.( session ) ;
@@ -351,6 +371,21 @@ describe('ComponentViewerBase', () => {
351371 expect ( ( controller as unknown as { _activeSession ?: Session } ) . _activeSession ) . toBe ( sessionA ) ;
352372 } ) ;
353373
374+ it ( 'updates instances on memory event' , async ( ) => {
375+ const sessionA = debugSessionFactory ( 's1' , [ ] , 'stopped' ) ;
376+
377+ ( controller as unknown as { _activeSession ?: Session } ) . _activeSession = sessionA ;
378+
379+ const scheduleSpy = jest
380+ . spyOn ( controller as unknown as { schedulePendingUpdate : ( reason : UpdateReason ) => void } , 'schedulePendingUpdate' )
381+ . mockImplementation ( ( ) => undefined ) ;
382+
383+ const handleOnMemoryEvent = ( controller as unknown as { handleOnMemoryEvent : ( s : Session ) => Promise < void > } ) . handleOnMemoryEvent . bind ( controller ) ;
384+ await handleOnMemoryEvent ( sessionA ) ;
385+
386+ expect ( scheduleSpy ) . toHaveBeenCalledWith ( 'stackTrace' ) ;
387+ } ) ;
388+
354389 it ( 'does not update active session when stack item matches the active session' , async ( ) => {
355390 const sessionA = debugSessionFactory ( 's1' ) ;
356391 const updateSpy = jest . fn ( ) ;
0 commit comments