☠☠ backed out by 2323e5887850 ☠ ☠ | |
author | Richard Newman <rnewman@mozilla.com> |
Mon, 24 Feb 2014 16:52:13 -0800 | |
changeset 170430 | efa293b9889326903c65166569a788565c2a4d77 |
parent 170429 | 706f36fe921f078104504dcbd7731486736846ba |
child 170431 | 432a8750016a7e86eb577ece6369fd2003cc0e16 |
push id | 26288 |
push user | ryanvm@gmail.com |
push date | Tue, 25 Feb 2014 20:20:43 +0000 |
treeherder | mozilla-central@22650589a724 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | me |
bugs | 975792 |
milestone | 30.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/tests/testBrowserProvider.java +++ b/mobile/android/base/tests/testBrowserProvider.java @@ -8,17 +8,16 @@ import android.content.OperationApplicat import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.util.Log; import java.util.ArrayList; import java.util.Random; -import org.mozilla.gecko.background.db.CursorDumper; import org.mozilla.gecko.db.BrowserContract; /* * This test is meant to exercise all operations exposed by Fennec's * history and bookmarks content provider. It does so in an isolated * environment (see ContentProviderTest) without affecting any UI-related * code. */ @@ -1864,9 +1863,81 @@ public class testBrowserProvider extends */ private void assertCountIsAndClose(Cursor c, int expectedCount, String message) { try { mAsserter.is(c.getCount(), expectedCount, message); } finally { c.close(); } } + + /** + * Pilfered from Android Background Services code. + */ + public static class CursorDumper { + protected static String fixedWidth(int width, String s) { + if (s == null) { + return spaces(width); + } + int length = s.length(); + if (width == length) { + return s; + } + if (width > length) { + return s + spaces(width - length); + } + return s.substring(0, width); + } + + protected static String spaces(int i) { + return " ".substring(0, i); + } + + protected static String dashes(int i) { + return "-------------------------------------".substring(0, i); + } + + public static void dumpCursor(Cursor cursor) { + dumpCursor(cursor, 18, "records"); + } + + protected static void dumpCursor(Cursor cursor, int columnWidth, + String tags) { + int originalPosition = cursor.getPosition(); + try { + String[] columnNames = cursor.getColumnNames(); + int columnCount = cursor.getColumnCount(); + + for (int i = 0; i < columnCount; ++i) { + System.out.print(fixedWidth(columnWidth, columnNames[i]) + + " | "); + } + System.out.println("(" + cursor.getCount() + " " + tags + ")"); + for (int i = 0; i < columnCount; ++i) { + System.out.print(dashes(columnWidth) + " | "); + } + System.out.println(""); + if (!cursor.moveToFirst()) { + System.out.println("EMPTY"); + return; + } + + cursor.moveToFirst(); + while (!cursor.isAfterLast()) { + for (int i = 0; i < columnCount; ++i) { + System.out.print(fixedWidth(columnWidth, + cursor.getString(i)) + + " | "); + } + System.out.println(""); + cursor.moveToNext(); + } + for (int i = 0; i < columnCount - 1; ++i) { + System.out.print(dashes(columnWidth + 3)); + } + System.out.print(dashes(columnWidth + 3 - 1)); + System.out.println(""); + } finally { + cursor.moveToPosition(originalPosition); + } + } + } }