gtest_motor_controller_node.cpp
Go to the documentation of this file.
00001 
00024 #include "gtest/gtest.h"
00025 #include "mcdc3006s_mock.h"
00026 #include "motor_controller_node.h"
00027 
00028 using testing::_;
00029 using testing::DoAll;
00030 using testing::SetArgumentPointee;
00031 using testing::AnyNumber;
00032 using testing::Return;
00033 
00034 class CallbackCounter : public testing::Test {
00035     protected:
00036         // Remember that SetUp() is run immediately before a test starts.
00037         virtual void SetUp()
00038         {
00039             _client = _nh.serviceClient<maggie_motor_controller_msgs::MoveAbsPos>("move_abs_pos");
00040         }
00041 
00042         // TearDown() is invoked immediately after a test finishes.
00043         virtual void TearDown()
00044         {
00045             _client.shutdown();
00046         }
00047 
00048         ros::NodeHandle _nh;
00049 
00050         ros::ServiceClient _client;
00051 
00052     public:
00053 
00054 };
00055 
00056 // Test set_max_pos() method.
00057 TEST_F(CallbackCounter, TestCounter_Node)
00058 {
00059 //    std_msgs::Int16 msg;
00060 //    ros::Rate loop_rate(1);
00061 //    msg.data = 0;
00062 //
00063 //    counter_pub_.publish(msg);
00064 //    loop_rate.sleep();      // Give some time the message to arrive
00065 //    ros::spinOnce();
00066 //    EXPECT_EQ(0, this->get_count());
00067 //
00068 //    counter_pub_.publish(msg);
00069 //    loop_rate.sleep();
00070 //    ros::spinOnce();
00071 //    EXPECT_EQ(1, this->get_count());
00072 //
00073 //    counter_pub_.publish(msg);
00074 //    loop_rate.sleep();
00075 //    ros::spinOnce();
00076 //    EXPECT_EQ(2, this->get_count());
00077 }
00078 
00079 // Test set_max_pos()
00080 TEST(MotorControllerNode, SetMaxPos)
00081 {
00082     MockMcdc3006s mock;
00083 
00084 //    EXPECT_CALL(mock, config())
00085 //        .Times(1)
00086 //        .WillOnce(Return(0));
00087 //    EXPECT_CALL(mock, readDIOs(_, _))
00088 //        .Times(1)
00089 //        .WillOnce(Return(0));
00090 //    EXPECT_CALL(mock, readAIs(_, _, _))
00091 //        .Times(2)
00092 //        .WillRepeatedly(Return(0));
00093 //    EXPECT_CALL(mock, readDirectionDs(_))
00094 //        .Times(1)
00095 //        .WillOnce(Return(0));
00096 //
00097 //    LabjackNode labjack_node(&mock);
00098 //
00099 //    // success
00100 //    EXPECT_CALL(mock, readDIOs(_, _))
00101 //        .Times(1)
00102 //        .WillOnce(Return(0));
00103 //
00104 //    ASSERT_FLOAT_EQ(0, labjack_node.getStateDs());
00105 //
00106 //    // fail
00107 //    EXPECT_CALL(mock, readDIOs(_, _))
00108 //        .Times(1)
00109 //        .WillOnce(Return(-1));
00110 //
00111 //    ASSERT_EQ(-1, labjack_node.getStateDs());
00112 }
00113 
00115 
00116 int main(int argc, char **argv)
00117 {
00118     ros::init(argc, argv, "motor_controller_node_tests");
00119 
00120     testing::InitGoogleMock(&argc, argv);
00121 
00122     return RUN_ALL_TESTS();
00123 }


maggie_motor_controller
Author(s): Raul Perula-Martinez
autogenerated on Thu Apr 23 2015 22:19:04