RTXI  2.4
The Real-Time eXperiment Interface Documentation
event_tests.cpp
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  */
19 
20 #include <event_tests.h>
21 #include <gmock/gmock.h>
22 #include <event.h>
23 
24 TEST_F(EventObjectTest, ParameterTests)
25 {
26  const char *TEST_EVENT_NAME = "EventManagerTest - postEvent : Test Event";
27  const char *TEST_EVENT_PARAM = "TEST_PARAM";
28  bool *TEST_EVENT_PARAM_VALUE;
29  event = new Event::Object(TEST_EVENT_NAME);
30  event->setParam(TEST_EVENT_PARAM, TEST_EVENT_PARAM_VALUE);
31  ASSERT_EQ(event->getName(), TEST_EVENT_NAME);
32  ASSERT_EQ(event->getParam(TEST_EVENT_PARAM), TEST_EVENT_PARAM_VALUE);
33 }
34 
35 
36 TEST_F(EventManagerTest, getInstance)
37 {
38  event_manager = Event::Manager::getInstance();
39  EXPECT_EQ(event_manager, Event::Manager::getInstance());
40  EXPECT_EQ(event_manager, event_manager->getInstance());
41 }
42 
44 {
45  event_manager = Event::Manager::getInstance();
46  const char *TEST_EVENT_NAME = "EventManagerTest - postEvent : Test Event";
47  MockEventObject event_object(TEST_EVENT_NAME);
48  MockEventHandler event_handler;
49  MockEventRTHandler event_rthandler;
50  // Make sure post event always calls the right handler
51  EXPECT_CALL(event_handler, receiveEvent).Times(::testing::AtLeast(1));
52  EXPECT_CALL(event_rthandler, receiveEventRT).Times(::testing::Exactly(0));
53  event_manager->postEvent(&event_object);
54 }
55 
56 TEST_F(EventManagerTest, postEventRT)
57 {
58  event_manager = Event::Manager::getInstance();
59  const char *TEST_EVENT_NAME = "EventManagerTest - postEventRT : Test Event";
60  MockEventObject event_object(TEST_EVENT_NAME);
61  MockEventRTHandler event_rthandler;
62  MockEventHandler event_handler;
63  // Make sure post event always calls the right handler
64  EXPECT_CALL(event_rthandler, receiveEventRT).Times(::testing::AtLeast(1));
65  EXPECT_CALL(event_handler, receiveEvent).Times(::testing::Exactly(0));
66  event_manager->postEventRT(&event_object);
67 }
68 
MockEventRTHandler
Definition: event_tests.h:64
event_tests.h
Event::Manager::getInstance
static Manager * getInstance(void)
Definition: event.cpp:149
TEST_F
TEST_F(EventObjectTest, ParameterTests)
Definition: event_tests.cpp:24
EventManagerTest
Definition: event_tests.h:37
MockEventHandler
Definition: event_tests.h:58
event.h
EventObjectTest
Definition: event_tests.h:28
Event::Object
Definition: event.h:128
MockEventObject
Definition: event_tests.h:47