Changeset View
Changeset View
Standalone View
Standalone View
src/backends/octave/testoctave.cpp
Show All 22 Lines | |||||
23 | #include "session.h" | 23 | #include "session.h" | ||
24 | #include "backend.h" | 24 | #include "backend.h" | ||
25 | #include "expression.h" | 25 | #include "expression.h" | ||
26 | #include "result.h" | 26 | #include "result.h" | ||
27 | #include "imageresult.h" | 27 | #include "imageresult.h" | ||
28 | #include "textresult.h" | 28 | #include "textresult.h" | ||
29 | #include "epsresult.h" | 29 | #include "epsresult.h" | ||
30 | #include "completionobject.h" | 30 | #include "completionobject.h" | ||
31 | #include "defaultvariablemodel.h" | ||||
31 | 32 | | |||
32 | #include "octaveexpression.h" | 33 | #include "octaveexpression.h" | ||
33 | 34 | | |||
34 | #include <QDebug> | 35 | #include <QDebug> | ||
35 | 36 | | |||
36 | QString TestOctave::backendName() | 37 | QString TestOctave::backendName() | ||
37 | { | 38 | { | ||
38 | return QLatin1String("octave"); | 39 | return QLatin1String("octave"); | ||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | 134 | { | |||
140 | const QStringList& completions = help->completions(); | 141 | const QStringList& completions = help->completions(); | ||
141 | qDebug() << completions; | 142 | qDebug() << completions; | ||
142 | QVERIFY(completions.contains(QLatin1String("asin"))); | 143 | QVERIFY(completions.contains(QLatin1String("asin"))); | ||
143 | QVERIFY(completions.contains(QLatin1String("asctime"))); | 144 | QVERIFY(completions.contains(QLatin1String("asctime"))); | ||
144 | QVERIFY(completions.contains(QLatin1String("asec"))); | 145 | QVERIFY(completions.contains(QLatin1String("asec"))); | ||
145 | QVERIFY(completions.contains(QLatin1String("assert"))); | 146 | QVERIFY(completions.contains(QLatin1String("assert"))); | ||
146 | } | 147 | } | ||
147 | 148 | | |||
149 | void TestOctave::testVariablesCreatingFromCode() | ||||
150 | { | ||||
151 | QAbstractItemModel* model = session()->variableModel(); | ||||
152 | QVERIFY(model != nullptr); | ||||
153 | | ||||
154 | evalExp(QLatin1String("clear();")); | ||||
155 | | ||||
156 | Cantor::Expression* e=evalExp(QLatin1String("a = 15; b = 'S';")); | ||||
157 | QVERIFY(e!=nullptr); | ||||
158 | | ||||
159 | if(session()->status()==Cantor::Session::Running) | ||||
160 | waitForSignal(session(), SIGNAL(statusChanged(Cantor::Session::Status))); | ||||
161 | | ||||
162 | QCOMPARE(2, model->rowCount()); | ||||
163 | | ||||
164 | QCOMPARE(model->index(0,0).data().toString(), QLatin1String("a")); | ||||
165 | QCOMPARE(model->index(0,1).data().toString(), QLatin1String(" 15")); | ||||
166 | | ||||
167 | QCOMPARE(model->index(1,0).data().toString(), QLatin1String("b")); | ||||
168 | QCOMPARE(model->index(1,1).data().toString(), QLatin1String("S")); | ||||
169 | } | ||||
170 | | ||||
171 | void TestOctave::testVariableCleanupAfterRestart() | ||||
172 | { | ||||
173 | Cantor::DefaultVariableModel* model = static_cast<Cantor::DefaultVariableModel*>(session()->variableModel()); | ||||
174 | QVERIFY(model != nullptr); | ||||
175 | | ||||
176 | evalExp(QLatin1String("clear();")); | ||||
177 | Cantor::Expression* e=evalExp(QLatin1String("a = 15; b = 'S';")); | ||||
178 | QVERIFY(e!=nullptr); | ||||
179 | | ||||
180 | if(session()->status()==Cantor::Session::Running) | ||||
181 | waitForSignal(session(), SIGNAL(statusChanged(Cantor::Session::Status))); | ||||
182 | | ||||
183 | QCOMPARE(2, static_cast<QAbstractItemModel*>(model)->rowCount()); | ||||
184 | | ||||
185 | session()->logout(); | ||||
186 | session()->login(); | ||||
187 | | ||||
188 | QCOMPARE(0, static_cast<QAbstractItemModel*>(model)->rowCount()); | ||||
189 | } | ||||
190 | | ||||
148 | void TestOctave::testPlot() | 191 | void TestOctave::testPlot() | ||
149 | { | 192 | { | ||
150 | Cantor::Expression* e=evalExp( QLatin1String("cantor_plot2d('sin(x)', 'x', -10,10);") ); | 193 | Cantor::Expression* e=evalExp( QLatin1String("cantor_plot2d('sin(x)', 'x', -10,10);") ); | ||
151 | 194 | | |||
152 | int cnt=0; | 195 | int cnt=0; | ||
153 | //give some time to create the image, but at most 5sec | 196 | //give some time to create the image, but at most 5sec | ||
154 | while(e->result()==nullptr||e->result()->type()!=OctavePlotResult::Type ) | 197 | while(e->result()==nullptr||e->result()->type()!=OctavePlotResult::Type ) | ||
155 | { | 198 | { | ||
Show All 23 Lines |