start testing of text facility
This commit is contained in:
parent
22807dfcad
commit
aac18bec43
4 changed files with 93 additions and 4 deletions
|
@ -182,7 +182,6 @@ class Text : public Element {
|
|||
void insert(TextCursor*, QChar);
|
||||
void insert(TextCursor*, SymId);
|
||||
void updateCursorFormat(TextCursor*);
|
||||
void setEditMode(bool val) { _editMode = val; }
|
||||
|
||||
protected:
|
||||
TextStyle _textStyle;
|
||||
|
@ -205,6 +204,7 @@ class Text : public Element {
|
|||
virtual void draw(QPainter*) const;
|
||||
|
||||
bool editMode() const { return _editMode; }
|
||||
void setEditMode(bool val) { _editMode = val; }
|
||||
|
||||
void setTextStyle(const TextStyle& st) { _textStyle = st; }
|
||||
const TextStyle& textStyle() const { return _textStyle; }
|
||||
|
@ -237,8 +237,8 @@ class Text : public Element {
|
|||
QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
|
||||
bool setCursor(const QPointF& p,
|
||||
QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
|
||||
void moveCursorToEnd() { movePosition(QTextCursor::Start); }
|
||||
void moveCursorToStart() { movePosition(QTextCursor::End); }
|
||||
void moveCursorToEnd() { movePosition(QTextCursor::End); }
|
||||
void moveCursorToStart() { movePosition(QTextCursor::Start); }
|
||||
|
||||
QString selectedText() const;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
subdirs(
|
||||
barline beam chordsymbol clef clef_courtesy compat concertpitch copypaste
|
||||
copypastesymbollist dynamic element hairpin join keysig layout parts measure midi
|
||||
note plugins repeat split splitstaff timesig transpose tuplet
|
||||
note plugins repeat split splitstaff timesig transpose tuplet text
|
||||
)
|
||||
|
||||
|
||||
|
|
17
mtest/libmscore/text/CMakeLists.txt
Normal file
17
mtest/libmscore/text/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
#=============================================================================
|
||||
# MuseScore
|
||||
# Music Composition & Notation
|
||||
# $Id:$
|
||||
#
|
||||
# Copyright (C) 2011 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_text)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc)
|
||||
|
72
mtest/libmscore/text/tst_text.cpp
Normal file
72
mtest/libmscore/text/tst_text.cpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
//=============================================================================
|
||||
// MuseScore
|
||||
// Music Composition & Notation
|
||||
// $Id:$
|
||||
//
|
||||
// Copyright (C) 2012 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 <QtTest/QtTest>
|
||||
|
||||
#include "libmscore/text.h"
|
||||
#include "libmscore/score.h"
|
||||
#include "mtest/testutils.h"
|
||||
|
||||
using namespace Ms;
|
||||
|
||||
//---------------------------------------------------------
|
||||
// TestNote
|
||||
//---------------------------------------------------------
|
||||
|
||||
class TestText : public QObject, public MTest
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testText();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
// initTestCase
|
||||
//---------------------------------------------------------
|
||||
|
||||
void TestText::initTestCase()
|
||||
{
|
||||
initMTest();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
/// testText
|
||||
/// read/write test of note
|
||||
//---------------------------------------------------------
|
||||
|
||||
void TestText::testText()
|
||||
{
|
||||
Text* text = new Text(score);
|
||||
text->setTextStyle(score->textStyle(TEXT_STYLE_DYNAMICS));
|
||||
|
||||
text->setEditMode("true");
|
||||
text->layout();
|
||||
|
||||
text->moveCursorToEnd();
|
||||
text->insertText("a");
|
||||
text->endEdit();
|
||||
QCOMPARE(text->text(), QString("a"));
|
||||
|
||||
text->setEditMode("true");
|
||||
text->moveCursorToEnd();
|
||||
text->insertText("b");
|
||||
text->endEdit();
|
||||
QCOMPARE(text->text(), QString("ab"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestText)
|
||||
|
||||
#include "tst_text.moc"
|
||||
|
Loading…
Reference in a new issue