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
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/raw_ostream.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
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
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) {
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::outs() << "NotifierTest...\n";
|
2015-06-25 15:07:55 -04:00
|
|
|
notifierCounter = 0;
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::outs() << "notifier(notifierHandler, nullptr)...\n";
|
2015-06-23 04:49:51 -07:00
|
|
|
Notifier notifier(notifierHandler, nullptr);
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::outs() << "Start Periodic...\n";
|
2015-06-25 15:07:55 -04:00
|
|
|
notifier.StartPeriodic(1.0);
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::outs() << "Wait...\n";
|
2015-06-25 15:07:55 -04:00
|
|
|
Wait(10.5);
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::outs() << "...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";
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::outs() << "Received " << notifierCounter
|
|
|
|
|
<< " notifications in 10.5 seconds";
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::outs() << "...NotifierTest\n";
|
2014-08-08 17:05:49 -04:00
|
|
|
}
|