Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id "cpp"
id "com.diffplug.spotless" version "8.1.0"
id "org.wpilib.WPILibRepositoriesPlugin" version "2027.0.0"
id 'org.wpilib.NativeUtils' version '2027.7.1' apply false
id 'org.wpilib.NativeUtils' version '2027.69.0' apply false
id 'org.wpilib.DeployUtils' version '2027.1.0' apply false
id 'org.photonvision.tools.WpilibTools' version 'v5.0.1'
id 'com.google.protobuf' version '0.9.5' apply false
Expand Down
2 changes: 1 addition & 1 deletion photon-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ model {
nativeUtils.useRequiredLibrary(it, "cscore_shared")
nativeUtils.useRequiredLibrary(it, "cameraserver_shared")
nativeUtils.useRequiredLibrary(it, "wpilib_shared")
nativeUtils.useRequiredLibrary(it, "googletest_static")
nativeUtils.useRequiredLibrary(it, "catch2_static")
nativeUtils.useRequiredLibrary(it, "apriltag_shared")
nativeUtils.useRequiredLibrary(it, "opencv_shared")
}
Expand Down
46 changes: 23 additions & 23 deletions photon-lib/src/test/native/cpp/PhotonCameraTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <string>
#include <vector>

#include <catch2/catch_test_macros.hpp>
#include <fmt/ranges.h>
#include <gtest/gtest.h>
#include <net/TimeSyncClient.h>
#include <net/TimeSyncServer.h>
#include <photon/PhotonCamera.h>
Expand All @@ -36,7 +36,7 @@
#include <wpi/simulation/AlertSim.hpp>
#include <wpi/smartdashboard/SmartDashboard.hpp>

TEST(TimeSyncProtocolTest, Smoketest) {
TEST_CASE("TimeSyncProtocolTest Smoketest", "[timesync]") {
using namespace wpi::tsp;
using namespace std::chrono_literals;

Expand All @@ -52,15 +52,15 @@ TEST(TimeSyncProtocolTest, Smoketest) {

// give us time to warm up
if (i > 5) {
EXPECT_TRUE(m.rtt2 > 0);
EXPECT_TRUE(m.pongsReceived > 0);
CHECK(m.rtt2 > 0);
CHECK(m.pongsReceived > 0);
}
}

client.Stop();
}

TEST(PhotonCameraTest, Alerts) {
TEST_CASE("PhotonCameraTest Alerts", "[photonlib]") {
// GIVEN a local-only NT instance
auto inst = wpi::nt::NetworkTableInstance::GetDefault();
inst.StopClient();
Expand All @@ -73,7 +73,7 @@ TEST(PhotonCameraTest, Alerts) {

// AND a PhotonCamera that is disconnected
photon::PhotonCamera camera(inst, cameraName);
EXPECT_FALSE(camera.IsConnected());
CHECK_FALSE(camera.IsConnected());
std::string disconnectedCameraString =
"PhotonCamera '" + cameraName + "' is disconnected.";

Expand All @@ -95,11 +95,11 @@ TEST(PhotonCameraTest, Alerts) {

// The alert state will be set (hard-coded here)
auto alerts = getActiveAlerts();
EXPECT_TRUE(std::any_of(alerts.begin(), alerts.end(),
[&disconnectedCameraString](
const wpi::sim::AlertSim::AlertInfo& alert) {
return alert.text == disconnectedCameraString;
}));
CHECK(std::any_of(alerts.begin(), alerts.end(),
[&disconnectedCameraString](
const wpi::sim::AlertSim::AlertInfo& alert) {
return alert.text == disconnectedCameraString;
}));

std::this_thread::sleep_for(std::chrono::milliseconds(20));
}
Expand All @@ -120,20 +120,20 @@ TEST(PhotonCameraTest, Alerts) {

// THEN the camera isn't disconnected
auto alerts = getActiveAlerts();
EXPECT_TRUE(std::none_of(alerts.begin(), alerts.end(),
[&disconnectedCameraString](
const wpi::sim::AlertSim::AlertInfo& alert) {
return alert.text == disconnectedCameraString;
}));
CHECK(std::none_of(alerts.begin(), alerts.end(),
[&disconnectedCameraString](
const wpi::sim::AlertSim::AlertInfo& alert) {
return alert.text == disconnectedCameraString;
}));

// AND the alert string looks like a timesync warning
EXPECT_EQ(1, std::count_if(
alerts.begin(), alerts.end(),
[](const wpi::sim::AlertSim::AlertInfo& alert) {
return alert.text.find(
"is not connected to the TimeSyncServer") !=
std::string::npos;
}));
CHECK(1 == std::count_if(
alerts.begin(), alerts.end(),
[](const wpi::sim::AlertSim::AlertInfo& alert) {
return alert.text.find(
"is not connected to the TimeSyncServer") !=
std::string::npos;
}));

std::this_thread::sleep_for(std::chrono::milliseconds(20));
}
Expand Down
Loading
Loading