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

Commit d394d112 authored by Ben Reich's avatar Ben Reich
Browse files

Update DirectoryAddonsAdapterTest 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 com.android.documentsui.dirlist.DirectoryAddonsAdapterTest
Flag: com.android.documentsui.flags.use_material3
Change-Id: I1a7076fafaf16e3d4771a4aefa8996ba147af1fb
parent 3f113b98
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 android.content.Context;
import android.os.Bundle;
import android.provider.DocumentsContract;
@@ -72,7 +74,8 @@ public class DirectoryAddonsAdapterTest 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() {
@@ -81,9 +84,12 @@ public class DirectoryAddonsAdapterTest 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.