@@ -44,6 +44,7 @@ void main() {
44
44
late Platform platform;
45
45
late FakeProcessManager processManager;
46
46
late OperatingSystemUtils operatingSystemUtils;
47
+ late BufferLogger testLogger;
47
48
48
49
setUp (() {
49
50
exceptionHandler = FileExceptionHandler ();
@@ -59,29 +60,86 @@ void main() {
59
60
processManager: processManager,
60
61
operatingSystemUtils: operatingSystemUtils,
61
62
browserFinder: findChromeExecutable,
62
- logger: BufferLogger .test (),
63
+ logger: testLogger = BufferLogger .test (),
63
64
);
64
65
});
65
66
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
+
66
95
testWithoutContext ('can launch chrome and connect to the devtools' , () async {
67
96
await expectReturnsNormallyLater (
68
- _testLaunchChrome (
97
+ testLaunchChrome (
69
98
'/.tmp_rand0/flutter_tools_chrome_device.rand0' ,
70
99
processManager,
71
100
chromeLauncher,
72
101
)
73
102
);
74
103
});
75
104
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
+
76
134
testWithoutContext ('cannot have two concurrent instances of chrome' , () async {
77
- await _testLaunchChrome (
135
+ await testLaunchChrome (
78
136
'/.tmp_rand0/flutter_tools_chrome_device.rand0' ,
79
137
processManager,
80
138
chromeLauncher,
81
139
);
82
140
83
141
await expectToolExitLater (
84
- _testLaunchChrome (
142
+ testLaunchChrome (
85
143
'/.tmp_rand0/flutter_tools_chrome_device.rand1' ,
86
144
processManager,
87
145
chromeLauncher,
@@ -91,15 +149,15 @@ void main() {
91
149
});
92
150
93
151
testWithoutContext ('can launch new chrome after stopping a previous chrome' , () async {
94
- final Chromium chrome = await _testLaunchChrome (
152
+ final Chromium chrome = await testLaunchChrome (
95
153
'/.tmp_rand0/flutter_tools_chrome_device.rand0' ,
96
154
processManager,
97
155
chromeLauncher,
98
156
);
99
157
await chrome.close ();
100
158
101
159
await expectReturnsNormallyLater (
102
- _testLaunchChrome (
160
+ testLaunchChrome (
103
161
'/.tmp_rand0/flutter_tools_chrome_device.rand1' ,
104
162
processManager,
105
163
chromeLauncher,
@@ -630,24 +688,6 @@ void main() {
630
688
});
631
689
}
632
690
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
-
651
691
/// Fake chrome connection that fails to get tabs a few times.
652
692
class FakeChromeConnection extends Fake implements ChromeConnection {
653
693
0 commit comments