@@ -44,6 +44,7 @@ void main() {
4444 late Platform platform;
4545 late FakeProcessManager processManager;
4646 late OperatingSystemUtils operatingSystemUtils;
47+ late BufferLogger testLogger;
4748
4849 setUp (() {
4950 exceptionHandler = FileExceptionHandler ();
@@ -59,29 +60,86 @@ void main() {
5960 processManager: processManager,
6061 operatingSystemUtils: operatingSystemUtils,
6162 browserFinder: findChromeExecutable,
62- logger: BufferLogger .test (),
63+ logger: testLogger = BufferLogger .test (),
6364 );
6465 });
6566
67+ Future <Chromium > testLaunchChrome (String userDataDir, FakeProcessManager processManager, ChromiumLauncher chromeLauncher) {
68+ if (testLogger.isVerbose) {
69+ processManager.addCommand (const FakeCommand (
70+ command: < String > [
71+ 'example_chrome' ,
72+ '--version' ,
73+ ],
74+ stdout: 'Chromium 115' ,
75+ ));
76+ }
77+
78+ processManager.addCommand (FakeCommand (
79+ command: < String > [
80+ 'example_chrome' ,
81+ '--user-data-dir=$userDataDir ' ,
82+ '--remote-debugging-port=12345' ,
83+ ...kChromeArgs,
84+ 'example_url' ,
85+ ],
86+ stderr: kDevtoolsStderr,
87+ ));
88+
89+ return chromeLauncher.launch (
90+ 'example_url' ,
91+ skipCheck: true ,
92+ );
93+ }
94+
6695 testWithoutContext ('can launch chrome and connect to the devtools' , () async {
6796 await expectReturnsNormallyLater (
68- _testLaunchChrome (
97+ testLaunchChrome (
6998 '/.tmp_rand0/flutter_tools_chrome_device.rand0' ,
7099 processManager,
71100 chromeLauncher,
72101 )
73102 );
74103 });
75104
105+ testWithoutContext ('can launch chrome in verbose mode' , () async {
106+ chromeLauncher = ChromiumLauncher (
107+ fileSystem: fileSystem,
108+ platform: platform,
109+ processManager: processManager,
110+ operatingSystemUtils: operatingSystemUtils,
111+ browserFinder: findChromeExecutable,
112+ logger: testLogger = BufferLogger .test (verbose: true ),
113+ );
114+
115+ await expectReturnsNormallyLater (
116+ testLaunchChrome (
117+ '/.tmp_rand0/flutter_tools_chrome_device.rand0' ,
118+ processManager,
119+ chromeLauncher,
120+ )
121+ );
122+
123+ expect (
124+ testLogger.traceText.trim (),
125+ 'Launching Chromium (url = example_url, headless = false, skipCheck = true, debugPort = null)\n '
126+ 'Will use Chromium executable at example_chrome\n '
127+ 'Using Chromium 115\n '
128+ '[CHROME]: \n '
129+ '[CHROME]: \n '
130+ '[CHROME]: DevTools listening' ,
131+ );
132+ });
133+
76134 testWithoutContext ('cannot have two concurrent instances of chrome' , () async {
77- await _testLaunchChrome (
135+ await testLaunchChrome (
78136 '/.tmp_rand0/flutter_tools_chrome_device.rand0' ,
79137 processManager,
80138 chromeLauncher,
81139 );
82140
83141 await expectToolExitLater (
84- _testLaunchChrome (
142+ testLaunchChrome (
85143 '/.tmp_rand0/flutter_tools_chrome_device.rand1' ,
86144 processManager,
87145 chromeLauncher,
@@ -91,15 +149,15 @@ void main() {
91149 });
92150
93151 testWithoutContext ('can launch new chrome after stopping a previous chrome' , () async {
94- final Chromium chrome = await _testLaunchChrome (
152+ final Chromium chrome = await testLaunchChrome (
95153 '/.tmp_rand0/flutter_tools_chrome_device.rand0' ,
96154 processManager,
97155 chromeLauncher,
98156 );
99157 await chrome.close ();
100158
101159 await expectReturnsNormallyLater (
102- _testLaunchChrome (
160+ testLaunchChrome (
103161 '/.tmp_rand0/flutter_tools_chrome_device.rand1' ,
104162 processManager,
105163 chromeLauncher,
@@ -630,24 +688,6 @@ void main() {
630688 });
631689}
632690
633- Future <Chromium > _testLaunchChrome (String userDataDir, FakeProcessManager processManager, ChromiumLauncher chromeLauncher) {
634- processManager.addCommand (FakeCommand (
635- command: < String > [
636- 'example_chrome' ,
637- '--user-data-dir=$userDataDir ' ,
638- '--remote-debugging-port=12345' ,
639- ...kChromeArgs,
640- 'example_url' ,
641- ],
642- stderr: kDevtoolsStderr,
643- ));
644-
645- return chromeLauncher.launch (
646- 'example_url' ,
647- skipCheck: true ,
648- );
649- }
650-
651691/// Fake chrome connection that fails to get tabs a few times.
652692class FakeChromeConnection extends Fake implements ChromeConnection {
653693
0 commit comments