Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */ |
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include "frc/Notifier.h" // NOLINT(build/include_order) |
| 9 | |
| 10 | #include <wpi/raw_ostream.h> |
| 11 | |
| 12 | #include "TestBench.h" |
| 13 | #include "frc/Timer.h" |
| 14 | #include "gtest/gtest.h" |
| 15 | |
| 16 | using namespace frc; |
| 17 | |
| 18 | unsigned notifierCounter; |
| 19 | |
| 20 | void notifierHandler(void*) { notifierCounter++; } |
| 21 | |
| 22 | /** |
| 23 | * Test if the Wait function works |
| 24 | */ |
| 25 | TEST(NotifierTest, DISABLED_TestTimerNotifications) { |
| 26 | wpi::outs() << "NotifierTest...\n"; |
| 27 | notifierCounter = 0; |
| 28 | wpi::outs() << "notifier(notifierHandler, nullptr)...\n"; |
| 29 | Notifier notifier(notifierHandler, nullptr); |
| 30 | wpi::outs() << "Start Periodic...\n"; |
| 31 | notifier.StartPeriodic(1.0); |
| 32 | |
| 33 | wpi::outs() << "Wait...\n"; |
| 34 | Wait(10.5); |
| 35 | wpi::outs() << "...Wait\n"; |
| 36 | |
| 37 | EXPECT_EQ(10u, notifierCounter) |
| 38 | << "Received " << notifierCounter << " notifications in 10.5 seconds"; |
| 39 | wpi::outs() << "Received " << notifierCounter |
| 40 | << " notifications in 10.5 seconds"; |
| 41 | |
| 42 | wpi::outs() << "...NotifierTest\n"; |
| 43 | } |