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

Commit a8b211dd authored by Ömer Faruk Yılmaz's avatar Ömer Faruk Yılmaz
Browse files

Add CallbackInfoTest

Bug: 237467631
Test: atest CallbackInfoTest
Change-Id: I0e53e6ef24ea2be8b1e2457beed2d4985a4f29a2
(cherry picked from commit d6664215)
parent d59ab29d
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.gatt;

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

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

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

import java.util.Arrays;

/**
 * Test cases for {@link CallbackInfo}.
 */
@SmallTest
@RunWith(AndroidJUnit4.class)
public class CallbackInfoTest {

    @Test
    public void callbackInfoBuilder() {
        String address = "TestAddress";
        int status = 0;
        int handle = 1;
        byte[] value = "Test Value Byte Array".getBytes();

        CallbackInfo callbackInfo = new CallbackInfo.Builder(address, status)
                .setHandle(handle)
                .setValue(value)
                .build();

        assertThat(callbackInfo.address).isEqualTo(address);
        assertThat(callbackInfo.status).isEqualTo(status);
        assertThat(callbackInfo.handle).isEqualTo(handle);
        assertThat(Arrays.equals(callbackInfo.value, value)).isTrue();
    }
}