Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2014. 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 <Notifier.h> |
| 9 | #include <Timer.h> |
| 10 | #include "gtest/gtest.h" |
| 11 | #include "TestBench.h" |
| 12 | |
| 13 | unsigned notifierCounter; |
| 14 | |
| 15 | void notifierHandler(void *) { notifierCounter++; } |
| 16 | |
| 17 | /** |
| 18 | * Test if the Wait function works |
| 19 | */ |
| 20 | TEST(NotifierTest, DISABLED_TestTimerNotifications) { |
| 21 | std::cout << "NotifierTest..." << std::endl; |
| 22 | notifierCounter = 0; |
| 23 | std::cout << "notifier(notifierHandler, nullptr)..." << std::endl; |
| 24 | Notifier notifier(notifierHandler, nullptr); |
| 25 | std::cout << "Start Periodic..." << std::endl; |
| 26 | notifier.StartPeriodic(1.0); |
| 27 | |
| 28 | std::cout << "Wait..." << std::endl; |
| 29 | Wait(10.5); |
| 30 | std::cout << "...Wait" << std::endl; |
| 31 | |
| 32 | EXPECT_EQ(10u, notifierCounter) << "Received " << notifierCounter |
| 33 | << " notifications in 10.5 seconds"; |
| 34 | std::cout << "Received " << notifierCounter |
| 35 | << " notifications in 10.5 seconds"; |
| 36 | |
| 37 | std::cout << "...NotifierTest" << std::endl; |
| 38 | } |