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

Commit 1e8d5ac3 authored by William Escande's avatar William Escande
Browse files

Migration Assert to Truth: assertEquals

Bug: 311772251
Test: atest BluetoothInstrumentationTests
Flag: TEST_ONLY
Change-Id: I209b5ff3e519412d91f17a74bb8c7736825561d9
parent 579e90e3
Loading
Loading
Loading
Loading
+0 −44
Original line number Diff line number Diff line
/*
 * 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
 *
 *      http://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.
 */

package com.android.bluetooth.channelsoundingtestapp;

import static com.google.common.truth.Truth.assertThat;

import android.content.Context;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {

    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        assertThat(appContext.getPackageName())
                .isEqualto("com.android.bluetooth.channelsoundingtestapp");
    }
}
+0 −34
Original line number Diff line number Diff line
/*
 * 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
 *
 *      http://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.
 */

package com.android.bluetooth.channelsoundingtestapp;

import static com.google.common.truth.Truth.assertThat;

import org.junit.Test;

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
public class ExampleUnitTest {

    @Test
    public void addition_isCorrect() {
        assertThat(2 + 2).isEqualTo(4);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class BipImageDescriptor {
         * @param encoding The encoding you would like to set as a BIP spec defined string
         * @return This object so you can continue building
         */
        public Builder setPropietaryEncoding(String encoding) {
        public Builder setProprietaryEncoding(String encoding) {
            mImageDescriptor.mEncoding = new BipEncoding(BipEncoding.USR_XXX, encoding);
            return this;
        }
+8 −6
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.bluetooth.a2dp;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.*;

import android.bluetooth.BluetoothAdapter;
@@ -243,22 +245,22 @@ public class A2dpCodecConfigTest {
        for (BluetoothCodecConfig config : codecConfigs) {
            switch (config.getCodecType()) {
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC:
                    Assert.assertEquals(config.getCodecPriority(), SBC_PRIORITY_DEFAULT);
                    assertThat(config.getCodecPriority()).isEqualTo(SBC_PRIORITY_DEFAULT);
                    break;
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC:
                    Assert.assertEquals(config.getCodecPriority(), AAC_PRIORITY_DEFAULT);
                    assertThat(config.getCodecPriority()).isEqualTo(AAC_PRIORITY_DEFAULT);
                    break;
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX:
                    Assert.assertEquals(config.getCodecPriority(), APTX_PRIORITY_DEFAULT);
                    assertThat(config.getCodecPriority()).isEqualTo(APTX_PRIORITY_DEFAULT);
                    break;
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD:
                    Assert.assertEquals(config.getCodecPriority(), APTX_HD_PRIORITY_DEFAULT);
                    assertThat(config.getCodecPriority()).isEqualTo(APTX_HD_PRIORITY_DEFAULT);
                    break;
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC:
                    Assert.assertEquals(config.getCodecPriority(), LDAC_PRIORITY_DEFAULT);
                    assertThat(config.getCodecPriority()).isEqualTo(LDAC_PRIORITY_DEFAULT);
                    break;
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS:
                    Assert.assertEquals(config.getCodecPriority(), OPUS_PRIORITY_DEFAULT);
                    assertThat(config.getCodecPriority()).isEqualTo(OPUS_PRIORITY_DEFAULT);
                    break;
            }
        }
+11 −12
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -274,7 +273,7 @@ public class BrowserPlayerWrapperTest {
        MediaBrowser.ConnectionCallback browserConnCb = mBrowserConnCb.getValue();
        browserConnCb.onConnected();

        Assert.assertEquals("root_folder", wrapper.getRootId());
        assertThat(wrapper.getRootId()).isEqualTo("root_folder");
        verify(mMockBrowser).disconnect();
    }

@@ -392,22 +391,22 @@ public class BrowserPlayerWrapperTest {
        for (int i = 0; i < item_list.size(); i++) {
            MediaItem expected = items.get(i);
            ListItem item = item_list.get(i);
            Assert.assertEquals(expected.isBrowsable(), item.isFolder);
            assertThat(item.isFolder).isEqualTo(expected.isBrowsable());
            if (item.isFolder) {
                Folder folder = item.folder;
                assertThat(folder).isNotNull();
                assertThat(folder.isPlayable).isFalse();
                Assert.assertEquals(expected.getDescription().getMediaId(), folder.mediaId);
                Assert.assertEquals(expected.getDescription().getTitle().toString(), folder.title);
                assertThat(folder.mediaId).isEqualTo(expected.getDescription().getMediaId());
                assertThat(folder.title).isEqualTo(expected.getDescription().getTitle().toString());
            } else {
                Metadata song = item.song;
                assertThat(song).isNotNull();
                Assert.assertEquals(expected.getDescription().getMediaId(), song.mediaId);
                Assert.assertEquals(expected.getDescription().getTitle().toString(), song.title);
                Assert.assertEquals(
                        expected.getDescription().getSubtitle().toString(), song.artist);
                Assert.assertEquals(
                        expected.getDescription().getDescription().toString(), song.album);
                assertThat(song.mediaId).isEqualTo(expected.getDescription().getMediaId());
                assertThat(song.title).isEqualTo(expected.getDescription().getTitle().toString());
                assertThat(song.artist)
                        .isEqualTo(expected.getDescription().getSubtitle().toString());
                assertThat(song.album)
                        .isEqualTo(expected.getDescription().getDescription().toString());
                if (expected.getDescription().getIconBitmap() != null) {
                    assertThat(song.image).isNotNull();
                    Bitmap expectedBitmap = expected.getDescription().getIconBitmap();
@@ -415,7 +414,7 @@ public class BrowserPlayerWrapperTest {
                } else if (expected.getDescription().getIconUri() != null) {
                    assertThat(mTestBitmap.sameAs(song.image.getImage())).isTrue();
                } else {
                    Assert.assertEquals(null, song.image);
                    assertThat(song.image).isNull();
                }
            }
        }
Loading