@@ -6,7 +6,7 @@ import { versionIsAtLeast } from "../../shared/utils";
66import { fsPath } from "../../shared/utils/fs" ;
77import { DartDebugClient } from "../dart_debug_client" ;
88import { createDebugClient , ensureServiceExtensionValue , flutterTestDeviceId , flutterTestDeviceIsWeb , killFlutterTester , startDebugger , waitAllThrowIfTerminates } from "../debug_helpers" ;
9- import { activateWithoutAnalysis , closeAllOpenFiles , customScriptExt , defer , deferUntilLast , delay , ensureHasRunWithArgsStarting , flutterHelloWorldFolder , flutterHelloWorldMainFile , flutterHelloWorldNavigateFromFile , flutterHelloWorldNavigateToFile , flutterHelloWorldOverflowFile , flutterHelloWorldReadmeFile , flutterHelloWorldStack60File , getLaunchConfiguration , getPackages , makeTrivialChangeToFileDirectly , openFile , positionOf , prepareHasRunFile , privateApi , saveTrivialChangeToFile , sb , setConfigForTest , waitForResult , watchPromise } from "../helpers" ;
9+ import { activateWithoutAnalysis , closeAllOpenFiles , customScriptExt , defer , deferUntilLast , delay , flutterHelloWorldFolder , flutterHelloWorldMainFile , flutterHelloWorldNavigateFromFile , flutterHelloWorldNavigateToFile , flutterHelloWorldOverflowFile , flutterHelloWorldReadmeFile , flutterHelloWorldStack60File , getLaunchConfiguration , getPackages , makeTrivialChangeToFileDirectly , openFile , positionOf , privateApi , saveTrivialChangeToFile , sb , setConfigForTest , waitForResult , watchPromise } from "../helpers" ;
1010
1111describe ( `flutter run debugger (only test device)` , ( ) => {
1212 beforeEach ( "Skip test-device tests on web" , function ( ) {
@@ -81,7 +81,7 @@ describe(`flutter run debugger (only test device)`, () => {
8181 } ) ;
8282 } ) ;
8383
84- it ( "can override platform, toggle brightness/ theme" , async ( ) => {
84+ it ( "can override platform/brightness and re-sends theme on hot restart only if set by us " , async ( ) => {
8585 const config = await startDebugger ( dc , flutterHelloWorldMainFile ) ;
8686 await waitAllThrowIfTerminates ( dc ,
8787 dc . flutterAppStarted ( ) ,
@@ -104,28 +104,6 @@ describe(`flutter run debugger (only test device)`, () => {
104104 // Wait for Brightness extension before trying to call it.
105105 await waitForResult ( ( ) => privateApi . debugCommands . vmServices . serviceExtensionIsLoaded ( VmServiceExtension . BrightnessOverride ) , "Brightness override loaded" ) ;
106106
107- await ensureServiceExtensionValue ( VmServiceExtension . BrightnessOverride , "Brightness.light" , dc ) ;
108- await vs . commands . executeCommand ( "flutter.toggleBrightness" ) ;
109- await ensureServiceExtensionValue ( VmServiceExtension . BrightnessOverride , "Brightness.dark" , dc ) ;
110- await vs . commands . executeCommand ( "flutter.toggleBrightness" ) ;
111- await ensureServiceExtensionValue ( VmServiceExtension . BrightnessOverride , "Brightness.light" , dc ) ;
112-
113- await waitAllThrowIfTerminates ( dc ,
114- dc . waitForEvent ( "terminated" ) ,
115- dc . terminateRequest ( ) ,
116- ) ;
117- } ) ;
118-
119- it ( "re-sends theme on hot restart only if set by us, not if set by someone else" , async ( ) => {
120- const config = await startDebugger ( dc , flutterHelloWorldMainFile ) ;
121- await waitAllThrowIfTerminates ( dc ,
122- dc . flutterAppStarted ( ) ,
123- dc . configurationSequence ( ) ,
124- dc . launch ( config ) ,
125- ) ;
126-
127- await waitForResult ( ( ) => privateApi . debugCommands . vmServices . serviceExtensionIsLoaded ( VmServiceExtension . BrightnessOverride ) , "Waiting for BrightnessOverride extension" , 60000 ) ;
128-
129107 // Re-sends theme on hot restart if set by us.
130108 {
131109 // Set the brightness to Dark through our toggle. This leaves us in control so we should
@@ -299,52 +277,41 @@ describe(`flutter run debugger (only test device)`, () => {
299277 ) ;
300278 } ) ;
301279
302- it ( "can run using a custom tool" , async ( ) => {
280+ it ( "passes custom tool in the launch config" , async ( ) => {
281+ // This only verifies the launch config (without spawning the app, which is slow).
282+ // The debug adapter tests cover testing that the custom tool is invoked.
303283 const root = fsPath ( flutterHelloWorldFolder ) ;
304- const hasRunFile = prepareHasRunFile ( root , "flutter" ) ;
305-
306- const config = await startDebugger ( dc , flutterHelloWorldMainFile , {
307- customTool : path . join ( root , `scripts/custom_flutter.${ customScriptExt } ` ) ,
284+ const customTool = path . join ( root , `scripts/custom_flutter.${ customScriptExt } ` ) ;
285+ const config = await getLaunchConfiguration ( flutterHelloWorldMainFile , {
286+ customTool,
308287 customToolReplacesArgs : 0 ,
288+ deviceId : flutterTestDeviceId ,
309289 } ) ;
310- await waitAllThrowIfTerminates ( dc ,
311- dc . assertOutputContains ( "console" , `Launching lib${ path . sep } main.dart on Flutter test device in debug mode...\n` ) ,
312- dc . flutterAppStarted ( ) ,
313- dc . configurationSequence ( ) ,
314- dc . launch ( config ) ,
315- ) ;
316290
317- await waitAllThrowIfTerminates ( dc ,
318- dc . waitForEvent ( "terminated" ) ,
319- dc . terminateRequest ( ) ,
320- ) ;
321-
322- ensureHasRunWithArgsStarting ( root , hasRunFile , "run --machine --start-paused" ) ;
291+ assert . equal ( config ! . customTool , customTool ) ;
292+ assert . equal ( config ! . customToolReplacesArgs , 0 ) ;
293+ assert . ok ( config ! . toolArgs ! . includes ( "-d" ) ) ;
294+ assert . ok ( config ! . toolArgs ! . includes ( flutterTestDeviceId ) ) ;
323295 } ) ;
324296
325- it ( "can replace all args using custom tool" , async ( ) => {
297+ it ( "passes custom tool args in the launch config" , async ( ) => {
298+ // This only verifies the config the extension produces (without spawning the
299+ // app, which is slow). The debug adapter replacing its args with these is
300+ // covered by the adapter's own tests.
326301 const root = fsPath ( flutterHelloWorldFolder ) ;
327- const hasRunFile = prepareHasRunFile ( root , "flutter" ) ;
328-
329- const config = await startDebugger ( dc , flutterHelloWorldMainFile , {
330- customTool : path . join ( root , `scripts/custom_flutter.${ customScriptExt } ` ) ,
302+ const customTool = path . join ( root , `scripts/custom_flutter.${ customScriptExt } ` ) ;
303+ // These differ to the usual ones so we can detect they replaced them.
304+ const toolArgs = [ "run" , "--ignore-deprecation" , "--start-paused" , "--machine" ] ;
305+ const config = await getLaunchConfiguration ( flutterHelloWorldMainFile , {
306+ customTool,
331307 customToolReplacesArgs : 999999 ,
332- // These differ to the usual ones so we can detect they replaced them.
333- toolArgs : [ "run" , "--ignore-deprecation" , "--start-paused" , "--machine" ] ,
308+ deviceId : flutterTestDeviceId ,
309+ toolArgs,
334310 } ) ;
335- await waitAllThrowIfTerminates ( dc ,
336- dc . assertOutputContains ( "console" , `Launching lib${ path . sep } main.dart on Flutter test device in debug mode...\n` ) ,
337- dc . flutterAppStarted ( ) ,
338- dc . configurationSequence ( ) ,
339- dc . launch ( config ) ,
340- ) ;
341-
342- await waitAllThrowIfTerminates ( dc ,
343- dc . waitForEvent ( "terminated" ) ,
344- dc . terminateRequest ( ) ,
345- ) ;
346311
347- ensureHasRunWithArgsStarting ( root , hasRunFile , "run --ignore-deprecation --start-paused --machine" ) ;
312+ assert . equal ( config ! . customTool , customTool ) ;
313+ assert . equal ( config ! . customToolReplacesArgs , 999999 ) ;
314+ assert . deepStrictEqual ( config ! . toolArgs ! . slice ( 0 , toolArgs . length ) , toolArgs ) ;
348315 } ) ;
349316
350317 it ( "can fetch slices of stack frames" , async ( ) => {
@@ -445,7 +412,7 @@ describe(`flutter run debugger (only test device)`, () => {
445412 } ) ;
446413
447414 describe ( "can evaluate at breakpoint" , ( ) => {
448- it ( "simple expressions" , async ( ) => {
415+ it ( "simple expressions, complex expressions, and expressions that return variables " , async ( ) => {
449416 await openFile ( flutterHelloWorldMainFile ) ;
450417 const config = await startDebugger ( dc , flutterHelloWorldMainFile ) ;
451418 await waitAllThrowIfTerminates ( dc ,
@@ -455,53 +422,30 @@ describe(`flutter run debugger (only test device)`, () => {
455422 } ) ,
456423 ) ;
457424
458- const evaluateResult = await dc . evaluateForFrame ( `"test"` ) ;
459- assert . ok ( evaluateResult ) ;
460- assert . equal ( evaluateResult . result , `"test"` ) ;
461- assert . equal ( evaluateResult . variablesReference , 0 ) ;
462-
463- await waitAllThrowIfTerminates ( dc ,
464- dc . waitForEvent ( "terminated" ) ,
465- dc . terminateRequest ( ) ,
466- ) ;
467- } ) ;
468-
469- it ( "complex expressions" , async ( ) => {
470- await openFile ( flutterHelloWorldMainFile ) ;
471- const config = await startDebugger ( dc , flutterHelloWorldMainFile ) ;
472- await waitAllThrowIfTerminates ( dc ,
473- dc . hitBreakpoint ( config , {
474- line : positionOf ( "^// BREAKPOINT1" ) . line ,
475- path : fsPath ( flutterHelloWorldMainFile ) ,
476- } ) ,
477- ) ;
478-
479- const evaluateResult = await dc . evaluateForFrame ( `(new DateTime.now()).year` ) ;
480- assert . ok ( evaluateResult ) ;
481- assert . equal ( evaluateResult . result , ( new Date ( ) ) . getFullYear ( ) . toString ( ) ) ;
482- assert . equal ( evaluateResult . variablesReference , 0 ) ;
483-
484- await waitAllThrowIfTerminates ( dc ,
485- dc . waitForEvent ( "terminated" ) ,
486- dc . terminateRequest ( ) ,
487- ) ;
488- } ) ;
425+ // Simple expressions.
426+ {
427+ const evaluateResult = await dc . evaluateForFrame ( `"test"` ) ;
428+ assert . ok ( evaluateResult ) ;
429+ assert . equal ( evaluateResult . result , `"test"` ) ;
430+ assert . equal ( evaluateResult . variablesReference , 0 ) ;
431+ }
489432
490- it ( "an expression that returns a variable" , async ( ) => {
491- await openFile ( flutterHelloWorldMainFile ) ;
492- const config = await startDebugger ( dc , flutterHelloWorldMainFile ) ;
493- await waitAllThrowIfTerminates ( dc ,
494- dc . hitBreakpoint ( config , {
495- line : positionOf ( "^// BREAKPOINT1" ) . line ,
496- path : fsPath ( flutterHelloWorldMainFile ) ,
497- } ) ,
498- ) ;
433+ // Complex expressions.
434+ {
435+ const evaluateResult = await dc . evaluateForFrame ( `(new DateTime.now()).year` ) ;
436+ assert . ok ( evaluateResult ) ;
437+ assert . equal ( evaluateResult . result , ( new Date ( ) ) . getFullYear ( ) . toString ( ) ) ;
438+ assert . equal ( evaluateResult . variablesReference , 0 ) ;
439+ }
499440
500- const evaluateResult = await dc . evaluateForFrame ( `new DateTime.now()` ) ;
501- const thisYear = new Date ( ) . getFullYear ( ) . toString ( ) ;
502- assert . ok ( evaluateResult ) ;
503- assert . ok ( evaluateResult . result . startsWith ( "DateTime (" + thisYear ) , `Result '${ evaluateResult . result } ' did not start with ${ thisYear } ` ) ;
504- assert . ok ( evaluateResult . variablesReference ) ;
441+ // An expression that returns a variable.
442+ {
443+ const evaluateResult = await dc . evaluateForFrame ( `new DateTime.now()` ) ;
444+ const thisYear = new Date ( ) . getFullYear ( ) . toString ( ) ;
445+ assert . ok ( evaluateResult ) ;
446+ assert . ok ( evaluateResult . result . startsWith ( "DateTime (" + thisYear ) , `Result '${ evaluateResult . result } ' did not start with ${ thisYear } ` ) ;
447+ assert . ok ( evaluateResult . variablesReference ) ;
448+ }
505449
506450 await waitAllThrowIfTerminates ( dc ,
507451 dc . waitForEvent ( "terminated" ) ,
0 commit comments