@Test
	public void testUndoRedoHexShort2() throws Exception {
		disableCodeBrowserLocationEvents();

		env.showTool();
		addViews();

		ByteViewerComponent c = findComponent(panel, "Hex Short");
		panel.setCurrentView(c);
		// make 3 changes
		// verify that the Undo button is enabled and undo can be done 5 times
		ToggleDockingAction action =
			(ToggleDockingAction) getAction(plugin, "Enable/Disable Byteviewer Editing");

		runSwing(() -> {
			Address addr = getAddr(0x01001003);
			FieldLocation loc = getFieldLocation(addr);
			ByteViewerComponent currentComponent = panel.getCurrentComponent();
			currentComponent.setCursorPosition(loc.getIndex(), loc.getFieldNum(), 0, 0);
			action.setSelected(true);
			action.actionPerformed(new DefaultActionContext());
		});

		runSwing(() -> {
			char[] values = { 'a', '1', '2' };
			int[] keyCodes =
				{ KeyEvent.VK_P, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_B, KeyEvent.VK_3 };

			ByteViewerComponent currentComponent = panel.getCurrentComponent();
			for (int i = 0; i < 3; i++) {
				FieldLocation loc = currentComponent.getCursorLocation();
				KeyEvent ev = new KeyEvent(currentComponent, 0, new Date().getTime(), 0,
					keyCodes[i], values[i]);
				currentComponent.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(),
					loc.getCol(), currentComponent.getCurrentField());
			}

		});
		program.flushEvents();
		waitForSwing();

		for (int i = 0; i < 3; i++) {
			assertTrue(program.canUndo());

			undo(program);

			FieldLocation loc = c.getCursorLocation();
			ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
			Color fg = field.getForeground();
			if (i == 2) {
				assertTrue(fg == null ||
					ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR == field.getForeground());
			}
			else {
				assertEquals(fg, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
			}
		}
		assertFalse(program.canUndo());

		for (int i = 0; i < 3; i++) {

			redo(program);

			FieldLocation loc = c.getCursorLocation();
			ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
			Color fg = field.getForeground();
			assertEquals(fg, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		}

		assertTrue(program.canUndo());
	}
Test editing in the Byte Viewer.
Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java