Merge remote-tracking branch 'origin/dev747368_fix_dataaction_tests'

This commit is contained in:
ghidravore 2019-04-10 17:55:46 -04:00
commit da40d9f2f0

View File

@ -1270,7 +1270,8 @@ public abstract class AbstractDataActionTest extends AbstractGhidraHeadedIntegra
checkAction(actions, EDIT_DATA_TYPE, checkAction(actions, EDIT_DATA_TYPE,
pdata != null && (pdata.isStructure() || pdata.isUnion()), caseName); pdata != null && (pdata.isStructure() || pdata.isUnion()), caseName);
checkAction(actions, CREATE_ARRAY, true, caseName); checkAction(actions, CREATE_ARRAY, true, caseName);
checkAction(actions, DEFAULT_DATA_SETTINGS, !hasSelection && hasSettings, caseName); checkAction(actions, DEFAULT_DATA_SETTINGS,
(!hasSelection || isSelectionJustSingleDataInstance(sel, d)) && hasSettings, caseName);
checkAction(actions, DATA_SETTINGS, hasNormalUnitSelection || hasSettings, caseName); checkAction(actions, DATA_SETTINGS, hasNormalUnitSelection || hasSettings, caseName);
checkAction(actions, CYCLE_FLOAT_DOUBLE, onFloatDoubleData, caseName); checkAction(actions, CYCLE_FLOAT_DOUBLE, onFloatDoubleData, caseName);
checkAction(actions, CYCLE_BYTE_WORD_DWORD_QWORD, onByteWordData, caseName); checkAction(actions, CYCLE_BYTE_WORD_DWORD_QWORD, onByteWordData, caseName);
@ -1332,7 +1333,8 @@ public abstract class AbstractDataActionTest extends AbstractGhidraHeadedIntegra
checkAction(actions, EDIT_DATA_TYPE, checkAction(actions, EDIT_DATA_TYPE,
pdata != null && (pdata.isStructure() || pdata.isUnion()), caseName); pdata != null && (pdata.isStructure() || pdata.isUnion()), caseName);
checkAction(actions, CREATE_ARRAY, true, caseName); checkAction(actions, CREATE_ARRAY, true, caseName);
checkAction(actions, DEFAULT_DATA_SETTINGS, hasSettings && !hasSelection, caseName); checkAction(actions, DEFAULT_DATA_SETTINGS,
hasSettings && (!hasSelection || isSelectionJustSingleDataInstance(sel, d)), caseName);
checkAction(actions, DATA_SETTINGS, hasSettings, caseName); checkAction(actions, DATA_SETTINGS, hasSettings, caseName);
checkAction(actions, CYCLE_FLOAT_DOUBLE, true, caseName); checkAction(actions, CYCLE_FLOAT_DOUBLE, true, caseName);
checkAction(actions, CYCLE_BYTE_WORD_DWORD_QWORD, true, caseName); checkAction(actions, CYCLE_BYTE_WORD_DWORD_QWORD, true, caseName);
@ -1474,6 +1476,14 @@ public abstract class AbstractDataActionTest extends AbstractGhidraHeadedIntegra
return; return;
} }
private boolean isSelectionJustSingleDataInstance(ProgramSelection selection, Data data) {
if (selection != null && data != null) {
AddressSet dataAS = new AddressSet(data.getAddress(), data.getMaxAddress());
return dataAS.hasSameAddresses(selection);
}
return false;
}
protected ActionContext getProgramContext() { protected ActionContext getProgramContext() {
cb.updateNow(); cb.updateNow();
ActionContext context = cb.getProvider().getActionContext(null); ActionContext context = cb.getProvider().getActionContext(null);