Ver código fonte

Fix tests.

pull/122/head
Greg Holmes 9 anos atrás
pai
commit
dab3f804c4

+ 34
- 24
awaycolours/test/com/dmdirc/addons/awaycolours/AwayColoursManagerTest.java Ver arquivo

@@ -29,6 +29,7 @@ import com.dmdirc.events.ChannelUserAwayEvent;
29 29
 import com.dmdirc.events.ChannelUserBackEvent;
30 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31 31
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
32
+import com.dmdirc.ui.messages.ColourManager;
32 33
 import com.dmdirc.util.colours.Colour;
33 34
 
34 35
 import java.util.Map;
@@ -53,16 +54,25 @@ public class AwayColoursManagerTest {
53 54
     @Mock private ChannelUserBackEvent backEvent;
54 55
     @Mock private ChannelClientInfo user;
55 56
     @Mock private Map<Object, Object> map;
57
+    @Mock private ColourManager colourManager;
56 58
     private AwayColoursManager instance;
57
-    private Colour colour;
59
+    private String red;
60
+    private Colour redColour;
61
+    private String black;
62
+    private Colour blackColour;
58 63
 
59 64
     @Before
60 65
     public void setUp() throws Exception {
61
-        colour = Colour.RED;
62
-        instance = new AwayColoursManager(eventBus, config, "test");
66
+        red = "red";
67
+        black = "black";
68
+        redColour = Colour.RED;
69
+        blackColour = Colour.BLACK;
70
+        instance = new AwayColoursManager(eventBus, config, "test", colourManager);
63 71
         when(awayEvent.getUser()).thenReturn(user);
64 72
         when(backEvent.getUser()).thenReturn(user);
65 73
         when(user.getMap()).thenReturn(map);
74
+        when(colourManager.getColourFromString(red, Colour.GRAY)).thenReturn(redColour);
75
+        when(colourManager.getColourFromString(black, Colour.GRAY)).thenReturn(blackColour);
66 76
     }
67 77
 
68 78
     @Test
@@ -79,50 +89,50 @@ public class AwayColoursManagerTest {
79 89
 
80 90
     @Test
81 91
     public void testHandleColourChange() throws Exception {
82
-        instance.handleColourChange(colour);
92
+        instance.handleColourChange(red);
83 93
         instance.handleNicklistChange(true);
84 94
         instance.handleTextChange(true);
85 95
         instance.handleAwayEvent(awayEvent);
86
-        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, colour);
87
-        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, colour);
88
-        instance.handleColourChange(Colour.BLACK);
96
+        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
97
+        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
98
+        instance.handleColourChange(black);
89 99
         instance.handleNicklistChange(true);
90 100
         instance.handleTextChange(true);
91 101
         instance.handleAwayEvent(awayEvent);
92
-        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, Colour.BLACK);
93
-        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, Colour.BLACK);
102
+        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, blackColour);
103
+        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, blackColour);
94 104
     }
95 105
 
96 106
     @Test
97 107
     public void testHandleNicklistChange() throws Exception {
98
-        instance.handleColourChange(colour);
108
+        instance.handleColourChange(red);
99 109
         instance.handleNicklistChange(true);
100 110
         instance.handleTextChange(true);
101 111
         instance.handleAwayEvent(awayEvent);
102
-        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, colour);
103
-        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, colour);
104
-        instance.handleColourChange(Colour.BLACK);
112
+        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
113
+        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
114
+        instance.handleColourChange(black);
105 115
         instance.handleNicklistChange(false);
106 116
         instance.handleTextChange(true);
107 117
         instance.handleAwayEvent(awayEvent);
108
-        verify(map, never()).put(ChannelClientProperty.NICKLIST_FOREGROUND, Colour.BLACK);
109
-        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, Colour.BLACK);
118
+        verify(map, never()).put(ChannelClientProperty.NICKLIST_FOREGROUND, blackColour);
119
+        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, blackColour);
110 120
     }
111 121
 
112 122
     @Test
113 123
     public void testHandleTextChange() throws Exception {
114
-        instance.handleColourChange(colour);
124
+        instance.handleColourChange(red);
115 125
         instance.handleNicklistChange(true);
116 126
         instance.handleTextChange(true);
117 127
         instance.handleAwayEvent(awayEvent);
118
-        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, colour);
119
-        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, colour);
120
-        instance.handleColourChange(Colour.BLACK);
128
+        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
129
+        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
130
+        instance.handleColourChange(black);
121 131
         instance.handleNicklistChange(true);
122 132
         instance.handleTextChange(false);
123 133
         instance.handleAwayEvent(awayEvent);
124
-        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, Colour.BLACK);
125
-        verify(map, never()).put(ChannelClientProperty.TEXT_FOREGROUND, Colour.BLACK);
134
+        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, blackColour);
135
+        verify(map, never()).put(ChannelClientProperty.TEXT_FOREGROUND, blackColour);
126 136
     }
127 137
 
128 138
     @Test
@@ -136,11 +146,11 @@ public class AwayColoursManagerTest {
136 146
 
137 147
     @Test
138 148
     public void testHandleBackEvent() throws Exception {
139
-        instance.handleColourChange(colour);
149
+        instance.handleColourChange(red);
140 150
         instance.handleNicklistChange(true);
141 151
         instance.handleTextChange(true);
142 152
         instance.handleAwayEvent(awayEvent);
143
-        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, colour);
144
-        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, colour);
153
+        verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
154
+        verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
145 155
     }
146 156
 }

Carregando…
Cancelar
Salvar