@@ -17,11 +17,24 @@ public class LogFormatterTest {
1717 @ Test
1818 public void testSettings () {
1919 Context context = new Context (PrefService .class );
20- LogFormatter formatter1 = new LogFormatter (context , "abc" );
20+ final String usedKey = "LogFormatterTest-key" ;
21+ final String nonMatchingKey = "LogFormatterTest-nonmatching" ;
22+ context .service (PrefService .class ).remove (LogFormatter .class , usedKey );
23+ context .service (PrefService .class ).remove (LogFormatter .class , nonMatchingKey );
24+
25+ // Assign some settings to a particular key.
26+ LogFormatter formatter1 = new LogFormatter (context , usedKey );
2127 formatter1 .setVisible (LogFormatter .Field .ATTACHMENT , true );
2228 formatter1 .setVisible (LogFormatter .Field .LEVEL , false );
23- LogFormatter formatter2 = new LogFormatter (context , "abc" );
29+
30+ // Check that matching key does share these settings.
31+ LogFormatter formatter2 = new LogFormatter (context , usedKey );
2432 assertTrue (formatter2 .isVisible (LogFormatter .Field .ATTACHMENT ));
2533 assertFalse (formatter2 .isVisible (LogFormatter .Field .LEVEL ));
34+
35+ // Check that non-matching key does not share these settings.
36+ LogFormatter formatter3 = new LogFormatter (context , nonMatchingKey );
37+ assertFalse (formatter3 .isVisible (LogFormatter .Field .ATTACHMENT ));
38+ assertTrue (formatter3 .isVisible (LogFormatter .Field .LEVEL ));
2639 }
2740}
0 commit comments