2014-08-08 17:05:49 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-01-01 01:05:57 -07:00
|
|
|
/* Copyright (c) FIRST 2014-2017. All Rights Reserved. */
|
2014-08-08 17:05:49 -04:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2016-09-25 16:50:13 -07:00
|
|
|
#include "Notifier.h" // NOLINT(build/include_order)
|
2016-05-25 22:38:11 -07:00
|
|
|
|
|
|
|
|
#include "TestBench.h"
|
|
|
|
|
#include "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;
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
void notifierHandler(void*) { notifierCounter++; }
|
2014-08-08 17:05:49 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test if the Wait function works
|
|
|
|
|
*/
|
|
|
|
|
TEST(NotifierTest, DISABLED_TestTimerNotifications) {
|
2015-06-25 15:07:55 -04:00
|
|
|
std::cout << "NotifierTest..." << std::endl;
|
|
|
|
|
notifierCounter = 0;
|
2015-06-23 04:49:51 -07:00
|
|
|
std::cout << "notifier(notifierHandler, nullptr)..." << std::endl;
|
|
|
|
|
Notifier notifier(notifierHandler, nullptr);
|
2015-06-25 15:07:55 -04:00
|
|
|
std::cout << "Start Periodic..." << std::endl;
|
|
|
|
|
notifier.StartPeriodic(1.0);
|
|
|
|
|
|
|
|
|
|
std::cout << "Wait..." << std::endl;
|
|
|
|
|
Wait(10.5);
|
|
|
|
|
std::cout << "...Wait" << std::endl;
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(10u, notifierCounter) << "Received " << notifierCounter
|
|
|
|
|
<< " notifications in 10.5 seconds";
|
|
|
|
|
std::cout << "Received " << notifierCounter
|
|
|
|
|
<< " notifications in 10.5 seconds";
|
|
|
|
|
|
|
|
|
|
std::cout << "...NotifierTest" << std::endl;
|
2014-08-08 17:05:49 -04:00
|
|
|
}
|