1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.contacts.tests; 17 18 import android.database.Cursor; 19 import android.database.CursorWrapper; 20 import android.database.DatabaseUtils; 21 22 /** 23 * Wrapper around a cursor with a custom toString that dumps the entire cursor data 24 * 25 * This is for providing more useful info during debugging and testing. 26 */ 27 public class StringableCursor extends CursorWrapper { 28 public StringableCursor(Cursor cursor) { 29 super(cursor); 30 } 31 32 @Override 33 public String toString() { 34 final Cursor wrapped = getWrappedCursor(); 35 36 if (wrapped.getCount() == 0) { 37 return "Empty Cursor"; 38 } 39 40 return DatabaseUtils.dumpCursorToString(wrapped); 41 } 42 } 43