|
@@ -23,18 +23,16 @@
|
23
|
23
|
package com.dmdirc.addons.awaycolours;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.Channel;
|
26
|
|
-import com.dmdirc.ChannelClientProperty;
|
27
|
26
|
import com.dmdirc.DMDircMBassador;
|
28
|
27
|
import com.dmdirc.config.ConfigBinder;
|
29
|
28
|
import com.dmdirc.events.ChannelUserAwayEvent;
|
30
|
29
|
import com.dmdirc.events.ChannelUserBackEvent;
|
|
30
|
+import com.dmdirc.events.DisplayProperty;
|
|
31
|
+import com.dmdirc.interfaces.GroupChatUser;
|
31
|
32
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
32
|
|
-import com.dmdirc.parser.interfaces.ChannelClientInfo;
|
33
|
33
|
import com.dmdirc.ui.messages.ColourManager;
|
34
|
34
|
import com.dmdirc.util.colours.Colour;
|
35
|
35
|
|
36
|
|
-import java.util.Map;
|
37
|
|
-
|
38
|
36
|
import org.junit.Before;
|
39
|
37
|
import org.junit.Test;
|
40
|
38
|
import org.junit.runner.RunWith;
|
|
@@ -42,7 +40,6 @@ import org.mockito.Mock;
|
42
|
40
|
import org.mockito.runners.MockitoJUnitRunner;
|
43
|
41
|
|
44
|
42
|
import static org.mockito.Matchers.anyString;
|
45
|
|
-import static org.mockito.Mockito.never;
|
46
|
43
|
import static org.mockito.Mockito.verify;
|
47
|
44
|
import static org.mockito.Mockito.when;
|
48
|
45
|
|
|
@@ -54,9 +51,8 @@ public class AwayColoursManagerTest {
|
54
|
51
|
@Mock private ConfigBinder binder;
|
55
|
52
|
@Mock private ChannelUserAwayEvent awayEvent;
|
56
|
53
|
@Mock private ChannelUserBackEvent backEvent;
|
57
|
|
- @Mock private ChannelClientInfo user;
|
|
54
|
+ @Mock private GroupChatUser user;
|
58
|
55
|
@Mock private Channel channel;
|
59
|
|
- @Mock private Map<Object, Object> map;
|
60
|
56
|
@Mock private ColourManager colourManager;
|
61
|
57
|
private AwayColoursManager instance;
|
62
|
58
|
private String red;
|
|
@@ -74,7 +70,6 @@ public class AwayColoursManagerTest {
|
74
|
70
|
when(awayEvent.getChannel()).thenReturn(channel);
|
75
|
71
|
when(backEvent.getUser()).thenReturn(user);
|
76
|
72
|
when(backEvent.getChannel()).thenReturn(channel);
|
77
|
|
- when(user.getMap()).thenReturn(map);
|
78
|
73
|
when(config.getBinder()).thenReturn(binder);
|
79
|
74
|
when(binder.withDefaultDomain(anyString())).thenReturn(binder);
|
80
|
75
|
when(colourManager.getColourFromString(red, Colour.GRAY)).thenReturn(redColour);
|
|
@@ -97,67 +92,23 @@ public class AwayColoursManagerTest {
|
97
|
92
|
@Test
|
98
|
93
|
public void testHandleColourChange() throws Exception {
|
99
|
94
|
instance.handleColourChange(red);
|
100
|
|
- instance.handleNicklistChange(true);
|
101
|
|
- instance.handleTextChange(true);
|
102
|
|
- instance.handleAwayEvent(awayEvent);
|
103
|
|
- verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
|
104
|
|
- verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
|
105
|
|
- instance.handleColourChange(black);
|
106
|
|
- instance.handleNicklistChange(true);
|
107
|
|
- instance.handleTextChange(true);
|
108
|
|
- instance.handleAwayEvent(awayEvent);
|
109
|
|
- verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, blackColour);
|
110
|
|
- verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, blackColour);
|
111
|
|
- }
|
112
|
|
-
|
113
|
|
- @Test
|
114
|
|
- public void testHandleNicklistChange() throws Exception {
|
115
|
|
- instance.handleColourChange(red);
|
116
|
|
- instance.handleNicklistChange(true);
|
117
|
|
- instance.handleTextChange(true);
|
118
|
|
- instance.handleAwayEvent(awayEvent);
|
119
|
|
- verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
|
120
|
|
- verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
|
121
|
|
- instance.handleColourChange(black);
|
122
|
|
- instance.handleNicklistChange(false);
|
123
|
|
- instance.handleTextChange(true);
|
124
|
|
- instance.handleAwayEvent(awayEvent);
|
125
|
|
- verify(map, never()).put(ChannelClientProperty.NICKLIST_FOREGROUND, blackColour);
|
126
|
|
- verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, blackColour);
|
127
|
|
- }
|
128
|
|
-
|
129
|
|
- @Test
|
130
|
|
- public void testHandleTextChange() throws Exception {
|
131
|
|
- instance.handleColourChange(red);
|
132
|
|
- instance.handleNicklistChange(true);
|
133
|
|
- instance.handleTextChange(true);
|
134
|
95
|
instance.handleAwayEvent(awayEvent);
|
135
|
|
- verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
|
136
|
|
- verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
|
|
96
|
+ verify(user).setDisplayProperty(DisplayProperty.FOREGROUND_COLOUR, redColour);
|
137
|
97
|
instance.handleColourChange(black);
|
138
|
|
- instance.handleNicklistChange(true);
|
139
|
|
- instance.handleTextChange(false);
|
140
|
98
|
instance.handleAwayEvent(awayEvent);
|
141
|
|
- verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, blackColour);
|
142
|
|
- verify(map, never()).put(ChannelClientProperty.TEXT_FOREGROUND, blackColour);
|
|
99
|
+ verify(user).setDisplayProperty(DisplayProperty.FOREGROUND_COLOUR, blackColour);
|
143
|
100
|
}
|
144
|
101
|
|
145
|
102
|
@Test
|
146
|
103
|
public void testHandleAwayEvent() throws Exception {
|
147
|
|
- instance.handleNicklistChange(true);
|
148
|
|
- instance.handleTextChange(true);
|
149
|
104
|
instance.handleBackEvent(backEvent);
|
150
|
|
- verify(map).remove(ChannelClientProperty.NICKLIST_FOREGROUND);
|
151
|
|
- verify(map).remove(ChannelClientProperty.TEXT_FOREGROUND);
|
|
105
|
+ verify(user).removeDisplayProperty(DisplayProperty.FOREGROUND_COLOUR);
|
152
|
106
|
}
|
153
|
107
|
|
154
|
108
|
@Test
|
155
|
109
|
public void testHandleBackEvent() throws Exception {
|
156
|
110
|
instance.handleColourChange(red);
|
157
|
|
- instance.handleNicklistChange(true);
|
158
|
|
- instance.handleTextChange(true);
|
159
|
111
|
instance.handleAwayEvent(awayEvent);
|
160
|
|
- verify(map).put(ChannelClientProperty.NICKLIST_FOREGROUND, redColour);
|
161
|
|
- verify(map).put(ChannelClientProperty.TEXT_FOREGROUND, redColour);
|
|
112
|
+ verify(user).setDisplayProperty(DisplayProperty.FOREGROUND_COLOUR, redColour);
|
162
|
113
|
}
|
163
|
114
|
}
|