Revision: 7529
Author: jlaba...@google.com
Date: Thu Feb  4 04:43:03 2010
Log: Use the getText() from SuggestBox instead of the one present in the TextBoxBase implementation.
http://gwt-code-reviews.appspot.com/132812/show

Patch by: manolo.carrasco
Review by: jlabanca

http://code.google.com/p/google-web-toolkit/source/detail?r=7529

Modified:
 /trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java
 /trunk/user/test/com/google/gwt/user/client/ui/SuggestBoxTest.java

=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java Tue Jan 26 10:25:12 2010 +++ /trunk/user/src/com/google/gwt/user/client/ui/SuggestBox.java Thu Feb 4 04:43:03 2010
@@ -1035,7 +1035,7 @@

   private void refreshSuggestions() {
     // Get the raw text.
-    String text = box.getText();
+    String text = getText();
     if (text.equals(currentText)) {
       return;
     } else {
=======================================
--- /trunk/user/test/com/google/gwt/user/client/ui/SuggestBoxTest.java Thu Jan 14 11:49:54 2010 +++ /trunk/user/test/com/google/gwt/user/client/ui/SuggestBoxTest.java Thu Feb 4 04:43:03 2010
@@ -96,6 +96,36 @@
     box.showSuggestions("test");
     assertTrue(box.isSuggestionListShowing());
   }
+
+  public void testGettextShouldBeCalledWhenOverrided() {
+
+    // Verify that the query matches the overridden getText.
+    SuggestOracle oracle = new SuggestOracle() {
+      @Override
+      public void requestSuggestions(Request request, Callback callback) {
+        if ("override".equals(request.getQuery())) {
+          finishTest();
+        } else {
+          fail("Expected query: override");
+        }
+      }
+    };
+
+    // Create a customized SuggestBox which overrides getText.
+    SuggestBox box = new SuggestBox(oracle) {
+      @Override
+      public String getText() {
+        return "override";
+      }
+    };
+
+    // Attach the box.
+    RootPanel.get().add(box);
+
+    // showSuggestionList should call the overridden method.
+    delayTestFinish(1000);
+    box.showSuggestionList();
+  }

   @SuppressWarnings("deprecation")
   public void testShowAndHide() {

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to