Matthew Dempsky has uploaded a new change for review.

  https://gwt-review.googlesource.com/3680


Change subject: Fix SingleSelectionModel.getSelectedSet()
......................................................................

Fix SingleSelectionModel.getSelectedSet()

Ensure that if recent changes have been made to the model, that
getSelectedSet() still returns the same object that
getSelectedObject() would.

Change-Id: I0d0fbb4e8f9650d77d2270f53cde681a9cf2ca0f
---
M user/src/com/google/gwt/view/client/SingleSelectionModel.java
M user/test/com/google/gwt/view/client/SingleSelectionModelTest.java
2 files changed, 19 insertions(+), 2 deletions(-)



diff --git a/user/src/com/google/gwt/view/client/SingleSelectionModel.java b/user/src/com/google/gwt/view/client/SingleSelectionModel.java
index c34c338..9c84c8b 100644
--- a/user/src/com/google/gwt/view/client/SingleSelectionModel.java
+++ b/user/src/com/google/gwt/view/client/SingleSelectionModel.java
@@ -71,8 +71,9 @@
   @Override
   public Set<T> getSelectedSet() {
     Set<T> set = new HashSet<T>();
-    if (curSelection != null) {
-      set.add(curSelection);
+    T item = getSelectedObject();
+    if (item != null) {
+      set.add(item);
     }
     return set;
   }
diff --git a/user/test/com/google/gwt/view/client/SingleSelectionModelTest.java b/user/test/com/google/gwt/view/client/SingleSelectionModelTest.java
index 5ab75f1..0ca4123 100644
--- a/user/test/com/google/gwt/view/client/SingleSelectionModelTest.java
+++ b/user/test/com/google/gwt/view/client/SingleSelectionModelTest.java
@@ -105,6 +105,13 @@
     assertFalse(model.isSelected("test1"));
     assertFalse(model.isSelected("test0"));
     assertEquals(0, model.getSelectedSet().size());
+
+    SingleSelectionModel<TestClass> objectSelectionModel =
+        new SingleSelectionModel<TestClass>(null);
+    TestClass testObject = new TestClass(10022, "test0");
+    objectSelectionModel.setSelected(testObject, true);
+    assertEquals(1, objectSelectionModel.getSelectedSet().size());
+ assertEquals(testObject, objectSelectionModel.getSelectedSet().iterator().next());
   }

   public void testSetSelectedNull() {
@@ -148,4 +155,13 @@
protected SingleSelectionModel<String> createSelectionModel(ProvidesKey<String> keyProvider) {
     return new SingleSelectionModel<String>(keyProvider);
   }
+
+  private class TestClass {
+    int i;
+    String str;
+    public TestClass(int i, String str) {
+      this.i = i;
+      this.str = str;
+    }
+  }
 }

--
To view, visit https://gwt-review.googlesource.com/3680
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d0fbb4e8f9650d77d2270f53cde681a9cf2ca0f
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Matthew Dempsky <[email protected]>

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to