2020-12-26 14:12:05 -08:00
|
|
|
// 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.
|
2014-08-08 17:05:49 -04:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/Notifier.h" // NOLINT(build/include_order)
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2021-05-31 10:21:34 -07:00
|
|
|
#include <fmt/core.h>
|
2017-08-27 00:11:52 -07:00
|
|
|
|
2016-05-25 22:38:11 -07:00
|
|
|
#include "TestBench.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/Timer.h"
|
2016-09-05 13:55:31 -07:00
|
|
|
#include "gtest/gtest.h"
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2014-08-08 17:05:49 -04:00
|
|
|
unsigned notifierCounter;
|
|
|
|
|
|
2020-12-28 12:58:06 -08:00
|
|
|
void notifierHandler(void*) {
|
|
|
|
|
notifierCounter++;
|
|
|
|
|
}
|
2014-08-08 17:05:49 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test if the Wait function works
|
|
|
|
|
*/
|
|
|
|
|
TEST(NotifierTest, DISABLED_TestTimerNotifications) {
|
2021-05-31 10:21:34 -07:00
|
|
|
fmt::print("NotifierTest...\n");
|
2015-06-25 15:07:55 -04:00
|
|
|
notifierCounter = 0;
|
2021-05-31 10:21:34 -07:00
|
|
|
fmt::print("notifier(notifierHandler, nullptr)...\n");
|
|
|
|
|
frc::Notifier notifier(notifierHandler, nullptr);
|
|
|
|
|
fmt::print("Start Periodic...\n");
|
2021-05-28 22:06:59 -07:00
|
|
|
notifier.StartPeriodic(1_s);
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2021-05-31 10:21:34 -07:00
|
|
|
fmt::print("Wait...\n");
|
|
|
|
|
frc::Wait(10.5_s);
|
|
|
|
|
fmt::print("...Wait\n");
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2017-11-11 22:09:51 -08:00
|
|
|
EXPECT_EQ(10u, notifierCounter)
|
|
|
|
|
<< "Received " << notifierCounter << " notifications in 10.5 seconds";
|
2021-05-31 10:21:34 -07:00
|
|
|
fmt::print("Received {} notifications in 10.5 seconds", notifierCounter);
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2021-05-31 10:21:34 -07:00
|
|
|
fmt::print("...NotifierTest\n");
|
2014-08-08 17:05:49 -04:00
|
|
|
}
|