Loading tests/DumpRenderTree2/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -24,5 +24,12 @@ limitations under the License. <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".LayoutTestsRunner" android:label="Layout tests' runner"> </activity> </application> <uses-permission android:name="android.permission.WRITE_SDCARD" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> </manifest> No newline at end of file tests/DumpRenderTree2/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -23,4 +23,6 @@ limitations under the License. <string name="dialog_progress_title">Loading items.</string> <string name="dialog_progress_msg">Please wait...</string> <string name="runner_preloading_title">Preloading tests...</string> </resources> No newline at end of file tests/DumpRenderTree2/src/com/android/dumprendertree2/AbstractResult.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dumprendertree2; /** * A class that represent a result of the test. It is responsible for returning the result's * raw data and generating its own diff in HTML format. */ public abstract class AbstractResult { public enum TestType { TEXT, PIXEL } public enum ResultCode { PASS("Passed"), FAIL_RESULT_DIFFERS("Failed: different results"), FAIL_NO_EXPECTED_RESULT("Failed: no expected result"), FAIL_TIMED_OUT("Failed: timed out"), FAIL_CRASHED("Failed: crashed"); private String mTitle; private ResultCode(String title) { mTitle = title; } @Override public String toString() { return mTitle; } } /** * Returns result's raw data that can be written to the disk. * * @return * results raw data */ public abstract byte[] getData(); /** * Returns the code of this result. * * @return * the code of this result */ public abstract ResultCode getCode(); /** * Return the type of the result data. * * @return * the type of the result data. */ public abstract TestType getType(); /** * Returns a piece of HTML code that presents a visual diff between a result and * the expected result. * * @return * a piece of HTML code with a visual diff between the result and the expected result */ public abstract String getDiffAsHtml(); } No newline at end of file tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java +53 −5 Original line number Diff line number Diff line Loading @@ -61,8 +61,6 @@ public class FileFilter { } public void reloadConfiguration() { Log.d(LOG_TAG + "::reloadConfiguration", "Begin."); File txt_exp = new File(mRootDirPath, TEST_EXPECTATIONS_TXT_PATH); BufferedReader bufferedReader; Loading Loading @@ -222,8 +220,7 @@ public class FileFilter { */ public static boolean isTestDir(String dirName) { return (!dirName.equals("script-tests") && !dirName.equals("resources") && !dirName.startsWith(".")); && !dirName.equals("resources") && !dirName.startsWith(".")); } /** Loading @@ -237,4 +234,55 @@ public class FileFilter { public static boolean isTestFile(String testName) { return testName.endsWith(".html") || testName.endsWith(".xhtml"); } /** * Return the path to the file relative to the tests root dir * * @param filePath * @return * the path relative to the tests root dir */ public String getRelativePath(String filePath) { File rootDir = new File(mRootDirPath); return filePath.replaceFirst(rootDir.getPath() + File.separator, ""); } /** * Return the path to the file relative to the tests root dir * * @param filePath * @return * the path relative to the tests root dir */ public String getRelativePath(File file) { return getRelativePath(file.getAbsolutePath()); } public File getAbsoluteFile(String relativePath) { return new File(mRootDirPath, relativePath); } public String getAboslutePath(String relativePath) { return getAbsoluteFile(relativePath).getAbsolutePath(); } /** * If the path contains extension (e.g .foo at the end of the file) then it changes * this (.foo) into newEnding (so it has to contain the dot if we want to preserve it). * * <p>If the path doesn't contain an extension, it adds the ending to the path. * * @param relativePath * @param newEnding * @return * a new path, containing the newExtension */ public static String setPathEnding(String relativePath, String newEnding) { int dotPos = relativePath.lastIndexOf('.'); if (dotPos == -1) { return relativePath + newEnding; } return relativePath.substring(0, dotPos) + newEnding; } } No newline at end of file tests/DumpRenderTree2/src/com/android/dumprendertree2/FsUtils.java 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dumprendertree2; import android.util.Log; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; /** * */ public class FsUtils { public static final String LOG_TAG = "FsUtils"; public static void writeDataToStorage(File file, byte[] bytes, boolean append) { Log.d(LOG_TAG + "::writeDataToStorage", file.getAbsolutePath()); try { OutputStream outputStream = null; try { file.getParentFile().mkdirs(); file.createNewFile(); Log.d(LOG_TAG + "::writeDataToStorage", "File created."); outputStream = new FileOutputStream(file, append); outputStream.write(bytes); } finally { if (outputStream != null) { outputStream.close(); } } } catch (IOException e) { Log.e(LOG_TAG + "::writeDataToStorage", e.getMessage()); } } } Loading
tests/DumpRenderTree2/AndroidManifest.xml +7 −0 Original line number Diff line number Diff line Loading @@ -24,5 +24,12 @@ limitations under the License. <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".LayoutTestsRunner" android:label="Layout tests' runner"> </activity> </application> <uses-permission android:name="android.permission.WRITE_SDCARD" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> </manifest> No newline at end of file
tests/DumpRenderTree2/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -23,4 +23,6 @@ limitations under the License. <string name="dialog_progress_title">Loading items.</string> <string name="dialog_progress_msg">Please wait...</string> <string name="runner_preloading_title">Preloading tests...</string> </resources> No newline at end of file
tests/DumpRenderTree2/src/com/android/dumprendertree2/AbstractResult.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dumprendertree2; /** * A class that represent a result of the test. It is responsible for returning the result's * raw data and generating its own diff in HTML format. */ public abstract class AbstractResult { public enum TestType { TEXT, PIXEL } public enum ResultCode { PASS("Passed"), FAIL_RESULT_DIFFERS("Failed: different results"), FAIL_NO_EXPECTED_RESULT("Failed: no expected result"), FAIL_TIMED_OUT("Failed: timed out"), FAIL_CRASHED("Failed: crashed"); private String mTitle; private ResultCode(String title) { mTitle = title; } @Override public String toString() { return mTitle; } } /** * Returns result's raw data that can be written to the disk. * * @return * results raw data */ public abstract byte[] getData(); /** * Returns the code of this result. * * @return * the code of this result */ public abstract ResultCode getCode(); /** * Return the type of the result data. * * @return * the type of the result data. */ public abstract TestType getType(); /** * Returns a piece of HTML code that presents a visual diff between a result and * the expected result. * * @return * a piece of HTML code with a visual diff between the result and the expected result */ public abstract String getDiffAsHtml(); } No newline at end of file
tests/DumpRenderTree2/src/com/android/dumprendertree2/FileFilter.java +53 −5 Original line number Diff line number Diff line Loading @@ -61,8 +61,6 @@ public class FileFilter { } public void reloadConfiguration() { Log.d(LOG_TAG + "::reloadConfiguration", "Begin."); File txt_exp = new File(mRootDirPath, TEST_EXPECTATIONS_TXT_PATH); BufferedReader bufferedReader; Loading Loading @@ -222,8 +220,7 @@ public class FileFilter { */ public static boolean isTestDir(String dirName) { return (!dirName.equals("script-tests") && !dirName.equals("resources") && !dirName.startsWith(".")); && !dirName.equals("resources") && !dirName.startsWith(".")); } /** Loading @@ -237,4 +234,55 @@ public class FileFilter { public static boolean isTestFile(String testName) { return testName.endsWith(".html") || testName.endsWith(".xhtml"); } /** * Return the path to the file relative to the tests root dir * * @param filePath * @return * the path relative to the tests root dir */ public String getRelativePath(String filePath) { File rootDir = new File(mRootDirPath); return filePath.replaceFirst(rootDir.getPath() + File.separator, ""); } /** * Return the path to the file relative to the tests root dir * * @param filePath * @return * the path relative to the tests root dir */ public String getRelativePath(File file) { return getRelativePath(file.getAbsolutePath()); } public File getAbsoluteFile(String relativePath) { return new File(mRootDirPath, relativePath); } public String getAboslutePath(String relativePath) { return getAbsoluteFile(relativePath).getAbsolutePath(); } /** * If the path contains extension (e.g .foo at the end of the file) then it changes * this (.foo) into newEnding (so it has to contain the dot if we want to preserve it). * * <p>If the path doesn't contain an extension, it adds the ending to the path. * * @param relativePath * @param newEnding * @return * a new path, containing the newExtension */ public static String setPathEnding(String relativePath, String newEnding) { int dotPos = relativePath.lastIndexOf('.'); if (dotPos == -1) { return relativePath + newEnding; } return relativePath.substring(0, dotPos) + newEnding; } } No newline at end of file
tests/DumpRenderTree2/src/com/android/dumprendertree2/FsUtils.java 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dumprendertree2; import android.util.Log; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; /** * */ public class FsUtils { public static final String LOG_TAG = "FsUtils"; public static void writeDataToStorage(File file, byte[] bytes, boolean append) { Log.d(LOG_TAG + "::writeDataToStorage", file.getAbsolutePath()); try { OutputStream outputStream = null; try { file.getParentFile().mkdirs(); file.createNewFile(); Log.d(LOG_TAG + "::writeDataToStorage", "File created."); outputStream = new FileOutputStream(file, append); outputStream.write(bytes); } finally { if (outputStream != null) { outputStream.close(); } } } catch (IOException e) { Log.e(LOG_TAG + "::writeDataToStorage", e.getMessage()); } } }