From dc836ccf67ddb734b432e6caba98d9a05a7660fe Mon Sep 17 00:00:00 2001 From: lasconic Date: Tue, 7 May 2013 13:36:21 +0200 Subject: [PATCH] add unit test for BIAB --- mtest/CMakeLists.txt | 3 +- mtest/biab/CMakeLists.txt | 16 + mtest/biab/chords-ref.mscx | 622 ++++++++++++++++++++++ test/chords1.SGU => mtest/biab/chords.SGU | Bin mtest/biab/tst_biab.cpp | 79 +++ mtest/testutils.cpp | 3 + 6 files changed, 722 insertions(+), 1 deletion(-) create mode 100644 mtest/biab/CMakeLists.txt create mode 100644 mtest/biab/chords-ref.mscx rename test/chords1.SGU => mtest/biab/chords.SGU (100%) create mode 100644 mtest/biab/tst_biab.cpp diff --git a/mtest/CMakeLists.txt b/mtest/CMakeLists.txt index 85b65634aa922..d6094c92d4b9f 100644 --- a/mtest/CMakeLists.txt +++ b/mtest/CMakeLists.txt @@ -32,6 +32,7 @@ add_library( ${mtestMocs} testutils.cpp ${PROJECT_SOURCE_DIR}/libmscore/mcursor.cpp + ${PROJECT_SOURCE_DIR}/mscore/bb.cpp ${PROJECT_SOURCE_DIR}/mscore/capella.cpp ${PROJECT_SOURCE_DIR}/mscore/capxml.cpp ${PROJECT_SOURCE_DIR}/mscore/exportxml.cpp @@ -76,7 +77,7 @@ add_custom_target(reporthtml WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/mtest" ) -subdirs (libmscore musicxml importmidi capella) +subdirs (libmscore musicxml importmidi capella biab) if (OMR) subdirs(omr) diff --git a/mtest/biab/CMakeLists.txt b/mtest/biab/CMakeLists.txt new file mode 100644 index 0000000000000..4c80e3cdbaee7 --- /dev/null +++ b/mtest/biab/CMakeLists.txt @@ -0,0 +1,16 @@ +#============================================================================= +# MuseScore +# Music Composition & Notation +# $Id:$ +# +# Copyright (C) 2013 Werner Schweer +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 +# as published by the Free Software Foundation and appearing in +# the file LICENSE.GPL +#============================================================================= + +set(TARGET tst_biab) + +include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc) diff --git a/mtest/biab/chords-ref.mscx b/mtest/biab/chords-ref.mscx new file mode 100644 index 0000000000000..0f1d8bf499fad --- /dev/null +++ b/mtest/biab/chords-ref.mscx @@ -0,0 +1,622 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + 10 + + + Chord Test1 + + + + + G + G + + + 0 + 1 + 1 + + + 14 + 2 + + + measure + + + + + + 14 + 3 + + + measure + + + + + + 14 + 4 + + + measure + + + + + + 14 + 5 + + + measure + + + + + + line + 3 + + + 14 + 6 + + + measure + + + + + + 14 + 7 + + + measure + + + + + + 14 + 8 + + + measure + + + + + + 14 + 9 + + + measure + + + + + + line + 3 + + + 14 + 10 + + + measure + + + + + + 14 + 13 + + + measure + + + + + + 14 + 14 + + + measure + + + + + + 14 + 15 + + + measure + + + + + + line + 3 + + + 14 + 16 + + + measure + + + + + + 14 + 17 + + + measure + + + + + + 14 + 18 + + + measure + + + + + + 14 + 19 + + + measure + + + + + + line + 3 + + + 14 + 20 + + + measure + + + + + + 14 + 21 + + + measure + + + + + + 14 + 22 + + + measure + + + + + + 14 + 23 + + + measure + + + + + + line + 3 + + + 14 + 24 + + + measure + + + + + + 14 + 25 + + + measure + + + + + + 14 + 26 + + + measure + + + + + + 14 + 28 + + + measure + + + + + + line + 3 + + + 14 + 29 + + + measure + + + + + + 14 + 32 + + + measure + + + + + + 14 + 33 + + + measure + + + + + + 14 + 34 + + + measure + + + + + + line + 3 + + + 14 + 40 + + + measure + + + + + + 14 + 56 + + + measure + + + + + + 14 + 57 + + + measure + + + + + + 14 + 58 + + + measure + + + + + + line + 3 + + + 14 + 64 + + + measure + + + + + + 14 + 65 + + + measure + + + + + + 14 + 66 + + + measure + + + + + + 14 + 67 + + + measure + + + + + + line + 3 + + + 14 + 74 + + + measure + + + + + + 14 + 75 + + + measure + + + + + + 14 + 76 + + + measure + + + + + + 14 + 77 + + + measure + + + + + + line + 3 + + + 14 + 85 + + + measure + + + + + + 14 + 74 + + + measure + + + + + + 14 + 75 + + + measure + + + + + + 14 + 76 + + + measure + + + + + + line + 3 + + + 14 + 77 + + + measure + + + + + + 14 + 78 + + + measure + + + + + + 14 + 79 + + + measure + + + + + + 14 + 80 + + + measure + + + + + + diff --git a/test/chords1.SGU b/mtest/biab/chords.SGU similarity index 100% rename from test/chords1.SGU rename to mtest/biab/chords.SGU diff --git a/mtest/biab/tst_biab.cpp b/mtest/biab/tst_biab.cpp new file mode 100644 index 0000000000000..2d4844131c00b --- /dev/null +++ b/mtest/biab/tst_biab.cpp @@ -0,0 +1,79 @@ +//============================================================================= +// MuseScore +// Music Composition & Notation +// $Id:$ +// +// Copyright (C) 2013 Werner Schweer +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 +// as published by the Free Software Foundation and appearing in +// the file LICENCE.GPL +//============================================================================= + +#include +#include "mtest/testutils.h" +#include "libmscore/score.h" + +#define DIR QString("biab/") + + +//--------------------------------------------------------- +// TestBiab +//--------------------------------------------------------- + +class TestBiab : public QObject, public MTest + { + Q_OBJECT + + private slots: + void initTestCase(); + void biab_data(); + void biab(); + }; + +//--------------------------------------------------------- +// initTestCase +//--------------------------------------------------------- + +void TestBiab::initTestCase() + { + initMTest(); + } + +//--------------------------------------------------------- +// biab_data +// every "xxx" test requires a *.SGU file and a *.mscx file: +// xxx.SGU is the SGU file +// xxx-ref.mscx is the corresponding (correct) +// mscore 2.0 file +//--------------------------------------------------------- + +void TestBiab::biab_data() + { + QTest::addColumn("file"); + + QTest::newRow("chords") << "chords"; // notes.SGU notes-ref.mscx + } + +//--------------------------------------------------------- +// biab +//--------------------------------------------------------- + +void TestBiab::biab() + { + QFETCH(QString, file); + + QString readFile(DIR + file + ".SGU"); + QString writeFile(file + "-test.mscx"); + QString reference(DIR + file + "-ref.mscx"); + + Score* score = readScore(readFile); + score->doLayout(); + QVERIFY(score); + QVERIFY(saveCompareScore(score, writeFile, reference)); + } + +QTEST_MAIN(TestBiab) +#include "tst_biab.moc" + diff --git a/mtest/testutils.cpp b/mtest/testutils.cpp index 1b7a416bc0fb5..4b0a9e1c57eb9 100644 --- a/mtest/testutils.cpp +++ b/mtest/testutils.cpp @@ -28,6 +28,7 @@ extern Score::FileError importPdf(Score*, const QString&); #endif +extern Score::FileError importBB(Score*, const QString&); extern Score::FileError importCapella(Score*, const QString&); extern Score::FileError importCapXml(Score*, const QString&); extern Score::FileError importCompressedMusicXml(Score*, const QString&); @@ -120,6 +121,8 @@ Score* MTest::readCreatedScore(const QString& name) rv = importCapella(score, name); else if (csl == "capx") rv = importCapXml(score, name); + else if (csl == "sgu") + rv = importBB(score, name); else if (csl == "mscz" || csl == "mscx") rv = score->loadMsc(name, false); else if (csl == "mxl")