Revision: 8430
Author: rj...@google.com
Date: Wed Jul 28 11:49:56 2010
Log: Adds UiBinder parser for AbsolutePanel.

Patch by konstantin.scheg...@gmail.com
Review by rj...@google.com

http://gwt-code-reviews.appspot.com/715802/show

Review by: robertvaw...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=8430

Added:
/trunk/user/src/com/google/gwt/uibinder/elementparsers/AbsolutePanelParser.java /trunk/user/test/com/google/gwt/uibinder/elementparsers/AbsolutePanelParserTest.java
Modified:
 /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java
 /trunk/user/src/com/google/gwt/user/client/ui/AbsolutePanel.java
 /trunk/user/src/com/google/gwt/user/client/ui/LayoutPanel.java
 /trunk/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
 /trunk/user/test/com/google/gwt/uibinder/rebind/DesignTimeUtilsTest.java
 /trunk/user/test/com/google/gwt/uibinder/test/UiJavaResources.java
 /trunk/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java
 /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java
 /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml

=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/uibinder/elementparsers/AbsolutePanelParser.java Wed Jul 28 11:49:56 2010
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.uibinder.elementparsers;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.uibinder.rebind.UiBinderWriter;
+import com.google.gwt.uibinder.rebind.XMLElement;
+
+/**
+ * Parses {...@link com.google.gwt.user.client.ui.AbsolutePanel AbsolutePanel}
+ * widgets.
+ */
+public class AbsolutePanelParser implements ElementParser {
+
+  private static final String CHILD = "child";
+
+  public void parse(XMLElement elem, String fieldName, JClassType type,
+      UiBinderWriter writer) throws UnableToCompleteException {
+
+    // Parse children.
+    for (XMLElement positionElem : elem.consumeChildElements()) {
+      // Ensure position element.
+      if (!isPositionElement(elem, positionElem)) {
+        writer.die(positionElem, "Only <%s:%s> children are allowed.",
+            elem.getPrefix(), CHILD);
+      }
+
+      // Parse position.
+      String left = positionElem.consumeRequiredIntAttribute("left");
+      String top = positionElem.consumeRequiredIntAttribute("top");
+
+      // Add child widget.
+      XMLElement widgetElem = positionElem.consumeSingleChildElement();
+      String widgetFieldName = writer.parseElementToField(widgetElem);
+      writer.addStatement("%1$s.add(%2$s, %3$s, %4$s);", fieldName,
+          widgetFieldName, left, top);
+    }
+  }
+
+  private boolean isPositionElement(XMLElement parent, XMLElement child) {
+    if (!parent.getNamespaceUri().equals(child.getNamespaceUri())) {
+      return false;
+    }
+    if (!CHILD.equals(child.getLocalName())) {
+      return false;
+    }
+    return true;
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/uibinder/elementparsers/AbsolutePanelParserTest.java Wed Jul 28 11:49:56 2010
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.uibinder.elementparsers;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+
+import junit.framework.TestCase;
+
+import java.util.Iterator;
+
+/**
+ * Test for {...@link AbsolutePanelParser}.
+ */
+public class AbsolutePanelParserTest extends TestCase {
+
+ private static final String PARSED_TYPE = "com.google.gwt.user.client.ui.AbsolutePanel";
+
+  private ElementParserTester tester;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+ tester = new ElementParserTester(PARSED_TYPE, new AbsolutePanelParser());
+  }
+
+  public void testBadChild_namespace() throws Exception {
+    checkBadLine("<ui:blah/>", "Only <g:child> children");
+  }
+
+  public void testBadChild_name() throws Exception {
+    checkBadLine("<g:blah/>", "Only <g:child> children");
+  }
+
+  public void testBadPosition_leftNo() throws Exception {
+    checkBadPosition("top='0'", "Missing required attribute \"left\"");
+  }
+
+  public void testBadPosition_left() throws Exception {
+ checkBadPosition("left='bad' top='0'", "Cannot parse attribute \"left\"");
+  }
+
+  public void testBadPosition_topNo() throws Exception {
+    checkBadPosition("left='0'", "Missing required attribute \"top\"");
+  }
+
+  public void testBadPosition_top() throws Exception {
+ checkBadPosition("left='0' top='bad'", "Cannot parse attribute \"top\"");
+  }
+
+  public void testBad_noWidget() throws Exception {
+    checkBadLine("<g:child left='1' top='2'/>",
+        "Element must have a single child element");
+  }
+
+  public void testBad_moreThanOneWidget() throws Exception {
+    checkBadLine("<g:child left='1' top='2'>"
+        + "<g:Button id='1'/><g:Button id='2'/></g:child>",
+        "Element may only contain a single child element");
+  }
+
+  private void checkBadLine(String badLine, String expectedDied)
+      throws Exception {
+    StringBuffer b = new StringBuffer();
+    b.append("<g:AbsolutePanel>");
+    b.append("  " + badLine);
+    b.append("</g:AbsolutePanel>");
+
+    try {
+      tester.parse(b.toString());
+      fail();
+    } catch (UnableToCompleteException e) {
+      assertTrue(tester.logger.died.contains(expectedDied));
+    }
+  }
+
+ private void checkBadPosition(String positionAttributes, String expectedDied)
+      throws Exception {
+    String badLine = "<g:child " + positionAttributes
+        + "><g:Button/></g:child>";
+    checkBadLine(badLine, expectedDied);
+  }
+
+  public void testGood() throws Exception {
+    StringBuffer b = new StringBuffer();
+    b.append("<g:AbsolutePanel>");
+    b.append("  <g:child left='1' top='2'>");
+    b.append("    <g:Button/>");
+    b.append("  </g:child>");
+    b.append("  <g:child left='10' top='20'>");
+    b.append("    <g:Label/>");
+    b.append("  </g:child>");
+    b.append("</g:AbsolutePanel>");
+
+    String[] expected = {
+ "fieldName.add(<g:Button>, 1, 2);", "fieldName.add(<g:Label>, 10, 20);"};
+
+    tester.parse(b.toString());
+
+    Iterator<String> i = tester.writer.statements.iterator();
+    for (String e : expected) {
+      assertEquals(e, i.next());
+    }
+    assertFalse(i.hasNext());
+    assertNull(tester.logger.died);
+  }
+}
=======================================
--- /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Fri Jul 23 14:20:15 2010 +++ /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java Wed Jul 28 11:49:56 2010
@@ -974,6 +974,7 @@
     addWidgetParser("HasHTML");
     addWidgetParser("HasWidgets");
     addWidgetParser("HTMLPanel");
+    addWidgetParser("AbsolutePanel");
     addWidgetParser("DockPanel");
     addWidgetParser("StackPanel");
     addWidgetParser("DisclosurePanel");
=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/AbsolutePanel.java Tue Sep 1 19:11:26 2009 +++ /trunk/user/src/com/google/gwt/user/client/ui/AbsolutePanel.java Wed Jul 28 11:49:56 2010
@@ -33,6 +33,24 @@
* "owns" the positioning of the widget. Any existing positioning attributes on
  * the widget may be modified by the panel.
  * </p>
+ *
+ * <h3>Use in UiBinder Templates</h3>
+ * <p>
+ * AbsolutePanel elements in {...@link com.google.gwt.uibinder.client.UiBinder
+ * UiBinder} templates lay out their children with absolute position, using
+ * &lt;g:position> elements. Each position should have <code>left</code> and
+ * <code>top</code> attributes in pixels.
+ *
+ * <p>
+ * For example:
+ *
+ * <pre>
+ * &lt;g:AbsolutePanel>
+ *   &lt;g:position left='10' top='20'>
+ *     &lt;g:Label>Lorem ipsum...&lt;/g:Label>
+ *   &lt;/g:position>
+ * &lt;/g:AbsolutePanel>
+ * </pre>
  */
 public class AbsolutePanel extends ComplexPanel implements InsertPanel {

@@ -179,7 +197,7 @@

   protected void setWidgetPositionImpl(Widget w, int left, int top) {
     Element h = w.getElement();
-    if ((left == -1) && (top == -1)) {
+    if (left == -1 && top == -1) {
       changeToStaticPositioning(h);
     } else {
       DOM.setStyleAttribute(h, "position", "absolute");
=======================================
--- /trunk/user/src/com/google/gwt/user/client/ui/LayoutPanel.java Tue Jul 20 08:04:29 2010 +++ /trunk/user/src/com/google/gwt/user/client/ui/LayoutPanel.java Wed Jul 28 11:49:56 2010
@@ -50,7 +50,7 @@
  *
  * <p>
* Precisely zero or two constraints are required for each axis (horizontal and - * vertial). Specifying no constraints implies that the child should fill that + * vertical). Specifying no constraints implies that the child should fill that
  * axis completely.
  *
  * <p>
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java Wed Jul 21 11:18:39 2010 +++ /trunk/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java Wed Jul 28 11:49:56 2010
@@ -25,6 +25,7 @@
 import com.google.gwt.uibinder.attributeparsers.StringAttributeParserTest;
import com.google.gwt.uibinder.attributeparsers.TextAlignConstantParserTest; import com.google.gwt.uibinder.attributeparsers.VerticalAlignmentConstantParserTest;
+import com.google.gwt.uibinder.elementparsers.AbsolutePanelParserTest;
 import com.google.gwt.uibinder.elementparsers.DialogBoxParserTest;
 import com.google.gwt.uibinder.elementparsers.DockLayoutPanelParserTest;
 import com.google.gwt.uibinder.elementparsers.GridParserTest;
@@ -81,6 +82,7 @@
     suite.addTestSuite(TextAlignConstantParserTest.class);

     // elementparsers
+    suite.addTestSuite(AbsolutePanelParserTest.class);
     suite.addTestSuite(DialogBoxParserTest.class);
     suite.addTestSuite(DockLayoutPanelParserTest.class);
     suite.addTestSuite(GridParserTest.class);
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/rebind/DesignTimeUtilsTest.java Fri Jul 23 14:20:15 2010 +++ /trunk/user/test/com/google/gwt/uibinder/rebind/DesignTimeUtilsTest.java Wed Jul 28 11:49:56 2010
@@ -38,11 +38,6 @@
   private final DesignTimeUtils stub = DesignTimeUtilsStub.EMPTY;
   private final DesignTimeUtilsImpl impl = new DesignTimeUtilsImpl();

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // addDeclarations()
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
    * Test for {...@link DesignTimeUtils#addDeclarations(IndentedWriter)}.
    */
@@ -76,11 +71,6 @@
     assertTrue(subString, content.contains(subString));
   }

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // getImplName()
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
    * Test for {...@link DesignTimeUtils#getImplName(String)}.
    */
@@ -105,11 +95,6 @@
     assertTrue(Math.abs(delta) < 1000 * 3600);
   }

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // Path
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
    * Test for {...@link DesignTimeUtils#getPath(Element)} and related methods.
    */
@@ -137,11 +122,6 @@
     assertEquals("0/1/0", impl.getPath(subSecond));
   }

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // getTemplateContent()
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
    * Test for {...@link DesignTimeUtils#getTemplateContent(String)}.
    */
@@ -165,11 +145,6 @@
     }
   }

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // handleUIObject()
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
    * Test for
* {...@link DesignTimeUtils#handleUIObject(IUiBinderWriterStatements, XMLElement, String)}
@@ -209,11 +184,6 @@
         statements.get(0));
   }

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // putAttribute(String)
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
* Test for {...@link DesignTimeUtils#putAttribute(XMLElement, String, String)}
    * and {...@link DesignTimeUtils#writeAttributes(Statements)}.
@@ -257,11 +227,6 @@
     return statements;
   }

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // putAttribute(String[])
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
* Test for {...@link DesignTimeUtils#putAttribute(XMLElement, String, String[])}
    * .
@@ -316,12 +281,6 @@
     }
     return statements;
   }
-
- ////////////////////////////////////////////////////////////////////////////
-  //
-  // Utilities
-  //
- ///////////////////////////////////////////////////////////////////////////

   /**
    * @return the only child {...@link Element} with given tag name.
@@ -340,11 +299,6 @@
     return new XMLElement(elem, null, null, null, null, designTime, null);
   }

- ////////////////////////////////////////////////////////////////////////////
-  //
-  // WriterStatements
-  //
- ///////////////////////////////////////////////////////////////////////////
   /**
* Implementation of {...@link IUiBinderWriterStatements} for simple statements.
    */
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/test/UiJavaResources.java Wed Jul 21 11:18:39 2010 +++ /trunk/user/test/com/google/gwt/uibinder/test/UiJavaResources.java Wed Jul 28 11:49:56 2010
@@ -29,6 +29,17 @@
  */
 public class UiJavaResources {

+ public static final MockJavaResource ABSOLUTE_PANEL = new MockJavaResource(
+      "com.google.gwt.user.client.ui.AbsolutePanel") {
+    @Override
+    protected CharSequence getContent() {
+      StringBuffer code = new StringBuffer();
+      code.append("package com.google.gwt.user.client.ui;\n");
+      code.append("public class AbsolutePanel extends Widget {\n");
+      code.append("}\n");
+      return code;
+    }
+  };
   public static final MockJavaResource BUTTON = new MockJavaResource(
       "com.google.gwt.user.client.ui.Button") {
     @Override
@@ -107,9 +118,9 @@
     }
   };
   public static final MockJavaResource GRID = new MockJavaResource(
-    "com.google.gwt.user.client.ui.Grid") {
-  @Override
-  protected CharSequence getContent() {
+      "com.google.gwt.user.client.ui.Grid") {
+    @Override
+    protected CharSequence getContent() {
       StringBuffer code = new StringBuffer();
       code.append("package com.google.gwt.user.client.ui;\n");
       code.append("public class Grid extends Widget {\n");
@@ -382,6 +393,7 @@
   public static Set<Resource> getUiResources() {
     Set<Resource> rtn = new HashSet<Resource>(
         Arrays.asList(JavaResourceBase.getStandardResources()));
+    rtn.add(ABSOLUTE_PANEL);
     rtn.add(BUTTON);
     rtn.add(CLICK_EVENT);
     rtn.add(CLICK_HANDLER);
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java Wed Jul 21 11:18:39 2010 +++ /trunk/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java Wed Jul 28 11:49:56 2010
@@ -22,10 +22,11 @@
 import com.google.gwt.dom.client.SpanElement;
 import com.google.gwt.junit.client.GWTTestCase;
 import com.google.gwt.resources.client.ClientBundle;
-import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.resources.client.CssResource.NotStrict;
+import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.uibinder.test.client.EnumeratedLabel.Suffix;
 import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.AbsolutePanel;
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.DisclosurePanel;
 import com.google.gwt.user.client.ui.HTML;
@@ -65,12 +66,12 @@
     assertEquals("th", domUi.th1.getTagName().toLowerCase());
     assertEquals("th", domUi.th2.getTagName().toLowerCase());
   }
-
+
   public void testTableWithExplicitTbody() {
     assertEquals("tbody", domUi.tbody.getTagName().toLowerCase());
     assertEquals("th", domUi.th4.getTagName().toLowerCase());
   }
-
+
   public void testAutoboxingFieldRef() {
     FakeBundle fakeBundle = new FakeBundle();

@@ -84,7 +85,8 @@

     assertEquals(new Integer((int) fakeBundle.aDouble()),
         widgetUi.mismatchPrimitiveIntoObject.getObjectInteger());
- assertEquals((int) fakeBundle.aDouble(), widgetUi.allMismatchPrimitive.getRawInt());
+    assertEquals((int) fakeBundle.aDouble(),
+        widgetUi.allMismatchPrimitive.getRawInt());

     assertEquals(new Boolean(fakeBundle.aBoolean()),
         widgetUi.primitiveBooleanIntoObject.getObjectBoolean());
@@ -92,26 +94,28 @@
         widgetUi.objectBooleanIntoPrimitive.getRawBoolean());
     assertEquals(fakeBundle.aBooleanObject(),
         widgetUi.allObjectBoolean.getObjectBoolean());
- assertEquals(fakeBundle.aBoolean(), widgetUi.allPrimitiveBoolean.getRawBoolean());
+    assertEquals(fakeBundle.aBoolean(),
+        widgetUi.allPrimitiveBoolean.getRawBoolean());
   }

   public void testAccessToNonStandardElement() {
     Element elm = widgetUi.nonStandardElement;
     assertEquals("I", elm.getTagName());
   }
-
+
   public void testAddStyleNamesAndDebugId() {
     Label l = widgetUi.lblDebugId;
     assertEquals("gwt-debug-joe", l.getElement().getId());

     assertEquals("styleName", l.getStylePrimaryName());
-
+
WidgetBasedUiExternalResources resources = GWT.create(WidgetBasedUiExternalResources.class);
     assertTrue(l.getStyleName().contains("newStyle"));
     assertTrue(l.getStyleName().contains("anotherStyle"));
     assertTrue(l.getStyleName().contains("styleName-dependentStyle"));
assertTrue(l.getStyleName().contains("styleName-anotherDependentStyle")); - assertTrue(l.getStyleName().contains("styleName-" + resources.style().prettyText()));
+    assertTrue(l.getStyleName().contains(
+        "styleName-" + resources.style().prettyText()));
   }

   // TODO(rjrjr) The direction stuff in these tests really belongs in
@@ -131,7 +135,8 @@
     assertEquals(getCenter(), widgetUi.bundledLabel.getParent());
assertEquals(new FakeBundle().helloText(), widgetUi.bundledLabel.getText()); WidgetBasedUiExternalResources resources = GWT.create(WidgetBasedUiExternalResources.class); - assertEquals(resources.style().prettyText(), widgetUi.bundledLabel.getStyleName());
+    assertEquals(resources.style().prettyText(),
+        widgetUi.bundledLabel.getStyleName());

     Element pretty = DOM.getElementById("prettyPara");
     assertEquals(resources.style().prettyText(), pretty.getClassName());
@@ -141,7 +146,7 @@
     foo.setPojo(pojo);
     assertEquals(foo.getText(), widgetUi.theFoo.getText());
   }
-
+
   public void testBundleLegacyBeansText() {
     assertEquals(widgetUi.legacyValuesForBeans.helloText(),
         widgetUi.bundledLabelLegacy.getText());
@@ -162,7 +167,8 @@
     // TODO(rjrjr) More of a test of HTMLPanelParser

     Widget center = getCenter();
- assertEquals(com.google.gwt.user.client.ui.DockPanel.CENTER, root.getWidgetDirection(center));
+    assertEquals(com.google.gwt.user.client.ui.DockPanel.CENTER,
+        root.getWidgetDirection(center));
     assertEquals(HTMLPanel.class, center.getClass());
     String html = center.getElement().getInnerHTML();
     assertTrue(html.contains("main area"));
@@ -182,11 +188,11 @@
WidgetBasedUiExternalResources resources = GWT.create(WidgetBasedUiExternalResources.class); assertEquals(resources.style().tmText(), widgetUi.tmElement.getClassName());
   }
-
+
   public void testCustomButtonBody() {
     assertEquals("Hi mom", widgetUi.toggle.getText());
   }
-
+
   public void testCustomDialogBox() {
     assertEquals("Custom dialog am I", widgetUi.fooDialog.getText());
     Widget body = widgetUi.fooDialog.iterator().next();
@@ -235,16 +241,18 @@
assertEquals("They might show up in body text that has been marked for "
         + "translation: funny characters \\ \" \" ' ' & < > > { }", t);
   }
-
+
   public void testEmptyAttributesOkay() {
     assertEquals("", widgetUi.styleLess.getStyleName());
   }

   public void testMixOfWidgetsAndElementsInUiMsg() {
- assertEquals("single translatable message", widgetUi.mixedMessageWidget.getText()); - assertEquals("exciting and subtle", widgetUi.mixedMessageSpan.getInnerText());
-  }
-
+    assertEquals("single translatable message",
+        widgetUi.mixedMessageWidget.getText());
+    assertEquals("exciting and subtle",
+        widgetUi.mixedMessageSpan.getInnerText());
+  }
+
   public void testEnums() {
     Suffix expected = EnumeratedLabel.Suffix.tail;
     assertTrue("Should end with suffix \"" + expected + "\"",
@@ -261,7 +269,7 @@
         widgetUi.pushButton.getUpHoveringFace().getHTML().toLowerCase());
     // Can't test the images at all :-P
   }
-
+
   public void testProtectedDomTextMessageWithFunnyChars() {
     String t = widgetUi.funnyCharsProtectedMessageParagraph.getInnerText();
     assertEquals("Don't forget about protected untranslatable blocks: "
@@ -293,14 +301,14 @@
   public void testFieldInPlaceholderedElement() {
     assertEquals("named portions", widgetUi.spanInMsg.getInnerText());
   }
-
+
   public void testGrid() {
     assertTrue(widgetUi.fooGrid.getWidget(0, 0) instanceof Label);
     assertTrue(widgetUi.fooGrid.getWidget(0, 1) instanceof Button);
     assertEquals(2, widgetUi.fooGrid.getColumnCount());
     assertEquals(1, widgetUi.fooGrid.getRowCount());
   }
-
+
   public void testListBox() {
     assertEquals(2, widgetUi.fooListBox.getItemCount());
     assertEquals("bar", widgetUi.fooListBox.getItemText(0));
@@ -369,7 +377,8 @@
   @SuppressWarnings("deprecation")
   public void testNorth() {
     Widget north = root.getWidget(0);
- assertEquals(com.google.gwt.user.client.ui.DockPanel.NORTH, root.getWidgetDirection(north));
+    assertEquals(com.google.gwt.user.client.ui.DockPanel.NORTH,
+        root.getWidgetDirection(north));
     assertEquals(HTML.class, north.getClass());
     assertTrue(((HTML) north).getHTML().contains("Title area"));
   }
@@ -421,6 +430,20 @@
     assertNotNull("Widget exists", w);
     assertEquals("Panel contains widget", w, p.getContent());
   }
+
+  public void testAbsolutePanel() {
+    AbsolutePanel p = widgetUi.myAbsolutePanel;
+    assertNotNull("Panel exists", p);
+
+    Widget w = widgetUi.myAbsolutePanelItem;
+    assertNotNull("Widget exists", w);
+
+ assertEquals("Panel contains exactly one widgets", 1, p.getWidgetCount());
+    assertEquals("Panel contains expected widget", w, p.getWidget(0));
+
+    assertEquals("Widget has left", 1, p.getWidgetLeft(w));
+    assertEquals("Widget has top", 2, p.getWidgetTop(w));
+  }

   public void testStringAttributeIgnoresStaticSetter() {
     // Assumes setPopupText() is overloaded such that there is a static
@@ -437,7 +460,8 @@
   @SuppressWarnings("deprecation")
   public void testWest() {
     Widget west = root.getWidget(1);
- assertEquals(com.google.gwt.user.client.ui.DockPanel.WEST, root.getWidgetDirection(west));
+    assertEquals(com.google.gwt.user.client.ui.DockPanel.WEST,
+        root.getWidgetDirection(west));
     assertEquals(HTML.class, west.getClass());
     String html = ((HTML) west).getHTML();
     assertTrue(html.contains("side bar"));
@@ -463,7 +487,7 @@
     assertEquals(resource.getTop(), widget.getOriginTop());
     assertEquals(resource.getLeft(), widget.getOriginLeft());
   }
-
+
   public void testImageResourceInImageWidget() {
     ImageResource resource = widgetUi.prettyImage;
     Image widget = widgetUi.babyWidget;
@@ -471,7 +495,7 @@
     assertEquals(resource.getHeight(), widget.getOffsetHeight());
     assertEquals(resource.getTop(), widget.getOriginTop());
     assertEquals(resource.getLeft(), widget.getOriginLeft());
-
+
     assertEquals("expected alt text", widget.getAltText());
     assertEquals("expected style name", widget.getStyleName());
   }
@@ -480,7 +504,7 @@
     assertEquals(100, widgetUi.sideBarWidget.getOffsetWidth());
     assertEquals(150, widgetUi.sideBarWidget.getOffsetHeight());
   }
-
+
   public void testDataResource() {
     assertNotNull(widgetUi.heartCursorResource.getUrl());
   }
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java Wed Jul 21 11:18:39 2010 +++ /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java Wed Jul 28 11:49:56 2010
@@ -30,6 +30,7 @@
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiFactory;
 import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.AbsolutePanel;
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.DisclosurePanel;
@@ -162,6 +163,8 @@
   @UiField FooDialog fooDialog;
   @UiField ListBox fooListBox;
   @UiField Grid fooGrid;
+  @UiField AbsolutePanel myAbsolutePanel;
+  @UiField Widget myAbsolutePanelItem;

   public WidgetBasedUi() {
     external.style().ensureInjected();
=======================================
--- /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml Wed Jul 21 11:18:39 2010 +++ /trunk/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml Wed Jul 28 11:49:56 2010
@@ -614,6 +614,12 @@
     </gwt:row>
   </gwt:Grid>

+  <gwt:AbsolutePanel ui:field='myAbsolutePanel'>
+    <gwt:child left='1' top='2'>
+ <gwt:Button ui:field='myAbsolutePanelItem'>AbsolutePanel item</gwt:Button>
+    </gwt:child>
+  </gwt:AbsolutePanel>
+
    </gwt:HTMLPanel>
   </gwt:Dock>
 </gwt:DockPanel>

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

Reply via email to