@@ -46,10 +46,20 @@ local({
4646 " jgd <- function() {" ,
4747 " path <- Sys.getenv('JGD_TEST_DEVICE_LOG', '')" ,
4848 " if (nzchar(path)) cat('jgd\\ n', file=path, append=TRUE)" ,
49+ # sess now tracks the opened device and attaches its session identity.
50+ # A null PDF supplies a real device without requiring a JGD renderer.
51+ " grDevices::pdf(NULL)" ,
52+ " invisible(NULL)" ,
53+ " }" ,
54+ " jgd_server_info <- function() list(server_info=c(deviceId=as.character(grDevices::dev.cur())))" ,
55+ " jgd_frame_ext <- function(value) {" ,
56+ " path <- Sys.getenv('JGD_TEST_DEVICE_LOG', '')" ,
57+ " if (nzchar(path)) cat(value, '\\ n', file=paste0(path, '-frames'), append=TRUE)" ,
4958 " invisible(NULL)" ,
5059 " }"
5160 ), file.path(package , " R" , " api.R" ))
52- writeLines(c(" export(fixture_device)" , " export(jgd)" ), file.path(package , " NAMESPACE" ))
61+ writeLines(c(" export(fixture_device)" , " export(jgd)" ,
62+ " export(jgd_server_info)" , " export(jgd_frame_ext)" ), file.path(package , " NAMESPACE" ))
5363 previous <- setwd(root )
5464 on.exit(setwd(previous ), add = TRUE )
5565 output <- system2_with_child_environment(
@@ -336,6 +346,16 @@ local({
336346 " fixture-jgd-socket-next" , " TRUE" )))
337347 stopifnot(identical(readLines(file.path(root , " real-approved-real-device" ), warn = FALSE ),
338348 c(" jgd" , " jgd" )))
349+ frames <- lapply(readLines(file.path(root , " real-approved-real-device-frames" ), warn = FALSE ),
350+ jsonlite :: fromJSON )
351+ stopifnot(length(frames ) == 2L )
352+ stopifnot(all(vapply(frames , function (frame ) {
353+ identity <- frame $ vscodeR
354+ nzchar(identity $ sessionId ) && nzchar(identity $ pid ) &&
355+ nzchar(identity $ deviceId ) && identical(identity $ restoring , FALSE )
356+ }, logical (1 ))))
357+ stopifnot(identical(frames [[1L ]]$ vscodeR $ sessionId , frames [[2L ]]$ vscodeR $ sessionId ))
358+ stopifnot(! identical(frames [[1L ]]$ vscodeR $ deviceId , frames [[2L ]]$ vscodeR $ deviceId ))
339359
340360 approved_root <- file.path(root , " approved" )
341361 dir.create(approved_root )
0 commit comments