Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
4/// guitest.C macro While replaying the session, several temporary macros (guitest0xx.C) macros will be saved. These
5/// 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
17Int_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)
24 return -1;
25 while (!feof(lunin)) {
26 c = fgetc(lunin);
27 if (c != 0x0d && c != 0x0a)
28 wc++;
29 }
30 fclose(lunin);
31 return wc;
32}
33
34// main function
35void guitest_playback()
36{
37 Int_t i;
38 Int_t guitest_ref[11], guitest_err[11], guitest_size[11];
39
40 gBenchmark->Start("guitest_playback");
41
42 // first delete old files, if any
43 for (i = 0; i < 11; ++i) {
44 gSystem->Unlink(TString::Format("guitest%03d.C", i + 1));
45 }
46
47 TRecorder r("http://root.cern/files/guitest_playback.root");
48
49 // wait for the recorder to finish the replay
50 while (r.GetState() == TRecorder::kReplaying) {
52 gSystem->Sleep(1);
53 }
54
55 for (i = 0; i < 11; ++i) {
56 guitest_ref[i] = 0;
57 guitest_err[i] = 100;
58 guitest_size[i] = file_size(TString::Format("guitest%03d.C", i + 1));
59 }
60
61 guitest_ref[0] = 23319;
62 guitest_ref[1] = 5633;
63 guitest_ref[2] = 14939;
64 guitest_ref[3] = 9459;
65 guitest_ref[4] = 5351;
66 guitest_ref[5] = 22982;
67 guitest_ref[6] = 23812;
68 guitest_ref[7] = 23869;
69 guitest_ref[8] = 23918;
70 guitest_ref[9] = 24067;
71 guitest_ref[10] = 65517;
72
73 printf("**********************************************************************\n");
74 printf("* Results of guitest_playback.C *\n");
75 printf("**********************************************************************\n");
76
77 for (i = 0; i < 11; ++i) {
78 printf("guitest %02d: output............................................", i + 1);
79 if (TMath::Abs(guitest_ref[i] - guitest_size[i]) <= guitest_err[i]) {
80 printf("..... OK\n");
81 // delete successful tests, keep only the failing ones (for verification)
82 gSystem->Unlink(TString::Format("guitest%03d.C", i + 1));
83 } else {
84 printf(". FAILED\n");
85 }
86 }
87 printf("**********************************************************************\n");
88 gBenchmark->Show("guitest_playback");
89}
#define c(i)
Definition RSha256.hxx:101
int Int_t
Definition RtypesCore.h:45
R__EXTERN TBenchmark * gBenchmark
Definition TBenchmark.h:59
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
virtual void Start(const char *name)
Starts Benchmark with the specified name.
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Class provides direct recorder/replayer interface for a user.
Definition TRecorder.h:266
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:2378
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:437
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:416
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1381
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123