Logo ROOT   6.10/09
Reference Guide
TQObjectTests.cxx
Go to the documentation of this file.
1 #include "gtest/gtest.h"
2 #include "gmock/gmock.h"
3 
4 #include "Rtypes.h"
5 #include "TQObject.h"
6 #include "TQConnection.h"
7 
8 #include "RQ_OBJECT.h"
9 
10 #define Stringify(s) Stringifyx(s)
11 #define Stringifyx(s) #s
12 
13 // The interpreter needs to know about RQ_OBJECTTester and using this trick avoids moving this non-reusable class into
14 // its own header file.
15 #define DICT_CLASS \
16  class RQ_OBJECTTester : public TQObject { \
17  /* This will expand, adding signal/slot support to this class */ \
18  RQ_OBJECT("RQ_OBJECTTester"); \
19  Int_t fValue = 0; \
20  \
21  public: \
22  void SetValue(Int_t value) \
23  { \
24  /* to prevent infinite looping in the case of cyclic connections */ \
25  if (value != fValue) { \
26  fValue = value; \
27  Emit("SetValue(Int_t)", fValue); \
28  } \
29  } \
30  void PrintValue() const { printf("value=%d\n", fValue); } \
31  Int_t GetValue() const { return fValue; } \
32  };
33 
35 
36 TEST(TQObject, Emit)
37 {
38  gInterpreter->ProcessLine(Stringify(DICT_CLASS));
39  RQ_OBJECTTester a;
40  RQ_OBJECTTester b;
41  a.Connect("SetValue(Int_t)", "RQ_OBJECTTester", &b, "SetValue(Int_t)");
42 
43  EXPECT_EQ(0, b.GetValue());
44 
45  a.SetValue(1);
46  EXPECT_EQ(1, b.GetValue());
47 }
TEST(TQObject, Emit)
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:49
TArc * a
Definition: textangle.C:12
#define gInterpreter
Definition: TInterpreter.h:499
#define Stringify(s)
#define DICT_CLASS
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630