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

Commit ace93cfa authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix broken unit test done by ag/1729776, and added unit test." into nyc-andromeda-dev

parents b5d5966b f085da03
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -429,7 +429,7 @@ public final class UserInputHandler<T extends InputEvent>
        // TODO: Refactor FocusManager to depend only on DocumentDetails so we can eliminate
        // difficult to test dependency on DocumentHolder.

        boolean onKey(DocumentHolder doc, int keyCode, KeyEvent event) {
        boolean onKey(@Nullable DocumentHolder doc, int keyCode, KeyEvent event) {
            // Only handle key-down events. This is simpler, consistent with most other UIs, and
            // enables the handling of repeated key events from holding down a key.
            if (event.getAction() != KeyEvent.ACTION_DOWN) {
@@ -441,13 +441,15 @@ public final class UserInputHandler<T extends InputEvent>
                return false;
            }

            int itemType = doc.getItemViewType();
            // Ignore events sent to Addon Holders.
            if (doc != null) {
                int itemType = doc.getItemViewType();
                if (itemType == DocumentsAdapter.ITEM_TYPE_HEADER_MESSAGE
                        || itemType == DocumentsAdapter.ITEM_TYPE_INFLATED_MESSAGE
                        || itemType == DocumentsAdapter.ITEM_TYPE_SECTION_BREAK) {
                    return false;
                }
            }

            if (mFocusHandler.handleKey(doc, keyCode, event)) {
                // Handle range selection adjustments. Extending the selection will adjust the
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class DirectoryListBot extends Bots.BaseBot {
        assertTrue(messageTextView.exists());

        String msg = String.valueOf(message);
        assertEquals(String.format(msg, "TEST_ROOT_0"), messageTextView.getText());
        assertEquals(msg, messageTextView.getText());

    }

+19 −2
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@ package com.android.documentsui;
import static com.android.documentsui.StubProvider.ROOT_0_ID;
import static com.android.documentsui.StubProvider.ROOT_1_ID;

import android.content.Intent;
import android.provider.DocumentsContract;
import android.os.RemoteException;
import android.support.test.filters.LargeTest;
import android.support.v7.recyclerview.R;

import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.Shared;
@@ -34,6 +34,11 @@ public class FilesActivityDefaultsUiTest extends ActivityTest<FilesActivity> {
        super(FilesActivity.class);
    }

    @Override
    protected void initTestFiles() throws RemoteException {
        // Overriding to init with no items in test roots
    }

    @Override
    protected RootInfo getInitialRoot() {
        return null;  // test the default, unaffected state of the app.
@@ -50,6 +55,18 @@ public class FilesActivityDefaultsUiTest extends ActivityTest<FilesActivity> {
        }
    }

    public void testNavigate_FromEmptyDirectory() throws Exception {
        device.waitForIdle();

        bots.roots.openRoot(rootDir0.title);

        String msg = String.valueOf(context.getString(R.string.empty));
        bots.directory.assertMessageTextView(msg);

        // Check to make sure back button is properly handled by non-Doc type DocHolders
        device.pressBack();
    }

    public void testDefaultRoots() throws Exception {
        device.waitForIdle();