-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for GenerateLocaleConfigTask
- Loading branch information
Showing
5 changed files
with
281 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/test/groovy/com/mermake/locale_resource_generator/data/Intermediates.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
223 changes: 223 additions & 0 deletions
223
src/test/groovy/com/mermake/locale_resource_generator/data/Xml.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
package com.mermake.locale_resource_generator.data | ||
|
||
class Xml { | ||
static String[] smallBatch = [ | ||
'<?xml version="1.0" encoding="utf-8"?>', | ||
'<locale-config xmlns:android="http://schemas.android.com/apk/res/android">', | ||
'<!-- English (United States) -->', | ||
'<locale android:name="en-US"/>', | ||
'<!-- English (Pseudo-Accents) -->', | ||
'<locale android:name="en-XA"/>', | ||
'<!-- 中文 (台灣) -->', | ||
'<locale android:name="zh-TW"/>', | ||
'</locale-config>', | ||
] | ||
|
||
static Set<String> pseudolocales = [ | ||
'<?xml version="1.0" encoding="utf-8"?>', | ||
'<locale-config xmlns:android="http://schemas.android.com/apk/res/android">', | ||
'<!-- العربية (لكنات تجريبية ثنائية الاتجاه) -->', | ||
'<locale android:name="ar-XB"/>', | ||
'<!-- English (Pseudo-Accents) -->', | ||
'<locale android:name="en-XA"/>', | ||
'</locale-config>', | ||
] | ||
|
||
static String[] androidSupported = [ | ||
'<?xml version="1.0" encoding="utf-8"?>', | ||
'<locale-config xmlns:android="http://schemas.android.com/apk/res/android">', | ||
'<!-- Afrikaans -->', | ||
'<locale android:name="af"/>', | ||
'<!-- Afrikaans (Suid-Afrika) -->', | ||
'<locale android:name="af-ZA"/>', | ||
'<!-- አማርኛ -->', | ||
'<locale android:name="am"/>', | ||
'<!-- አማርኛ (ኢትዮጵያ) -->', | ||
'<locale android:name="am-ET"/>', | ||
'<!-- العربية -->', | ||
'<locale android:name="ar"/>', | ||
'<!-- العربية (مصر) -->', | ||
'<locale android:name="ar-EG"/>', | ||
'<!-- العربية (إسرائيل) -->', | ||
'<locale android:name="ar-IL"/>', | ||
'<!-- অসমীয়া -->', | ||
'<locale android:name="as"/>', | ||
'<!-- azərbaycan -->', | ||
'<locale android:name="az"/>', | ||
'<!-- беларуская -->', | ||
'<locale android:name="be"/>', | ||
'<!-- български -->', | ||
'<locale android:name="bg"/>', | ||
'<!-- български (България) -->', | ||
'<locale android:name="bg-BG"/>', | ||
'<!-- বাংলা -->', | ||
'<locale android:name="bn"/>', | ||
'<!-- bosanski -->', | ||
'<locale android:name="bs"/>', | ||
'<!-- català -->', | ||
'<locale android:name="ca"/>', | ||
'<!-- català (Espanya) -->', | ||
'<locale android:name="ca-ES"/>', | ||
'<!-- čeština -->', | ||
'<locale android:name="cs"/>', | ||
'<!-- čeština (Česko) -->', | ||
'<locale android:name="cs-CZ"/>', | ||
'<!-- dansk -->', | ||
'<locale android:name="da"/>', | ||
'<!-- dansk (Danmark) -->', | ||
'<locale android:name="da-DK"/>', | ||
'<!-- Deutsch -->', | ||
'<locale android:name="de"/>', | ||
'<!-- Deutsch (Österreich) -->', | ||
'<locale android:name="de-AT"/>', | ||
'<!-- Deutsch (Schweiz) -->', | ||
'<locale android:name="de-CH"/>', | ||
'<!-- Deutsch (Deutschland) -->', | ||
'<locale android:name="de-DE"/>', | ||
'<!-- Deutsch (Liechtenstein) -->', | ||
'<locale android:name="de-LI"/>', | ||
'<!-- Ελληνικά -->', | ||
'<locale android:name="el"/>', | ||
'<!-- Ελληνικά (Ελλάδα) -->', | ||
'<locale android:name="el-GR"/>', | ||
'<!-- English (Australia) -->', | ||
'<locale android:name="en-AU"/>', | ||
'<!-- English (Canada) -->', | ||
'<locale android:name="en-CA"/>', | ||
'<!-- English (United Kingdom) -->', | ||
'<locale android:name="en-GB"/>', | ||
'<!-- English (Ireland) -->', | ||
'<locale android:name="en-IE"/>', | ||
'<!-- English (India) -->', | ||
'<locale android:name="en-IN"/>', | ||
'<!-- English (New Zealand) -->', | ||
'<locale android:name="en-NZ"/>', | ||
'<!-- English (Singapore) -->', | ||
'<locale android:name="en-SG"/>', | ||
'<!-- English (United States) -->', | ||
'<locale android:name="en-US"/>', | ||
'<!-- English (South Africa) -->', | ||
'<locale android:name="en-ZA"/>', | ||
'<!-- español -->', | ||
'<locale android:name="es"/>', | ||
'<!-- español (Colombia) -->', | ||
'<locale android:name="es-CO"/>', | ||
'<!-- español (Costa Rica) -->', | ||
'<locale android:name="es-CR"/>', | ||
'<!-- español (Ecuador) -->', | ||
'<locale android:name="es-EC"/>', | ||
'<!-- español (España) -->', | ||
'<locale android:name="es-ES"/>', | ||
'<!-- español (Guatemala) -->', | ||
'<locale android:name="es-GT"/>', | ||
'<!-- español (Honduras) -->', | ||
'<locale android:name="es-HN"/>', | ||
'<!-- español (México) -->', | ||
'<locale android:name="es-MX"/>', | ||
'<!-- español (Nicaragua) -->', | ||
'<locale android:name="es-NI"/>', | ||
'<!-- español (Panamá) -->', | ||
'<locale android:name="es-PA"/>', | ||
'<!-- español (Perú) -->', | ||
'<locale android:name="es-PE"/>', | ||
'<!-- español (El Salvador) -->', | ||
'<locale android:name="es-SV"/>', | ||
'<!-- español (Estados Unidos) -->', | ||
'<locale android:name="es-US"/>', | ||
'<!-- eesti -->', | ||
'<locale android:name="et"/>', | ||
'<!-- euskara -->', | ||
'<locale android:name="eu"/>', | ||
'<!-- فارسی -->', | ||
'<locale android:name="fa"/>', | ||
'<!-- فارسی (ایران) -->', | ||
'<locale android:name="fa-IR"/>', | ||
'<!-- suomi -->', | ||
'<locale android:name="fi"/>', | ||
'<!-- suomi (Suomi) -->', | ||
'<locale android:name="fi-FI"/>', | ||
'<!-- français -->', | ||
'<locale android:name="fr"/>', | ||
'<!-- français (Belgique) -->', | ||
'<locale android:name="fr-BE"/>', | ||
'<!-- français (Canada) -->', | ||
'<locale android:name="fr-CA"/>', | ||
'<!-- français (Suisse) -->', | ||
'<locale android:name="fr-CH"/>', | ||
'<!-- français (France) -->', | ||
'<locale android:name="fr-FR"/>', | ||
'<!-- galego -->', | ||
'<locale android:name="gl"/>', | ||
'<!-- ગુજરાતી -->', | ||
'<locale android:name="gu"/>', | ||
'<!-- עברית -->', | ||
'<locale android:name="he"/>', | ||
'<!-- हिन्दी -->', | ||
'<locale android:name="hi"/>', | ||
'<!-- हिन्दी (भारत) -->', | ||
'<locale android:name="hi-IN"/>', | ||
'<!-- hrvatski -->', | ||
'<locale android:name="hr"/>', | ||
'<!-- hrvatski (Hrvatska) -->', | ||
'<locale android:name="hr-HR"/>', | ||
'<!-- magyar -->', | ||
'<locale android:name="hu"/>', | ||
'<!-- magyar (Magyarország) -->', | ||
'<locale android:name="hu-HU"/>', | ||
'<!-- հայերեն -->', | ||
'<locale android:name="hy"/>', | ||
'<!-- Indonesia -->', | ||
'<locale android:name="in"/>', | ||
'<!-- Indonesia (Indonesia) -->', | ||
'<locale android:name="in-ID"/>', | ||
'<!-- íslenska -->', | ||
'<locale android:name="is"/>', | ||
'<!-- italiano -->', | ||
'<locale android:name="it"/>', | ||
'<!-- italiano (Svizzera) -->', | ||
'<locale android:name="it-CH"/>', | ||
'<!-- italiano (Italia) -->', | ||
'<locale android:name="it-IT"/>', | ||
'<!-- עברית -->', | ||
'<locale android:name="iw"/>', | ||
'<!-- עברית (ישראל) -->', | ||
'<locale android:name="iw-IL"/>', | ||
'<!-- 日本語 -->', | ||
'<locale android:name="ja"/>', | ||
'<!-- 日本語 (日本) -->', | ||
'<locale android:name="ja-JP"/>', | ||
'<!-- ქართული -->', | ||
'<locale android:name="ka"/>', | ||
'<!-- қазақ тілі -->', | ||
'<locale android:name="kk"/>', | ||
'<!-- ខ្មែរ -->', | ||
'<locale android:name="km"/>', | ||
'<!-- ಕನ್ನಡ -->', | ||
'<locale android:name="kn"/>', | ||
'<!-- 한국어 -->', | ||
'<locale android:name="ko"/>', | ||
'<!-- 한국어 (대한민국) -->', | ||
'<locale android:name="ko-KR"/>', | ||
'<!-- кыргызча -->', | ||
'<locale android:name="ky"/>', | ||
'<!-- ລາວ -->', | ||
'<locale android:name="lo"/>', | ||
'<!-- lietuvių -->', | ||
'<locale android:name="lt"/>', | ||
'<!-- lietuvių (Lietuva) -->', | ||
'<locale android:name="lt-LT"/>', | ||
'<!-- latviešu -->', | ||
'<locale android:name="lv"/>', | ||
'<!-- latviešu (Latvija) -->', | ||
'<locale android:name="lv-LV"/>', | ||
'<!-- srpski (latinica) -->', | ||
'<locale android:name="sr-Latn"/>', | ||
'<!-- 中文 -->', | ||
'<locale android:name="zh"/>', | ||
'<!-- 中文 (中国) -->', | ||
'<locale android:name="zh-CN"/>', | ||
'<!-- 中文 (台灣) -->', | ||
'<locale android:name="zh-TW"/>', | ||
'</locale-config>', | ||
] | ||
} |
43 changes: 43 additions & 0 deletions
43
...st/groovy/com/mermake/locale_resource_generator/tasks/GenerateLocaleConfigTaskTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.mermake.locale_resource_generator.tasks | ||
|
||
import com.mermake.locale_resource_generator.data.Intermediates | ||
import com.mermake.locale_resource_generator.data.Xml | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import spock.lang.Specification | ||
import spock.lang.TempDir | ||
|
||
class GenerateLocaleConfigTaskTest extends Specification { | ||
|
||
@TempDir | ||
File outputDir | ||
|
||
GenerateLocaleConfigTask task | ||
File outputFile | ||
|
||
def setup() { | ||
def project = ProjectBuilder.builder().build() | ||
task = project.tasks.register("generateLocaleConfig", GenerateLocaleConfigTask).get() | ||
|
||
outputFile = new File(outputDir, "locale_config.xml") | ||
task.localeConfigOutput.set(outputFile) | ||
} | ||
|
||
def "process locales, output correct locale config"(String[] input, String[] output) { | ||
given: "temp intermediate local tags file" | ||
task.languageListInput.set(Intermediates.createFile(input)) | ||
|
||
when: "task is executed, xml is generated" | ||
task.taskAction() | ||
|
||
then: "output file contains correctly formatted language tag data" | ||
outputFile.readLines().eachWithIndex { String s, int i -> | ||
assert s.trim() == output[i] | ||
} | ||
|
||
where: | ||
input || output | ||
Intermediates.smallBatch || Xml.smallBatch | ||
Intermediates.androidSupported || Xml.androidSupported | ||
Intermediates.pseudolocales || Xml.pseudolocales | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters