package org.scijava.ui.swing.console;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.scijava.Context;
import org.scijava.prefs.PrefService;

/**
 * Tests {@link LogFormatter}.
 *
 * @author Matthias Arzt
 */
public class LogFormatterTest {

	@Test
	public void testSettings() {
		Context context = new Context(PrefService.class);
		LogFormatter formatter1 = new LogFormatter(context, "abc");
		formatter1.setVisible(LogFormatter.Field.ATTACHMENT, true);
		formatter1.setVisible(LogFormatter.Field.LEVEL, false);
		LogFormatter formatter2 = new LogFormatter(context, "abc");
		assertTrue(formatter2.isVisible(LogFormatter.Field.ATTACHMENT));
		assertFalse(formatter2.isVisible(LogFormatter.Field.LEVEL));
	}
}

@@ -399,16 +399,332 @@
 class);%0A
+%09%09final String usedKey = %22LogFormatterTest-key%22;%0A%09%09final String nonMatchingKey = %22LogFormatterTest-nonmatching%22;%0A%09%09context.service(PrefService.class).remove(LogFormatter.class, usedKey);%0A%09%09context.service(PrefService.class).remove(LogFormatter.class, nonMatchingKey);%0A%0A%09%09// Assign some settings to a particular key.%0A
 %09%09LogFor
@@ -765,29 +765,31 @@
 er(context, 
-%22abc%22
+usedKey
 );%0A%09%09formatt
@@ -898,16 +898,73 @@
  false);
+%0A%0A%09%09// Check that matching key does share these settings.
 %0A%09%09LogFo
@@ -1014,13 +1014,15 @@
 xt, 
-%22abc%22
+usedKey
 );%0A%09
@@ -1149,14 +1149,280 @@
 LEVEL));
+%0A%0A%09%09// Check that non-matching key does not share these settings.%0A%09%09LogFormatter formatter3 = new LogFormatter(context, nonMatchingKey);%0A%09%09assertFalse(formatter3.isVisible(LogFormatter.Field.ATTACHMENT));%0A%09%09assertTrue(formatter3.isVisible(LogFormatter.Field.LEVEL));
 %0A%09%7D%0A%7D%0A

improve the settings test