1 #ifndef TESTCFSM_H
2 #define TESTCFSM_H
3 
4 #include <QObject>
5 #include <QString>
6 #include <QTextStream>
7 
8 #include "customfilesystemmodel.h"
9 
10 class TestCFSM : public QObject
11 {
12     Q_OBJECT
13 
14 public:
15     TestCFSM(int scenario_num);
16     ~TestCFSM();
17 
18 public slots:
19     // Start running the test scenarios.
20     void start();
21 
22 private:
23     // The model we are testing.
24     CustomFileSystemModel _model;
25     // The root directory of the model.
26     QString _rootDir;
27     // Allows running a single scenario
28     int _scenario_num;
29 
30     // Recursively checks for any unread subdirectories.
31     // ASSUME: every directory must contain something.  See comment in .cpp
32     // file.
33     bool needToReadSubdirs(const QString dirname);
34 
35     // Helper functions for processing the scenario text files.
36     // "relname" is the "relative name", i.e. relative to the _rootDir.
37     QString getRelname(const QString line);
38     QModelIndex getIndex(const QString line);
39     int getLineState(const QString line);
40     int getCheckedStateInt(const QString line);
41 
42     // Main scenario-handling functions.
43     int processActions(QTextStream &in);
44     // Returns 0 if success, 1 if a model error, 2 if an emit error.
45     int processResults(QTextStream &in);
46     int runScenario(const int num);
47 
48     // For debugging and/or notifying of failed tests.
49     void printModel();
50     void printDir(const QString dirname, const int depth);
51 };
52 
53 #endif
54