Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 2 | /* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 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 <DriverStation.h> |
| 9 | #include <LiveWindow/LiveWindow.h> |
| 10 | #include <Timer.h> |
| 11 | #include "gtest/gtest.h" |
| 12 | |
| 13 | class TestEnvironment : public testing::Environment { |
| 14 | bool m_alreadySetUp = false; |
| 15 | |
| 16 | public: |
| 17 | virtual void SetUp() override { |
| 18 | /* Only set up once. This allows gtest_repeat to be used to |
| 19 | automatically repeat tests. */ |
| 20 | if (m_alreadySetUp) return; |
| 21 | m_alreadySetUp = true; |
| 22 | |
| 23 | if (!HALInitialize()) { |
| 24 | std::cerr << "FATAL ERROR: HAL could not be initialized" << std::endl; |
| 25 | exit(-1); |
| 26 | } |
| 27 | |
| 28 | /* This sets up the network communications library to enable the driver |
| 29 | station. After starting network coms, it will loop until the driver |
| 30 | station returns that the robot is enabled, to ensure that tests |
| 31 | will be able to run on the hardware. */ |
| 32 | HALNetworkCommunicationObserveUserProgramStarting(); |
| 33 | LiveWindow::GetInstance()->SetEnabled(false); |
| 34 | |
| 35 | std::cout << "Waiting for enable" << std::endl; |
| 36 | |
| 37 | while (!DriverStation::GetInstance().IsEnabled()) { |
| 38 | Wait(0.1); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | virtual void TearDown() override {} |
| 43 | }; |
| 44 | |
| 45 | testing::Environment *const environment = |
| 46 | testing::AddGlobalTestEnvironment(new TestEnvironment); |