summaryrefslogtreecommitdiff
path: root/scripts/run_android_tests.py
diff options
context:
space:
mode:
authorRoozbeh Pournader <roozbeh@google.com>2015-01-07 22:13:51 -0800
committerJames Godfrey-Kittle <jamesgk@google.com>2015-04-16 12:16:25 -0700
commit1f5e1d448f49e5cfd2abecdb0fb57e75ad174741 (patch)
tree9870da8f87a8affeb909704dc60424a83811e274 /scripts/run_android_tests.py
parentfe99ea44799ee2243c8bafd56d9a835884b3ed5b (diff)
Refactor tests to a reusable structure.
Tests that are common to some targets are not moved to common_tests.py, with target-specific tests basically inheriting its classes and modifying them. The web tests are not refactored yet.
Diffstat (limited to 'scripts/run_android_tests.py')
-rwxr-xr-xscripts/run_android_tests.py76
1 files changed, 21 insertions, 55 deletions
diff --git a/scripts/run_android_tests.py b/scripts/run_android_tests.py
index 077ebcb..060965b 100755
--- a/scripts/run_android_tests.py
+++ b/scripts/run_android_tests.py
@@ -1,75 +1,33 @@
#!/usr/bin/python
"""Test assumptions that Android relies on."""
-import glob
import unittest
-from fontTools import ttLib
from nototools import coverage
-from nototools import font_data
-import roboto_data
+import common_tests
+FONTS = common_tests.load_fonts(
+ ['out/android/*.ttf'],
+ expected_count=18)
-def load_fonts():
- """Load all fonts built for Android."""
- all_font_files = glob.glob('out/android/*.ttf')
- all_fonts = [ttLib.TTFont(font) for font in all_font_files]
- assert len(all_font_files) == 18
- return all_font_files, all_fonts
+class TestItalicAngle(common_tests.TestItalicAngle):
+ loaded_fonts = FONTS
-class TestMetaInfo(unittest.TestCase):
- """Test various meta information."""
+class TestMetaInfo(common_tests.TestMetaInfo):
+ loaded_fonts = FONTS
- def setUp(self):
- _, self.fonts = load_fonts()
-
- def test_us_weight(self):
- "Tests the usWeight of the fonts to be correct."""
- for font in self.fonts:
- weight = roboto_data.extract_weight_name(font_data.font_name(font))
- expected_numeric_weight = roboto_data.WEIGHTS[weight]
- self.assertEqual(
- font['OS/2'].usWeightClass,
- expected_numeric_weight)
-
- def test_version_numbers(self):
- "Tests the two version numbers of the font to be correct."""
- for font in self.fonts:
- build_number = roboto_data.get_build_number()
- expected_version = '2.' + build_number
- version = font_data.font_version(font)
- usable_part_of_version = version.split(';')[0]
- self.assertEqual(usable_part_of_version,
- 'Version ' + expected_version)
-
- revision = font_data.printable_font_revision(font, accuracy=5)
- self.assertEqual(revision, expected_version)
+class TestDigitWidths(common_tests.TestDigitWidths):
+ loaded_fonts = FONTS
-class TestVerticalMetrics(unittest.TestCase):
- """Test the vertical metrics of fonts."""
-
- def setUp(self):
- _, self.fonts = load_fonts()
-
- def test_ymin_ymax(self):
- """Tests yMin and yMax to be equal to what Android expects."""
- for font in self.fonts:
- head_table = font['head']
- self.assertEqual(head_table.yMin, -555)
- self.assertEqual(head_table.yMax, 2163)
-
-class TestCharacterCoverage(unittest.TestCase):
- """Tests character coverage."""
-
- def setUp(self):
- _, self.fonts = load_fonts()
+class TestCharacterCoverage(common_tests.TestCharacterCoverage):
+ loaded_fonts = FONTS
def test_lack_of_arrows_and_combining_keycap(self):
- """Tests that arrows and combining keycap are not in the fonts."""
+ """Tests that arrows and combining keycap are not in Android fonts."""
for font in self.fonts:
charset = coverage.character_set(font)
self.assertNotIn(0x20E3, charset) # COMBINING ENCLOSING KEYCAP
@@ -77,6 +35,14 @@ class TestCharacterCoverage(unittest.TestCase):
self.assertNotIn(0x2193, charset) # DOWNWARDS ARROW
+class TestLigatures(common_tests.TestLigatures):
+ loaded_fonts = FONTS
+
+
+class TestVerticalMetrics(common_tests.TestVerticalMetrics):
+ loaded_fonts = FONTS
+
+
if __name__ == '__main__':
unittest.main()