Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
a67718cc
Commit
a67718cc
authored
Jan 20, 2010
by
Thomas Hartmann
Browse files
QmlDesigner.tests: Adding test for RewritingException
parent
81499ebe
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/auto/qml/qmldesigner/coretests/testcore.cpp
View file @
a67718cc
...
...
@@ -39,6 +39,7 @@
#include <qmlanchors.h>
#include <invalididexception.h>
#include <invalidmodelnodeexception.h>
#include <rewritingexception.h>
#include <nodeinstanceview.h>
#include <nodeinstance.h>
#include <QDebug>
...
...
@@ -2540,6 +2541,46 @@ void TestCore::testRewriterNodeSliding()
QCOMPARE
(
rootNode
.
nodeListProperty
(
QLatin1String
(
"data"
)).
toModelNodeList
().
at
(
1
).
id
(),
QLatin1String
(
"rectangle2"
));
}
void
TestCore
::
testRewriterExecptionHandling
()
{
const
QLatin1String
qmlString
(
"import Qt 4.6
\n
"
"Text {
\n
"
"}"
);
QPlainTextEdit
textEdit
;
textEdit
.
setPlainText
(
qmlString
);
PlainTextEditModifier
textModifier
(
&
textEdit
);
QScopedPointer
<
Model
>
model
(
Model
::
create
(
"Qt/Item"
,
4
,
6
));
QVERIFY
(
model
.
data
());
QScopedPointer
<
TestView
>
view
(
new
TestView
);
model
->
attachView
(
view
.
data
());
// read in
QScopedPointer
<
TestRewriterView
>
testRewriterView
(
new
TestRewriterView
());
testRewriterView
->
setTextModifier
(
&
textModifier
);
model
->
attachView
(
testRewriterView
.
data
());
ModelNode
rootNode
=
view
->
rootModelNode
();
QVERIFY
(
rootNode
.
isValid
());
QCOMPARE
(
rootNode
.
type
(),
QLatin1String
(
"Qt/Text"
));
try
{
RewriterTransaction
transaction
=
view
->
beginRewriterTransaction
();
rootNode
.
variantProperty
(
"bla"
)
=
QVariant
(
"blah
\"
"
);
rootNode
.
variantProperty
(
"text"
)
=
QVariant
(
"text"
);
transaction
.
commit
();
QFAIL
(
"RewritingExecption should be thrown"
);
}
catch
(
RewritingException
&
e
)
{
QVERIFY
(
rootNode
.
isValid
());
QCOMPARE
(
rootNode
.
type
(),
QLatin1String
(
"Qt/Text"
));
QVERIFY
(
!
rootNode
.
hasProperty
(
"bla"
));
QVERIFY
(
!
rootNode
.
hasProperty
(
"text"
));
}
}
void
TestCore
::
testRewriterFirstDefinitionInside
()
{
const
QString
qmlString
(
"import Qt 4.6
\n
"
...
...
tests/auto/qml/qmldesigner/coretests/testcore.h
View file @
a67718cc
...
...
@@ -117,6 +117,7 @@ private slots:
void
testRewriterForArrayMagic
();
void
testRewriterWithSignals
();
void
testRewriterNodeSliding
();
void
testRewriterExecptionHandling
();
//
// unit tests QmlModelNodeFacade/QmlModelState
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment