diff options
author | Juan C Nuno <juancnuno@google.com> | 2022-03-23 15:27:57 -0700 |
---|---|---|
committer | Juan Nuno <juancnuno@google.com> | 2022-03-24 00:22:22 +0000 |
commit | 6c0572a6dfaa6e2541e35ba9eeff0bdb85f39f71 (patch) | |
tree | 2d0706d3639132359f755535c45a800da41ab241 /device-manager | |
parent | 0fa3a3f9a8ed49f133d34811e0bcd2abc2a3a129 (diff) | |
download | idea-6c0572a6dfaa6e2541e35ba9eeff0bdb85f39f71.tar.gz |
Move PhysicalDeviceTable::getData to TestTables
Bug: 223246111
Test: Not applicable
Change-Id: I5c8c1850747fd287afde8521bb01f9ffab3763ac
Diffstat (limited to 'device-manager')
3 files changed, 41 insertions, 18 deletions
diff --git a/device-manager/src/com/android/tools/idea/devicemanager/physicaltab/PhysicalDeviceTable.java b/device-manager/src/com/android/tools/idea/devicemanager/physicaltab/PhysicalDeviceTable.java index 96dd32a58cd..c49269f3b96 100644 --- a/device-manager/src/com/android/tools/idea/devicemanager/physicaltab/PhysicalDeviceTable.java +++ b/device-manager/src/com/android/tools/idea/devicemanager/physicaltab/PhysicalDeviceTable.java @@ -37,8 +37,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.IntStream; import javax.swing.DefaultRowSorter; import javax.swing.ListSelectionModel; import javax.swing.RowSorter; @@ -136,20 +134,6 @@ public final class PhysicalDeviceTable extends DeviceTable<PhysicalDevice> { return Optional.of(getDeviceAt(viewRowIndex)); } - @VisibleForTesting - @NotNull Object getData() { - return IntStream.range(0, getRowCount()) - .mapToObj(this::getRowAt) - .collect(Collectors.toList()); - } - - @VisibleForTesting - private @NotNull Object getRowAt(int viewRowIndex) { - return IntStream.range(0, getColumnCount()) - .mapToObj(viewColumnIndex -> getValueAt(viewRowIndex, viewColumnIndex)) - .collect(Collectors.toList()); - } - @Override protected @NotNull JTableHeader createDefaultTableHeader() { TableColumnModel model = new DefaultTableColumnModel(); diff --git a/device-manager/testSrc/com/android/tools/idea/devicemanager/TestTables.java b/device-manager/testSrc/com/android/tools/idea/devicemanager/TestTables.java new file mode 100644 index 00000000000..08d63813bb2 --- /dev/null +++ b/device-manager/testSrc/com/android/tools/idea/devicemanager/TestTables.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tools.idea.devicemanager; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import javax.swing.JTable; +import org.jetbrains.annotations.NotNull; + +public final class TestTables { + private TestTables() { + } + + public static @NotNull Object getData(@NotNull JTable table) { + return IntStream.range(0, table.getRowCount()) + .mapToObj(viewRowIndex -> getRowAt(table, viewRowIndex)) + .collect(Collectors.toList()); + } + + private static @NotNull Object getRowAt(@NotNull JTable table, int viewRowIndex) { + return IntStream.range(0, table.getColumnCount()) + .mapToObj(viewColumnIndex -> table.getValueAt(viewRowIndex, viewColumnIndex)) + .collect(Collectors.toList()); + } +} diff --git a/device-manager/testSrc/com/android/tools/idea/devicemanager/physicaltab/PhysicalDevicePanelTest.java b/device-manager/testSrc/com/android/tools/idea/devicemanager/physicaltab/PhysicalDevicePanelTest.java index e0afb35c5f2..46ffeebc047 100644 --- a/device-manager/testSrc/com/android/tools/idea/devicemanager/physicaltab/PhysicalDevicePanelTest.java +++ b/device-manager/testSrc/com/android/tools/idea/devicemanager/physicaltab/PhysicalDevicePanelTest.java @@ -28,6 +28,7 @@ import com.android.tools.idea.devicemanager.CountDownLatchAssert; import com.android.tools.idea.devicemanager.CountDownLatchFutureCallback; import com.android.tools.idea.devicemanager.DetailsPanel; import com.android.tools.idea.devicemanager.PopUpMenuValue; +import com.android.tools.idea.devicemanager.TestTables; import com.android.tools.idea.devicemanager.physicaltab.PhysicalDevicePanel.SetDevices; import com.android.tools.idea.devicemanager.physicaltab.PhysicalDeviceTableModel.RemoveValue; import com.google.common.util.concurrent.FutureCallback; @@ -127,7 +128,7 @@ public final class PhysicalDevicePanelTest { RemoveValue.INSTANCE, PopUpMenuValue.INSTANCE)); - assertEquals(data, myPanel.getTable().getData()); + assertEquals(data, TestTables.getData(myPanel.getTable())); } @Test @@ -162,7 +163,7 @@ public final class PhysicalDevicePanelTest { RemoveValue.INSTANCE, PopUpMenuValue.INSTANCE)); - assertEquals(data, myPanel.getTable().getData()); + assertEquals(data, TestTables.getData(myPanel.getTable())); } private @NotNull FutureCallback<@Nullable List<@NotNull PhysicalDevice>> newSetDevices(@NotNull PhysicalDevicePanel panel) { |