ConnectedAndroidDevice implements AndroidDevice { @NotNull @Override public String getName() { if (myDeviceNameRenderer != null) { return myDeviceNameRenderer.getName(myDevice); } if (isVirtual()) { if (myAvdName != null) { return myAvdName; } else { return getDeviceName() + " [" + getSerial() + "]"; } } return getDeviceName(); } ConnectedAndroidDevice(@NotNull IDevice device, @Nullable List<AvdInfo> avdInfos); @Override boolean isRunning(); @Override boolean isVirtual(); @NotNull @Override AndroidVersion getVersion(); @Override int getDensity(); @NotNull @Override List<Abi> getAbis(); @NotNull @Override String getSerial(); @Override boolean supportsFeature(@NotNull IDevice.HardwareFeature feature); @NotNull @Override String getName(); @Override boolean renderLabel(@NotNull SimpleColoredComponent renderer, boolean isCompatible, @Nullable String searchPrefix); @Override void prepareToRenderLabel(); @NotNull @Override ListenableFuture<IDevice> launch(@NotNull Project project); @NotNull @Override ListenableFuture<IDevice> launch(@NotNull Project project, @NotNull List<String> arguments); @NotNull @Override ListenableFuture<IDevice> getLaunchedDevice(); @NotNull IDevice getDevice(); @Override @NotNull LaunchCompatibility canRun(@NotNull AndroidVersion minSdkVersion,
                                    @NotNull IAndroidTarget projectTarget,
                                    @NotNull EnumSet<IDevice.HardwareFeature> requiredFeatures,
                                    @Nullable Set<String> supportedAbis); @Override boolean isDebuggable();  }
@Test public void getName_emulatorWithNoAvdName() { IDevice emulatorWithNoAvdName = createMockRunningEmulator(null); assertThat(new ConnectedAndroidDevice(emulatorWithNoAvdName, null).getName()).isEqualTo("Google Pixel [local:5554]"); }
@Test public void getName_emulatorWithAvdName() { IDevice emulatorWithNoAvdName = createMockRunningEmulator("My Pixel"); assertThat(new ConnectedAndroidDevice(emulatorWithNoAvdName, null).getName()).isEqualTo("Google Pixel [My Pixel]"); }