Fix ModuleLicensePreferenceTest. The intent may contain multiple flags, so just checking whether the needed one is included

Fix: 215072120

Test: atest
Change-Id: I71707a6e8dc0e728e3c20d2c626c204c63064dae
This commit is contained in:
FanWu
2023-11-20 16:13:30 +08:00
committed by Fan Wu
parent a909150e53
commit 45e2bcb8bb

View File

@@ -24,7 +24,6 @@ import android.content.Intent;
import android.content.pm.ModuleInfo; import android.content.pm.ModuleInfo;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
@@ -57,7 +56,6 @@ public class ModuleLicensePreferenceTest {
} }
@Test @Test
@Ignore
public void onClick_sendsCorrectIntent() { public void onClick_sendsCorrectIntent() {
ModuleLicensePreference pref = new ModuleLicensePreference(mContext, mModuleInfo); ModuleLicensePreference pref = new ModuleLicensePreference(mContext, mModuleInfo);
@@ -69,7 +67,7 @@ public class ModuleLicensePreferenceTest {
.isEqualTo(ModuleLicenseProvider.getUriForPackage(PACKAGE_NAME)); .isEqualTo(ModuleLicenseProvider.getUriForPackage(PACKAGE_NAME));
assertThat(intent.getType()).isEqualTo(ModuleLicenseProvider.LICENSE_FILE_MIME_TYPE); assertThat(intent.getType()).isEqualTo(ModuleLicenseProvider.LICENSE_FILE_MIME_TYPE);
assertThat(intent.getCharSequenceExtra(Intent.EXTRA_TITLE)).isEqualTo(NAME); assertThat(intent.getCharSequenceExtra(Intent.EXTRA_TITLE)).isEqualTo(NAME);
assertThat(intent.getFlags()).isEqualTo(Intent.FLAG_GRANT_READ_URI_PERMISSION); assertThat((intent.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION)).isNotEqualTo(0);
assertThat(intent.getCategories()).contains(Intent.CATEGORY_DEFAULT); assertThat(intent.getCategories()).contains(Intent.CATEGORY_DEFAULT);
assertThat(intent.getPackage()).isEqualTo("com.android.htmlviewer"); assertThat(intent.getPackage()).isEqualTo("com.android.htmlviewer");
} }