@Test
	public void testUndoRedo2() throws Exception {

		disableCodeBrowserLocationEvents();

		env.showTool();

		// make 5 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(0x01001000);
			FieldLocation loc = getFieldLocation(addr);
			ByteViewerComponent c = panel.getCurrentComponent();
			c.setCursorPosition(loc.getIndex(), loc.getFieldNum(), 0, 0);
			action.setSelected(true);
			action.actionPerformed(new DefaultActionContext());
		});
		ByteViewerComponent c = panel.getCurrentComponent();

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

			Address addr = getAddr(0x01001000);
			for (int i = 0; i < 5; i++) {
				FieldLocation loc = getFieldLocation(addr);
				KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, keyCodes[i], values[i]);
				c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
					c.getCurrentField());
				addr = addr.add(1);
			}

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

		FieldLocation loc1 = new FieldLocation(0, 0, 0, 0); // first byte on first line
		FieldLocation loc2 = new FieldLocation(0, 1, 0, 0); // second byte on first line

		undo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);

		undo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);

		undo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, null);

		undo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, null);

		undo(program);
		testFieldColor(loc1, null);
		testFieldColor(loc2, null);
		assertFalse(program.canUndo());

		redo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, null);

		redo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, null);

		redo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);

		redo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);

		redo(program);
		testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
		testFieldColor(loc2, 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