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

Commit 3aa2195c authored by William Escande's avatar William Escande
Browse files

Migration Assert to Truth: assertTrue

Bug: 311772251
Test: atest BluetoothInstrumentationTests
Flag: TEST_ONLY
Change-Id: I8f5d19d33bbcf31f56ddd52128eb76ba8e3c67b2
parent c6d73e6b
Loading
Loading
Loading
Loading
+8 −19
Original line number Diff line number Diff line
@@ -15,10 +15,11 @@
 */
package com.android.bluetooth;

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

import androidx.test.filters.MediumTest;
import androidx.test.runner.AndroidJUnit4;

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

@@ -30,35 +31,23 @@ import java.io.IOException;
@RunWith(AndroidJUnit4.class)
public class FileSystemWriteTest {
    @Test
    public void testBluetoothDirWrite() {
        try {
    public void testBluetoothDirWrite() throws IOException {
            File file = new File("/data/misc/bluetooth/test.file");
            Assert.assertTrue("File not created", file.createNewFile());
        assertThat(file.createNewFile()).isTrue();
            file.delete();
        } catch (IOException e) {
            Assert.fail("Exception creating file /data/misc/bluetooth/test.file: " + e);
        }
    }

    @Test
    public void testBluedroidDirWrite() {
        try {
    public void testBluedroidDirWrite() throws IOException {
            File file = new File("/data/misc/bluedroid/test.file");
            Assert.assertTrue("File not created", file.createNewFile());
        assertThat(file.createNewFile()).isTrue();
            file.delete();
        } catch (IOException e) {
            Assert.fail("Exception creating file /data/misc/bluedroid/test.file: " + e);
        }
    }

    @Test
    public void testBluetoothLogsDirWrite() {
        try {
    public void testBluetoothLogsDirWrite() throws IOException {
            File file = new File("/data/misc/bluetooth/logs/test.file");
            Assert.assertTrue("File not created", file.createNewFile());
        assertThat(file.createNewFile()).isTrue();
            file.delete();
        } catch (IOException e) {
            Assert.fail("Exception creating file /data/misc/bluetooth/logs/test.file: " + e);
        }
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public class TestUtils {
     * @return {@link BluetoothDevice} test device for the device ID
     */
    public static BluetoothDevice getTestDevice(BluetoothAdapter bluetoothAdapter, int id) {
        Assert.assertTrue(id <= 0xFF);
        assertThat(id).isAtMost(0xFF);
        assertThat(bluetoothAdapter).isNotNull();
        BluetoothDevice testDevice =
                bluetoothAdapter.getRemoteDevice(String.format("00:01:02:03:04:%02X", id));
@@ -278,7 +278,7 @@ public class TestUtils {
     * <pre>{@code
     * TestUtils.runOnMainSync(new Runnable() {
     *       public void run() {
     *           Assert.assertTrue(mA2dpService.stop());
     *           assertThat(mA2dpService.stop()).isTrue();
     *       }
     *   });
     * }</pre>
+2 −2
Original line number Diff line number Diff line
@@ -411,9 +411,9 @@ public class BrowserPlayerWrapperTest {
                if (expected.getDescription().getIconBitmap() != null) {
                    assertThat(song.image).isNotNull();
                    Bitmap expectedBitmap = expected.getDescription().getIconBitmap();
                    Assert.assertTrue(expectedBitmap.sameAs(song.image.getImage()));
                    assertThat(expectedBitmap.sameAs(song.image.getImage())).isTrue();
                } else if (expected.getDescription().getIconUri() != null) {
                    Assert.assertTrue(mTestBitmap.sameAs(song.image.getImage()));
                    assertThat(mTestBitmap.sameAs(song.image.getImage())).isTrue();
                } else {
                    Assert.assertEquals(null, song.image);
                }
+6 −6
Original line number Diff line number Diff line
@@ -186,8 +186,8 @@ public class MediaPlayerWrapperTest {
    public void testIsReady() {
        MediaPlayerWrapper wrapper =
                MediaPlayerWrapperFactory.wrap(mMockContext, mMockController, mThread.getLooper());
        Assert.assertTrue(wrapper.isPlaybackStateReady());
        Assert.assertTrue(wrapper.isMetadataReady());
        assertThat(wrapper.isPlaybackStateReady()).isTrue();
        assertThat(wrapper.isMetadataReady()).isTrue();

        // Test isPlaybackStateReady() is false when the playback state is null
        doReturn(null).when(mMockController).getPlaybackState();
@@ -195,7 +195,7 @@ public class MediaPlayerWrapperTest {

        // Restore the old playback state
        doReturn(mTestState.build()).when(mMockController).getPlaybackState();
        Assert.assertTrue(wrapper.isPlaybackStateReady());
        assertThat(wrapper.isPlaybackStateReady()).isTrue();

        // Test isMetadataReady() is false when the metadata is null
        doReturn(null).when(mMockController).getMetadata();
@@ -203,7 +203,7 @@ public class MediaPlayerWrapperTest {

        // Restore the old metadata
        doReturn(mTestMetadata.build()).when(mMockController).getMetadata();
        Assert.assertTrue(wrapper.isMetadataReady());
        assertThat(wrapper.isMetadataReady()).isTrue();
    }

    /*
@@ -215,8 +215,8 @@ public class MediaPlayerWrapperTest {
        // Create the wrapper object and register the looper with the timeout handler
        MediaPlayerWrapper wrapper =
                MediaPlayerWrapperFactory.wrap(mMockContext, mMockController, mThread.getLooper());
        Assert.assertTrue(wrapper.isPlaybackStateReady());
        Assert.assertTrue(wrapper.isMetadataReady());
        assertThat(wrapper.isPlaybackStateReady()).isTrue();
        assertThat(wrapper.isMetadataReady()).isTrue();
        wrapper.registerCallback(mTestCbs);

        // Create a new MediaController that has different metadata than the previous controller
+1 −2
Original line number Diff line number Diff line
@@ -42,7 +42,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;
@@ -261,7 +260,7 @@ public class MetadataTest {
        assertThat(metadata.numTracks).isEqualTo(numTracks);
        assertThat(metadata.genre).isEqualTo(genre);
        assertThat(metadata.duration).isEqualTo(duration);
        Assert.assertTrue(Image.sameAs(metadata.image, image));
        assertThat(Image.sameAs(metadata.image, image)).isTrue();
    }

    /** Make sure the media ID we set is transferred to Metadata object we build */
Loading