blob: ccfb796419fac8881a63556720b4dbc920c91e91 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* 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 <Jaguar.h>
9#include <PowerDistributionPanel.h>
10#include <Talon.h>
11#include <Timer.h>
12#include <Victor.h>
13#include "gtest/gtest.h"
14#include "TestBench.h"
15
16static const double kMotorTime = 0.25;
17
18class PowerDistributionPanelTest : public testing::Test {
19 protected:
20 PowerDistributionPanel *m_pdp;
21 Talon *m_talon;
22 Victor *m_victor;
23 Jaguar *m_jaguar;
24
25 virtual void SetUp() override {
26 m_pdp = new PowerDistributionPanel();
27 m_talon = new Talon(TestBench::kTalonChannel);
28 m_victor = new Victor(TestBench::kVictorChannel);
29 m_jaguar = new Jaguar(TestBench::kJaguarChannel);
30 }
31
32 virtual void TearDown() override {
33 delete m_pdp;
34 delete m_talon;
35 delete m_victor;
36 delete m_jaguar;
37 }
38};
39
40/**
41 * Test if the current changes when the motor is driven using a talon
42 */
43TEST_F(PowerDistributionPanelTest, CheckCurrentTalon) {
44 Wait(kMotorTime);
45
46 /* The Current should be 0 */
47 EXPECT_FLOAT_EQ(0, m_pdp->GetCurrent(TestBench::kTalonPDPChannel))
48 << "The Talon current was non-zero";
49
50 /* Set the motor to full forward */
51 m_talon->Set(1.0);
52 Wait(kMotorTime);
53
54 /* The current should now be positive */
55 ASSERT_GT(m_pdp->GetCurrent(TestBench::kTalonPDPChannel), 0)
56 << "The Talon current was not positive";
57}
58