blob: a677eb5968cd732049bdf515e2ad51261d062a4a [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<UnitTester testDir="resources/ResourceManager/Methods/" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" testSWF="ResourceManagerApp.mxml">
<!-- this set of lines form a template that must be in each unit test -->
<mx:Script><![CDATA[
public static function init(o:DisplayObject):void{}
]]></mx:Script>
<mx:Metadata><![CDATA[
[Mixin]
]]></mx:Metadata>
<!-- end of set of lines that must be in each unit test -->
<mx:Script><![CDATA[
import mx.resources.ResourceManager;
import mx.resources.IResourceManager;
import mx.resources.ResourceBundle;
import mx.resources.IResourceBundle;
]]></mx:Script>
<testCases>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_1Locale1Bundle" description="Use removeResourceBundle() to remove the only bundle from a locale. Be sure the bundle is removed, the locale is removed, and the locale chain is untouched." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1')" />
<RunCode code="ResourceManager.getInstance().localeChain=['fr_FR']" />
</setup>
<body>
<RunCode code="ResourceManager.getInstance().removeResourceBundle('fr_FR', 'bundle1')" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').length" value="0" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().length" value="0" />
<AssertMethodValue method="value=ResourceManager.getInstance().localeChain.toString()" value="fr_FR" />
</body>
</TestCase>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_1Locale3Bundles_Remove1st" description="Use removeResourceBundle() to remove the 1st of three bundles for a locale." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1')" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle2')" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle3')" />
</setup>
<body>
<RunCode code="ResourceManager.getInstance().removeResourceBundle('fr_FR', 'bundle1')" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').length" value="2" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle1')" value="-1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle2') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle3') != -1" value="true" />
</body>
</TestCase>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_1Locale3Bundles_Remove2nd" description="Use removeResourceBundle() to remove the 2nd of three bundles for a locale." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1')" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle2')" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle3')" />
</setup>
<body>
<RunCode code="ResourceManager.getInstance().removeResourceBundle('fr_FR', 'bundle2')" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').length" value="2" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle2')" value="-1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle1') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle3') != -1" value="true" />
</body>
</TestCase>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_1Locale3Bundles_Remove3rd" description="Use removeResourceBundle() to remove the 3rd of three bundles for a locale." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1')" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle2')" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle3')" />
</setup>
<body>
<RunCode code="ResourceManager.getInstance().removeResourceBundle('fr_FR', 'bundle3')" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').length" value="2" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle3')" value="-1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle1') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle2') != -1" value="true" />
</body>
</TestCase>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_3LocalesVariousBundles_RemoveOnlyBundleFromOne" description="Be sure removeResourceBundle() removes from the correct locale when there are several." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1_frFR')" />
<RunCode code="application.doAddResourceBundle('ja_JP', 'bundle1_jaJP')" />
<RunCode code="application.doAddResourceBundle('ja_JP', 'bundle2_jaJP')" />
<RunCode code="application.doAddResourceBundle('de_DE', 'bundle1_deDE')" />
<RunCode code="application.doAddResourceBundle('de_DE', 'bundle2_deDE')" />
<RunCode code="application.doAddResourceBundle('de_DE', 'bundle3_deDE')" />
</setup>
<body>
<RunCode code="ResourceManager.getInstance().removeResourceBundle('fr_FR', 'bundle1_frFR')" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().length" value="2" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().indexOf('fr_FR')" value="-1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().indexOf('ja_JP') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().indexOf('de_DE') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('ja_JP').length" value="2" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('ja_JP').indexOf('bundle1_jaJP') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('ja_JP').indexOf('bundle2_jaJP') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').length" value="3" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').indexOf('bundle1_deDE') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').indexOf('bundle2_deDE') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').indexOf('bundle3_deDE') != -1" value="true" />
</body>
</TestCase>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_3LocalesVariousBundles_RemoveOneOfSeveralFromOne" description="Be sure removeResourceBundle() removes from the correct locale when there are several." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1_frFR')" />
<RunCode code="application.doAddResourceBundle('ja_JP', 'bundle1_jaJP')" />
<RunCode code="application.doAddResourceBundle('ja_JP', 'bundle2_jaJP')" />
<RunCode code="application.doAddResourceBundle('de_DE', 'bundle1_deDE')" />
<RunCode code="application.doAddResourceBundle('de_DE', 'bundle2_deDE')" />
<RunCode code="application.doAddResourceBundle('de_DE', 'bundle3_deDE')" />
</setup>
<body>
<RunCode code="ResourceManager.getInstance().removeResourceBundle('de_DE', 'bundle2_deDE')" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().length" value="3" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().indexOf('fr_FR') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().indexOf('ja_JP') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getLocales().indexOf('fr_FR') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').length" value="1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').indexOf('bundle1_frFR') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('ja_JP').length" value="2" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('ja_JP').indexOf('bundle1_jaJP') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('ja_JP').indexOf('bundle2_jaJP') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').length" value="2" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').indexOf('bundle1_deDE') != -1" value="true" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').indexOf('bundle2_deDE')" value="-1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('de_DE').indexOf('bundle3_deDE') != -1" value="true" />
</body>
</TestCase>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_NonexistantBundle" description="Call removeResourceBundle() for a nonexistant bundle." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1')" />
</setup>
<body>
<RunCode code="ResourceManager.getInstance().removeResourceBundle('fr_FR', 'bundle2')" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').length" value="1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR')[0]" value="bundle1" />
</body>
</TestCase>
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_NonexistantLocale" description="Call removeResourceBundle() for a nonexistant locale." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
<RunCode code="application.doAddResourceBundle('fr_FR', 'bundle1')" />
</setup>
<body>
<AssertMethodValue method="try{ ResourceManager.getInstance().removeResourceBundle('aa_BB', 'bundle1'); } catch(e:Error){ value=e.message; }" errorArray="['Error #1010:']" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR').length" value="1" />
<AssertMethodValue method="value=ResourceManager.getInstance().getBundleNamesForLocale('fr_FR')[0]" value="bundle1" />
</body>
</TestCase>
<!--
Call this mainly to be sure something crazy doesn't happen.
-->
<TestCase frequency="all" testID="ResourceManager_removeResourceBundle_NoLocalesPresent" description="Call removeResourceBundle() when there are no locales." keywords="[Runtime Localization,ResourceManager,removeResourceBundle]" >
<setup>
<RunCode code="application.clearLocales()" />
</setup>
<body>
<AssertMethodValue method="try{ ResourceManager.getInstance().removeResourceBundle('fr_FR', 'bundle1'); } catch(e:Error){ value=e.message; }" errorArray="['Error #1010:']" />
</body>
</TestCase>
</testCases>
</UnitTester>