瀏覽代碼

Fix tests.

pull/122/head
Greg Holmes 9 年之前
父節點
當前提交
dab3f804c4
共有 1 個文件被更改,包括 34 次插入24 次删除
  1. 34
    24
      awaycolours/test/com/dmdirc/addons/awaycolours/AwayColoursManagerTest.java

+ 34
- 24
awaycolours/test/com/dmdirc/addons/awaycolours/AwayColoursManagerTest.java 查看文件

29
 import com.dmdirc.events.ChannelUserBackEvent;
29
 import com.dmdirc.events.ChannelUserBackEvent;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
31
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
32
+import com.dmdirc.ui.messages.ColourManager;
32
 import com.dmdirc.util.colours.Colour;
33
 import com.dmdirc.util.colours.Colour;
33
 
34
 
34
 import java.util.Map;
35
 import java.util.Map;
53
     @Mock private ChannelUserBackEvent backEvent;
54
     @Mock private ChannelUserBackEvent backEvent;
54
     @Mock private ChannelClientInfo user;
55
     @Mock private ChannelClientInfo user;
55
     @Mock private Map<Object, Object> map;
56
     @Mock private Map<Object, Object> map;
57
+    @Mock private ColourManager colourManager;
56
     private AwayColoursManager instance;
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
     @Before
64
     @Before
60
     public void setUp() throws Exception {
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
         when(awayEvent.getUser()).thenReturn(user);
71
         when(awayEvent.getUser()).thenReturn(user);
64
         when(backEvent.getUser()).thenReturn(user);
72
         when(backEvent.getUser()).thenReturn(user);
65
         when(user.getMap()).thenReturn(map);
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
     @Test
78
     @Test
79
 
89
 
80
     @Test
90
     @Test
81
     public void testHandleColourChange() throws Exception {
91
     public void testHandleColourChange() throws Exception {
82
-        instance.handleColourChange(colour);
92
+        instance.handleColourChange(red);
83
         instance.handleNicklistChange(true);
93
         instance.handleNicklistChange(true);
84
         instance.handleTextChange(true);
94
         instance.handleTextChange(true);
85
         instance.handleAwayEvent(awayEvent);
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
         instance.handleNicklistChange(true);
99
         instance.handleNicklistChange(true);
90
         instance.handleTextChange(true);
100
         instance.handleTextChange(true);
91
         instance.handleAwayEvent(awayEvent);
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
     @Test
106
     @Test
97
     public void testHandleNicklistChange() throws Exception {
107
     public void testHandleNicklistChange() throws Exception {
98
-        instance.handleColourChange(colour);
108
+        instance.handleColourChange(red);
99
         instance.handleNicklistChange(true);
109
         instance.handleNicklistChange(true);
100
         instance.handleTextChange(true);
110
         instance.handleTextChange(true);
101
         instance.handleAwayEvent(awayEvent);
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
         instance.handleNicklistChange(false);
115
         instance.handleNicklistChange(false);
106
         instance.handleTextChange(true);
116
         instance.handleTextChange(true);
107
         instance.handleAwayEvent(awayEvent);
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
     @Test
122
     @Test
113
     public void testHandleTextChange() throws Exception {
123
     public void testHandleTextChange() throws Exception {
114
-        instance.handleColourChange(colour);
124
+        instance.handleColourChange(red);
115
         instance.handleNicklistChange(true);
125
         instance.handleNicklistChange(true);
116
         instance.handleTextChange(true);
126
         instance.handleTextChange(true);
117
         instance.handleAwayEvent(awayEvent);
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
         instance.handleNicklistChange(true);
131
         instance.handleNicklistChange(true);
122
         instance.handleTextChange(false);
132
         instance.handleTextChange(false);
123
         instance.handleAwayEvent(awayEvent);
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
     @Test
138
     @Test
136
 
146
 
137
     @Test
147
     @Test
138
     public void testHandleBackEvent() throws Exception {
148
     public void testHandleBackEvent() throws Exception {
139
-        instance.handleColourChange(colour);
149
+        instance.handleColourChange(red);
140
         instance.handleNicklistChange(true);
150
         instance.handleNicklistChange(true);
141
         instance.handleTextChange(true);
151
         instance.handleTextChange(true);
142
         instance.handleAwayEvent(awayEvent);
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
 }

Loading…
取消
儲存