Backed out changeset efa293b98893 (bug 975792) for frequent failures on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book 2014-02-25 13:35:41 +01:00
parent 14829c87bb
commit 8643485376

View File

@ -13,6 +13,7 @@ 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;
/*
@ -1868,76 +1869,4 @@ public class testBrowserProvider extends ContentProviderTest {
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);
}
}
}
}