ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tutorials
gui
guitest_playback.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This macro plays a recorded ROOT session showing how to perform various interactive GUI operations with the guitest.C macro
4
/// While replaying the session, several temporary macros (guitest0xx.C) macros will be saved.
5
/// These files will be later on compared with some reference values to verify the validity of different parts of the test.
6
///
7
/// \macro_code
8
///
9
/// \author Bertrand Bellenot
10
11
#include "
TSystem.h
"
12
#include "
TSystemFile.h
"
13
#include "
TRecorder.h
"
14
#include "
Riostream.h
"
15
16
// count characters in the file, skipping cr/lf
17
Int_t
file_size
(
const
char
*filename)
18
{
19
FILE *lunin;
20
Int_t
c
, wc = 0;
21
22
lunin = fopen(filename,
"rb"
);
23
if
(lunin == 0)
return
-1;
24
while
(!feof(lunin)) {
25
c = fgetc(lunin);
26
if
(c != 0x0d && c != 0x0a)
27
wc++;
28
}
29
fclose(lunin);
30
return
wc;
31
}
32
33
// main function
34
void
guitest_playback()
35
{
36
Int_t
i;
37
Int_t
guitest_ref[11], guitest_err[11], guitest_size[11];
38
39
gBenchmark
->
Start
(
"guitest_playback"
);
40
41
// first delete old files, if any
42
for
(i=0;i<11;++i) {
43
gSystem
->
Unlink
(
TString::Format
(
"guitest%03d.C"
, i+1));
44
}
45
46
TRecorder
r
(
"http://root.cern.ch/files/guitest_playback.root"
);
47
48
// wait for the recorder to finish the replay
49
while
(
r
.GetState() ==
TRecorder::kReplaying
) {
50
gSystem
->
ProcessEvents
();
51
gSystem
->
Sleep
(1);
52
}
53
54
for
(i=0;i<11;++i) {
55
guitest_ref[i] = 0;
56
guitest_err[i] = 100;
57
guitest_size[i] =
file_size
(
TString::Format
(
"guitest%03d.C"
, i+1));
58
}
59
60
guitest_ref[0] = 23319;
61
guitest_ref[1] = 5633;
62
guitest_ref[2] = 14939;
63
guitest_ref[3] = 9459;
64
guitest_ref[4] = 5351;
65
guitest_ref[5] = 22982;
66
guitest_ref[6] = 23812;
67
guitest_ref[7] = 23869;
68
guitest_ref[8] = 23918;
69
guitest_ref[9] = 24067;
70
guitest_ref[10] = 65517;
71
72
printf
(
"**********************************************************************\n"
);
73
printf
(
"* Results of guitest_playback.C *\n"
);
74
printf
(
"**********************************************************************\n"
);
75
76
for
(i=0;i<11;++i) {
77
printf
(
"guitest %02d: output............................................"
, i+1);
78
if
(
TMath::Abs
(guitest_ref[i] - guitest_size[i]) <= guitest_err[i]) {
79
printf
(
"..... OK\n"
);
80
// delete successful tests, keep only the failing ones (for verification)
81
gSystem
->
Unlink
(
TString::Format
(
"guitest%03d.C"
, i+1));
82
}
83
else
{
84
printf
(
". FAILED\n"
);
85
}
86
}
87
printf
(
"**********************************************************************\n"
);
88
gBenchmark
->
Show
(
"guitest_playback"
);
89
}
TSystem::ProcessEvents
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition:
TSystem.cxx:420
c
return c
Definition:
entrylist_figure1.C:47
TRecorder.h
TBenchmark::Show
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition:
TBenchmark.cxx:155
Int_t
int Int_t
Definition:
RtypesCore.h:41
TMath::Abs
Short_t Abs(Short_t d)
Definition:
TMathBase.h:110
TSystem::Unlink
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition:
TSystem.cxx:1294
TBenchmark::Start
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition:
TBenchmark.cxx:172
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition:
TString.cxx:2321
TSystem::Sleep
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition:
TSystem.cxx:441
TSystem.h
TRecorder::kReplaying
Definition:
TRecorder.h:469
r
ROOT::R::TRInterface & r
Definition:
Object.C:4
gSystem
R__EXTERN TSystem * gSystem
Definition:
TSystem.h:545
gBenchmark
R__EXTERN TBenchmark * gBenchmark
Definition:
TBenchmark.h:63
Riostream.h
printf
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
file_size
Int_t file_size(char *filename)
Definition:
fitpanel_playback.C:19
TRecorder
Definition:
TRecorder.h:438
TSystemFile.h