2014-08-08 17:05:49 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-08-23 22:06:13 -07:00
|
|
|
/* Copyright (c) 2014-2017 FIRST. 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
|
|
|
|
2017-08-27 00:11:52 -07:00
|
|
|
#include <llvm/raw_ostream.h>
|
|
|
|
|
|
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) {
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::outs() << "NotifierTest...\n";
|
2015-06-25 15:07:55 -04:00
|
|
|
notifierCounter = 0;
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::outs() << "notifier(notifierHandler, nullptr)...\n";
|
2015-06-23 04:49:51 -07:00
|
|
|
Notifier notifier(notifierHandler, nullptr);
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::outs() << "Start Periodic...\n";
|
2015-06-25 15:07:55 -04:00
|
|
|
notifier.StartPeriodic(1.0);
|
|
|
|
|
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::outs() << "Wait...\n";
|
2015-06-25 15:07:55 -04:00
|
|
|
Wait(10.5);
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::outs() << "...Wait\n";
|
2015-06-25 15:07:55 -04:00
|
|
|
|
|
|
|
|
EXPECT_EQ(10u, notifierCounter) << "Received " << notifierCounter
|
|
|
|
|
<< " notifications in 10.5 seconds";
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::outs() << "Received " << notifierCounter
|
|
|
|
|
<< " notifications in 10.5 seconds";
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2017-06-30 22:33:43 -04:00
|
|
|
llvm::outs() << "...NotifierTest\n";
|
2014-08-08 17:05:49 -04:00
|
|
|
}
|