mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Enable lint errors in session tests
Also resolve some failures. Lint checks [aren't enabled in tests by default](http://groups.google.com/g/lint-dev/c/rtjVpqHmY0Y). This change suppresses `NewApi` failures in Robolectric tests because these tests only run at 'target SDK' by default (currently 30), but the lint doesn't understand this and so flags spurious issues with API usages below this. PiperOrigin-RevId: 653172059
This commit is contained in:
parent
3b8ea4a412
commit
76db936d68
@ -33,6 +33,11 @@ android {
|
||||
buildFeatures {
|
||||
aidl true
|
||||
}
|
||||
lintOptions {
|
||||
// TODO: b/353490583 - Move this to common_library_config.gradle once it's enabled for all
|
||||
// libraries.
|
||||
checkTestSources true
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
api project(modulePrefix + 'lib-common')
|
||||
|
@ -225,7 +225,7 @@ public class CommandButtonTest {
|
||||
assertThat(button)
|
||||
.isNotEqualTo(
|
||||
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
|
||||
.setSessionCommand(new SessionCommand(Player.COMMAND_PLAY_PAUSE))
|
||||
.setSessionCommand(new SessionCommand(SessionCommand.COMMAND_CODE_LIBRARY_GET_ITEM))
|
||||
.setDisplayName("button")
|
||||
.setIconResId(R.drawable.media3_notification_small_icon)
|
||||
.build());
|
||||
@ -268,17 +268,17 @@ public class CommandButtonTest {
|
||||
public void equals_differencesInSessionCommand_notEqual() {
|
||||
assertThat(
|
||||
new CommandButton.Builder(CommandButton.ICON_PLAY)
|
||||
.setSessionCommand(new SessionCommand(Player.COMMAND_PLAY_PAUSE))
|
||||
.setSessionCommand(new SessionCommand(SessionCommand.COMMAND_CODE_LIBRARY_GET_ITEM))
|
||||
.setDisplayName("button")
|
||||
.build())
|
||||
.isNotEqualTo(
|
||||
new CommandButton.Builder(CommandButton.ICON_PLAY)
|
||||
.setSessionCommand(new SessionCommand(Player.COMMAND_SEEK_BACK))
|
||||
.setSessionCommand(new SessionCommand(SessionCommand.COMMAND_CODE_LIBRARY_SEARCH))
|
||||
.setDisplayName("button")
|
||||
.build());
|
||||
assertThat(
|
||||
new CommandButton.Builder(CommandButton.ICON_PLAY)
|
||||
.setSessionCommand(new SessionCommand(Player.COMMAND_PLAY_PAUSE))
|
||||
.setSessionCommand(new SessionCommand(SessionCommand.COMMAND_CODE_LIBRARY_GET_ITEM))
|
||||
.setDisplayName("button")
|
||||
.build())
|
||||
.isNotEqualTo(
|
||||
|
@ -1159,20 +1159,17 @@ public final class LegacyConversionsTest {
|
||||
LegacyConversions.convertToAudioAttributes((MediaControllerCompat.PlaybackInfo) null))
|
||||
.isSameInstanceAs(AudioAttributes.DEFAULT);
|
||||
|
||||
int contentType = AudioAttributesCompat.CONTENT_TYPE_MUSIC;
|
||||
int flags = AudioAttributesCompat.FLAG_AUDIBILITY_ENFORCED;
|
||||
int usage = AudioAttributesCompat.USAGE_MEDIA;
|
||||
AudioAttributesCompat aaCompat =
|
||||
new AudioAttributesCompat.Builder()
|
||||
.setContentType(contentType)
|
||||
.setFlags(flags)
|
||||
.setUsage(usage)
|
||||
.setContentType(AudioAttributesCompat.CONTENT_TYPE_MUSIC)
|
||||
.setFlags(AudioAttributesCompat.FLAG_AUDIBILITY_ENFORCED)
|
||||
.setUsage(AudioAttributesCompat.USAGE_MEDIA)
|
||||
.build();
|
||||
AudioAttributes aa =
|
||||
new AudioAttributes.Builder()
|
||||
.setContentType(contentType)
|
||||
.setFlags(flags)
|
||||
.setUsage(usage)
|
||||
.setContentType(C.AUDIO_CONTENT_TYPE_MUSIC)
|
||||
.setFlags(C.FLAG_AUDIBILITY_ENFORCED)
|
||||
.setUsage(C.USAGE_MEDIA)
|
||||
.build();
|
||||
assertThat(LegacyConversions.convertToAudioAttributes(aaCompat)).isEqualTo(aa);
|
||||
assertThat(LegacyConversions.convertToAudioAttributesCompat(aa)).isEqualTo(aaCompat);
|
||||
|
@ -36,6 +36,7 @@ public class SessionErrorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("WrongConstant") // Deliberately testing an unrecognized error code.
|
||||
public void constructor_withNonErrorCode_throwsIllegalArgumentException() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
|
21
libraries/session/src/test/lint.xml
Normal file
21
libraries/session/src/test/lint.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2024 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<lint>
|
||||
<!-- Robolectric tests run at targetApi by default, but the linter doesn't understand this so
|
||||
generates lots of spurious NewApi failures. -->
|
||||
<issue id="NewApi" severity="ignore" />
|
||||
</lint>
|
Loading…
x
Reference in New Issue
Block a user