Unverified Commit ca03beda authored by Anas's avatar Anas Committed by GitHub

[tools] Add column header for emulators information (#142853)

Add column information as table header for `flutter emulators` command.

**Before:**

```
2 available emulators:

Pixel_3_API_30   • Pixel 3 API 30   • Google • android
Resizable_API_33 • Resizable API 33 • Google • android

To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.

You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager
```

**After:**

```
2 available emulators:

Id               • Name             • Manufacturer • Platform

Pixel_3_API_30   • Pixel 3 API 30   • Google       • android
Resizable_API_33 • Resizable API 33 • Google       • android

To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.

You can find more information on managing emulators at the links below:
  https://developer.android.com/studio/run/managing-avds
  https://developer.android.com/studio/command-line/avdmanager
```

fixes #140656
parent abadf9ff
...@@ -291,8 +291,16 @@ abstract class Emulator { ...@@ -291,8 +291,16 @@ abstract class Emulator {
return <String>[]; return <String>[];
} }
const List<String> tableHeader = <String>[
'Id',
'Name',
'Manufacturer',
'Platform',
];
// Extract emulators information // Extract emulators information
final List<List<String>> table = <List<String>>[ final List<List<String>> table = <List<String>>[
tableHeader,
for (final Emulator emulator in emulators) for (final Emulator emulator in emulators)
<String>[ <String>[
emulator.id, emulator.id,
...@@ -323,7 +331,10 @@ abstract class Emulator { ...@@ -323,7 +331,10 @@ abstract class Emulator {
} }
static void printEmulators(List<Emulator> emulators, Logger logger) { static void printEmulators(List<Emulator> emulators, Logger logger) {
descriptions(emulators).forEach(logger.printStatus); final List<String> emulatorDescriptions = descriptions(emulators);
// Prints the first description as the table header, followed by a newline.
logger.printStatus('${emulatorDescriptions.first}\n');
emulatorDescriptions.sublist(1).forEach(logger.printStatus);
} }
} }
......
...@@ -87,6 +87,18 @@ void main() { ...@@ -87,6 +87,18 @@ void main() {
returnsNormally); returnsNormally);
}); });
testUsingContext('printEmulators prints the the emualtors information with header', () {
Emulator.printEmulators(emulators, testLogger);
expect(testLogger.statusText, '''
Id • Name • Manufacturer • Platform
Nexus_5 • Nexus 5 • Google • android
Nexus_5X_API_27_x86 • Nexus 5X • Google • android
iOS Simulator • iOS Simulator • Apple • android
''');
});
testUsingContext('getEmulators with no Android SDK', () async { testUsingContext('getEmulators with no Android SDK', () async {
// Test that EmulatorManager.getEmulators() doesn't throw when there's no Android SDK. // Test that EmulatorManager.getEmulators() doesn't throw when there's no Android SDK.
final EmulatorManager emulatorManager = EmulatorManager( final EmulatorManager emulatorManager = EmulatorManager(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment