@Test
	public void testMemoryMapEdits() throws Exception {
		env.showTool();

		// put the byte viewer in edit mode
		ToggleDockingAction action =
			(ToggleDockingAction) getAction(plugin, "Enable/Disable Byteviewer Editing");
		runSwing(() -> {
			action.setSelected(true);
			action.actionPerformed(new DefaultActionContext());
		});

		// add a memory block		
		txSwing(() -> {
			Address addr = getAddr(0x100);
			memory.createInitializedBlock(".test", addr, 10, (byte) 0, null, false);
		});

		// edit the first 3 bytes in the block
		ByteViewerComponent c = panel.getCurrentComponent();
		runSwing(() -> {
			Address testAddress = getAddr(0x100);
			FieldLocation loc = getFieldLocation(testAddress);
			KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_1, '1');
			c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
				c.getCurrentField());

			testAddress = testAddress.add(1);
			loc = getFieldLocation(testAddress);
			ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_2, '2');
			c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
				c.getCurrentField());

			testAddress = testAddress.add(1);
			loc = getFieldLocation(testAddress);
			ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_3, '3');
			c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
				c.getCurrentField());
		});
		program.flushEvents();
		waitForSwing();

		Address addr = getAddr(0x100);
		for (int i = 0; i < 3; i++) {
			// verify that the bytes are rendered in red
			FieldLocation loc = getFieldLocation(addr);
			ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
			assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
			addr = addr.add(i);
		}
	}
Test editing in the Byte Viewer.
Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java