Merge remote-tracking branch 'origin/GP-210_dragonmacher_PR-744_S-S-P_master'

This commit is contained in:
ghidravore 2020-11-24 10:57:00 -05:00
commit f76577e99b
15 changed files with 1083 additions and 375 deletions

View file

@ -16,16 +16,22 @@
package help.screenshot;
import java.awt.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.*;
import org.junit.Test;
import docking.DialogComponentProvider;
import docking.action.DockingAction;
import docking.action.DockingActionIf;
import docking.widgets.fieldpanel.FieldPanel;
import ghidra.app.plugin.core.clipboard.CopyPasteSpecialDialog;
import ghidra.app.plugin.core.clipboard.*;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.codebrowser.CodeViewerProvider;
import ghidra.app.services.ClipboardContentProviderService;
import ghidra.app.util.viewer.field.MnemonicFieldFactory;
import ghidra.program.util.ProgramSelection;
import ghidra.util.Msg;
@ -33,10 +39,6 @@ import ghidra.util.exception.AssertException;
public class ClipboardPluginScreenShots extends GhidraScreenShotGenerator {
public ClipboardPluginScreenShots() {
super();
}
@Test
public void testCaptureCopySpecial() {
@ -47,9 +49,12 @@ public class ClipboardPluginScreenShots extends GhidraScreenShotGenerator {
makeSelection(0x401000, 0x401000);
sel = cb.getCurrentSelection();
Msg.debug(this, "selection: " + sel);
showCopySpecialDialog();
CopyPasteSpecialDialog dialog = showCopySpecialDialog();
Window window = SwingUtilities.windowForComponent(dialog.getComponent());
Dimension size = window.getSize();
setWindowSize(window, size.width, 330);
captureDialog();
}
@ -184,7 +189,39 @@ public class ClipboardPluginScreenShots extends GhidraScreenShotGenerator {
crop(imageBounds);
}
private void showCopySpecialDialog() {
performAction("Copy Special", "ClipboardPlugin", false);
private CopyPasteSpecialDialog showCopySpecialDialog() {
ClipboardPlugin plugin = getPlugin(tool, ClipboardPlugin.class);
ClipboardContentProviderService service = getClipboardService(plugin);
DockingActionIf pasteAction = getLocalAction(service, "Copy Special", plugin);
performAction(pasteAction, false);
return waitForDialogComponent(CopyPasteSpecialDialog.class);
}
private ClipboardContentProviderService getClipboardService(
ClipboardPlugin clipboardPlugin) {
Map<?, ?> serviceMap = (Map<?, ?>) getInstanceField("serviceActionMap", clipboardPlugin);
Set<?> keySet = serviceMap.keySet();
for (Object name : keySet) {
ClipboardContentProviderService service = (ClipboardContentProviderService) name;
if (service.getClass().equals(CodeBrowserClipboardProvider.class)) {
return service;
}
}
return null;
}
@SuppressWarnings("unchecked")
private DockingAction getLocalAction(ClipboardContentProviderService service, String actionName,
ClipboardPlugin clipboardPlugin) {
Map<?, ?> actionsByService =
(Map<?, ?>) getInstanceField("serviceActionMap", clipboardPlugin);
List<DockingAction> actionList = (List<DockingAction>) actionsByService.get(service);
for (DockingAction pluginAction : actionList) {
if (pluginAction.getName().equals(actionName)) {
return pluginAction;
}
}
return null;
}
}

View file

@ -0,0 +1,36 @@
/* ###
* IP: GHIDRA
*
* 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 ghidra.app.plugin.core.clipboard;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import ghidra.app.plugin.core.byteviewer.ByteViewerClipboardProviderTest;
//@formatter:off
@RunWith(Suite.class)
@SuiteClasses({
ClipboardPluginTest.class,
ByteViewerClipboardProviderTest.class,
CodeBrowserClipboardProviderTest.class,
CopyPasteCommentsTest.class,
CopyPasteFunctionInfoTest.class
})
public class CopyPasteTestSuite {
// in the annotation
}
//@formatter:on