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

Commit 2ee220bc authored by Erfan Norozi's avatar Erfan Norozi
Browse files

Remove SetFlagsRule from DocsUI tests and replace them with CheckFlagsRule.

SetFlagsRule is not supported in mts. Instead we should filter tests to
test the code under both states of the flags.

I couldn't reproduce the mts issue locally so not certain this fixes it.

Bug: 390031738
Test: Fixing unit tests. No production code change.
Flag: EXEMPT test only
Change-Id: I3f46bc160eb8819dd4d35a8f942480d2b4c9aa92
parent 28fdd411
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -39,9 +39,10 @@ import android.content.ClipData;
import android.content.Intent;
import android.net.Uri;
import android.os.Parcelable;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Path;
import android.util.Pair;
@@ -109,7 +110,7 @@ public class ActionHandlerTest {
    private boolean refreshAnswer = false;

    @Rule
    public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();

    @Parameter(0)
    public boolean isPrivateSpaceEnabled;
@@ -165,7 +166,7 @@ public class ActionHandlerTest {
    }

    @Test
    @DisableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING})
    @RequiresFlagsDisabled({Flags.FLAG_DESKTOP_FILE_HANDLING})
    public void testOpenFileFlags() {
        mHandler.onDocumentOpened(TestEnv.FILE_GIF,
                com.android.documentsui.files.ActionHandler.VIEW_TYPE_PREVIEW,
@@ -178,7 +179,7 @@ public class ActionHandlerTest {
    }

    @Test
    @EnableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING})
    @RequiresFlagsEnabled({Flags.FLAG_DESKTOP_FILE_HANDLING})
    public void testOpenFileFlagsDesktop() {
        mHandler.onDocumentOpened(TestEnv.FILE_GIF,
                com.android.documentsui.files.ActionHandler.VIEW_TYPE_PREVIEW,
@@ -475,7 +476,7 @@ public class ActionHandlerTest {
    }

    @Test
    @DisableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING})
    @RequiresFlagsDisabled({Flags.FLAG_DESKTOP_FILE_HANDLING})
    public void testShowChooser() throws Exception {
        mActivity.currentRoot = TestProvidersAccess.DOWNLOADS;

@@ -484,7 +485,7 @@ public class ActionHandlerTest {
    }

    @Test
    @EnableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING})
    @RequiresFlagsEnabled({Flags.FLAG_DESKTOP_FILE_HANDLING})
    public void testShowChooserDesktop() throws Exception {
        mActivity.currentRoot = TestProvidersAccess.DOWNLOADS;

+7 −6
Original line number Diff line number Diff line
@@ -21,9 +21,10 @@ import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import android.net.Uri;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;

@@ -129,7 +130,7 @@ public final class MenuManagerTest {
    private int mFilesCount;

    @Rule
    public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();

    @Before
    public void setUp() {
@@ -598,7 +599,7 @@ public final class MenuManagerTest {
    }

    @Test
    @DisableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING})
    @RequiresFlagsDisabled({Flags.FLAG_DESKTOP_FILE_HANDLING})
    public void testContextMenu_OnFile_CanOpen() {
        selectionDetails.canOpen = true;
        mgr.updateContextMenuForFiles(testMenu, selectionDetails);
@@ -607,7 +608,7 @@ public final class MenuManagerTest {
    }

    @Test
    @EnableFlags({Flags.FLAG_DESKTOP_FILE_HANDLING})
    @RequiresFlagsEnabled({Flags.FLAG_DESKTOP_FILE_HANDLING})
    public void testContextMenu_OnFile_CanOpenDesktop() {
        selectionDetails.canOpen = true;
        mgr.updateContextMenuForFiles(testMenu, selectionDetails);