001: /*
002: * Copyright 2006 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016:
017: package com.google.gwt.i18n.client.resolutiontest;
018:
019: import com.google.gwt.core.client.GWT;
020: import com.google.gwt.i18n.client.Constants;
021: import com.google.gwt.i18n.client.Localizable;
022: import com.google.gwt.i18n.client.Messages;
023: import com.google.gwt.i18n.client.TestConstants;
024: import com.google.gwt.i18n.client.resolutiontest.Inners.InnerClass.ProtectedInnerInnerClass.ExtendsAnotherInner;
025: import com.google.gwt.i18n.client.resolutiontest.Inners.InnerClass.ProtectedInnerInnerClass.ExtendsAnotherInner.ExtendProtectedInner;
026: import com.google.gwt.i18n.client.resolutiontest.Inners.OuterLoc.InnerLoc;
027:
028: import java.util.Map;
029:
030: /**
031: * Test class.
032: */
033: public class Inners {
034:
035: public static String testInnerLoc() {
036: // Check being able to create inner
037: InnerLoc loc = (InnerLoc) GWT.create(InnerLoc.class);
038: return loc.string();
039: }
040:
041: /**
042: * Check binding to static inner.
043: */
044: public static class OuterLoc implements Localizable {
045: public String string() {
046: return "default";
047: }
048:
049: /**
050: * Test Inner Localizable.
051: */
052: protected abstract static class InnerLoc implements Localizable {
053: public abstract String string();
054: }
055:
056: /**
057: * Inner Localizable Impl.
058: */
059: protected static class InnerLoc_ extends InnerLoc {
060: public String string() {
061: return "InnerLoc";
062: }
063: }
064: }
065:
066: /**
067: * Test Extension of Inner Inner.
068: */
069: public interface ExtendsInnerInner extends InnerClass.InnerInner {
070: public String extendsInnerInner();
071: }
072:
073: /** Test inner localizable. */
074: public interface LocalizableSimpleInner extends Localizable {
075: public String getLocalizableInner();
076: }
077:
078: /**
079: * Tests Localizable, Must be static.
080: */
081: public static class LocalizableSimpleInner_ implements
082: LocalizableSimpleInner {
083:
084: public String getLocalizableInner() {
085: return "getLocalizableInner";
086: }
087: }
088:
089: /**
090: * Test embedded constant.
091: */
092: public interface HasInner extends SimpleInner {
093:
094: /**
095: * Test inner or constant.
096: */
097: public interface IsInner extends Constants {
098: public int isInner();
099: }
100:
101: public String hasInner();
102: }
103:
104: /**
105: * Inner class.
106: */
107: public static class InnerClass {
108:
109: /** Test inner inner,abstract,and static localizable. */
110: public abstract static class LocalizableInnerInner implements
111: Localizable {
112: public abstract String string();
113: }
114:
115: /** Test inner inner and static localizable. */
116: public static class LocalizableInnerInner_ extends
117: LocalizableInnerInner {
118: public String string() {
119: return "localizableInnerInner";
120: }
121: }
122:
123: /**
124: * Messages use the same resolution mechanisms as constants, but including a
125: * couple of message cases to sanity check.
126: */
127: public static interface InnerInnerMessages extends Messages {
128: public String innerClassMessages(String a);
129: }
130:
131: /** Test inner interface of inner interface. */
132: public interface InnerInner extends Outer {
133: public float innerInner();
134: }
135:
136: /**
137: * OuterLoc piglatin binding.
138: */
139: public static class OuterLoc_piglatin extends OuterLoc {
140: public String string() {
141: return "piglatin";
142: }
143: }
144:
145: /** Tests Protected Inner Class. */
146: public String testExtendsAnotherInner() {
147: ExtendsAnotherInner clazz = (ExtendsAnotherInner) GWT
148: .create(ExtendsAnotherInner.class);
149: Map answer = clazz.extendsAnotherInner();
150: return answer.toString();
151: }
152:
153: /** Test for ExtendProtectedInner. */
154: public String testExtendsProtectedInner() {
155: ExtendProtectedInner inner = (ExtendsAnotherInner.ExtendProtectedInner) GWT
156: .create(ExtendProtectedInner.class);
157: return inner.extendProtectedInner();
158: }
159:
160: /** Another inner class. */
161: protected static class ProtectedInnerInnerClass {
162:
163: /** Test extension. */
164: public interface ExtendsAnotherInner extends InnerInner {
165:
166: /** Test protected extension. */
167: interface ExtendProtectedInner extends ProtectedInner {
168: public String extendProtectedInner();
169: }
170:
171: /** Test maps in extension. */
172: public Map extendsAnotherInner();
173: }
174:
175: /**
176: * Checks inner inner and across packages.
177: */
178: public interface InnerInnerInner extends TestConstants {
179: public String[] innerInnerInner();
180: }
181:
182: /**
183: * Messages use the same resolution mechanisms as constants, but including
184: * a couple of message cases to sanity check.
185: */
186: public static interface InnerInnerInnerMessages extends
187: InnerInnerMessages {
188: public String innerClassMessages(String a);
189: }
190: }
191: }
192:
193: /** Tests Simple Constant inheritance. */
194: public interface SimpleInner extends TestConstants {
195: public String simpleInner();
196: }
197:
198: /**
199: * Boolean return from protected inner.
200: */
201: protected interface ProtectedInner extends TestConstants {
202: public boolean protectedInner();
203: }
204:
205: /**
206: * Testing protected inner.
207: */
208: public boolean testProtectedInner() {
209: ProtectedInner inner = (ProtectedInner) GWT
210: .create(ProtectedInner.class);
211: return inner.protectedInner();
212: }
213: }
214:
215: /** Used to test extension from package protected file. */
216: interface Outer extends Constants {
217: public String outer();
218: }
|