0

Android: Suppress and/or fix a batch of minor Error Prone violations

Bug: 40661145
Change-Id: Ia8484fb974df88090c55cc3033012f4373c16151
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5898036
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Peter Wen <wnwen@chromium.org>
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1362577}
This commit is contained in:
Andrew Grieve
2024-10-01 18:50:22 +00:00
committed by Chromium LUCI CQ
parent 79500a8ee7
commit 3a9318f108
65 changed files with 170 additions and 241 deletions
base/android
javatests
src
org
chromium
junit
src
chrome
android
features
tab_ui
javatests
src
org
chromium
chrome
browser
feed
core
java
src
org
chromium
chrome
java
src
org
chromium
javatests
src
junit
webapk
libs
runtime_library
javatests
src
org
chromium
webapk
lib
shell_apk
junit
src
browser
download
internal
android
java
src
org
chromium
chrome
browser
feed
android
java
src
org
chromium
chrome
hub
magic_stack
android
java
src
org
chromium
chrome
browser
optimization_guide
android
java
src
org
chromium
chrome
partnercustomizations
java
src
org
chromium
chrome
password_check
android
java
src
org
chromium
chrome
browser
password_manager
android
access_loss
java
src
org
chromium
chrome
share
android
java
src
org
chromium
chrome
browser
javatests
src
org
chromium
chrome
browser
tab
java
src
org
chromium
chrome
browser
thumbnail
generator
android
java
src
org
chromium
chrome
browser
translate
android
java
src
org
chromium
ui
android
omnibox
plus_addresses
searchactivityutils
java
src
org
chromium
chrome
browser
signin
java
src
org
chromium
chrome
browser
ui
signin
test
android
javatests
src
org
chromium
chromecast/media/cma/backend/android/java/src/org/chromium/chromecast/cma/backend/android
components
autofill
android
java
src
org
chromium
components
browser_ui
media
android
java
src
org
chromium
components
widget
android
java
src
org
chromium
components
browser_ui
widget
cronet
android
api
src
org
sample
javatests
src
org
chromium
cronet_sample_apk
src
org
chromium
cronet_sample_apk
test
embedder_support
android
native_java_unittests
src
org
chromium
components
embedder_support
module_installer
android
junit
src
org
chromium
components
module_installer
omnibox
browser
android
java
src
org
chromium
components
paint_preview
player
android
junit
src
org
chromium
components
paintpreview
signin
public
android
java
src
org
chromium
components
junit
src
org
chromium
components
content
public
android
java
javatests
src
org
chromium
shell
android
browsertests
src
org
chromium
content_shell
media/midi/java/src/org/chromium/midi
mojo/public/java/bindings/src/org/chromium/mojo/bindings
net/android/junit/src/org/chromium/net
services/device/generic_sensor/android/junit/src/org/chromium/device/sensors
ui/android/javatests/src/org/chromium/ui/test/util

@ -132,7 +132,7 @@ public class ChainedTasksTest {
secondTaskFinished.notifyCalled();
waitForHighPriorityTask.waitForOnly();
} catch (TimeoutException e) {
Assert.fail();
throw new RuntimeException(e);
}
});
tasks.add(TaskTraits.UI_DEFAULT, new TestRunnable(messages, "Third"));

@ -124,6 +124,7 @@ public class UnownedUserDataKeyTest {
mHost2 = null;
}
@SuppressWarnings({"SelfAssertion", "JUnitIncompatibleType"})
@Test
public void testKeyEquality() {
assertEquals(Foo.KEY, Foo.KEY);

@ -192,9 +192,9 @@ public class TabGridDialogViewBinderTest extends BlankUiTestActivityTestCase {
assertNull(mTabGridDialogView.getBindingToken());
String title = "1024 tabs";
assertNotEquals(title, mTitleTextView.getText());
assertNotEquals(title, mTitleTextView.getText().toString());
mModel.set(TabGridDialogProperties.HEADER_TITLE, title);
assertNotEquals(title, mTitleTextView.getText());
assertNotEquals(title, mTitleTextView.getText().toString());
mModel.set(TabGridDialogProperties.BINDING_TOKEN, 4);
assertEquals(mTabGridDialogView.getBindingToken().intValue(), 4);
@ -240,7 +240,7 @@ public class TabGridDialogViewBinderTest extends BlankUiTestActivityTestCase {
@UiThreadTest
public void testSetHeaderTitle() {
String title = "1024 tabs";
assertNotEquals(title, mTitleTextView.getText());
assertNotEquals(title, mTitleTextView.getText().toString());
mModel.set(TabGridDialogProperties.HEADER_TITLE, title);

@ -550,8 +550,7 @@ public class FeedSurfaceMediator
mSigninManager.getIdentityManager().addObserver(this);
mSectionHeaderModel.set(SectionHeaderListProperties.MENU_MODEL_LIST_KEY, mFeedMenuModel);
mSectionHeaderModel.set(
SectionHeaderListProperties.MENU_DELEGATE_KEY, this::onItemSelected);
mSectionHeaderModel.set(SectionHeaderListProperties.MENU_DELEGATE_KEY, this);
setUpWebFeedTab();

@ -2209,11 +2209,7 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
};
mUndoBarPopupController =
new UndoBarController(
this,
mTabModelSelector,
this::getSnackbarManager,
dialogVisibilitySupplier);
new UndoBarController(this, mTabModelSelector, this, dialogVisibilitySupplier);
if (ChromeFeatureList.sTabGroupParityAndroid.isEnabled()) {
TabModelUtils.runOnTabStateInitialized(

@ -247,7 +247,6 @@ public class BookmarkToolbarTest extends BlankUiTestActivityTestCase {
for (int menuId : applicableMenuIds) {
boolean isVisible = !hiddenIdSet.contains(menuId);
MenuItem menuItem = mBookmarkToolbar.getMenu().findItem(menuId);
assertNotNull(menuId);
assertEquals(
"Mismatched visibility for menu item " + menuItem,
isVisible,
@ -259,7 +258,6 @@ public class BookmarkToolbarTest extends BlankUiTestActivityTestCase {
for (int menuId : applicableMenuIds) {
boolean isEnabled = !disabledIds.contains(menuId);
MenuItem menuItem = mBookmarkToolbar.getMenu().findItem(menuId);
assertNotNull(menuId);
assertEquals(
"Mismatched enabled state for menu item " + menuItem,
isEnabled,

@ -198,7 +198,7 @@ public class DigitalGoodsTest {
try {
Assert.assertNotEquals("null", exec(variable));
} catch (TimeoutException e) {
Assert.fail();
throw new RuntimeException(e);
}
});
}

@ -69,7 +69,7 @@ public class IncognitoCustomTabActivityTestRule extends CustomTabActivityTestRul
try {
createNewCustomTabSessionForIntent(intent);
} catch (TimeoutException e) {
Assert.fail();
throw new RuntimeException(e);
}
}
super.startCustomTabActivityWithIntent(intent);

@ -101,7 +101,7 @@ public class NewTabPageNavigationTest {
Assert.assertEquals(UrlConstants.NTP_URL, url);
// Check that the NTP is actually displayed.
Assert.assertNotNull(tab.getNativePage() instanceof NewTabPage);
Assert.assertTrue(tab.getNativePage() instanceof NewTabPage);
}
/** Tests navigating to the tab switcher from the NTP. */

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.autofill.settings;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
@ -24,7 +26,6 @@ import org.robolectric.RuntimeEnvironment;
import org.chromium.base.Callback;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.autofill.settings.AutofillDeletePaymentMethodConfirmationDialog;
import org.chromium.ui.modaldialog.DialogDismissalCause;
import org.chromium.ui.modaldialog.ModalDialogManager.ModalDialogType;
import org.chromium.ui.modaldialog.ModalDialogProperties;

@ -852,7 +852,6 @@ public class BookmarkManagerMediatorTest {
assertEquals(mBookmarkItem21.getTitle(), model.get(ImprovedBookmarkRowProperties.TITLE));
assertEquals(EXAMPLE_URL_FORMATTED, model.get(ImprovedBookmarkRowProperties.DESCRIPTION));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_ICON_DRAWABLE));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_AREA_BACKGROUND_COLOR));
assertNull(model.get(ImprovedBookmarkRowProperties.START_ICON_TINT));
assertNotNull(model.get(ImprovedBookmarkRowProperties.POPUP_LISTENER));
assertEquals(false, model.get(ImprovedBookmarkRowProperties.SELECTION_ACTIVE));
@ -927,7 +926,6 @@ public class BookmarkManagerMediatorTest {
assertEquals(mBookmarkItem21.getTitle(), model.get(ImprovedBookmarkRowProperties.TITLE));
assertEquals(EXAMPLE_URL_FORMATTED, model.get(ImprovedBookmarkRowProperties.DESCRIPTION));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_ICON_DRAWABLE));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_AREA_BACKGROUND_COLOR));
assertNull(model.get(ImprovedBookmarkRowProperties.START_ICON_TINT));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_ICON_DRAWABLE));
assertNotNull(model.get(ImprovedBookmarkRowProperties.POPUP_LISTENER));
@ -1013,7 +1011,6 @@ public class BookmarkManagerMediatorTest {
ImageVisibility.DRAWABLE,
model.get(ImprovedBookmarkRowProperties.START_IMAGE_VISIBILITY));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_ICON_DRAWABLE));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_AREA_BACKGROUND_COLOR));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_ICON_TINT));
assertNotNull(model.get(ImprovedBookmarkRowProperties.POPUP_LISTENER));
assertEquals(false, model.get(ImprovedBookmarkRowProperties.SELECTION_ACTIVE));
@ -1075,7 +1072,6 @@ public class BookmarkManagerMediatorTest {
assertEquals(
mFolderItem2.getTitle() + " (1)", model.get(ImprovedBookmarkRowProperties.TITLE));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_ICON_DRAWABLE));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_AREA_BACKGROUND_COLOR));
assertNotNull(model.get(ImprovedBookmarkRowProperties.START_ICON_TINT));
assertNotNull(model.get(ImprovedBookmarkRowProperties.POPUP_LISTENER));
assertEquals(false, model.get(ImprovedBookmarkRowProperties.SELECTION_ACTIVE));

@ -269,7 +269,6 @@ public class ImprovedBookmarkRowCoordinatorTest {
PropertyModel model = mCoordinator.createBasePropertyModel(READING_LIST_BOOKMARK_ID);
assertFalse(mCoordinator.shouldShowImagesForFolder(READING_LIST_BOOKMARK_ID));
assertNotNull(model.get(ImprovedBookmarkRowProperties.FOLDER_START_AREA_BACKGROUND_COLOR));
assertNotNull(model.get(ImprovedBookmarkRowProperties.FOLDER_START_ICON_TINT));
assertNotNull(model.get(ImprovedBookmarkRowProperties.FOLDER_START_ICON_DRAWABLE));
assertEquals(0, model.get(ImprovedBookmarkRowProperties.FOLDER_CHILD_COUNT));

@ -98,7 +98,7 @@ public final class FirstRunIntegrationUnitTest {
activityClass =
(Class<? extends Activity>) Class.forName(intent.getComponent().getClassName());
} catch (ClassNotFoundException e) {
Assert.fail();
throw new RuntimeException(e);
}
createActivity(activityClass, intent);
}

@ -103,9 +103,8 @@ public class WebApkServiceImplTest {
context.getPackageName(), PackageManager.GET_META_DATA);
return appInfo.uid;
} catch (Exception e) {
Assert.fail();
throw new RuntimeException(e);
}
return -1;
}
/**

@ -23,6 +23,7 @@ import org.chromium.webapk.lib.common.WebApkCommonUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/** Tests HostBrowserClassLoader. */
@ -47,7 +48,7 @@ public class HostBrowserClassLoaderTest {
private DexLoader mMockDexLoader;
@Before
public void setUp() {
public void setUp() throws Exception {
mContext = RuntimeEnvironment.application;
mPackageManager = mContext.getPackageManager();
setRemoteVersionCode(REMOTE_VERSION_CODE);
@ -65,7 +66,7 @@ public class HostBrowserClassLoaderTest {
/** Test upgrading to a new runtime dex version. */
@Test
public void testNewRuntimeDexVersion() {
public void testNewRuntimeDexVersion() throws Exception {
HostBrowserClassLoader.createClassLoader(mContext, mRemoteContext, mMockDexLoader, null);
String expectedDexName = WebApkCommonUtils.getRuntimeDexName(REMOTE_DEX_VERSION);
@ -139,13 +140,9 @@ public class HostBrowserClassLoaderTest {
* Sets the version of the current runtime library dex stored in the remote host browser's
* assets.
*/
public void setRemoteDexVersion(int dexVersion) {
try {
Mockito.when(mRemoteAssetManager.open("webapk_dex_version.txt"))
.thenReturn(createIntInputStream(dexVersion));
} catch (Exception e) {
Assert.fail();
}
public void setRemoteDexVersion(int dexVersion) throws IOException {
Mockito.when(mRemoteAssetManager.open("webapk_dex_version.txt"))
.thenReturn(createIntInputStream(dexVersion));
}
/**

@ -791,7 +791,7 @@ public final class LaunchTest {
(Class<? extends Activity>)
Class.forName(startedActivityIntent.getComponent().getClassName());
} catch (ClassNotFoundException e) {
Assert.fail();
throw new RuntimeException(e);
}
buildActivityFully(startedActivityClass, startedActivityIntent);
}

@ -15,10 +15,14 @@ import org.chromium.ui.modelutil.PropertyModel.WritableIntPropertyKey;
import org.chromium.ui.modelutil.PropertyModel.WritableObjectPropertyKey;
/**
* Extends the properties defined in {@link ListProperties} to facilitate the logic for an entire
* UI containing a download ListItem.
* Extends the properties defined in {@link ListProperties} to facilitate the logic for an entire UI
* containing a download ListItem.
*/
interface DownloadInterstitialProperties extends ListProperties {
/**
* Keeps track of the state of the DownloadInterstitial. This may be different to the state of
* the offline item displayed within the UI.
*/
@IntDef({
State.UNKNOWN,
State.IN_PROGRESS,
@ -27,10 +31,6 @@ interface DownloadInterstitialProperties extends ListProperties {
State.PAUSED,
State.PENDING
})
/**
* Keeps track of the state of the DownloadInterstitial. This may be different to the state of
* the offline item displayed within the UI.
*/
@interface State {
int UNKNOWN = 0;
int IN_PROGRESS = 1;

@ -201,12 +201,8 @@ public final class WebFeedMainMenuItemTest {
assertTrue(intent.hasExtra(CreatorIntentConstants.CREATOR_URL));
assertNotNull(intent.getExtras().getString(CreatorIntentConstants.CREATOR_URL));
assertTrue(intent.hasExtra(CreatorIntentConstants.CREATOR_ENTRY_POINT));
assertNotNull(intent.getExtras().getInt(CreatorIntentConstants.CREATOR_ENTRY_POINT));
assertTrue(intent.hasExtra(CreatorIntentConstants.CREATOR_FOLLOWING));
assertNotNull(
intent.getExtras().getBoolean(CreatorIntentConstants.CREATOR_FOLLOWING, false));
assertTrue(intent.hasExtra(CreatorIntentConstants.CREATOR_TAB_ID));
assertNotNull(intent.getExtras().getInt(CreatorIntentConstants.CREATOR_TAB_ID));
}
@Test

@ -60,7 +60,6 @@ public class DrawableButtonDataUnitTest {
DisplayButtonData buttonData =
new DrawableButtonData(
R.string.button_new_tab, R.string.button_new_incognito_tab, drawable);
assertEquals(buttonData, buttonData);
assertEquals(
buttonData,
new DrawableButtonData(

@ -61,7 +61,6 @@ public class ResourceButtonDataUnitTest {
R.string.button_new_tab,
R.string.button_new_incognito_tab,
R.drawable.ic_add);
assertEquals(buttonData, buttonData);
assertEquals(
buttonData,
new ResourceButtonData(

@ -140,7 +140,7 @@ public class HomeModulesCoordinator implements ModuleDelegate, OnViewCreatedCall
super.onViewRecycled(holder);
}
};
mModuleRegistry.registerAdapter(mAdapter, this::onViewCreated);
mModuleRegistry.registerAdapter(mAdapter, this);
mRecyclerView.setAdapter(mAdapter);
}

@ -200,7 +200,7 @@ public class OptimizationGuidePushNotificationManager {
@VisibleForTesting
public static String cacheKey(OptimizationType optimizationType) {
return ChromePreferenceKeys.OPTIMIZATION_GUIDE_PUSH_NOTIFICATION_CACHE.createKey(
optimizationType.toString());
optimizationType.name());
}
public static void setNativeIsInitializedForTesting(Boolean nativeIsInitialized) {

@ -118,21 +118,21 @@ public class PartnerBrowserCustomizationsRoboUnitTest {
public ShadowCustomizationProviderDelegate() {}
/** Returns the homepage string or null if none is available. */
@Implementation
@Nullable
/** Returns the homepage string or null if none is available. */
protected String getHomepage() {
return sHomepage;
}
@Implementation
/** Returns whether incognito mode is disabled. */
@Implementation
protected boolean isIncognitoModeDisabled() {
return false;
}
@Implementation
/** Returns whether bookmark editing is disabled. */
@Implementation
protected boolean isBookmarksEditingDisabled() {
return false;
}

@ -22,8 +22,6 @@ public @interface PasswordChangeType {
/** A user opened a site to change a password manually. */
int MANUAL_CHANGE = 1;
/**
* Deprecated as a part of APC removal (crbug.com/1386065).
* int AUTOMATED_CHANGE = 2;
*/
// Deprecated as a part of APC removal (crbug.com/1386065).
// int AUTOMATED_CHANGE = 2;
}

@ -70,8 +70,8 @@ public class PasswordAccessLossWarningHelper {
coordinator.showSheet(model);
}
@Nullable
/** Creates the model that has the text and functionality appropriate for the warning type. */
@Nullable
PropertyModel getModelForWarningType(@PasswordAccessLossWarningType int warningType) {
switch (warningType) {
case PasswordAccessLossWarningType.NO_GMS_CORE:

@ -128,13 +128,11 @@ public class ShareSheetCoordinator
if (bottomSheet == mBottomSheet) {
mBottomSheet
.getContentView()
.addOnLayoutChangeListener(
ShareSheetCoordinator.this::onLayoutChange);
.addOnLayoutChangeListener(ShareSheetCoordinator.this);
} else {
mBottomSheet
.getContentView()
.removeOnLayoutChangeListener(
ShareSheetCoordinator.this::onLayoutChange);
.removeOnLayoutChangeListener(ShareSheetCoordinator.this);
}
}
};

@ -883,7 +883,9 @@ public class PageInfoSharingControllerUnitTest {
.findViewById(R.id.learn_more_text);
var learnMoreTextLinks = learnMoreText.getClickableSpans();
assertNotEquals(
"TextView should contain clickable spans", 0, learnMoreTextLinks);
"TextView should contain clickable spans",
0,
learnMoreTextLinks.length);
// Click first span, which should contain a "learn more" text and link to a web
// page.
learnMoreTextLinks[0].onClick(learnMoreText);

@ -557,11 +557,10 @@ public abstract class PersistedTabData implements UserData {
public static void performStorageMaintenance(List<Integer> liveTabIds) {
ThreadUtils.assertOnUiThread();
for (Class<? extends PersistedTabData> clazz : sSupportedMaintenanceClasses) {
// Maintenance is supported only for regular Tabs.
boolean isEncrypted = false;
PersistedTabDataConfiguration config =
PersistedTabDataConfiguration.get(
clazz, false
/** Maintenance is only supported for regular Tabs */
);
PersistedTabDataConfiguration.get(clazz, isEncrypted);
PersistedTabDataStorage storage = config.getStorage();
storage.performMaintenance(liveTabIds, config.getId());
}

@ -73,29 +73,21 @@ public class ThumbnailMediaParserTest {
return result;
}
/** Verify that the metadata from audio file can be retrieved correctly. */
@Test
@LargeTest
@Feature({"MediaParser"})
/**
* Verify that the metadata from audio file can be retrieved correctly.
*
* @throws InterruptedException
*/
public void testParseAudioMetatadata() {
String filePath = UrlUtils.getIsolatedTestRoot() + "/media/test/data/sfx.mp3";
MediaParserResult result = parseMediaFile(filePath, "audio/mp3");
Assert.assertTrue("Failed to parse audio metadata.", result.mediaData != null);
}
/** Verify metadata and thumbnail can be retrieved correctly from h264 video file. */
@Test
@LargeTest
@Feature({"MediaParser"})
@Restriction(DeviceFormFactor.PHONE)
/**
* Verify metadata and thumbnail can be retrieved correctly from h264 video file.
*
* @throws InterruptedException
*/
public void testParseVideoH264() {
String filePath = UrlUtils.getIsolatedTestRoot() + "/media/test/data/bear.mp4";
MediaParserResult result = parseMediaFile(filePath, "video/mp4");
@ -106,14 +98,10 @@ public class ThumbnailMediaParserTest {
"Failed to retrieve thumbnail.", result.mediaData.thumbnail.getHeight() > 0);
}
/** Verify metadata and thumbnail can be retrieved correctly from vp8 video file. */
@Test
@LargeTest
@Feature({"MediaParser"})
/**
* Verify metadata and thumbnail can be retrieved correctly from vp8 video file.
*
* @throws InterruptedException
*/
public void testParseVideoThumbnailVp8() {
String filePath = UrlUtils.getIsolatedTestRoot() + "/media/test/data/bear-vp8-webvtt.webm";
MediaParserResult result = parseMediaFile(filePath, "video/webm");
@ -124,15 +112,13 @@ public class ThumbnailMediaParserTest {
"Failed to retrieve thumbnail.", result.mediaData.thumbnail.getHeight() > 0);
}
@Test
@LargeTest
@Feature({"MediaParser"})
/**
* Verify metadata and thumbnail can be retrieved correctly from vp8 video file with alpha
* plane.
*
* @throws InterruptedException
*/
@Test
@LargeTest
@Feature({"MediaParser"})
public void testParseVideoThumbnailVp8WithAlphaPlane() {
String filePath = UrlUtils.getIsolatedTestRoot() + "/media/test/data/bear-vp8a.webm";
MediaParserResult result = parseMediaFile(filePath, "video/webm");
@ -143,14 +129,10 @@ public class ThumbnailMediaParserTest {
"Failed to retrieve thumbnail.", result.mediaData.thumbnail.getHeight() > 0);
}
/** Verify metadata and thumbnail can be retrieved correctly from vp9 video file. */
@Test
@LargeTest
@Feature({"MediaParser"})
/**
* Verify metadata and thumbnail can be retrieved correctly from vp9 video file.
*
* @throws InterruptedException
*/
public void testParseVideoThumbnailVp9() {
String filePath = UrlUtils.getIsolatedTestRoot() + "/media/test/data/bear-vp9.webm";
MediaParserResult result = parseMediaFile(filePath, "video/webm");
@ -161,14 +143,10 @@ public class ThumbnailMediaParserTest {
"Failed to retrieve thumbnail.", result.mediaData.thumbnail.getHeight() > 0);
}
/** Verify metadata and thumbnail can be retrieved correctly from av1 video file. */
@Test
@LargeTest
@Feature({"MediaParser"})
/**
* Verify metadata and thumbnail can be retrieved correctly from av1 video file.
*
* @throws InterruptedException
*/
public void testParseVideoThumbnailAv1() {
String filePath = UrlUtils.getIsolatedTestRoot() + "/media/test/data/bear-av1.mp4";
MediaParserResult result = parseMediaFile(filePath, "video/mp4");
@ -179,14 +157,10 @@ public class ThumbnailMediaParserTest {
"Failed to retrieve thumbnail.", result.mediaData.thumbnail.getHeight() > 0);
}
/** Verify metadata and thumbnail can be retrieved correctly from h265 video file. */
@Test
@LargeTest
@Feature({"MediaParser"})
/**
* Verify metadata and thumbnail can be retrieved correctly from h265 video file.
*
* @throws InterruptedException
*/
public void testParseVideoThumbnailH265() {
String filePath = UrlUtils.getIsolatedTestRoot() + "/media/test/data/bear-hevc-frag.mp4";
MediaParserResult result = parseMediaFile(filePath, "video/mp4");
@ -197,14 +171,10 @@ public class ThumbnailMediaParserTest {
"Failed to retrieve thumbnail.", result.mediaData.thumbnail.getHeight() > 0);
}
/** Verify graceful failure on parsing invalid video file. */
@Test
@LargeTest
@Feature({"MediaParser"})
/**
* Verify graceful failure on parsing invalid video file.
*
* @throws InterruptedException
*/
public void testParseInvalidVideoFile() throws Exception {
File invalidFile = File.createTempFile("test", "webm");
MediaParserResult result = parseMediaFile(invalidFile.getAbsolutePath(), "video/webm");

@ -87,14 +87,14 @@ public final class AutoTranslateSnackbarControllerJavaTest {
Assert.assertEquals("en", data.getTargetLanguage());
}
@Test
@SmallTest
/**
* The target language is stored in Translate format, which uses the old deprecated Java codes
* for several languages (Hebrew, Indonesian), and uses "tl" while Chromium uses "fil" for
* Tagalog/Filipino. This tests that when using Translate format codes the Chrome version is
* displayed in the Snackbar.
*/
@Test
@SmallTest
public void testShowSnackbarChromeLanguage() throws Exception {
// Use the Translate tag tl which Chrome should display as "Filipino"
showSnackbar("tl");

@ -356,7 +356,8 @@ class DropdownItemViewInfoListBuilder {
nextSuggestionLogicalIndex++;
} else {
assert false
: "Unsupported group render type: " + currentGroupConfig.getRenderType();
: "Unsupported group render type: "
+ currentGroupConfig.getRenderType().name();
}
previousGroupConfig = currentGroupConfig;

@ -339,7 +339,8 @@ public class AnswerSuggestionProcessorUnitTest {
for (AnswerType type : ANSWER_TYPES) {
SuggestionTestHelper suggHelper = createAnswerSuggestion(type, "", 1, "", 1, null);
// Note: model is re-created on every iteration.
Assert.assertNotNull("No icon associated with type: " + type, suggHelper.getIcon());
Assert.assertNotNull(
"No icon associated with type: " + type.name(), suggHelper.getIcon());
}
}
@ -348,7 +349,8 @@ public class AnswerSuggestionProcessorUnitTest {
for (AnswerType type : ANSWER_TYPES) {
SuggestionTestHelper suggHelper = createRichAnswerSuggestion(type, 0, false);
// Note: model is re-created on every iteration.
Assert.assertNotNull("No icon associated with type: " + type, suggHelper.getIcon());
Assert.assertNotNull(
"No icon associated with type: " + type.name(), suggHelper.getIcon());
}
}

@ -223,7 +223,8 @@ public class DynamicSpacingRecyclerViewItemDecorationUnitTest {
// It's unlikely that the minimum spacing would guarantee 2.5 items to be shown, but we can
// verify this fast.
assertNotEquals(CONTAINER_SIZE, LEAD_IN_SPACE + itemWidth * 2.5 + MIN_ELEMENT_SPACE * 2);
assertNotEquals(
CONTAINER_SIZE, (int) (LEAD_IN_SPACE + itemWidth * 2.5 + MIN_ELEMENT_SPACE * 2));
// However, we don't permit dynamic spacing in landscape mode, so this should fall back to
// MIN_ELEMENT_SPACE.

@ -10,8 +10,8 @@ import org.jni_zero.CalledByNative;
import org.jni_zero.JNINamespace;
import org.jni_zero.JniType;
@JNINamespace("plus_addresses")
/** Contains necessary information to show a meaningful error message to the user. */
@JNINamespace("plus_addresses")
class PlusAddressCreationErrorStateInfo {
private final @PlusAddressCreationBottomSheetErrorType int mErrorType;
private final String mTitle;

@ -14,8 +14,8 @@ import org.chromium.url.GURL;
import java.util.Objects;
@JNINamespace("plus_addresses")
/** Contains necessary information to show a meaningful error message to the user. */
@JNINamespace("plus_addresses")
class PlusAddressCreationNormalStateInfo {
private final String mTitle;
private final String mDescription;

@ -144,8 +144,6 @@ public class SearchActivityPreferencesManagerTest {
SearchActivityPreferences p2 =
new SearchActivityPreferences(
"test", new GURL("https://test.url"), true, true, true);
Assert.assertEquals(p1, p1);
Assert.assertEquals(p2, p2);
Assert.assertEquals(p1, p2);
Assert.assertEquals(p1.hashCode(), p2.hashCode());

@ -481,13 +481,13 @@ public class HistorySyncTest {
histogramWatcher.assertExpected();
}
@Test
@MediumTest
/**
* This tests ensure that onClickListeners are attached to the accept/decline buttons when the
* HistorySyncCoordinator is created without a view and the MinorModeHelper resolves before a
* View is set.
*/
@Test
@MediumTest
public void testOnClickListenersAttachedWithMinorModeAccount() {
mSigninTestRule.addAccountThenSignin(AccountManagerTestRule.AADC_MINOR_ACCOUNT);
@ -532,13 +532,13 @@ public class HistorySyncTest {
});
}
@Test
@MediumTest
/**
* This tests ensure that onClickListeners are attached to the accept/decline buttons when the
* HistorySyncCoordinator is created without a view and the MinorModeHelper resolves before a
* View is set.
*/
@Test
@MediumTest
public void testOnClickListenersAttachedWithNonMinorModeAccount() {
mSigninTestRule.addAccountThenSignin(AccountManagerTestRule.AADC_ADULT_ACCOUNT);

@ -25,10 +25,8 @@ public class ChromeBrowserTestRule implements TestRule {
new Statement() {
@Override
public void evaluate() throws Throwable {
/**
* Loads the native library on the activity UI thread. After loading the library,
* this will initialize the browser process if necessary.
*/
// Loads the native library on the activity UI thread. After loading the
// library, this will initialize the browser process if necessary.
NativeLibraryTestUtils.loadNativeLibraryAndInitBrowserProcess();
base.evaluate();
}

@ -454,11 +454,8 @@ class AudioSinkAudioTrackImpl {
return (playtimeLeftNsecs < 0) ? 0 : playtimeLeftNsecs / 1000; // return usecs
}
/** Closes the instance by stopping playback and releasing the AudioTrack object. */
@CalledByNative
/**
* Closes the instance by stopping playback and releasing the AudioTrack
* object.
*/
private void close() {
Log.i(mTag, "Close AudioSinkAudioTrackImpl!");
if (!isStopped()) mAudioTrack.stop();

@ -17,11 +17,11 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
@JNINamespace("autofill")
/**
* The android version of the C++ AutofillSaveIbanUiInfo providing UI resources for the save IBAN
* bottom sheet.
*/
@JNINamespace("autofill")
public class AutofillSaveIbanUiInfo {
private final String mAcceptText;
private final String mCancelText;
@ -64,8 +64,6 @@ public class AutofillSaveIbanUiInfo {
return mTitleText;
}
@CalledByNative
@VisibleForTesting
/**
* Construct the {@link AutofillSaveIbanUiInfo} given all the members. This constructor is used
* for native binding purposes.
@ -80,6 +78,8 @@ public class AutofillSaveIbanUiInfo {
* {@code 0} for local save.
* @param titleText A bottom sheet title UI string. This value must not be {@code null}.
*/
@CalledByNative
@VisibleForTesting
/* package */ AutofillSaveIbanUiInfo(
@JniType("std::u16string") String acceptText,
@JniType("std::u16string") String cancelText,

@ -90,7 +90,6 @@ public class MediaNotificationInfoTest {
assertNotNull(info);
// Make sure hashCode() doesn't crash.
int hashValue = info.hashCode();
assertNotNull(hashValue);
info.hashCode();
}
}

@ -61,7 +61,7 @@ public class SelectableItemViewBaseTest {
SelectionDelegate<Integer> selectionDelegate = new SelectionDelegate<>();
mSelectableItemViewBase.setSelectionDelegate(selectionDelegate);
Integer item = new Integer(1);
Integer item = 1;
assertNull(mSelectableItemViewBase.getItem());
mSelectableItemViewBase.setItem(item);
assertEquals(item, mSelectableItemViewBase.getItem());
@ -87,7 +87,7 @@ public class SelectableItemViewBaseTest {
@Test
public void testSelection_NullDelegate() {
Integer item = new Integer(1);
Integer item = 1;
assertNull(mSelectableItemViewBase.getItem());
mSelectableItemViewBase.setItem(item);
assertNull(mSelectableItemViewBase.getItem());

@ -172,7 +172,7 @@ final class ContentTypeParametersParser {
}
private static boolean isAscii(char ch) {
return (char) 0 <= ch && ch <= (char) 127;
return ch <= 127;
}
private static boolean isWhitespace(char c) {

@ -18,6 +18,6 @@ public class CronetSampleTest {
@Test
@SmallTest
public void testSimple() throws Exception {
assertThat(1).isEqualTo(1);
assertThat(1 + 1).isEqualTo(2);
}
}

@ -14,29 +14,34 @@ import java.util.List;
import java.util.Map;
/**
* Adding an option here will make it show up in the list of available options.
* Each {@link Option} has the following attributes:
* Adding an option here will make it show up in the list of available options. Each {@link Option}
* has the following attributes:
*
* <ul>
* <li>A short name which appears in bold on the options list.</li>
* <li>A description which provides a thorough explanation of what this option does.</li>
* <li>An {@link Action} which is applied on CronetEngine's Builder each time the user hits "Reset
* Engine". </li> <li>A default value, every option must have a default value.</li>
* <li>A short name which appears in bold on the options list.
* <li>A description which provides a thorough explanation of what this option does.
* <li>An {@link Action} which is applied on CronetEngine's Builder each time the user hits "Reset
* Engine".
* <li>A default value, every option must have a default value.
* </ul>
*
* <b>NOTE</b>: Each option must map to one {@link OptionsIdentifier OptionsIdentifier}. This is
* necessary to provide custom implementation for options that does not configure the builders. See
* {@link OptionsIdentifier#SLOW_DOWNLOAD} as an example.
*
* <p> To add a new option, do the following:
* <p>To add a new option, do the following:
*
* <ol>
* <li> Add a new optionIdentifier {@link OptionsIdentifier} </li>
* <li> Inject a new Option instance into your optionIdentifier enum value. </li>
* <li> Implement the logic for the new option within a new {@link Action}. </li>
* <li> If the {@link Action} interface is not enough to satisfy the use-case. Feel free to add
* custom logic, See {@link OptionsIdentifier#SLOW_DOWNLOAD} as an example.</li>
* <li> Restart the APK and verify that your option is working as intended. </li>
* <li>Add a new optionIdentifier {@link OptionsIdentifier}
* <li>Inject a new Option instance into your optionIdentifier enum value.
* <li>Implement the logic for the new option within a new {@link Action}.
* <li>If the {@link Action} interface is not enough to satisfy the use-case. Feel free to add
* custom logic, See {@link OptionsIdentifier#SLOW_DOWNLOAD} as an example.
* <li>Restart the APK and verify that your option is working as intended.
* </ol>
*/
public class Options {
@SuppressWarnings("ImmutableEnumChecker")
public enum OptionsIdentifier {
MIGRATE_SESSIONS_ON_NETWORK_CHANGE_V2(
new BooleanOption(
@ -57,9 +62,9 @@ public class Options {
new BooleanOption(
"migrate_sessions_early_v2",
"Enable QUIC early session migration. This will make quic send probing"
+ " packets when the network is degrading, QUIC will migrate the "
+ "sessions to a different network even before the original network "
+ "has disconnected.",
+ " packets when the network is degrading, QUIC will migrate the"
+ " sessions to a different network even before the original network"
+ " has disconnected.",
new Action<Boolean>() {
@Override
@OptIn(markerClass = ConnectionMigrationOptions.Experimental.class)
@ -72,7 +77,8 @@ public class Options {
SLOW_DOWNLOAD(
new BooleanOption(
"Slow Download (10s)",
"Hang the onReadCompleted for 10s before proceeding. This should simulate slow connection.",
"Hang the onReadCompleted for 10s before proceeding. This should simulate"
+ " slow connection.",
new Action<>() {},
false));

@ -678,6 +678,8 @@ public class CronetTestRule implements TestRule {
ExperimentalCronetEngine.Builder getCronetEngineBuilder(Context context);
}
// Warning should go away once we can use java.util.function.Function.
@SuppressWarnings("ImmutableEnumChecker")
public enum CronetImplementation {
STATICALLY_LINKED(
context ->

@ -1813,17 +1813,11 @@ public class CronetUrlRequestContextTest {
String url = NativeTestServer.getFileURL("/cacheable.txt");
// When cache is disabled, making a request does not write to the cache.
checkRequestCaching(
cronetEngine, url, false, true
/** disable cache */
);
checkRequestCaching(cronetEngine, url, false, true);
checkRequestCaching(cronetEngine, url, false);
// When cache is enabled, the second request is cached.
checkRequestCaching(
cronetEngine, url, false, true
/** disable cache */
);
checkRequestCaching(cronetEngine, url, false, true);
checkRequestCaching(cronetEngine, url, true);
// Shut down the server, next request should have a cached response.

@ -2875,12 +2875,12 @@ public class CronetUrlRequestTest {
}
}
@Test
@SmallTest
/**
* Open many connections and cancel them right away. This test verifies all internal sockets and
* other Closeables are properly closed. See crbug.com/726193.
*/
@Test
@SmallTest
public void testGzipCancel() throws Exception {
String url = NativeTestServer.getFileURL("/gzipped.html");
for (int i = 0; i < 100; i++) {
@ -2912,10 +2912,10 @@ public class CronetUrlRequestTest {
}
}
/** Do a HEAD request and get back a 404. */
@Test
@SmallTest
@RequiresMinApi(8) // JavaUrlRequest fixed in API level 8: crrev.com/499303
/** Do a HEAD request and get back a 404. */
public void test404Head() throws Exception {
TestUrlRequestCallback callback = new TestUrlRequestCallback();
UrlRequest.Builder builder =
@ -2997,12 +2997,12 @@ public class CronetUrlRequestTest {
assertThat(CronetTestUtil.nativeGetTaggedBytes(tag)).isGreaterThan(priorBytes);
}
@Test
@SmallTest
/**
* Initiate many requests concurrently to make sure neither Cronet implementation crashes.
* Regression test for https://crbug.com/844031.
*/
@Test
@SmallTest
public void testManyRequests() throws Exception {
String url = NativeTestServer.getMultiRedirectURL();
final int numRequests = 2000;

@ -198,7 +198,7 @@ public class TestUrlRequestCallback extends UrlRequest.Callback {
// Termination shouldn't take long. Use 1 min which should be more than enough.
mExecutorService.awaitTermination(1, TimeUnit.MINUTES);
} catch (InterruptedException e) {
fail("ExecutorService is interrupted while waiting for termination");
throw new RuntimeException(e);
}
assertThat(mExecutorService.isTerminated()).isTrue();
}

@ -88,6 +88,7 @@ public class CronetHttpURLStreamHandlerTest {
@Test
@SmallTest
@SuppressWarnings("AddressSelection")
public void testOpenConnectionWithProxy() throws Exception {
URL url = new URL(NativeTestServer.getEchoMethodURL());
CronetHttpURLStreamHandler streamHandler =

@ -9,6 +9,7 @@ import org.jni_zero.CalledByNative;
import java.io.IOException;
import java.io.InputStream;
@SuppressWarnings("InputStreamSlowMultibyteRead")
class InputStreamUnittest {
private InputStreamUnittest() {}

@ -86,12 +86,8 @@ public class SplitCompatEngineTest {
// Arrange.
String installedModule = "m1";
String uninstalledModule = "m2";
Set<String> installedModules =
new HashSet<String>() {
{
add(installedModule);
}
};
Set<String> installedModules = new HashSet<String>();
installedModules.add(installedModule);
doReturn(installedModules).when(mManager).getInstalledModules();
// Act & Assert.

@ -509,6 +509,7 @@ public class AutocompleteMatch {
}
@Override
@SuppressWarnings("LiteProtoToString")
public String toString() {
List<String> pieces =
Arrays.asList(

@ -341,9 +341,7 @@ public class PlayerFrameMediatorTest {
// we should have only one column.
Bitmap[][] bitmapMatrix = mModel.get(PlayerFrameProperties.BITMAP_MATRIX);
Assert.assertTrue(Arrays.deepEquals(bitmapMatrix, new Bitmap[4][1]));
Assert.assertEquals(
new ArrayList<Pair<View, Rect>>(),
mModel.get(PlayerFrameProperties.SUBFRAME_VIEWS));
Assert.assertEquals(List.of(), mModel.get(PlayerFrameProperties.SUBFRAME_VIEWS));
}
/**

@ -37,7 +37,7 @@ public class AccountCapabilities {
}
@VisibleForTesting
public AccountCapabilities(HashMap<String, Boolean> accountCapabilities) {
public AccountCapabilities(Map<String, Boolean> accountCapabilities) {
mAccountCapabilities = accountCapabilities;
}
@ -49,7 +49,7 @@ public class AccountCapabilities {
Map<String, Integer> capabilityResponses) {
assert capabilityResponses.size()
== AccountCapabilitiesConstants.SUPPORTED_ACCOUNT_CAPABILITY_NAMES.size();
HashMap<String, Boolean> capabilities = new HashMap<>();
Map<String, Boolean> capabilities = new HashMap<>();
for (String capabilityName :
AccountCapabilitiesConstants.SUPPORTED_ACCOUNT_CAPABILITY_NAMES) {
assert capabilityResponses.containsKey(capabilityName);

@ -27,6 +27,7 @@ import org.chromium.components.signin.test.util.FakeAccountManagerDelegate;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** Test class for {@link AccountCapabilities}. */
@RunWith(ParameterizedRunner.class)
@ -81,7 +82,7 @@ public final class AccountCapabilitiesTest {
}
/** Populates all capabilities with the given response value. */
public static HashMap<String, Integer> populateCapabilitiesResponse(
public static Map<String, Integer> populateCapabilitiesResponse(
@AccountManagerDelegate.CapabilityResponse int value) {
HashMap<String, Integer> response = new HashMap<>();
for (String capabilityName :
@ -182,33 +183,21 @@ public final class AccountCapabilitiesTest {
@Test
@ParameterAnnotations.UseMethodParameter(CapabilitiesTestParams.class)
public void testCapabilityResponseException(String capabilityName) {
AccountCapabilities capabilities = new AccountCapabilities(new HashMap<>());
AccountCapabilities capabilities = new AccountCapabilities(Map.of());
Assert.assertEquals(getCapability(capabilityName, capabilities), Tribool.UNKNOWN);
}
@Test
@ParameterAnnotations.UseMethodParameter(CapabilitiesTestParams.class)
public void testCapabilityResponseYes(String capabilityName) {
AccountCapabilities capabilities =
new AccountCapabilities(
new HashMap<String, Boolean>() {
{
put(capabilityName, true);
}
});
AccountCapabilities capabilities = new AccountCapabilities(Map.of(capabilityName, true));
Assert.assertEquals(getCapability(capabilityName, capabilities), Tribool.TRUE);
}
@Test
@ParameterAnnotations.UseMethodParameter(CapabilitiesTestParams.class)
public void testCapabilityResponseNo(String capabilityName) {
AccountCapabilities capabilities =
new AccountCapabilities(
new HashMap<String, Boolean>() {
{
put(capabilityName, false);
}
});
AccountCapabilities capabilities = new AccountCapabilities(Map.of(capabilityName, false));
Assert.assertEquals(getCapability(capabilityName, capabilities), Tribool.FALSE);
}

@ -11,6 +11,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import androidx.annotation.IntDef;
import com.google.android.gms.auth.api.phone.SmsCodeBrowserClient;
import com.google.android.gms.auth.api.phone.SmsCodeRetriever;
import com.google.android.gms.auth.api.phone.SmsRetriever;
@ -27,13 +29,14 @@ import org.chromium.base.metrics.RecordHistogram;
import org.chromium.content.browser.sms.Wrappers.WebOTPServiceContext;
import org.chromium.ui.base.WindowAndroid;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Encapsulates logic to retrieve OTP code via SMS Browser Code API.
* See also:
* Encapsulates logic to retrieve OTP code via SMS Browser Code API. See also:
* https://developers.google.com/android/reference/com/google/android/gms/auth/api/phone/SmsCodeBrowserClient
*
* TODO(majidvp): rename legacy Verification name to more appropriate name (
* e.g., BrowserCode.
* <p>TODO(majidvp): rename legacy Verification name to more appropriate name ( e.g., BrowserCode.
*/
public class SmsVerificationReceiver extends BroadcastReceiver {
private static final int CODE_PERMISSION_REQUEST = 1;
@ -43,12 +46,19 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
private boolean mDestroyed;
private Wrappers.WebOTPServiceContext mContext;
private enum BackendAvailability {
AVAILABLE,
API_NOT_CONNECTED,
PLATFORM_NOT_SUPPORTED,
API_NOT_AVAILABLE,
NUM_ENTRIES
@IntDef({
BackendAvailability.AVAILABLE,
BackendAvailability.API_NOT_CONNECTED,
BackendAvailability.PLATFORM_NOT_SUPPORTED,
BackendAvailability.API_NOT_AVAILABLE
})
@Retention(RetentionPolicy.SOURCE)
public @interface BackendAvailability {
int AVAILABLE = 0;
int API_NOT_CONNECTED = 1;
int PLATFORM_NOT_SUPPORTED = 2;
int API_NOT_AVAILABLE = 3;
int NUM_ENTRIES = 4;
}
public SmsVerificationReceiver(SmsProviderGms provider, WebOTPServiceContext context) {
@ -210,12 +220,10 @@ public class SmsVerificationReceiver extends BroadcastReceiver {
if (DEBUG) Log.d(TAG, "Installed task");
}
public void reportBackendAvailability(BackendAvailability availability) {
if (DEBUG) Log.d(TAG, "Backend availability: %d", availability.ordinal());
public void reportBackendAvailability(@BackendAvailability int availability) {
if (DEBUG) Log.d(TAG, "Backend availability: %d", availability);
RecordHistogram.recordEnumeratedHistogram(
"Blink.Sms.BackendAvailability",
availability.ordinal(),
BackendAvailability.NUM_ENTRIES.ordinal());
"Blink.Sms.BackendAvailability", availability, BackendAvailability.NUM_ENTRIES);
}
// Handles the case when the backend is available but user has previously denied to grant the

@ -97,22 +97,14 @@ public class IdentityCredentialsDelegate {
Log.d(TAG, "Sending an intent for sender");
Log.d(TAG, request);
startIntentSenderForResult(
/** activity= */
window,
/** intent= */
response.getPendingIntent().getIntentSender(),
/** requestCode= */
777,
/** fillInIntent= */
null,
/** flagsMask= */
0,
/** flagsValues= */
0,
/** extraFlags= */
0,
/** options= */
null);
/* activity= */ window,
/* intent= */ response.getPendingIntent().getIntentSender(),
/* requestCode= */ 777,
/* fillInIntent= */ null,
/* flagsMask= */ 0,
/* flagsValues= */ 0,
/* extraFlags= */ 0,
/* options= */ null);
} catch (SendIntentException e) {
Log.e(TAG, "Sending an intent for sender failed");
result.reject(e);

@ -105,7 +105,7 @@ public class ContentViewLocationTest {
mActivityTestRule.launchContentShellWithUrlSync(
"content/test/data/android/geolocation.html");
} catch (Throwable t) {
Assert.fail();
throw new RuntimeException(t);
}
mTestCallbackHelperContainer =

@ -102,13 +102,13 @@ public abstract class ContentShellBrowserTestActivity extends NativeBrowserTestA
});
}
@Override
/**
* Ensure that the user data directory gets overridden to getPrivateDataDirectory() (which is
* cleared at the start of every run); the directory that ANDROID_APP_DATA_DIR is set to in the
* context of Java browsertests is not cleared as it also holds persistent state, which
* causes test failures due to state bleedthrough. See crbug.com/617734 for details.
* context of Java browsertests is not cleared as it also holds persistent state, which causes
* test failures due to state bleedthrough. See crbug.com/617734 for details.
*/
@Override
protected String getUserDataDirectoryCommandLineSwitch() {
return "user-data-dir";
}

@ -10,8 +10,8 @@ import android.media.midi.MidiDeviceInfo;
import org.jni_zero.CalledByNative;
import org.jni_zero.JNINamespace;
@JNINamespace("midi")
/** A class implementing midi::MidiDeviceAndroid functionality. */
@JNINamespace("midi")
class MidiDeviceAndroid {
/** The underlying device. */
private final MidiDevice mDevice;

@ -811,13 +811,13 @@ public class Decoder {
* array of booleans.
*/
private DataHeader readDataHeaderForBooleanArray(
long expectedLength, boolean containsHasValueBitfield) {
int expectedLength, boolean containsHasValueBitfield) {
DataHeader dataHeader = readDataHeader();
long packedBoolSize = (dataHeader.elementsOrVersion + 7) / 8;
long expectedSize = DataHeader.HEADER_SIZE + packedBoolSize;
int packedBoolSize = (dataHeader.elementsOrVersion + 7) / 8;
int expectedSize = DataHeader.HEADER_SIZE + packedBoolSize;
if (containsHasValueBitfield) {
long hasValueBitfieldSize = packedBoolSize;
int hasValueBitfieldSize = packedBoolSize;
expectedSize += hasValueBitfieldSize;
}

@ -8,7 +8,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
@ -441,7 +440,7 @@ public class HttpNegotiateAuthenticatorTest {
when(accountManagerFuture.getResult()).thenReturn(result);
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
// Can never happen - artifact of Mockito.
fail();
throw new RuntimeException(e);
}
return accountManagerFuture;
}
@ -459,7 +458,7 @@ public class HttpNegotiateAuthenticatorTest {
when(accountManagerFuture.getResult()).thenThrow(ex);
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
// Can never happen - artifact of Mockito.
fail();
throw new RuntimeException(e);
}
return accountManagerFuture;
}

@ -60,9 +60,8 @@ public class PlatformSensorAndProviderTest {
private static final long PLATFORM_SENSOR_TIMESTAMP = 314159265358979L;
private static final double SECONDS_IN_NANOSECOND = 0.000000001d;
@SuppressWarnings("LockNotBeforeTry")
/** Class that overrides thread management callbacks for testing purposes. */
@SuppressWarnings("LockNotBeforeTry")
private static class TestPlatformSensorProvider extends PlatformSensorProvider {
public TestPlatformSensorProvider(Context context) {
super(context);

@ -50,7 +50,7 @@ public class MockitoHelper {
}
/** When no argument is needed. */
public static <T> Stubber doRunnable(Runnable runnable) {
public static Stubber doRunnable(Runnable runnable) {
return Mockito.doAnswer(
ignored -> {
runnable.run();