This just does a couple of tests that need to be fleshed out, but basically just proves that your suggestion of putting a hacked junit.html into a public path of a particular test module works for setting the runtime locale.
-- John A. Tamplin Software Engineer (GWT), Google --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
Index: user/test/com/google/gwt/i18n/public_es_MX/junit.html =================================================================== --- user/test/com/google/gwt/i18n/public_es_MX/junit.html (revision 0) +++ user/test/com/google/gwt/i18n/public_es_MX/junit.html (revision 0) @@ -0,0 +1,62 @@ +<!-- +Copyright 2008 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. +--> +<html> +<head> +<meta name='gwt:onLoadErrorFn' content='junitOnLoadErrorFn'> +<meta name='gwt:onPropertyErrorFn' content='junitOnPropertyErrorFn'> +</head> +<body> +<script language='javascript'> +<!-- +window['__gwt_Locale'] = 'es_MX'; + +function junitOnLoadErrorFn(moduleName) { + junitError('Failed to load module "' + moduleName + + '".\nPlease see the log for details.'); +} + +function junitOnPropertyErrorFn(propName, allowedValues, badValue) { + var msg = 'While attempting to load the module, property "' + propName; + if (badValue != null) { + msg += '" was set to the unexpected value "' + badValue + '"'; + } else { + msg += '" was not specified'; + } + msg += 'Allowed values: ' + allowedValues; + junitError(msg); +} + +function junitError(msg) { + var xmlHttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); + xmlHttpRequest.open('POST', 'junithost/loadError', true); + xmlHttpRequest.setRequestHeader('Content-Type', 'text/x-gwt-rpc; charset=utf-8'); + xmlHttpRequest.send(msg); +} + +function loadSelectionScript() { + var moduleName = document.location.href; + var pos = moduleName.lastIndexOf('/'); + moduleName = moduleName.substr(0, pos); + pos = moduleName.lastIndexOf('/'); + moduleName = moduleName.substr(pos + 1); + document.write("<script language='javascript' src='" + moduleName + ".nocache.js'></script>"); +} +loadSelectionScript(); +--> +</script> +<iframe src="javascript:''" id='__gwt_historyFrame' style='position:absolute;width:0;height:0;border:0'></iframe> +</body> +</html> Property changes on: user/test/com/google/gwt/i18n/public_es_MX/junit.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + native Index: user/test/com/google/gwt/i18n/I18NTest_es_MX_runtime.gwt.xml =================================================================== --- user/test/com/google/gwt/i18n/I18NTest_es_MX_runtime.gwt.xml (revision 0) +++ user/test/com/google/gwt/i18n/I18NTest_es_MX_runtime.gwt.xml (revision 0) @@ -0,0 +1,25 @@ +<!-- --> +<!-- 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 --> +<!-- 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. License for the specific language governing permissions and --> +<!-- limitations under the License. --> + +<module> + <!-- Inherit the JUnit support --> + <inherits name='com.google.gwt.junit.JUnit'/> + <inherits name = 'com.google.gwt.i18n.I18N'/> + <!-- Include client-side source for the test cases --> + <source path="client"/> + <extend-property name="locale" values="es_419"/> + <set-property name = "locale" value = "es_419"/> + <set-configuration-property name="runtime.locales" value="es_AR,es_MX"/> + <public path="public_es_MX"/> +</module> Index: user/test/com/google/gwt/i18n/client/I18N_es_MX_RuntimeTest.java =================================================================== --- user/test/com/google/gwt/i18n/client/I18N_es_MX_RuntimeTest.java (revision 0) +++ user/test/com/google/gwt/i18n/client/I18N_es_MX_RuntimeTest.java (revision 0) @@ -0,0 +1,73 @@ +/* + * Copyright 2007 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.i18n.client; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.I18N_es_MX_Test.MyConstants; +import com.google.gwt.i18n.client.I18N_es_MX_Test.MyMessages; +import com.google.gwt.i18n.client.impl.CurrencyData; +import com.google.gwt.i18n.client.impl.CurrencyList; +import com.google.gwt.junit.client.GWTTestCase; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Tests regional inheritance for es_MX. + */ +public class I18N_es_MX_RuntimeTest extends GWTTestCase { + + @Override + public String getModuleName() { + return "com.google.gwt.i18n.I18NTest_es_MX_runtime"; + } + + public void testAvailableLocales() { + String[] locales = LocaleInfo.getAvailableLocaleNames(); + Set<String> localeSet = new HashSet<String>(); + List<String> localeList = Arrays.asList(locales); + localeSet.addAll(localeList); + List<String> expectedList = Arrays.asList("default", "es_419", "es_AR", + "es_MX"); + assertEquals(expectedList.size(), localeSet.size()); + localeSet.removeAll(expectedList); + assertEquals(0, localeSet.size()); + } + + public void testDefaultCurrency() { + CurrencyData data = CurrencyList.get().getDefault(); + assertEquals("MXN", data.getCurrencyCode()); + assertEquals("$", data.getCurrencySymbol()); + assertEquals(2, data.getDefaultFractionDigits()); + } + + public void testRegionalInheritance() { + MyMessages msg = GWT.create(MyMessages.class); + assertEquals("es_419", msg.getSourceLocale()); + MyConstants cst = GWT.create(MyConstants.class); + // Since our copile-time locale is es_419 (Latin America), we do + // not get es_019 (Central America) in the inheritance chain for + // es_MX as only the compile-time locales are used for translation + // inheritance. + assertEquals("default", cst.getSourceLocale()); + } + + public void testRuntimeLocale() { + assertEquals("es_MX", LocaleInfo.getCurrentLocale().getLocaleName()); + } +} Property changes on: user/test/com/google/gwt/i18n/client/I18N_es_MX_RuntimeTest.java ___________________________________________________________________ Name: svn:mime-type + text/x-java Name: svn:eol-style + native
