UiBinder tests contributed by external user (Konstantin Scheglov).
http://gwt-code-reviews.appspot.com/633801


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8281 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java b/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
index e828dba..9058362 100644
--- a/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
+++ b/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
@@ -17,11 +17,13 @@
 
 import com.google.gwt.uibinder.attributeparsers.CssNameConverterTest;
 import com.google.gwt.uibinder.attributeparsers.FieldReferenceConverterTest;
+import com.google.gwt.uibinder.attributeparsers.HorizontalAlignmentConstantParser_Test;
 import com.google.gwt.uibinder.attributeparsers.IntAttributeParserTest;
 import com.google.gwt.uibinder.attributeparsers.IntPairAttributeParserTest;
 import com.google.gwt.uibinder.attributeparsers.LengthAttributeParserTest;
 import com.google.gwt.uibinder.attributeparsers.StrictAttributeParserTest;
 import com.google.gwt.uibinder.attributeparsers.StringAttributeParserTest;
+import com.google.gwt.uibinder.attributeparsers.VerticalAlignmentConstantParser_Test;
 import com.google.gwt.uibinder.elementparsers.DialogBoxParserTest;
 import com.google.gwt.uibinder.elementparsers.DockLayoutPanelParserTest;
 import com.google.gwt.uibinder.elementparsers.ImageParserTest;
@@ -70,6 +72,8 @@
     suite.addTestSuite(StrictAttributeParserTest.class);
     suite.addTestSuite(StringAttributeParserTest.class);
     suite.addTestSuite(LengthAttributeParserTest.class);
+    suite.addTestSuite(HorizontalAlignmentConstantParser_Test.class);
+    suite.addTestSuite(VerticalAlignmentConstantParser_Test.class);
 
     // elementparsers
     suite.addTestSuite(DialogBoxParserTest.class);
diff --git a/user/test/com/google/gwt/uibinder/attributeparsers/HorizontalAlignmentConstantParser_Test.java b/user/test/com/google/gwt/uibinder/attributeparsers/HorizontalAlignmentConstantParser_Test.java
new file mode 100644
index 0000000..69bcdfb
--- /dev/null
+++ b/user/test/com/google/gwt/uibinder/attributeparsers/HorizontalAlignmentConstantParser_Test.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2009 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.attributeparsers;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.javac.CompilationStateBuilder;
+import com.google.gwt.uibinder.rebind.MortalLogger;
+import com.google.gwt.uibinder.test.UiJavaResources;
+
+import junit.framework.TestCase;
+
+/**
+ * Test for {@link HorizontalAlignmentConstantParser}.
+ */
+public class HorizontalAlignmentConstantParser_Test extends TestCase {
+  private static final String HHA = "com.google.gwt.user.client.ui.HasHorizontalAlignment";
+  private HorizontalAlignmentConstantParser parser;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    CompilationState state = CompilationStateBuilder.buildFrom(TreeLogger.NULL,
+        UiJavaResources.getUiResources());
+    TypeOracle types = state.getTypeOracle();
+    parser = new HorizontalAlignmentConstantParser(new FieldReferenceConverter(
+        null), types.parse(HHA + ".HorizontalAlignmentConstant"),
+        MortalLogger.NULL);
+  }
+
+  public void testGood() throws UnableToCompleteException {
+    assertEquals(HHA + ".ALIGN_LEFT", parser.parse("ALIGN_LEFT"));
+    assertEquals(HHA + ".ALIGN_CENTER", parser.parse("ALIGN_CENTER"));
+    assertEquals(HHA + ".ALIGN_RIGHT", parser.parse("ALIGN_RIGHT"));
+  }
+
+  public void testBad() {
+    try {
+      parser.parse("fnord");
+      fail("Expected UnableToCompleteException");
+    } catch (UnableToCompleteException e) {
+      /* pass */
+    }
+  }
+
+  public void testFieldRef() throws UnableToCompleteException {
+    assertEquals("foo.bar().baz()", parser.parse("{foo.bar.baz}"));
+  }
+}
diff --git a/user/test/com/google/gwt/uibinder/attributeparsers/VerticalAlignmentConstantParser_Test.java b/user/test/com/google/gwt/uibinder/attributeparsers/VerticalAlignmentConstantParser_Test.java
new file mode 100644
index 0000000..8a66727
--- /dev/null
+++ b/user/test/com/google/gwt/uibinder/attributeparsers/VerticalAlignmentConstantParser_Test.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2009 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.attributeparsers;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.javac.CompilationStateBuilder;
+import com.google.gwt.uibinder.rebind.MortalLogger;
+import com.google.gwt.uibinder.test.UiJavaResources;
+
+import junit.framework.TestCase;
+
+/**
+ * Test for {@link VerticalAlignmentConstantParser}.
+ */
+public class VerticalAlignmentConstantParser_Test extends TestCase {
+  private static final String HVA = "com.google.gwt.user.client.ui.HasVerticalAlignment";
+  private VerticalAlignmentConstantParser parser;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    CompilationState state = CompilationStateBuilder.buildFrom(TreeLogger.NULL,
+        UiJavaResources.getUiResources());
+    TypeOracle types = state.getTypeOracle();
+    parser = new VerticalAlignmentConstantParser(new FieldReferenceConverter(
+        null), types.parse(HVA + ".VerticalAlignmentConstant"),
+        MortalLogger.NULL);
+  }
+
+  public void testGood() throws UnableToCompleteException {
+    assertEquals(HVA + ".ALIGN_TOP", parser.parse("ALIGN_TOP"));
+    assertEquals(HVA + ".ALIGN_MIDDLE", parser.parse("ALIGN_MIDDLE"));
+    assertEquals(HVA + ".ALIGN_BOTTOM", parser.parse("ALIGN_BOTTOM"));
+  }
+
+  public void testBad() {
+    try {
+      parser.parse("fnord");
+      fail("Expected UnableToCompleteException");
+    } catch (UnableToCompleteException e) {
+      /* pass */
+    }
+  }
+
+  public void testFieldRef() throws UnableToCompleteException {
+    assertEquals("foo.bar().baz()", parser.parse("{foo.bar.baz}"));
+  }
+}