Skip to content

Commit

Permalink
Fixed issue on Android compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ollandos committed Apr 16, 2018
1 parent 000d216 commit cca4efe
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openformats/formats/android.py
Expand Up @@ -464,6 +464,8 @@ def _compile_string_array(self, child):
break

if has_match:
# Make sure you include the <string-array> tag
self.transcriber.copy_until(item_itterator[0].start)
# Compile found item nodes. Remove the rest.
for item_tag in item_itterator:
self._compile_string(item_tag)
Expand Down
39 changes: 39 additions & 0 deletions openformats/tests/formats/android/test_android.py
Expand Up @@ -479,6 +479,45 @@ def test_missing_name(self):
self._test_parse_error('<resources><string>hello</string></resources>',
u"Missing the `name` attribute on line 1")

def test_missing_first_item_in_array_list(self):
source = """
<resources>
<string-array name="settings_report_a_problem_problem_types">
<item>@string/space</item>
<item>Installation</item>
<item>Bluetooth Connection</item>
<item>Technical Troubleshooting</item>
<item>How to use Navdy</item>
<item>Ordering \u002F Shipping \u002F Payments</item>
<item>Other</item>
<item>Feedback \u0026 Suggestions</item>
<item>Partnership Opportunities</item>
<item>Send Logs</item>
</string-array>
</resources>
"""
expected = """
<resources>
<string-array name="settings_report_a_problem_problem_types">
<item>Installation</item>
<item>Bluetooth Connection</item>
<item>Technical Troubleshooting</item>
<item>How to use Navdy</item>
<item>Ordering \u002F Shipping \u002F Payments</item>
<item>Other</item>
<item>Feedback \u0026 Suggestions</item>
<item>Partnership Opportunities</item>
<item>Send Logs</item>
</string-array>
</resources>
"""
template, stringset = self.handler.parse(source)
stringset.pop(0)
compiled = self.handler.compile(template, stringset)
self.assertEqual(
compiled, expected
)

def test_compile_removes_missing_strings(self):
source = strip_leading_spaces('''
<resources>
Expand Down

0 comments on commit cca4efe

Please sign in to comment.