mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GT-3222 - review fixes
This commit is contained in:
parent
c2f2a417c9
commit
0db9205645
3 changed files with 70 additions and 18 deletions
|
@ -175,6 +175,18 @@ public class HistoryList<T> {
|
|||
broadcast(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a {@link #goBack()} until the given item becomes the current item. This is
|
||||
* useful if you wish to go backward to a specific item in the list.
|
||||
*
|
||||
* @param t the item
|
||||
*/
|
||||
public void goBackTo(T t) {
|
||||
while (!getCurrentHistoryItem().equals(t) && hasPrevious()) {
|
||||
goBack();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves this history list's current item pointer forward one and then calls the user-provided
|
||||
* callback to signal the newly selected item.
|
||||
|
@ -190,6 +202,18 @@ public class HistoryList<T> {
|
|||
broadcast(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a {@link #goForward()} until the given item becomes the current item. This is
|
||||
* useful if you wish to go forward to a specific item in the list.
|
||||
*
|
||||
* @param t the item
|
||||
*/
|
||||
public void goForwardTo(T t) {
|
||||
while (!getCurrentHistoryItem().equals(t) && hasNext()) {
|
||||
goForward();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item currently pointed to within the list of items. When an item is
|
||||
* added, this will be that item. Otherwise, it will be the last item navigated.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package util;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -425,6 +425,32 @@ public class HistoryListTest {
|
|||
assertNextItems();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackToItem() {
|
||||
|
||||
addHistory(A);
|
||||
addHistory(B);
|
||||
addHistory(C);
|
||||
|
||||
historyList.goBackTo(A);
|
||||
assertCurrentItem(A);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForwardToItem() {
|
||||
|
||||
addHistory(A);
|
||||
addHistory(B);
|
||||
addHistory(C);
|
||||
goBack();
|
||||
goBack();
|
||||
goBack();
|
||||
assertCurrentItem(A);
|
||||
|
||||
historyList.goForwardTo(C);
|
||||
assertCurrentItem(C);
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
// Private Methods
|
||||
//==================================================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue