blob: 7c5db9edb451d441da1ec8480403b56ce442435c [file] [log] [blame]
/*
* Copyright (C) 2015 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 android.bluetooth.cts;
import android.bluetooth.le.ScanRecord;
import junit.framework.Assert;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
/**
* Utility class for Bluetooth CTS test.
*/
class TestUtils {
/**
* Utility method to call hidden ScanRecord.parseFromBytes method.
*/
static ScanRecord parseScanRecord(byte[] bytes) {
Class<?> scanRecordClass = ScanRecord.class;
try {
Method method = scanRecordClass.getDeclaredMethod("parseFromBytes", byte[].class);
return (ScanRecord)method.invoke(null, bytes);
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
return null;
}
}
// Assert two byte arrays are equal.
static void assertArrayEquals(byte[] expected, byte[] actual) {
if (!Arrays.equals(expected, actual)) {
Assert.fail("expected:<" + Arrays.toString(expected) +
"> but was:<" + Arrays.toString(actual) + ">");
}
}
}