diff --git a/AndroidWiFiADB.iml b/AndroidWiFiADB.iml index 8929c0a..e9c44ad 100644 --- a/AndroidWiFiADB.iml +++ b/AndroidWiFiADB.iml @@ -1,146 +1,19 @@ - + - - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + \ No newline at end of file diff --git a/art/android_devices_window.png b/art/android_devices_window.png index 581a504..0559cd9 100644 Binary files a/art/android_devices_window.png and b/art/android_devices_window.png differ diff --git a/src/main/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADB.java b/src/main/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADB.java index 746d92d..421b5e0 100644 --- a/src/main/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADB.java +++ b/src/main/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADB.java @@ -17,22 +17,23 @@ package com.github.pedrovgs.androidwifiadb; import com.github.pedrovgs.androidwifiadb.adb.ADB; -import com.intellij.openapi.project.Project; import com.github.pedrovgs.androidwifiadb.view.View; - import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedList; import java.util.List; +import java.util.Set; public class AndroidWiFiADB { + private static final Set DEVICES = new HashSet(); private final ADB adb; private final View view; - private List devices; public AndroidWiFiADB(ADB adb, View view) { this.adb = adb; this.view = view; - this.devices = new ArrayList(); } public void connectDevices() { @@ -40,25 +41,27 @@ public void connectDevices() { view.showADBNotInstalledNotification(); return; } - devices = adb.getDevicesConnectedByUSB(); - if (devices.isEmpty()) { + DEVICES.clear(); + DEVICES.addAll(adb.getDevicesConnectedByUSB()); + if (DEVICES.isEmpty()) { view.showNoConnectedDevicesNotification(); return; } - devices = adb.connectDevices(devices); - showConnectionResultNotification(devices); + DEVICES.addAll(adb.connectDevices(DEVICES)); + showConnectionResultNotification(DEVICES); } public boolean refreshDevicesList() { if (!isADBInstalled()) { return false; } - final List connected = adb.getDevicesConnectedByUSB(); + removeNotConnectedDevices(); + final Collection connected = adb.getDevicesConnectedByUSB(); for (Device connectedDevice : connected) { if (!checkDeviceExistance(connectedDevice)) { connectedDevice.setIp(adb.getDeviceIp(connectedDevice)); - devices.add(connectedDevice); + DEVICES.add(connectedDevice); } else { updateDeviceConnectionState(connectedDevice); } @@ -66,12 +69,19 @@ public boolean refreshDevicesList() { return true; } - public List getDevices() { - return devices; + private void removeNotConnectedDevices() { + List connectedDevices = new LinkedList(); + for (Device device : DEVICES) { + if (device.isConnected()) { + connectedDevices.add(device); + } + } + DEVICES.clear(); + DEVICES.addAll(connectedDevices); } - public void updateProject(Project project) { - this.adb.updateProject(project); + public Collection getDevices() { + return DEVICES; } public void connectDevice(Device device) { @@ -80,7 +90,7 @@ public void connectDevice(Device device) { return; } - List connectedDevices = new ArrayList(); + Collection connectedDevices = new ArrayList(); connectedDevices.add(device); connectedDevices = adb.connectDevices(connectedDevices); for (Device connected : connectedDevices) { @@ -105,19 +115,12 @@ public void disconnectDevice(Device device) { } private void updateDeviceConnectionState(final Device updatedDevice) { - for (int i = 0, size = devices.size(); i < size; i++) { - Device device = devices.get(i); - if (updatedDevice.getId().equals(device.getId())) { - devices.remove(i); - device.setName(updatedDevice.getName()); - devices.add(i, device); - } - } + DEVICES.add(updatedDevice); } private boolean checkDeviceExistance(Device connectedDevice) { boolean deviceExists = false; - for (Device device : devices) { + for (Device device : DEVICES) { if (connectedDevice.getId().equals(device.getId())) { deviceExists = true; } @@ -129,7 +132,7 @@ private boolean isADBInstalled() { return adb.isInstalled(); } - private void showConnectionResultNotification(List devices) { + private void showConnectionResultNotification(Collection devices) { for (Device device : devices) { if (device.isConnected()) { view.showConnectedDeviceNotification(device); @@ -139,7 +142,7 @@ private void showConnectionResultNotification(List devices) { } } - private void showDisconnectionResultNotification(List devices) { + private void showDisconnectionResultNotification(Collection devices) { for (Device device : devices) { if (!device.isConnected()) { view.showDisconnectedDeviceNotification(device); diff --git a/src/main/java/com/github/pedrovgs/androidwifiadb/Device.java b/src/main/java/com/github/pedrovgs/androidwifiadb/Device.java index 09b8dcf..9187897 100644 --- a/src/main/java/com/github/pedrovgs/androidwifiadb/Device.java +++ b/src/main/java/com/github/pedrovgs/androidwifiadb/Device.java @@ -16,10 +16,10 @@ package com.github.pedrovgs.androidwifiadb; -public class Device implements Cloneable { +public class Device { - private String name; private final String id; + private String name; private String ip = ""; private boolean connected; @@ -32,6 +32,10 @@ public String getName() { return name; } + public void setName(String name) { + this.name = name; + } + public String getId() { return id; } @@ -44,10 +48,6 @@ public void setIp(String ip) { this.ip = ip; } - public void setName(String name) { - this.name = name; - } - public boolean isConnected() { return connected; } @@ -56,42 +56,24 @@ public void setConnected(boolean connected) { this.connected = connected; } - @Override - public String toString() { - StringBuilder builder = new StringBuilder(getName()); - if (!ip.isEmpty()) { - builder.append(" (").append(ip).append(")"); - } - return builder.toString(); - } - @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Device device = (Device) o; - if (connected != device.connected) return false; - if (name != null ? !name.equals(device.name) : device.name != null) return false; - if (id != null ? !id.equals(device.id) : device.id != null) return false; - return !(ip != null ? !ip.equals(device.ip) : device.ip != null); + return id.equals(device.id); } @Override public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (id != null ? id.hashCode() : 0); - result = 31 * result + (ip != null ? ip.hashCode() : 0); - result = 31 * result + (connected ? 1 : 0); - return result; + return id.hashCode(); } - @Override protected Device clone() { - Device clone; - try { - clone = (Device) super.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - return clone; + @Override public String toString() { + return name; } } diff --git a/src/main/java/com/github/pedrovgs/androidwifiadb/action/AndroidWiFiADBAction.java b/src/main/java/com/github/pedrovgs/androidwifiadb/action/AndroidWiFiADBAction.java index 8e812ef..2327b58 100644 --- a/src/main/java/com/github/pedrovgs/androidwifiadb/action/AndroidWiFiADBAction.java +++ b/src/main/java/com/github/pedrovgs/androidwifiadb/action/AndroidWiFiADBAction.java @@ -37,7 +37,6 @@ public AndroidWiFiADBAction() { } public void actionPerformed(final AnActionEvent event) { - this.androidWifiADB.updateProject(event.getProject()); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { androidWifiADB.connectDevices(); diff --git a/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADB.java b/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADB.java index 9894837..51428e5 100644 --- a/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADB.java +++ b/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADB.java @@ -17,11 +17,9 @@ package com.github.pedrovgs.androidwifiadb.adb; import com.github.pedrovgs.androidwifiadb.Device; -import com.intellij.openapi.project.Project; - import com.intellij.util.EnvironmentUtil; - import java.io.File; +import java.util.Collection; import java.util.List; public class ADB { @@ -33,7 +31,6 @@ public class ADB { private final CommandLine commandLine; private final ADBParser adbParser; - private Project project; public ADB(CommandLine commandLine, ADBParser adbParser) { this.commandLine = commandLine; @@ -45,13 +42,13 @@ public boolean isInstalled() { return !commandLine.executeCommand(versionCommand).isEmpty(); } - public List getDevicesConnectedByUSB() { + public Collection getDevicesConnectedByUSB() { String getDevicesCommand = getCommand("devices -l"); String adbDevicesOutput = commandLine.executeCommand(getDevicesCommand); return adbParser.parseGetDevicesOutput(adbDevicesOutput); } - public List connectDevices(List devices) { + public Collection connectDevices(Collection devices) { for (Device device : devices) { boolean connected = connectDeviceByIp(device); device.setConnected(connected); @@ -74,10 +71,6 @@ public List disconnectDevices(List devices) { return devices; } - public void updateProject(Project project) { - this.project = project; - } - private boolean connectDeviceByIp(Device device) { String deviceIp = !device.getIp().isEmpty() ? device.getIp() : getDeviceIp(device); if (deviceIp.isEmpty()) { @@ -110,7 +103,7 @@ private void enableTCPCommand() { private boolean checkTCPCommandExecuted() { String getPropCommand = getCommand("adb shell getprop | grep adb"); String getPropOutput = commandLine.executeCommand(getPropCommand); - String adbTcpPort = adbParser.parseAdbServiceTcpPort(getPropOutput); + String adbTcpPort = adbParser.parseAdbServiceTcpPort(getPropOutput); return TCPIP_PORT.equals(adbTcpPort); } diff --git a/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADBParser.java b/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADBParser.java index 85882eb..15f94d8 100644 --- a/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADBParser.java +++ b/src/main/java/com/github/pedrovgs/androidwifiadb/adb/ADBParser.java @@ -61,9 +61,14 @@ public String parseGetDeviceIp(String ipInfo) { if (ipInfo.isEmpty() || ipInfo.contains(ERROR_PARSING_DEVICE_IP_KEY)) { return ""; } - int start = ipInfo.indexOf(START_DEVICE_IP_INDICATOR) + 5; - int end = ipInfo.indexOf(END_DEVICE_IP_INDICATOR); - return ipInfo.substring(start, end); + try { + int start = ipInfo.indexOf(START_DEVICE_IP_INDICATOR) + 5; + int end = ipInfo.indexOf(END_DEVICE_IP_INDICATOR); + return ipInfo.substring(start, end); + } catch (StringIndexOutOfBoundsException e) { + System.out.println(e); + return ""; + } } public String parseAdbServiceTcpPort(String getPropOutput) { diff --git a/src/main/java/com/github/pedrovgs/androidwifiadb/window/AndroidWiFiADBWindow.java b/src/main/java/com/github/pedrovgs/androidwifiadb/window/AndroidWiFiADBWindow.java index 92d7cd4..9088f46 100644 --- a/src/main/java/com/github/pedrovgs/androidwifiadb/window/AndroidWiFiADBWindow.java +++ b/src/main/java/com/github/pedrovgs/androidwifiadb/window/AndroidWiFiADBWindow.java @@ -50,8 +50,6 @@ public AndroidWiFiADBWindow() { } @Override public void createToolWindowContent(Project project, ToolWindow toolWindow) { - this.androidWifiADB.updateProject(project); - createToolWindowContent(toolWindow); setupUI(); monitorDevices(); diff --git a/src/main/java/com/github/pedrovgs/androidwifiadb/window/CardLayoutDevices.java b/src/main/java/com/github/pedrovgs/androidwifiadb/window/CardLayoutDevices.java index d3fec5a..d4d4c65 100644 --- a/src/main/java/com/github/pedrovgs/androidwifiadb/window/CardLayoutDevices.java +++ b/src/main/java/com/github/pedrovgs/androidwifiadb/window/CardLayoutDevices.java @@ -18,13 +18,11 @@ import com.github.pedrovgs.androidwifiadb.Device; import com.intellij.ui.table.JBTable; - import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Container; import java.util.ArrayList; -import java.util.List; - +import java.util.Collection; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; @@ -43,7 +41,7 @@ public class CardLayoutDevices implements ActionButtonListener { private JPanel panelNoDevices; private JPanel panelDevices; private JTable tableDevices; - private List devices; + private Collection devices; private DeviceAction deviceAction; public CardLayoutDevices(Container parentContainer, DeviceAction action) { @@ -52,7 +50,7 @@ public CardLayoutDevices(Container parentContainer, DeviceAction action) { this.devices = new ArrayList(); } - public void setDevices(List devices) { + public void setDevices(Collection devices) { this.devices = devices; } @@ -132,8 +130,9 @@ private void configureTableAppearance() { tableDevices.getColumnModel().getColumn(2).setMinWidth(215); tableDevices.getColumnModel().getColumn(2).setMaxWidth(215); tableDevices.getColumnModel().getColumn(2).setCellRenderer(new ConnectDisconnectRenderer()); - tableDevices.getColumnModel().getColumn(2).setCellEditor( - new ConnectDisconnectEditor(new JCheckBox(), this)); + tableDevices.getColumnModel() + .getColumn(2) + .setCellEditor(new ConnectDisconnectEditor(new JCheckBox(), this)); } private void updateDevicesTable() { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index bf1473a..1798cf2 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ com.github.pedrovgs.androidwifiadb Android WiFi ADB - 1.3-SNAPSHOT + 2.0 Pedro Vicente Gómez Sánchez @@ -11,14 +11,15 @@
Connect your device using a USB cable and press the Android WiFi ADB button. Once the device be connected over WiFi you'll see an IntelliJ/Android Studio notification. Now you can disconnect your USB cable and enjoy deploying, running and debugging your applications over WiFi.
- To be able to connect your device over WiFi an environment variable with name ANDROID_HOME should be configured pointing at your Android SDK. + The version 2.0 enables a window to check which of your devices are connected or not and connect/disconnect it manually if needed. ]]> 1.1: Fixes for Windows and Linux.
- 1.2: Remove the usage of the ANDROID_HOME environment variable. This variable is not needed now. + 1.2: Remove the usage of the ANDROID_HOME environment variable. This variable is not needed now.
+ 2.0: Add a new Android WiFi ADB control panel showing all the devices connected by USB to be able to connect devices individually. ]]>
diff --git a/src/test/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADBTest.java b/src/test/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADBTest.java index 7d5d5e6..cea743a 100644 --- a/src/test/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADBTest.java +++ b/src/test/java/com/github/pedrovgs/androidwifiadb/AndroidWiFiADBTest.java @@ -18,7 +18,6 @@ import com.github.pedrovgs.androidwifiadb.adb.ADB; import com.github.pedrovgs.androidwifiadb.view.View; - import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; @@ -44,29 +43,29 @@ public class AndroidWiFiADBTest extends UnitTest { @Mock private View view; @Test public void shouldShowErrorIfADBIsNotInstalled() { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); givenADBIsNotInstalled(); - sut.connectDevices(); + androidWiFiAdb.connectDevices(); verify(view).showADBNotInstalledNotification(); } @Test public void shouldShowNoConnectedDevicesNotificationIfThereAreNotConnectedDevicesByUSB() { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); givenThereAreNoConnectedDevices(); - sut.connectDevices(); + androidWiFiAdb.connectDevices(); verify(view).showNoConnectedDevicesNotification(); } @Test public void shouldShowDevicesConnectedIfADBWiFiWhenConnectionIsEstablished() { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); List devices = givenThereAreSomeDevicesConnectedByUSB(); givenDevicesAreConnectedSuccessfully(devices); - sut.connectDevices(); + androidWiFiAdb.connectDevices(); for (Device device : devices) { verify(view).showConnectedDeviceNotification(device); @@ -74,69 +73,64 @@ public class AndroidWiFiADBTest extends UnitTest { } @Test public void shouldShowDeviceConnectionErrorWhenConnectionIsNotEstablished() { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); List devices = givenThereAreSomeDevicesConnectedByUSB(); givenDevicesAreNotConnectedSuccessfully(devices); - sut.connectDevices(); + androidWiFiAdb.connectDevices(); for (Device device : devices) { verify(view).showErrorConnectingDeviceNotification(device); } } - @Test - public void shouldNotRefreshDevicesListIfAdbIsNotIstalled() throws Exception { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + @Test public void shouldNotRefreshDevicesListIfAdbIsNotIstalled() throws Exception { + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); givenADBIsNotInstalled(); - assertFalse(sut.refreshDevicesList()); + assertFalse(androidWiFiAdb.refreshDevicesList()); } - @Test - public void shouldRefreshDevicesListAddNewDevice() throws Exception { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + @Test public void shouldRefreshDevicesListAddNewDevice() throws Exception { + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); List devices = givenThereAreSomeDevicesConnectedByUSB(); givenDevicesAreConnectedSuccessfully(devices); givenAnyIpToDevices(); - assertEquals(0, sut.getDevices().size()); - sut.refreshDevicesList(); - assertEquals(devices.size(), sut.getDevices().size()); + assertEquals(0, androidWiFiAdb.getDevices().size()); + androidWiFiAdb.refreshDevicesList(); + assertEquals(devices.size(), androidWiFiAdb.getDevices().size()); } - @Test - public void shouldRefreshDevicesListUpdateExistingDevices() throws Exception { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + @Test public void shouldRefreshDevicesListUpdateExistingDevices() throws Exception { + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); List devices = givenThereAreSomeDevicesConnectedByUSB(); givenDevicesAreConnectedSuccessfully(devices); - sut.connectDevices(); - sut.refreshDevicesList(); + androidWiFiAdb.connectDevices(); + androidWiFiAdb.refreshDevicesList(); - assertEquals(devices.size(), sut.getDevices().size()); + assertEquals(devices.size(), androidWiFiAdb.getDevices().size()); } - @Test - public void shouldDisconnectDevice() throws Exception { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + @Test public void shouldDisconnectDevice() throws Exception { + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); givenADBIsInstalled(); Device device = givenAnyConnectedDevice(); givenDevicesAreDisconnectedSuccessfully(Arrays.asList(device)); - sut.disconnectDevice(device); + androidWiFiAdb.disconnectDevice(device); assertFalse(device.isConnected()); } - @Test - public void shouldConnectDevice() throws Exception { - AndroidWiFiADB sut = givenAnAndroidWiFiADB(); + @Test public void shouldConnectDevice() throws Exception { + AndroidWiFiADB androidWiFiAdb = givenAnAndroidWiFiADB(); givenADBIsInstalled(); Device device = givenAnyDisonnectedDevice(); givenDevicesAreConnectedSuccessfully(Arrays.asList(device)); - sut.connectDevice(device); + androidWiFiAdb.connectDevice(device); assertTrue(device.isConnected()); } diff --git a/src/test/java/com/github/pedrovgs/androidwifiadb/window/AndroidDevicesTableModelTest.java b/src/test/java/com/github/pedrovgs/androidwifiadb/window/AndroidDevicesTableModelTest.java index 2bd7730..506ec20 100644 --- a/src/test/java/com/github/pedrovgs/androidwifiadb/window/AndroidDevicesTableModelTest.java +++ b/src/test/java/com/github/pedrovgs/androidwifiadb/window/AndroidDevicesTableModelTest.java @@ -49,92 +49,93 @@ public class AndroidDevicesTableModelTest extends UnitTest { @Test public void shouldAddDevice() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); - assertNull(sut.get(0)); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); + assertNull(androidDevicesTableModel.get(0)); Device device = givenAnyDevice(); - sut.add(device); + androidDevicesTableModel.add(device); - assertEquals(device, sut.get(0)); + assertEquals(device, androidDevicesTableModel.get(0)); } @Test public void shouldClearDevicesList() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); - sut.add(givenAnyDevice()); + androidDevicesTableModel.add(givenAnyDevice()); - assertEquals(1, sut.getRowCount()); - sut.clear(); - assertEquals(0, sut.getRowCount()); + assertEquals(1, androidDevicesTableModel.getRowCount()); + androidDevicesTableModel.clear(); + assertEquals(0, androidDevicesTableModel.getRowCount()); } @Test public void shouldReturnValueDeviceAsStringForDeviceColumn() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); Device device = givenAnyDevice(); - sut.add(device); + androidDevicesTableModel.add(device); - assertEquals(device.toString(), sut.getValueAt(0, COLUMN_DEVICE)); + assertEquals(device.toString(), androidDevicesTableModel.getValueAt(0, COLUMN_DEVICE)); } @Test public void shouldReturnValueConnectedStringForConnectedDevice() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); Device device = givenAnyDevice(); device.setConnected(true); - sut.add(device); + androidDevicesTableModel.add(device); - assertEquals(CONNECTED, sut.getValueAt(0, COLUMN_STATE)); + assertEquals(CONNECTED, androidDevicesTableModel.getValueAt(0, COLUMN_STATE)); } @Test public void shouldReturnValueDisconnectedStringForDisconnectedDevice() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); Device device = givenAnyDevice(); device.setConnected(false); - sut.add(device); + androidDevicesTableModel.add(device); - assertEquals(DISCONNECTED, sut.getValueAt(0, COLUMN_STATE)); + assertEquals(DISCONNECTED, androidDevicesTableModel.getValueAt(0, COLUMN_STATE)); } @Test public void shouldReturnNullValueForActionColumn() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); - sut.add(givenAnyDevice()); + androidDevicesTableModel.add(givenAnyDevice()); - assertEquals(null, sut.getValueAt(0, COLUMN_ACTION)); + assertEquals(null, androidDevicesTableModel.getValueAt(0, COLUMN_ACTION)); } @Test public void shouldReturnNullValueForUnknownColumn() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); - sut.add(givenAnyDevice()); + androidDevicesTableModel.add(givenAnyDevice()); - assertEquals(null, sut.getValueAt(0, COLUMN_WITH_NOT_VALID_INDEX)); + assertEquals(null, androidDevicesTableModel.getValueAt(0, COLUMN_WITH_NOT_VALID_INDEX)); } @Test public void shouldReturnEditableCellForActionColumn() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); - sut.add(givenAnyDevice()); + androidDevicesTableModel.add(givenAnyDevice()); - assertFalse(sut.isCellEditable(0, COLUMN_STATE) || sut.isCellEditable(0, COLUMN_DEVICE)); - assertTrue(sut.isCellEditable(0, COLUMN_ACTION)); + assertFalse(androidDevicesTableModel.isCellEditable(0, COLUMN_STATE) + || androidDevicesTableModel.isCellEditable(0, COLUMN_DEVICE)); + assertTrue(androidDevicesTableModel.isCellEditable(0, COLUMN_ACTION)); } @Test public void shouldFireCellUpdateOnlyForActionColumn() throws Exception { - AndroidDevicesTableModel sut = givenEmptyDevicesTableModel(); + AndroidDevicesTableModel androidDevicesTableModel = givenEmptyDevicesTableModel(); - sut.addTableModelListener(tableModelListener); - sut.setValueAt(anyObject(), 0, COLUMN_ACTION); + androidDevicesTableModel.addTableModelListener(tableModelListener); + androidDevicesTableModel.setValueAt(anyObject(), 0, COLUMN_ACTION); verify(tableModelListener, atLeastOnce()).tableChanged((TableModelEvent) anyObject()); }