OSDN Git Service

Fix testModelIdIsUnique test in DocumentsUI.
authorTomasz Mikolajewski <mtomasz@google.com>
Wed, 23 Mar 2016 07:41:48 +0000 (16:41 +0900)
committerTomasz Mikolajewski <mtomasz@google.com>
Wed, 23 Mar 2016 07:41:48 +0000 (16:41 +0900)
The logic changed, so the test had to be updated. Basically we support
multiple authorities only for cursors wrapped with MergeCursor.

Bug: 27742039
Change-Id: If07e1bf52279072e408a90efbe838a1d76adfcfd

packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/ModelTest.java

index c6ad511..cef3863 100644 (file)
@@ -21,6 +21,7 @@ import android.content.Context;
 import android.content.ContextWrapper;
 import android.database.Cursor;
 import android.database.MatrixCursor;
+import android.database.MergeCursor;
 import android.provider.DocumentsContract.Document;
 import android.test.AndroidTestCase;
 import android.test.mock.MockContentResolver;
@@ -117,21 +118,25 @@ public class ModelTest extends AndroidTestCase {
 
     // Tests multiple authorities with clashing document IDs.
     public void testModelIdIsUnique() {
-        MatrixCursor cIn = new MatrixCursor(COLUMNS);
+        MatrixCursor cIn1 = new MatrixCursor(COLUMNS);
+        MatrixCursor cIn2 = new MatrixCursor(COLUMNS);
 
         // Make two sets of items with the same IDs, under different authorities.
         final String AUTHORITY0 = "auth0";
         final String AUTHORITY1 = "auth1";
+
         for (int i = 0; i < ITEM_COUNT; ++i) {
-            MatrixCursor.RowBuilder row0 = cIn.newRow();
+            MatrixCursor.RowBuilder row0 = cIn1.newRow();
             row0.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY0);
             row0.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
 
-            MatrixCursor.RowBuilder row1 = cIn.newRow();
+            MatrixCursor.RowBuilder row1 = cIn2.newRow();
             row1.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY1);
             row1.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
         }
 
+        Cursor cIn = new MergeCursor(new Cursor[] { cIn1, cIn2 });
+
         // Update the model, then make sure it contains all the expected items.
         DirectoryResult r = new DirectoryResult();
         r.cursor = cIn;