Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #ifndef MUSE_TESTFLOW_ITESTFLOW_H
23 : #define MUSE_TESTFLOW_ITESTFLOW_H
24 :
25 : #include <vector>
26 : #include <QJSValue>
27 :
28 : #include "modularity/imoduleinterface.h"
29 : #include "io/path.h"
30 : #include "async/channel.h"
31 : #include "testflowtypes.h"
32 : #include "itestcasecontext.h"
33 : #include "internal/testflowinteractive.h"
34 :
35 : namespace muse::testflow {
36 : class ITestflow : MODULE_CONTEXT_INTERFACE
37 : {
38 0 : INTERFACE_ID(ITestflow)
39 : public:
40 : virtual ~ITestflow() = default;
41 :
42 : enum class Status {
43 : Undefined = 0,
44 : Running,
45 : Paused,
46 : Aborted,
47 : Error,
48 : Finished
49 : };
50 :
51 : static QString statusToString(Status st)
52 : {
53 : switch (st) {
54 : case ITestflow::Status::Undefined: return "";
55 : case ITestflow::Status::Running: return "Running";
56 : case ITestflow::Status::Paused: return "Paused";
57 : case ITestflow::Status::Aborted: return "Aborted";
58 : case ITestflow::Status::Error: return "Error";
59 : case ITestflow::Status::Finished: return "Finished";
60 : }
61 : return QString();
62 : }
63 :
64 : virtual Status status() const = 0;
65 : virtual async::Channel<io::path_t, Status> statusChanged() const = 0;
66 : virtual async::Channel<StepInfo, Ret> stepStatusChanged() const = 0;
67 :
68 : virtual SpeedMode speedMode() const = 0;
69 : virtual void setSpeedMode(SpeedMode mode) = 0;
70 : virtual async::Channel<SpeedMode> speedModeChanged() const = 0;
71 : virtual void setDefaultIntervalMsec(int msec) = 0;
72 : virtual int defaultIntervalMsec() const = 0;
73 : virtual int intervalMsec() const = 0;
74 :
75 : struct Options {
76 : io::path_t context;
77 : std::string contextVal;
78 : std::string func;
79 : std::string funcArgs;
80 : };
81 :
82 : virtual void execScript(const io::path_t& path, const Options& opt = Options()) = 0;
83 :
84 : virtual void runTestCase(const TestCase& testCase) = 0;
85 : virtual void sleep(int msec) = 0;
86 : virtual void pause() = 0;
87 : virtual void unpause() = 0;
88 : virtual void abort() = 0;
89 : virtual void fatal(const QString& msg) = 0;
90 :
91 : virtual ITestCaseContextPtr context() const = 0;
92 : virtual TestflowInteractivePtr testflowInteractive() const = 0;
93 : };
94 : }
95 :
96 : #endif // MUSE_TESTFLOW_ITESTFLOW_H
|