summaryrefslogtreecommitdiff
path: root/same/src/test/java/com
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-23 14:18:12 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-23 14:18:12 +0100
commit6a893a7ba5563774e66519988398b67b06bcd8b0 (patch)
treee983e464b995a6ac5287d95f18c62c2bdc6797c3 /same/src/test/java/com
parentef8563e3106f1774b05fe5ea94f538e9983b0182 (diff)
Implement listeners in Variables.
Diffstat (limited to 'same/src/test/java/com')
-rw-r--r--same/src/test/java/com/orbekk/same/VariableFactoryTest.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/same/src/test/java/com/orbekk/same/VariableFactoryTest.java b/same/src/test/java/com/orbekk/same/VariableFactoryTest.java
index 7d20fa7..a6efa4b 100644
--- a/same/src/test/java/com/orbekk/same/VariableFactoryTest.java
+++ b/same/src/test/java/com/orbekk/same/VariableFactoryTest.java
@@ -59,4 +59,22 @@ public class VariableFactoryTest {
string.set("NewValue");
verify(client).set("X", "\"NewValue\"", 0);
}
+
+ @Test
+ public void addsListener() throws Exception {
+ Variable<String> v = vf.create("X", stringType);
+ verify(client).addStateListener((StateChangedListener)v);
+ }
+
+ @Test
+ public void listenerNotifies() throws Exception {
+ @SuppressWarnings("unchecked")
+ Variable.OnChangeListener<Integer> listener =
+ mock(Variable.OnChangeListener.class);
+ Variable<Integer> v = vf.create("z", intType);
+ v.setOnChangeListener(listener);
+ ((StateChangedListener) v).stateChanged(
+ new State.Component("z", 1, "abc"));
+ verify(listener).valueChanged(v);
+ }
}