mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[wpilib] Allow SendableCameraWrappers to take arbitrary URLs (#3850)
Useful for adding cameras that are streamed from a coprocessor Co-authored-by: Peter Johnson <johnson.peter@gmail.com> Co-authored-by: Sam Carlberg <sam.carlberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package edu.wpi.first.wpilibj.shuffleboard;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SendableCameraWrapperTest {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
NetworkTableInstance.getDefault().deleteAllEntries();
|
||||
SendableCameraWrapper.clearWrappers();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void tearDown() {
|
||||
NetworkTableInstance.getDefault().deleteAllEntries();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullCameraName() {
|
||||
assertThrows(NullPointerException.class, () -> SendableCameraWrapper.wrap(null, ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEmptyCameraName() {
|
||||
assertThrows(IllegalArgumentException.class, () -> SendableCameraWrapper.wrap("", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullUrlArray() {
|
||||
assertThrows(
|
||||
NullPointerException.class, () -> SendableCameraWrapper.wrap("name", (String[]) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullUrlInArray() {
|
||||
assertThrows(NullPointerException.class, () -> SendableCameraWrapper.wrap("name", "url", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEmptyUrlArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> SendableCameraWrapper.wrap("name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUrlsAddedToNt() {
|
||||
SendableCameraWrapper.wrap("name", "url1", "url2");
|
||||
assertArrayEquals(
|
||||
new String[] {"url1", "url2"},
|
||||
NetworkTableInstance.getDefault()
|
||||
.getEntry("/CameraPublisher/name/streams")
|
||||
.getValue()
|
||||
.getStringArray());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user