@@ -58,6 +58,19 @@ const Map<String, dynamic> macStudioInfoPlist2020_3 = <String, dynamic>{
58
58
},
59
59
};
60
60
61
+ const Map <String , dynamic > macStudioInfoPlistEAP = < String , dynamic > {
62
+ 'CFBundleGetInfoString' : 'Android Studio EAP AI-212.5712.43.2112.8233820, build AI-212.5712.43.2112.8233820. Copyright JetBrains s.r.o., (c) 2000-2022' ,
63
+ 'CFBundleShortVersionString' : 'EAP AI-212.5712.43.2112.8233820' ,
64
+ 'CFBundleVersion' : 'AI-212.5712.43.2112.8233820' ,
65
+ 'JVMOptions' : < String , dynamic > {
66
+ 'Properties' : < String , dynamic > {
67
+ 'idea.vendor.name' : 'Google' ,
68
+ 'idea.paths.selector' : 'AndroidStudio2021.2' ,
69
+ 'idea.platform.prefix' : 'AndroidStudio' ,
70
+ },
71
+ },
72
+ };
73
+
61
74
final Platform linuxPlatform = FakePlatform (
62
75
environment: < String , String > {'HOME' : homeLinux},
63
76
);
@@ -135,6 +148,14 @@ void main() {
135
148
136
149
final String plistFilePath = globals.fs.path.join (studioInApplicationPlistFolder, 'Info.plist' );
137
150
plistUtils.fileContents[plistFilePath] = macStudioInfoPlist4_1;
151
+ processManager.addCommand (FakeCommand (
152
+ command: < String > [
153
+ globals.fs.path.join (studioInApplicationPlistFolder, 'jre' , 'jdk' , 'Contents' , 'Home' , 'bin' , 'java' ),
154
+ '-version' ,
155
+ ],
156
+ stderr: '123' ,
157
+ )
158
+ );
138
159
final AndroidStudio studio = AndroidStudio .fromMacOSBundle (
139
160
globals.fs.directory (studioInApplicationPlistFolder)? .parent? .path,
140
161
);
@@ -147,10 +168,11 @@ void main() {
147
168
'Google' ,
148
169
'AndroidStudio4.1' ,
149
170
)));
171
+ expect (studio.validationMessages, < String > ['Java version 123' ]);
150
172
}, overrides: < Type , Generator > {
151
173
FileSystem : () => fileSystem,
152
174
FileSystemUtils : () => fsUtils,
153
- ProcessManager : () => FakeProcessManager . any () ,
175
+ ProcessManager : () => processManager ,
154
176
// Custom home paths are not supported on macOS nor Windows yet,
155
177
// so we force the platform to fake Linux here.
156
178
Platform : () => platform,
@@ -168,6 +190,14 @@ void main() {
168
190
169
191
final String plistFilePath = globals.fs.path.join (studioInApplicationPlistFolder, 'Info.plist' );
170
192
plistUtils.fileContents[plistFilePath] = macStudioInfoPlist2020_3;
193
+ processManager.addCommand (FakeCommand (
194
+ command: < String > [
195
+ globals.fs.path.join (studioInApplicationPlistFolder, 'jre' , 'Contents' , 'Home' , 'bin' , 'java' ),
196
+ '-version' ,
197
+ ],
198
+ stderr: '123' ,
199
+ )
200
+ );
171
201
final AndroidStudio studio = AndroidStudio .fromMacOSBundle (
172
202
globals.fs.directory (studioInApplicationPlistFolder)? .parent? .path,
173
203
);
@@ -180,10 +210,11 @@ void main() {
180
210
'Google' ,
181
211
'AndroidStudio2020.3' ,
182
212
)));
213
+ expect (studio.validationMessages, < String > ['Java version 123' ]);
183
214
}, overrides: < Type , Generator > {
184
215
FileSystem : () => fileSystem,
185
216
FileSystemUtils : () => fsUtils,
186
- ProcessManager : () => FakeProcessManager . any () ,
217
+ ProcessManager : () => processManager ,
187
218
// Custom home paths are not supported on macOS nor Windows yet,
188
219
// so we force the platform to fake Linux here.
189
220
Platform : () => platform,
@@ -201,6 +232,14 @@ void main() {
201
232
202
233
final String plistFilePath = globals.fs.path.join (studioInApplicationPlistFolder, 'Info.plist' );
203
234
plistUtils.fileContents[plistFilePath] = macStudioInfoPlist;
235
+ processManager.addCommand (FakeCommand (
236
+ command: < String > [
237
+ globals.fs.path.join (studioInApplicationPlistFolder, 'jre' , 'jdk' , 'Contents' , 'Home' , 'bin' , 'java' ),
238
+ '-version' ,
239
+ ],
240
+ stderr: '123' ,
241
+ )
242
+ );
204
243
final AndroidStudio studio = AndroidStudio .fromMacOSBundle (
205
244
globals.fs.directory (studioInApplicationPlistFolder)? .parent? .path,
206
245
);
@@ -212,10 +251,52 @@ void main() {
212
251
'Application Support' ,
213
252
'AndroidStudio3.3' ,
214
253
)));
254
+ expect (studio.validationMessages, < String > ['Java version 123' ]);
215
255
}, overrides: < Type , Generator > {
216
256
FileSystem : () => fileSystem,
217
257
FileSystemUtils : () => fsUtils,
218
- ProcessManager : () => FakeProcessManager .any (),
258
+ ProcessManager : () => processManager,
259
+ // Custom home paths are not supported on macOS nor Windows yet,
260
+ // so we force the platform to fake Linux here.
261
+ Platform : () => platform,
262
+ PlistParser : () => plistUtils,
263
+ });
264
+
265
+ testUsingContext ('Can discover Android Studio EAP location on Mac' , () {
266
+ final String studioInApplicationPlistFolder = globals.fs.path.join (
267
+ '/' ,
268
+ 'Application' ,
269
+ 'Android Studio with suffix.app' ,
270
+ 'Contents' ,
271
+ );
272
+ globals.fs.directory (studioInApplicationPlistFolder).createSync (recursive: true );
273
+
274
+ final String plistFilePath = globals.fs.path.join (studioInApplicationPlistFolder, 'Info.plist' );
275
+ plistUtils.fileContents[plistFilePath] = macStudioInfoPlistEAP;
276
+ processManager.addCommand (FakeCommand (
277
+ command: < String > [
278
+ globals.fs.path.join (studioInApplicationPlistFolder, 'jre' , 'Contents' , 'Home' , 'bin' , 'java' ),
279
+ '-version' ,
280
+ ],
281
+ stderr: '123' ,
282
+ )
283
+ );
284
+ final AndroidStudio studio = AndroidStudio .fromMacOSBundle (
285
+ globals.fs.directory (studioInApplicationPlistFolder)? .parent? .path,
286
+ );
287
+
288
+ expect (studio, isNotNull);
289
+ expect (studio.pluginsPath, equals (globals.fs.path.join (
290
+ homeMac,
291
+ 'Library' ,
292
+ 'Application Support' ,
293
+ 'AndroidStudio2021.2' ,
294
+ )));
295
+ expect (studio.validationMessages, < String > ['Java version 123' ]);
296
+ }, overrides: < Type , Generator > {
297
+ FileSystem : () => fileSystem,
298
+ FileSystemUtils : () => fsUtils,
299
+ ProcessManager : () => processManager,
219
300
// Custom home paths are not supported on macOS nor Windows yet,
220
301
// so we force the platform to fake Linux here.
221
302
Platform : () => platform,
0 commit comments