Don't fail unit test if resources not found on device.
authortomhudson <tomhudson@chromium.org>
Thu, 7 Aug 2014 17:20:51 +0000 (10:20 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 7 Aug 2014 17:20:51 +0000 (10:20 -0700)
Not 100% sure about the right thing to do here; looks like some other
tests warn but don't officially fail.

R=djsollen@google.com, tomhudson@google.com

Author: tomhudson@chromium.org

Review URL: https://codereview.chromium.org/451703004

tests/FontConfigParser.cpp

index 73e9d2b..1c32704 100644 (file)
@@ -50,15 +50,21 @@ void DumpLoadedFonts(SkTDArray<FontFamily*> fontFamilies) {
 
 DEF_TEST(FontConfigParserAndroid, reporter) {
 
+    bool resourcesMissing = false;
+
     SkTDArray<FontFamily*> preV17FontFamilies;
     SkFontConfigParser::GetTestFontFamilies(preV17FontFamilies,
         GetResourcePath("android_fonts/pre_v17/system_fonts.xml").c_str(),
         GetResourcePath("android_fonts/pre_v17/fallback_fonts.xml").c_str());
 
-    REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14);
+    if (preV17FontFamilies.count() > 0) {
+        REPORTER_ASSERT(reporter, preV17FontFamilies.count() == 14);
 
-    DumpLoadedFonts(preV17FontFamilies);
-    ValidateLoadedFonts(preV17FontFamilies, reporter);
+        DumpLoadedFonts(preV17FontFamilies);
+        ValidateLoadedFonts(preV17FontFamilies, reporter);
+    } else {
+        resourcesMissing = true;
+    }
 
 
     SkTDArray<FontFamily*> v17FontFamilies;
@@ -66,10 +72,14 @@ DEF_TEST(FontConfigParserAndroid, reporter) {
         GetResourcePath("android_fonts/v17/system_fonts.xml").c_str(),
         GetResourcePath("android_fonts/v17/fallback_fonts.xml").c_str());
 
-    REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41);
+    if (v17FontFamilies.count() > 0) {
+        REPORTER_ASSERT(reporter, v17FontFamilies.count() == 41);
 
-    DumpLoadedFonts(v17FontFamilies);
-    ValidateLoadedFonts(v17FontFamilies, reporter);
+        DumpLoadedFonts(v17FontFamilies);
+        ValidateLoadedFonts(v17FontFamilies, reporter);
+    } else {
+        resourcesMissing = true;
+    }
 
 
     SkTDArray<FontFamily*> v22FontFamilies;
@@ -77,9 +87,17 @@ DEF_TEST(FontConfigParserAndroid, reporter) {
         GetResourcePath("android_fonts/v22/fonts.xml").c_str(),
         NULL);
 
-    REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53);
+    if (v22FontFamilies.count() > 0) {
+        REPORTER_ASSERT(reporter, v22FontFamilies.count() == 53);
 
-    DumpLoadedFonts(v22FontFamilies);
-    ValidateLoadedFonts(v22FontFamilies, reporter);
+        DumpLoadedFonts(v22FontFamilies);
+        ValidateLoadedFonts(v22FontFamilies, reporter);
+    } else {
+        resourcesMissing = true;
+    }
+
+    if (resourcesMissing) {
+        SkDebugf("---- Resource files missing for FontConfigParser test\n");
+    }
 }