diff options
author | Stephan Altmueller <stephana@google.com> | 2018-01-16 15:55:48 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-16 21:33:39 +0000 |
commit | 8ee7fb0083c0b00e494f580cba216ab71a889e22 (patch) | |
tree | 159a276f68090b7f6db94ee0e3249f555d8c9177 /platform_tools | |
parent | 57393797c0c0ab10e19f3ce6a3ad16a024e3cea9 (diff) |
Fix directory creation in skqp app
Bug: skia:
Change-Id: Id26832ccce7d09d3d3d640bcdd11a424f18943f7
Reviewed-on: https://skia-review.googlesource.com/92682
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'platform_tools')
3 files changed, 41 insertions, 28 deletions
diff --git a/platform_tools/android/apps/skqp/src/main/AndroidManifest.xml b/platform_tools/android/apps/skqp/src/main/AndroidManifest.xml index b080286f2f..f39fddad56 100644 --- a/platform_tools/android/apps/skqp/src/main/AndroidManifest.xml +++ b/platform_tools/android/apps/skqp/src/main/AndroidManifest.xml @@ -3,6 +3,9 @@ package="org.skia.skqp" android:versionCode="1" android:versionName="1.0"> + + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <application android:allowBackup="false" android:theme="@style/AppTheme" diff --git a/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQP.java b/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQP.java index 8ced43dbe2..1ebfa223da 100644 --- a/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQP.java +++ b/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQP.java @@ -25,21 +25,19 @@ public class SkQP { protected static final String kSkiaGM = "SkiaGM_"; protected static final String kSkiaUnitTests = "Skia_UnitTests"; - protected static final String LOG_PREFIX = "org.skis.skqp"; + protected static final String LOG_PREFIX = "org.skia.skqp"; static { System.loadLibrary("skqp_app"); } protected void runTests(Context context, String outputDirPath) { - Log.w(LOG_PREFIX, "Output Dir: " + outputDirPath); + Log.i(LOG_PREFIX, "Output Dir: " + outputDirPath); File outputDir = new File(outputDirPath); - if (outputDir.exists()) { - try { - deleteDirectoryContents(outputDir); - } catch (IOException e) { - Log.w(LOG_PREFIX, "DeleteDirectoryContents: " + e.getMessage()); - } + try { + ensureEmtpyDirectory(outputDir); + } catch (IOException e) { + Log.e(LOG_PREFIX, "ensureEmtpyDirectory:" + e.getMessage()); } // Note: nInit will initialize the mGMs, mBackends and mUnitTests fields. @@ -68,28 +66,40 @@ public class SkQP { // Record success for this test. } } + } + for (int unitTest = 0; unitTest < mUnitTests.length; unitTest++) { + String testName = kSkiaUnitTests + "_" + mUnitTests[unitTest]; + Log.w(LOG_PREFIX, "Running: " + testName); + String[] errors = this.nExecuteUnitTest(unitTest); + if (errors != null && errors.length > 0) { + for (String error : errors) { + Log.w(LOG_PREFIX, "Error running " + testName + ":" + error); + } + } else { + Log.i(LOG_PREFIX, "Test: " + testName + " finished successfully."); + } + } + Log.i(LOG_PREFIX, "Finished running all tests."); + nMakeReport(); + } + + protected static void ensureEmtpyDirectory(File f) throws IOException { + if (f.exists()) { + delete(f); } - for (int unitTest = 0; unitTest < mUnitTests.length; unitTest++) { - String testName = kSkiaUnitTests + "_" + mUnitTests[unitTest]; - Log.w(LOG_PREFIX, "Running: " + testName); - String[] errors = this.nExecuteUnitTest(unitTest); - if (errors != null && errors.length > 0) { - for (String error : errors) { - // Record unit test failures. - } - } else { - // Record success. - } + if (!f.mkdirs()) { + throw new IOException("Unable to create directory:" + f.getAbsolutePath()); } - nMakeReport(); } - protected static void deleteDirectoryContents(File f) throws IOException { - for (File s : f.listFiles()) { - if (s.isDirectory()) { - deleteDirectoryContents(s); - } - s.delete(); + protected static void delete(File f) throws IOException { + if (f.isDirectory()) { + for (File s : f.listFiles()) { + delete(s); + } + } + if (!f.delete()) { + throw new IOException("Unable to delete:" + f.getAbsolutePath()); } } } diff --git a/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQPRunner.java b/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQPRunner.java index dc9aea3f19..e7fc49950e 100644 --- a/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQPRunner.java +++ b/platform_tools/android/apps/skqp/src/main/java/org/skia/skqp/SkQPRunner.java @@ -35,9 +35,9 @@ public class SkQPRunner extends Runner { Context context = InstrumentationRegistry.getTargetContext(); File filesDir = context.getFilesDir(); try { - SkQP.deleteDirectoryContents(filesDir); + SkQP.ensureEmtpyDirectory(filesDir); } catch (IOException e) { - Log.w("org.skis.skqp", "DeleteDirectoryContents: " + e.getMessage()); + Log.w("org.skis.skqp", "ensureEmtpyDirectory: " + e.getMessage()); } Resources resources = context.getResources(); |