@Test
	public void testEditLastByteInBlock() throws Exception {

		env.showTool();

		runSwing(() -> {
			ByteViewerComponent c = panel.getCurrentComponent();
			FieldLocation loc = getFieldLocation(getAddr(0x01001000));
			c.setCursorPosition(loc.getIndex(), loc.getFieldNum(), 0, 0);
		}, false);

		ByteViewerOptionsDialog d = launchByteViewerOptions();
		FixedBitSizeValueField field =
			(FixedBitSizeValueField) getInstanceField("bytesPerLineField", d);
		runSwing(() -> field.setValue(BigInteger.valueOf(10)));
		pressButtonByText(d.getComponent(), "OK");
		runSwing(() -> {
			ToggleDockingAction action =
				(ToggleDockingAction) getAction(plugin, "Enable/Disable Byteviewer Editing");
			action.setSelected(true);
			action.actionPerformed(new DefaultActionContext());
		});

		// add the block
		txSwing(() -> {
			Address addr = getAddr(0x30);
			memory.createInitializedBlock(".test", addr, 0x12, (byte) 0, null, false);

			// add the second block at 0x48
			Address addr2 = getAddr(0x48);
			memory.createInitializedBlock(".test2", addr2, 0x100, (byte) 0, null, false);
		});

		runSwing(() -> {
			ByteViewerComponent c = panel.getCurrentComponent();
			Address a = getAddr(0x41);
			FieldLocation loc = getFieldLocation(a);
			c.setCursorPosition(loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol());

			KeyEvent 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();

		assertEquals((byte) 0x30, memory.getByte(getAddr(0x41)));
	}
Test editing in the Byte Viewer.
Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java