@Test
	public void testSaveRestoreState() throws Exception {
		env.showTool();
		addViews();
		ByteViewerComponent c = panel.getCurrentComponent();

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

		ByteViewerOptionsDialog dialog = launchByteViewerOptions();
		FixedBitSizeValueField field =
			(FixedBitSizeValueField) getInstanceField("groupSizeField", dialog);
		runSwing(() -> field.setValue(BigInteger.valueOf(4)));
		pressButtonByText(dialog.getComponent(), "OK");

		// change the font
		Options opt = tool.getOptions("ByteViewer");
		Font font = new Font("Times New Roman", Font.BOLD, 12);

		runSwing(() -> {

			opt.setFont(ByteViewerComponentProvider.OPTION_FONT, font);
			GoToService goToService = tool.getService(GoToService.class);
			goToService.goTo(new ProgramLocation(program, getAddr(0x01002500)));
		});
		assertEquals(4, plugin.getProvider().getGroupSize());

		ViewerPosition vp = panel.getViewerPosition();
		runSwing(() -> env.saveRestoreToolState());

		waitForSwing();
		c = panel.getCurrentComponent();
		assertEquals(4, plugin.getProvider().getGroupSize());

		assertEquals(getFieldLocation(getAddr(0x01002500)), c.getCursorLocation());
		assertEquals(font, panel.getFontMetrics().getFont());
		waitForSwing();

		assertEquals(vp, panel.getViewerPosition());
	}
Test editing in the Byte Viewer.
Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java