Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25a25fbd authored by Ben Reich's avatar Ben Reich
Browse files

Update DirectoryAddonsAdapterPrivateSpaceTest for use_material3

There is no break between files and folders when the use_material3 flag
is enabled, this changes the expectation in 2 of the tests where they
add 1 to the expected item count due to the artificial item injected to
break the layout.

Bug: 412776499
Test: atest DirectoryAddonsAdapterPrivateSpaceTest
Flag: com.android.documentsui.flags.use_material3
Change-Id: Ib8aa4486f95336bb71c888eed262b4700b1caf20
parent 90853be3
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.documentsui.dirlist;

import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;

import static org.mockito.Mockito.when;

import android.content.Context;
@@ -98,7 +100,8 @@ public class DirectoryAddonsAdapterPrivateSpaceTest extends AndroidTestCase {
    public void testItemCount_mixed() {
        mEnv.reset();  // creates a mix of folders and files for us.

        assertEquals(mEnv.model.getItemCount() + 1, mAdapter.getItemCount());
        int expectedItemCount = mEnv.model.getItemCount() + (isUseMaterial3FlagEnabled() ? 0 : 1);
        assertEquals(expectedItemCount, mAdapter.getItemCount());
    }

    public void testGetPosition() {
@@ -107,9 +110,12 @@ public class DirectoryAddonsAdapterPrivateSpaceTest extends AndroidTestCase {
        mEnv.model.update();

        assertEquals(0, mAdapter.getPosition(ModelId.build(mEnv.model.mUserId, AUTHORITY, "1")));
        // adapter inserts a view between item 0 and 1 to force layout
        // break between folders and files. This is reflected by an offset position.
        assertEquals(2, mAdapter.getPosition(ModelId.build(mEnv.model.mUserId, AUTHORITY, "2")));
        // adapter inserts a view between item 0 and 1 (this doesn't happen when use_material3 flag
        // is enabled) to force a layout break between folders and files. This is reflected by an
        // offset position.
        int position = isUseMaterial3FlagEnabled() ? 1 : 2;
        assertEquals(
                position, mAdapter.getPosition(ModelId.build(mEnv.model.mUserId, AUTHORITY, "2")));
    }

    // Tests that the item count is correct for a directory containing only subdirs.