fixed test barline
This commit is contained in:
parent
2b20dbe762
commit
4817d7c6b4
7 changed files with 290 additions and 40 deletions
|
@ -20,10 +20,15 @@
|
|||
#include <QGuiApplication>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include "framework/global/runtime.h"
|
||||
|
||||
GTEST_API_ int main(int argc, char** argv)
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
mu::runtime::mainThreadId(); //! NOTE Needs only call
|
||||
mu::runtime::setThreadName("main");
|
||||
|
||||
testing::InitGoogleMock(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -21,13 +21,14 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include "qtestsuite.h"
|
||||
#include "framework/global/runtime.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
qDebug() << i << " " << argv[i];
|
||||
}
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
mu::runtime::mainThreadId(); //! NOTE Needs only call
|
||||
mu::runtime::setThreadName("main");
|
||||
|
||||
return mu::testing::QTestSuite::run(argc, argv);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,10 @@
|
|||
## Setup
|
||||
# set(MODULE_TEST somename) - set module (target) name
|
||||
# set(MODULE_TEST_INCLUDE ...) - set include (by default see below include_directories)
|
||||
# set(MODULE_TEST_DEF ...) - set definitions
|
||||
# set(MODULE_TEST_SRC ...) - set sources and headers files
|
||||
# set(MODULE_TEST_LINK ...) - set libraries for link
|
||||
# set(MODULE_TEST_DATA_ROOT ...) - set test data root path
|
||||
|
||||
# After all the settings you need to do:
|
||||
# include(${PROJECT_SOURCE_DIR}/framework/testing/gtest.cmake)
|
||||
|
@ -44,6 +46,11 @@ target_include_directories(${MODULE_TEST} PRIVATE
|
|||
${MODULE_TEST_INCLUDE}
|
||||
)
|
||||
|
||||
target_compile_definitions(${MODULE_TEST} PRIVATE
|
||||
${MODULE_TEST_DEF}
|
||||
${MODULE_TEST}_DATA_ROOT="${MODULE_TEST_DATA_ROOT}"
|
||||
)
|
||||
|
||||
find_package(Qt5Test REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ set(MODULE_TEST_SRC
|
|||
set(MODULE_TEST_LINK
|
||||
qzip
|
||||
libmscore
|
||||
fonts
|
||||
)
|
||||
|
||||
set(MODULE_TEST_DATA_ROOT ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/src/framework/testing/qtest.cmake)
|
||||
|
|
194
src/libmscore/tests/test.mscx
Normal file
194
src/libmscore/tests/test.mscx
Normal file
|
@ -0,0 +1,194 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<museScore version="3.01">
|
||||
<Score>
|
||||
<LayerTag id="0" tag="default"></LayerTag>
|
||||
<currentLayer>0</currentLayer>
|
||||
<Division>480</Division>
|
||||
<Style>
|
||||
<Spatium>1.76389</Spatium>
|
||||
</Style>
|
||||
<showInvisible>1</showInvisible>
|
||||
<showUnprintable>1</showUnprintable>
|
||||
<showFrames>1</showFrames>
|
||||
<showMargins>0</showMargins>
|
||||
<metaTag name="arranger"></metaTag>
|
||||
<metaTag name="composer"></metaTag>
|
||||
<metaTag name="copyright"></metaTag>
|
||||
<metaTag name="lyricist"></metaTag>
|
||||
<metaTag name="movementNumber"></metaTag>
|
||||
<metaTag name="movementTitle"></metaTag>
|
||||
<metaTag name="poet"></metaTag>
|
||||
<metaTag name="source"></metaTag>
|
||||
<metaTag name="translator"></metaTag>
|
||||
<metaTag name="workNumber"></metaTag>
|
||||
<metaTag name="workTitle">Test</metaTag>
|
||||
<Part>
|
||||
<Staff id="1">
|
||||
<StaffType group="pitched">
|
||||
<name>stdNormal</name>
|
||||
</StaffType>
|
||||
</Staff>
|
||||
<trackName>Voice</trackName>
|
||||
<Instrument>
|
||||
<trackName>Voice</trackName>
|
||||
<minPitchP>36</minPitchP>
|
||||
<maxPitchP>94</maxPitchP>
|
||||
<minPitchA>40</minPitchA>
|
||||
<maxPitchA>79</maxPitchA>
|
||||
<Articulation>
|
||||
<velocity>100</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="staccato">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>85</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="tenuto">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="sforzato">
|
||||
<velocity>120</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Channel>
|
||||
</Channel>
|
||||
</Instrument>
|
||||
</Part>
|
||||
<Part>
|
||||
<Staff id="2">
|
||||
<StaffType group="pitched">
|
||||
<name>stdNormal</name>
|
||||
</StaffType>
|
||||
</Staff>
|
||||
<trackName>Voice</trackName>
|
||||
<Instrument>
|
||||
<longName>Voice</longName>
|
||||
<shortName>Vo.</shortName>
|
||||
<trackName>Voice</trackName>
|
||||
<minPitchP>36</minPitchP>
|
||||
<maxPitchP>94</maxPitchP>
|
||||
<minPitchA>40</minPitchA>
|
||||
<maxPitchA>79</maxPitchA>
|
||||
<instrumentId>voice.vocals</instrumentId>
|
||||
<Articulation>
|
||||
<velocity>100</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="staccatissimo">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>33</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="staccato">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>50</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="portato">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>67</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="tenuto">
|
||||
<velocity>100</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="marcato">
|
||||
<velocity>120</velocity>
|
||||
<gateTime>67</gateTime>
|
||||
</Articulation>
|
||||
<Articulation name="sforzato">
|
||||
<velocity>120</velocity>
|
||||
<gateTime>100</gateTime>
|
||||
</Articulation>
|
||||
<Channel>
|
||||
<program value="52"/>
|
||||
</Channel>
|
||||
</Instrument>
|
||||
</Part>
|
||||
<Staff id="1">
|
||||
<VBox>
|
||||
<height>10</height>
|
||||
<Text>
|
||||
<style>Title</style>
|
||||
<text>Test</text>
|
||||
</Text>
|
||||
<Text>
|
||||
<style>Subtitle</style>
|
||||
<text>Split Measure+Slur</text>
|
||||
</Text>
|
||||
</VBox>
|
||||
<Measure>
|
||||
<voice>
|
||||
<TimeSig>
|
||||
<sigN>4</sigN>
|
||||
<sigD>4</sigD>
|
||||
</TimeSig>
|
||||
<Tempo>
|
||||
<tempo>1.66667</tempo>
|
||||
<text>𝅘𝅥 = 100</text>
|
||||
</Tempo>
|
||||
<Chord>
|
||||
<durationType>quarter</durationType>
|
||||
<Spanner type="Slur">
|
||||
<Slur>
|
||||
</Slur>
|
||||
<next>
|
||||
<location>
|
||||
<fractions>3/4</fractions>
|
||||
</location>
|
||||
</next>
|
||||
</Spanner>
|
||||
<Note>
|
||||
<pitch>60</pitch>
|
||||
<tpc>14</tpc>
|
||||
</Note>
|
||||
</Chord>
|
||||
<Chord>
|
||||
<durationType>quarter</durationType>
|
||||
<Note>
|
||||
<pitch>62</pitch>
|
||||
<tpc>16</tpc>
|
||||
</Note>
|
||||
</Chord>
|
||||
<Chord>
|
||||
<durationType>quarter</durationType>
|
||||
<Note>
|
||||
<pitch>64</pitch>
|
||||
<tpc>18</tpc>
|
||||
</Note>
|
||||
</Chord>
|
||||
<Chord>
|
||||
<durationType>quarter</durationType>
|
||||
<Spanner type="Slur">
|
||||
<prev>
|
||||
<location>
|
||||
<fractions>-3/4</fractions>
|
||||
</location>
|
||||
</prev>
|
||||
</Spanner>
|
||||
<Note>
|
||||
<pitch>65</pitch>
|
||||
<tpc>13</tpc>
|
||||
</Note>
|
||||
</Chord>
|
||||
<BarLine>
|
||||
<subtype>end</subtype>
|
||||
</BarLine>
|
||||
</voice>
|
||||
</Measure>
|
||||
</Staff>
|
||||
<Staff id="2">
|
||||
<Measure>
|
||||
<voice>
|
||||
<TimeSig>
|
||||
<sigN>4</sigN>
|
||||
<sigD>4</sigD>
|
||||
</TimeSig>
|
||||
<Rest>
|
||||
<durationType>measure</durationType>
|
||||
<duration>4/4</duration>
|
||||
</Rest>
|
||||
</voice>
|
||||
</Measure>
|
||||
</Staff>
|
||||
</Score>
|
||||
</museScore>
|
|
@ -10,34 +10,28 @@
|
|||
// the file LICENCE.GPL
|
||||
//=============================================================================
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "config.h"
|
||||
#include "libmscore/score.h"
|
||||
#include "libmscore/note.h"
|
||||
#include "libmscore/chord.h"
|
||||
#include "libmscore/instrtemplate.h"
|
||||
#include "testutils.h"
|
||||
#include "libmscore/page.h"
|
||||
#include "libmscore/musescoreCore.h"
|
||||
#include "libmscore/xml.h"
|
||||
#include "libmscore/excerpt.h"
|
||||
#include "thirdparty/qzip/qzipreader_p.h"
|
||||
|
||||
#include "framework/global/globalmodule.h"
|
||||
#include "framework/fonts/fontsmodule.h"
|
||||
|
||||
static void initMyResources()
|
||||
{
|
||||
// Q_INIT_RESOURCE(mtest);
|
||||
// Q_INIT_RESOURCE(fonts_Leland);
|
||||
// Q_INIT_RESOURCE(fonts_Bravura);
|
||||
// Q_INIT_RESOURCE(fonts_Campania);
|
||||
// Q_INIT_RESOURCE(fonts_Free);
|
||||
// Q_INIT_RESOURCE(fonts_FreeSerif);
|
||||
// Q_INIT_RESOURCE(fonts_Gootville);
|
||||
// Q_INIT_RESOURCE(fonts_MScore);
|
||||
// Q_INIT_RESOURCE(fonts_MuseJazz);
|
||||
// Q_INIT_RESOURCE(fonts_Smufl);
|
||||
// Q_INIT_RESOURCE(fonts_Tabulature);
|
||||
// Q_INIT_RESOURCE(fonts_Petaluma);
|
||||
}
|
||||
|
||||
namespace Ms {
|
||||
|
@ -101,8 +95,14 @@ MasterScore* MTest::readCreatedScore(const QString& name)
|
|||
score->setName(fi.completeBaseName());
|
||||
QString csl = fi.suffix().toLower();
|
||||
|
||||
// ScoreLoad sl;
|
||||
// Score::FileError rv;
|
||||
ScoreLoad sl;
|
||||
Score::FileError rv;
|
||||
if (csl == "mscz" || csl == "mscx") {
|
||||
rv = score->loadMsc(name, false);
|
||||
} else {
|
||||
rv = Score::FileError::FILE_UNKNOWN_TYPE;
|
||||
}
|
||||
|
||||
// if (csl == "cap") {
|
||||
// rv = importCapella(score, name);
|
||||
// score->setMetaTag("originalFormat", csl);
|
||||
|
@ -125,15 +125,15 @@ MasterScore* MTest::readCreatedScore(const QString& name)
|
|||
// rv = Score::FileError::FILE_UNKNOWN_TYPE;
|
||||
// }
|
||||
|
||||
// if (rv != Score::FileError::FILE_NO_ERROR) {
|
||||
// QWARN(qPrintable(QString("readScore: cannot load <%1> type <%2>\n").arg(name).arg(csl)));
|
||||
// delete score;
|
||||
// score = 0;
|
||||
// } else {
|
||||
// for (Score* s : score->scoreList()) {
|
||||
// s->doLayout();
|
||||
// }
|
||||
// }
|
||||
if (rv != Score::FileError::FILE_NO_ERROR) {
|
||||
QWARN(qPrintable(QString("readScore: cannot load <%1> type <%2>\n").arg(name).arg(csl)));
|
||||
delete score;
|
||||
score = 0;
|
||||
} else {
|
||||
for (Score* s : score->scoreList()) {
|
||||
s->doLayout();
|
||||
}
|
||||
}
|
||||
return score;
|
||||
}
|
||||
|
||||
|
@ -221,6 +221,7 @@ bool MTest::saveCompareBrailleScore(MasterScore* score, const QString& saveName,
|
|||
|
||||
bool MTest::savePdf(MasterScore* cs, const QString& saveName)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
// QPrinter printerDev(QPrinter::HighResolution);
|
||||
// double w = cs->styleD(Sid::pageWidth);
|
||||
|
@ -276,6 +277,7 @@ bool MTest::savePdf(MasterScore* cs, const QString& saveName)
|
|||
|
||||
bool MTest::saveMusicXml(MasterScore* score, const QString& saveName)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return false;// saveXml(score, saveName);
|
||||
}
|
||||
|
||||
|
@ -285,6 +287,7 @@ bool MTest::saveMusicXml(MasterScore* score, const QString& saveName)
|
|||
|
||||
bool MTest::saveBraille(MasterScore* score, const QString& saveName)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return false;// Ms::saveBraille(score, saveName);
|
||||
}
|
||||
|
||||
|
@ -342,7 +345,7 @@ void MTest::extractRootFile(const QString& zipFile, const QString& destination)
|
|||
|
||||
QString MTest::rootPath()
|
||||
{
|
||||
return QString();//TESTROOT "/mtest/";
|
||||
return QString(libmscore_tests_DATA_ROOT);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -352,7 +355,44 @@ QString MTest::rootPath()
|
|||
void MTest::initMTest()
|
||||
{
|
||||
qputenv("QML_DISABLE_DISK_CACHE", "true");
|
||||
qSetMessagePattern("%{function}: %{message}");
|
||||
|
||||
static mu::framework::GlobalModule globalModule;
|
||||
static QList<mu::framework::IModuleSetup*> modules;
|
||||
|
||||
modules
|
||||
<< new mu::fonts::FontsModule()
|
||||
;
|
||||
|
||||
globalModule.registerResources();
|
||||
globalModule.registerExports();
|
||||
globalModule.registerUiTypes();
|
||||
globalModule.onInit();
|
||||
|
||||
//! NOTE Now we can use logger and profiler
|
||||
|
||||
for (mu::framework::IModuleSetup* m : modules) {
|
||||
m->registerResources();
|
||||
}
|
||||
|
||||
for (mu::framework::IModuleSetup* m : modules) {
|
||||
m->registerExports();
|
||||
}
|
||||
|
||||
globalModule.resolveImports();
|
||||
for (mu::framework::IModuleSetup* m : modules) {
|
||||
m->registerUiTypes();
|
||||
m->resolveImports();
|
||||
}
|
||||
|
||||
for (mu::framework::IModuleSetup* m : modules) {
|
||||
m->onInit();
|
||||
}
|
||||
|
||||
globalModule.onStartApp();
|
||||
for (mu::framework::IModuleSetup* m : modules) {
|
||||
m->onStartApp();
|
||||
}
|
||||
|
||||
initMyResources();
|
||||
// DPI = 120;
|
||||
// PDPI = 120;
|
||||
|
@ -363,7 +403,7 @@ void MTest::initMTest()
|
|||
new MuseScoreCore;
|
||||
mscore->init();
|
||||
|
||||
//root = TESTROOT "/mtest";
|
||||
root = rootPath();
|
||||
loadInstrumentTemplates(":/instruments.xml");
|
||||
score = readScore("test.mscx");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libmscore/undo.h"
|
||||
#include "libmscore/bracket.h"
|
||||
|
||||
#define DIR QString("libmscore/barline/")
|
||||
static const QString BARLINE_DATA_DIR("barline_data/");
|
||||
|
||||
using namespace Ms;
|
||||
|
||||
|
@ -84,7 +84,7 @@ static const qreal BARLINE_HEIGHT_MAX = 15;
|
|||
void TestBarline::barline01()
|
||||
{
|
||||
char msg[256];
|
||||
Score* score = readScore(DIR + "barline01.mscx");
|
||||
Score* score = readScore(BARLINE_DATA_DIR + "barline01.mscx");
|
||||
|
||||
qreal height, heightMin, heightMax;
|
||||
qreal spatium = score->spatium();
|
||||
|
@ -142,7 +142,7 @@ void TestBarline::barline01()
|
|||
void TestBarline::barline02()
|
||||
{
|
||||
char msg[256];
|
||||
Score* score = readScore(DIR + "barline02.mscx");
|
||||
Score* score = readScore(BARLINE_DATA_DIR + "barline02.mscx");
|
||||
QVERIFY(score);
|
||||
Measure* msr = score->firstMeasure()->nextMeasure();
|
||||
TimeSig* ts = new TimeSig(score);
|
||||
|
@ -184,7 +184,7 @@ void TestBarline::barline02()
|
|||
|
||||
void TestBarline::barline03()
|
||||
{
|
||||
Score* score = readScore(DIR + "barline03.mscx");
|
||||
Score* score = readScore(BARLINE_DATA_DIR + "barline03.mscx");
|
||||
QVERIFY(score);
|
||||
score->startCmd();
|
||||
score->undo(new ChangeProperty(score->staff(0), Pid::STAFF_BARLINE_SPAN, 1));
|
||||
|
@ -224,7 +224,7 @@ void TestBarline::barline03()
|
|||
|
||||
void TestBarline::barline04()
|
||||
{
|
||||
Score* score = readScore(DIR + "barline04.mscx");
|
||||
Score* score = readScore(BARLINE_DATA_DIR + "barline04.mscx");
|
||||
QVERIFY(score);
|
||||
score->doLayout();
|
||||
|
||||
|
@ -266,7 +266,7 @@ void TestBarline::barline04()
|
|||
|
||||
void TestBarline::barline05()
|
||||
{
|
||||
Score* score = readScore(DIR + "barline05.mscx");
|
||||
Score* score = readScore(BARLINE_DATA_DIR + "barline05.mscx");
|
||||
QVERIFY(score);
|
||||
score->doLayout();
|
||||
|
||||
|
@ -316,7 +316,7 @@ void TestBarline::barline05()
|
|||
void TestBarline::barline06()
|
||||
{
|
||||
char msg[256];
|
||||
Score* score = readScore(DIR + "barline06.mscx");
|
||||
Score* score = readScore(BARLINE_DATA_DIR + "barline06.mscx");
|
||||
QVERIFY(score);
|
||||
score->doLayout();
|
||||
|
||||
|
@ -384,7 +384,7 @@ void dropNormalBarline(Element* e)
|
|||
|
||||
void TestBarline::barline179726()
|
||||
{
|
||||
Score* score = readScore(DIR + "barline179726.mscx");
|
||||
Score* score = readScore(BARLINE_DATA_DIR + "barline179726.mscx");
|
||||
QVERIFY(score);
|
||||
score->doLayout();
|
||||
|
||||
|
@ -455,7 +455,7 @@ void TestBarline::barline179726()
|
|||
|
||||
void TestBarline::deleteSkipBarlines()
|
||||
{
|
||||
MasterScore* score = readScore(DIR + "barlinedelete.mscx");
|
||||
MasterScore* score = readScore(BARLINE_DATA_DIR + "barlinedelete.mscx");
|
||||
|
||||
Measure* m1 = score->firstMeasure();
|
||||
QVERIFY(m1);
|
||||
|
@ -468,7 +468,7 @@ void TestBarline::deleteSkipBarlines()
|
|||
score->doLayout();
|
||||
|
||||
QVERIFY(saveCompareScore(score, QString("barlinedelete.mscx"),
|
||||
DIR + QString("barlinedelete-ref.mscx")));
|
||||
BARLINE_DATA_DIR + QString("barlinedelete-ref.mscx")));
|
||||
delete score;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue