Tests - fixed failing tests

This commit is contained in:
dragonmacher 2019-11-29 16:31:34 -05:00
parent 2c4e0155db
commit b126f6bd06
3 changed files with 34 additions and 35 deletions

View file

@ -18,14 +18,9 @@ package ghidra.app.plugin.core.function.tags;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.*;
import docking.DockingWindowManager;
import docking.widgets.OptionDialog;
@ -34,9 +29,7 @@ import ghidra.app.cmd.function.ChangeFunctionTagCmd;
import ghidra.app.cmd.function.DeleteFunctionTagCmd;
import ghidra.framework.cmd.Command;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.FunctionTag;
import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.*;
import ghidra.util.Msg;
/**
@ -98,8 +91,8 @@ public abstract class TagListPanel extends JPanel {
// If the tag is a temporary one, it's not editable. Show a message to the user.
if (tag instanceof FunctionTagTemp) {
Msg.showWarn(this, table, "Tag Not Editable", "Tag " + "\"" + tag.getName() +
"\"" +
Msg.showWarn(this, table, "Tag Not Editable",
"Tag " + "\"" + tag.getName() + "\"" +
" must be added to the program before it can be modified/deleted");
return;
}
@ -121,7 +114,8 @@ public abstract class TagListPanel extends JPanel {
// If the name is empty, show a warning and don't allow it. A user should
// never want to do this.
if (newName.isEmpty()) {
Msg.showWarn(this, table, "Empty Tag Name?", "Tag name cannot be empty");
Msg.showWarn(this, table, "Empty Tag Name?",
"Tag name cannot be empty");
return false;
}
@ -219,8 +213,8 @@ public abstract class TagListPanel extends JPanel {
protected boolean isSelectionImmutable() {
int[] selectedRows = table.getSelectedRows();
int nameCol = table.getColumnModel().getColumnIndex("Name");
for (int i=0; i<selectedRows.length; i++) {
String tagName = (String) table.getValueAt(i, nameCol);
for (int selectedRow : selectedRows) {
String tagName = (String) table.getValueAt(selectedRow, nameCol);
FunctionTag tag = filteredModel.getTag(tagName);
if (tag instanceof FunctionTagTemp) {
return true;
@ -302,7 +296,8 @@ public abstract class TagListPanel extends JPanel {
int[] selectedIndices = table.getSelectedRows();
for (int i : selectedIndices) {
String tagName = (String) filteredModel.getValueAt(i, 0);
Optional<FunctionTag> tag = filteredModel.getTags().stream().filter(t -> t.getName().equals(tagName)).findAny();
Optional<FunctionTag> tag =
filteredModel.getTags().stream().filter(t -> t.getName().equals(tagName)).findAny();
if (tag.isPresent()) {
tags.add(tag.get());
}

View file

@ -15,7 +15,7 @@
*/
package ghidra.app.plugin.core.navigation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import java.awt.Color;
@ -82,7 +82,7 @@ public class NextPrevCodeUnitPluginTest extends AbstractGhidraHeadedIntegrationT
tool.addPlugin(BookmarkPlugin.class.getName());
NextPrevCodeUnitPlugin p = getPlugin(tool, NextPrevCodeUnitPlugin.class);
direction = getAction(p, "Toggle Code Unit Search Direction");
direction = getAction(p, "Toggle Search Direction");
nextInst = getAction(p, "Next Instruction");
nextData = getAction(p, "Next Data");
nextUndef = getAction(p, "Next Undefined");

View file

@ -17,6 +17,8 @@ package ghidra.util;
import static org.junit.Assert.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Test;
@ -30,9 +32,11 @@ public class DateUtilsTest {
}
@Test
public void testFormatDateTime() {
Date date = new Date(1572896586687L);
assertEquals("Nov 04, 2019 02:43 PM", DateUtils.formatDateTimestamp(date));
public void testFormatDateTime() throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy hh:mm a");
String dateString = "Nov 04, 2019 02:43 PM";
Date date = format.parse(dateString);
assertEquals(dateString, DateUtils.formatDateTimestamp(date));
}
@Test