mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 04:09:40 +08:00
fixing multiTabPluginTest
This commit is contained in:
+30
-24
@@ -99,7 +99,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
openPrograms(programNames);
|
openPrograms(programNames);
|
||||||
assertNotNull(panel);
|
assertNotNull(panel);
|
||||||
assertEquals(programNames.length, panel.getTabCount());
|
assertEquals(programNames.length, panel.getTabCount());
|
||||||
assertEquals(programs[programs.length - 1], panel.getSelectedTabValue());
|
assertEquals(programs[programs.length - 1], getSelectedTabValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -119,13 +119,13 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
JPanel tab = panel.getTab(programs[1]);
|
JPanel tab = panel.getTab(programs[1]);
|
||||||
Point p = tab.getLocationOnScreen();
|
Point p = tab.getLocationOnScreen();
|
||||||
clickMouse(tab, MouseEvent.BUTTON1, p.x + 1, p.y + 1, 1, 0);
|
clickMouse(tab, MouseEvent.BUTTON1, p.x + 1, p.y + 1, 1, 0);
|
||||||
assertEquals(programs[1], panel.getSelectedTabValue());
|
assertEquals(programs[1], getSelectedTabValue());
|
||||||
|
|
||||||
// select first tab
|
// select first tab
|
||||||
tab = panel.getTab(programs[0]);
|
tab = panel.getTab(programs[0]);
|
||||||
p = tab.getLocationOnScreen();
|
p = tab.getLocationOnScreen();
|
||||||
clickMouse(tab, MouseEvent.BUTTON1, p.x + 1, p.y + 1, 1, 0);
|
clickMouse(tab, MouseEvent.BUTTON1, p.x + 1, p.y + 1, 1, 0);
|
||||||
assertEquals(programs[0], panel.getSelectedTabValue());
|
assertEquals(programs[0], getSelectedTabValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -231,7 +231,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
SearchList<Program> list = findComponent(tabListPopup, SearchList.class);
|
SearchList<Program> list = findComponent(tabListPopup, SearchList.class);
|
||||||
list.setSelectedItem(programs[1]);
|
list.setSelectedItem(programs[1]);
|
||||||
triggerText(list.getFilterField(), "\n");
|
triggerText(list.getFilterField(), "\n");
|
||||||
assertEquals(programs[1], panel.getSelectedTabValue());
|
assertEquals(programs[1], getSelectedTabValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -280,7 +280,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
Program p = doOpenProgram(builder.getProgram(), true);
|
Program p = doOpenProgram(builder.getProgram(), true);
|
||||||
p.setTemporary(false); // we need to be notified of changes
|
p.setTemporary(false); // we need to be notified of changes
|
||||||
// select notepad
|
// select notepad
|
||||||
panel.selectTab(p);
|
selectTab(p);
|
||||||
int transactionID = p.startTransaction("test");
|
int transactionID = p.startTransaction("test");
|
||||||
try {
|
try {
|
||||||
SymbolTable symTable = p.getSymbolTable();
|
SymbolTable symTable = p.getSymbolTable();
|
||||||
@@ -305,7 +305,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
assertHidden(programs[1]);
|
assertHidden(programs[1]);
|
||||||
|
|
||||||
runSwing(() -> panel.selectTab(programs[1]));
|
runSwing(() -> panel.selectTab(programs[1]));
|
||||||
assertEquals(programs[1], panel.getSelectedTabValue());
|
assertEquals(programs[1], getSelectedTabValue());
|
||||||
assertShowing(programs[1]);
|
assertShowing(programs[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +314,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
|
|
||||||
openPrograms_HideLastOpened();
|
openPrograms_HideLastOpened();
|
||||||
|
|
||||||
Program startProgram = panel.getSelectedTabValue();
|
Program startProgram = getSelectedTabValue();
|
||||||
|
|
||||||
MultiTabPlugin plugin = env.getPlugin(MultiTabPlugin.class);
|
MultiTabPlugin plugin = env.getPlugin(MultiTabPlugin.class);
|
||||||
DockingAction action =
|
DockingAction action =
|
||||||
@@ -325,13 +325,13 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
JPanel tab = panel.getTab(programs[1]);
|
JPanel tab = panel.getTab(programs[1]);
|
||||||
Point p = tab.getLocationOnScreen();
|
Point p = tab.getLocationOnScreen();
|
||||||
clickMouse(tab, MouseEvent.BUTTON1, p.x + 1, p.y + 1, 1, 0);
|
clickMouse(tab, MouseEvent.BUTTON1, p.x + 1, p.y + 1, 1, 0);
|
||||||
assertEquals(programs[1], panel.getSelectedTabValue());
|
assertEquals(programs[1], getSelectedTabValue());
|
||||||
assertTrue(!startProgram.equals(panel.getSelectedTabValue()));
|
assertTrue(!startProgram.equals(getSelectedTabValue()));
|
||||||
|
|
||||||
assertTrue(action.isEnabled());
|
assertTrue(action.isEnabled());
|
||||||
|
|
||||||
performAction(action, true);
|
performAction(action, true);
|
||||||
assertEquals(startProgram, panel.getSelectedTabValue());
|
assertEquals(startProgram, getSelectedTabValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -374,8 +374,8 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
// don't let focus issues hide the popup list
|
// don't let focus issues hide the popup list
|
||||||
panel.setIgnoreFocus(true);
|
panel.setIgnoreFocus(true);
|
||||||
|
|
||||||
panel.selectTab(p);
|
selectTab(p);
|
||||||
assertEquals(p, panel.getSelectedTabValue());
|
assertEquals(p, getSelectedTabValue());
|
||||||
|
|
||||||
addComment(p);
|
addComment(p);
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
private void assertProgramSelected(Program p) {
|
private void assertProgramSelected(Program p) {
|
||||||
Program selectedProgram = panel.getSelectedTabValue();
|
Program selectedProgram = getSelectedTabValue();
|
||||||
assertEquals(selectedProgram, p);
|
assertEquals(selectedProgram, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,10 +553,14 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void selectTab(Program p) {
|
private void selectTab(Program p) {
|
||||||
JPanel tab = panel.getTab(p);
|
JPanel tab = runSwing(() -> panel.getTab(p));
|
||||||
Point point = tab.getLocationOnScreen();
|
Point point = runSwing(() -> tab.getLocationOnScreen());
|
||||||
clickMouse(tab, MouseEvent.BUTTON1, point.x + 1, point.y + 1, 1, 0);
|
clickMouse(tab, MouseEvent.BUTTON1, point.x + 1, point.y + 1, 1, 0);
|
||||||
assertEquals(p, panel.getSelectedTabValue());
|
assertEquals(p, getSelectedTabValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Program getSelectedTabValue() {
|
||||||
|
return runSwing(() -> panel.getSelectedTabValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel getTabPanel(Program p) {
|
private JPanel getTabPanel(Program p) {
|
||||||
@@ -614,15 +618,17 @@ public class MultiTabPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Program doOpenProgram(Program p, boolean makeCurrent) {
|
private Program doOpenProgram(Program p, boolean makeCurrent) {
|
||||||
int programState = makeCurrent ? ProgramManager.OPEN_CURRENT : ProgramManager.OPEN_VISIBLE;
|
runSwing(() -> {
|
||||||
pm.openProgram(p, programState);
|
int programState =
|
||||||
|
makeCurrent ? ProgramManager.OPEN_CURRENT : ProgramManager.OPEN_VISIBLE;
|
||||||
|
pm.openProgram(p, programState);
|
||||||
|
panel = findComponent(tool.getToolFrame(), GTabPanel.class);
|
||||||
|
|
||||||
|
// don't let focus issues hide the popup list
|
||||||
|
panel.setIgnoreFocus(true);
|
||||||
|
panel.setShowTabsAlways(true);
|
||||||
|
});
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
panel = findComponent(tool.getToolFrame(), GTabPanel.class);
|
|
||||||
|
|
||||||
// don't let focus issues hide the popup list
|
|
||||||
panel.setIgnoreFocus(true);
|
|
||||||
panel.setShowTabsAlways(true);
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user