-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVerifyingSelectionChangedListener.java
43 lines (33 loc) · 1.46 KB
/
VerifyingSelectionChangedListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.sap.clap.test;
import static org.junit.Assert.assertEquals;
import org.eclipse.swt.graphics.Rectangle;
import com.sap.clap.common.text.selection.SelectionChangedListener;
public class VerifyingSelectionChangedListener<T> implements SelectionChangedListener<T> {
private final T expectedSelectable;
private final Rectangle expectedNewSelectionBounds;
private final Rectangle expectedOldSelectionBounds;
private final int expectedCallCount;
private int callCount = 0;
public VerifyingSelectionChangedListener(final T expectedSelectable, final Rectangle expectedNewSelectionBounds,
final Rectangle expectedOldSelectionBounds) {
this.expectedSelectable = expectedSelectable;
this.expectedNewSelectionBounds = expectedNewSelectionBounds;
this.expectedOldSelectionBounds = expectedOldSelectionBounds;
this.expectedCallCount = 1;
}
public VerifyingSelectionChangedListener() {
this.expectedSelectable = null;
this.expectedNewSelectionBounds = null;
this.expectedOldSelectionBounds = null;
this.expectedCallCount = 0;
}
public void selectionChanged(final T selectable, final Rectangle newSelectionBounds, final Rectangle oldSelectionBounds) {
assertEquals(expectedSelectable, selectable);
assertEquals(expectedNewSelectionBounds, newSelectionBounds);
assertEquals(expectedOldSelectionBounds, oldSelectionBounds);
callCount++;
}
public void verify() {
assertEquals(expectedCallCount, callCount);
}
}