Skip to content

Commit 33c2c87

Browse files
Ian Southamspark404
authored andcommitted
Findbugs finding
Signed-off-by: Hugo Trippaers <htrippaers@schubergphilis.com>
1 parent 1237bf3 commit 33c2c87

2 files changed

Lines changed: 53 additions & 4 deletions

File tree

services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ public int mapMouseDownModifier(int code, int modifiers) {
179179
int mod = mapModifier(modifiers);
180180
switch (code) {
181181
case 0:
182-
return mod = mod | MouseEvent.BUTTON1_DOWN_MASK;
182+
mod = mod | MouseEvent.BUTTON1_DOWN_MASK;
183+
break;
183184
case 2:
184-
return mod = mod | MouseEvent.BUTTON3_DOWN_MASK;
185+
mod = mod | MouseEvent.BUTTON3_DOWN_MASK;
186+
break;
185187
default:
186188
}
187189
return mod;
@@ -191,9 +193,11 @@ public int mapMouseUpModifier(int code, int modifiers) {
191193
int mod = mapModifier(modifiers);
192194
switch (code) {
193195
case 0:
194-
return mod = mod | MouseEvent.BUTTON1_MASK;
196+
mod = mod | MouseEvent.BUTTON1_MASK;
197+
break;
195198
case 2:
196-
return mod = mod | MouseEvent.BUTTON3_MASK;
199+
mod = mod | MouseEvent.BUTTON3_MASK;
200+
break;
197201
default:
198202
}
199203
return mod;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.cloud.consoleproxy;
2+
3+
import junit.framework.Assert;
4+
5+
import org.junit.Test;
6+
7+
public class ConsoleProxyRdpClientTest {
8+
9+
@Test
10+
public void testMapMouseDownModifierButton1Mask() throws Exception {
11+
int code = 0;
12+
int modifiers = 960;
13+
int expected = 1024 + 960;
14+
15+
ConsoleProxyRdpClient rdpc = new ConsoleProxyRdpClient();
16+
int actual = rdpc.mapMouseDownModifier(code, modifiers);
17+
18+
Assert.assertEquals(expected, actual);
19+
}
20+
21+
@Test
22+
public void testMapMouseDownModifierButton2() throws Exception {
23+
int code = 1;
24+
int modifiers = 0xffff;
25+
int expected = 960;
26+
27+
ConsoleProxyRdpClient rdpc = new ConsoleProxyRdpClient();
28+
int actual = rdpc.mapMouseDownModifier(code, modifiers);
29+
30+
Assert.assertEquals(expected, actual);
31+
}
32+
33+
@Test
34+
public void testMapMouseDownModifierButton3Mask() throws Exception {
35+
int code = 2;
36+
int modifiers = 960;
37+
int expected = 4096 + 960;
38+
39+
ConsoleProxyRdpClient rdpc = new ConsoleProxyRdpClient();
40+
int actual = rdpc.mapMouseDownModifier(code, modifiers);
41+
42+
Assert.assertEquals(expected, actual);
43+
}
44+
45+
}

0 commit comments

Comments
 (0)