@@ -17,11 +17,24 @@ public class LogFormatterTest {
17
17
@ Test
18
18
public void testSettings () {
19
19
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 );
21
27
formatter1 .setVisible (LogFormatter .Field .ATTACHMENT , true );
22
28
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 );
24
32
assertTrue (formatter2 .isVisible (LogFormatter .Field .ATTACHMENT ));
25
33
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 ));
26
39
}
27
40
}
0 commit comments