Reviewers: skybrian,

Description:
GWT Messages can support SafeHtml output. Add this support to the
FakeMessagesMaker as well.


Please review this at http://gwt-code-reviews.appspot.com/1890803/

Affected files:
  M user/src/com/google/gwt/junit/FakeMessagesMaker.java
  M user/test/com/google/gwt/junit/FakeMessagesMakerTest.java


Index: user/src/com/google/gwt/junit/FakeMessagesMaker.java
===================================================================
--- user/src/com/google/gwt/junit/FakeMessagesMaker.java        (revision 11517)
+++ user/src/com/google/gwt/junit/FakeMessagesMaker.java        (working copy)
@@ -16,6 +16,8 @@
 package com.google.gwt.junit;

 import com.google.gwt.i18n.client.Messages;
+import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;

 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
@@ -57,7 +59,11 @@
       throws Throwable {
     String name = method.getName();

-    return (args == null || args.length == 0) ? name : name
+    String result = (args == null || args.length == 0) ? name : name
         + Arrays.asList(args);
+    if (SafeHtml.class.isAssignableFrom(method.getReturnType())) {
+      return SafeHtmlUtils.fromString(result);
+    }
+    return result;
   }
 }
Index: user/test/com/google/gwt/junit/FakeMessagesMakerTest.java
===================================================================
--- user/test/com/google/gwt/junit/FakeMessagesMakerTest.java (revision 11517)
+++ user/test/com/google/gwt/junit/FakeMessagesMakerTest.java   (working copy)
@@ -16,6 +16,7 @@
 package com.google.gwt.junit;

 import com.google.gwt.i18n.client.Messages;
+import com.google.gwt.safehtml.shared.SafeHtml;

 import junit.framework.TestCase;

@@ -27,21 +28,30 @@
     @DefaultMessage("Isn''t this the fakiest?")
     @Description("A sample message to be tested.")
     String myMessage();
-
+
     @DefaultMessage("Isn''t this the fakiest? Pick one: {1} or {2}?")
     @Description("A sample message with parameters.")
     String myArgumentedMessage(@Example("yes") String yes,
         @Example("no") String no);
+
+    @DefaultMessage("This should be safe HTML")
+    @Description("A sample SafeHtml message.")
+    SafeHtml mySafeHtmlMessage();
   }
-
+
   public void testSimple() {
     MyMessages messages = FakeMessagesMaker.create(MyMessages.class);
     assertEquals("myMessage", messages.myMessage());
   }
-
+
   public void testArgs() {
     MyMessages messages = FakeMessagesMaker.create(MyMessages.class);
     assertEquals("myArgumentedMessage[oui, non]",
         messages.myArgumentedMessage("oui", "non"));
   }
+
+  public void testSafeHtml() {
+    MyMessages messages = FakeMessagesMaker.create(MyMessages.class);
+ assertEquals("mySafeHtmlMessage", messages.mySafeHtmlMessage().asString());
+  }
 }


--
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "Google Web Toolkit Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to