Bug 976418 - Amend CursorDumper to log BLOBs. a=test-only
☠☠ backed out by 60b1a8b6214a ☠ ☠
authorRichard Newman <rnewman@mozilla.com>
Mon, 24 Feb 2014 20:26:51 -0800
changeset 170859 f3aa442c84e46237de05da61f4725caf5a34f009
parent 170858 c03ae393e75f7a19af63e7395caa0623aacba7f1
child 170860 b92e36eba34932089a1e205070838104ef7037e4
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerstest-only
bugs976418
milestone30.0a1
Bug 976418 - Amend CursorDumper to log BLOBs. a=test-only
mobile/android/base/tests/testBrowserProvider.java
--- a/mobile/android/base/tests/testBrowserProvider.java
+++ b/mobile/android/base/tests/testBrowserProvider.java
@@ -1894,18 +1894,39 @@ public class testBrowserProvider extends
         protected static String dashes(int i) {
             return "-------------------------------------".substring(0, i);
         }
 
         public static void dumpCursor(Cursor cursor) {
             dumpCursor(cursor, 18, "records");
         }
 
+        private static void dumpColumn(Cursor cursor, int column, int columnWidth) {
+            switch (cursor.getType(column)) {
+            case Cursor.FIELD_TYPE_BLOB:
+                System.out.print(fixedWidth(columnWidth, "<blob>"));
+                break;
+            case Cursor.FIELD_TYPE_INTEGER:
+                System.out.print(fixedWidth(columnWidth, Integer.toString(cursor.getInt(column), 10)));
+                break;
+            case Cursor.FIELD_TYPE_NULL:
+                System.out.print(fixedWidth(columnWidth, "<null>"));
+                break;
+            default:
+                // These don't apply to us.
+                System.out.print(fixedWidth(columnWidth, "<other>"));
+                break;
+            }
+
+            System.out.print(" | ");
+        }
+
         protected static void dumpCursor(Cursor cursor, int columnWidth,
                                          String tags) {
+            System.out.println("Dumped cursor:");
             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]) +
                                      " | ");
@@ -1918,19 +1939,17 @@ public class testBrowserProvider extends
                 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)) +
-                                         " | ");
+                        dumpColumn(cursor, i, columnWidth);
                     }
                     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));