DeviceRenderer { public static void renderDeviceName(@NotNull IDevice d, @NotNull DeviceNameProperties deviceProperties, @NotNull ColoredTextContainer component, boolean showSerialNumber) { renderDeviceName(d, deviceProperties, component, showSerialNumber, null); } private  DeviceRenderer(); static void renderDeviceName(@NotNull IDevice d,
                                      @NotNull DeviceNameProperties deviceProperties,
                                      @NotNull ColoredTextContainer component,
                                      boolean showSerialNumber); static void renderDeviceName(@NotNull IDevice d,
                                      @NotNull DeviceNameProperties deviceNameProperties,
                                      @NotNull ColoredTextContainer component,
                                      boolean showSerialNumber,
                                      @Nullable AvdManager avdManager); static boolean shouldShowSerialNumbers(@NotNull List<IDevice> devices);  }
@Test public void deviceNameRendering1() throws Exception { String serial = "123"; IDevice d = createDevice(false, null, manufacturer, model, buildVersion, apiLevel, serial, IDevice.DeviceState.ONLINE); DeviceNameProperties deviceNameProperties = new DeviceNameProperties(model, manufacturer, buildVersion, apiLevel); SimpleColoredText target = new SimpleColoredText(); DeviceRenderer.renderDeviceName(d, deviceNameProperties, target, false); String name = target.toString(); assertEquals(String.format("%s %s Android %s, API %s", StringUtil.capitalizeWords(manufacturer, false), StringUtil.capitalizeWords(model, false), buildVersion, apiLevel), name); assertFalse(StringUtil.containsIgnoreCase(name, IDevice.DeviceState.ONLINE.toString())); assertFalse(StringUtil.containsIgnoreCase(name, serial)); }
@Test public void deviceNameRendering2() throws Exception { String serial = "123"; IDevice d = createDevice(true, "Avdname", manufacturer, model, buildVersion, apiLevel, serial, IDevice.DeviceState.BOOTLOADER); DeviceNameProperties deviceNameProperties = new DeviceNameProperties(model, manufacturer, buildVersion, apiLevel); SimpleColoredText target = new SimpleColoredText(); DeviceRenderer.renderDeviceName(d, deviceNameProperties, target, false); String name = target.toString(); assertFalse(StringUtil.containsIgnoreCase(name, "Nexus 4")); assertTrue(StringUtil.containsIgnoreCase(name, "Avdname")); assertTrue(StringUtil.containsIgnoreCase(name, IDevice.DeviceState.BOOTLOADER.toString())); assertTrue(StringUtil.containsIgnoreCase(name, serial)); }
@Test public void deviceNameRenderingSerial() throws Exception { String serial = "123"; IDevice d = createDevice(false, null, manufacturer, model, buildVersion, apiLevel, serial, IDevice.DeviceState.ONLINE); DeviceNameProperties deviceNameProperties = new DeviceNameProperties(model, manufacturer, buildVersion, apiLevel); SimpleColoredText target = new SimpleColoredText(); DeviceRenderer.renderDeviceName(d, deviceNameProperties, target, true); String name = target.toString(); assertEquals("Google Nexus 4 123 Android 4.2, API 17", name); }
@Test public void nullAvdNameForEmulator() throws Exception { String serial = "emulator-5554"; IDevice d = createDevice(true, null, manufacturer, model, buildVersion, apiLevel, serial, IDevice.DeviceState.ONLINE); DeviceNameProperties deviceNameProperties = new DeviceNameProperties(model, manufacturer, buildVersion, apiLevel); SimpleColoredText target = new SimpleColoredText(); DeviceRenderer.renderDeviceName(d, deviceNameProperties, target, false); String name = target.toString(); assertEquals("Emulator emulator-5554 Android 4.2, API 17", name); }