Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
1b3160e6
Commit
1b3160e6
authored
8 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
Unit test for ComboProperty's XML.
parent
b4661409
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/coregui/Models/SessionXML.h
+1
-2
1 addition, 2 deletions
GUI/coregui/Models/SessionXML.h
Tests/UnitTests/GUI/TestComboProperty.h
+43
-0
43 additions, 0 deletions
Tests/UnitTests/GUI/TestComboProperty.h
with
44 additions
and
2 deletions
GUI/coregui/Models/SessionXML.h
+
1
−
2
View file @
1b3160e6
...
...
@@ -67,7 +67,6 @@ class BA_CORE_API_ SessionWriter
public:
static
void
writeTo
(
QXmlStreamWriter
*
writer
,
SessionItem
*
parent
);
static
void
writeItemAndChildItems
(
QXmlStreamWriter
*
writer
,
const
SessionItem
*
item
);
private:
static
void
writeVariant
(
QXmlStreamWriter
*
writer
,
QVariant
variant
,
int
role
);
};
...
...
@@ -77,10 +76,10 @@ public:
static
void
readItems
(
QXmlStreamReader
*
reader
,
SessionItem
*
item
,
const
QString
&
topTag
=
QString
(),
WarningMessageService
*
messageService
=
0
);
private:
static
QString
readProperty
(
QXmlStreamReader
*
reader
,
SessionItem
*
item
,
WarningMessageService
*
messageService
=
0
);
private:
static
void
report_error
(
WarningMessageService
*
messageService
,
SessionItem
*
item
,
const
QString
&
error_type
,
const
QString
&
message
);
};
...
...
This diff is collapsed.
Click to expand it.
Tests/UnitTests/GUI/TestComboProperty.h
+
43
−
0
View file @
1b3160e6
#include
<QtTest>
#include
"ComboProperty.h"
#include
"PropertyItem.h"
#include
"SessionXML.h"
#include
<QXmlStreamWriter>
#include
<QXmlStreamReader>
#include
<QPair>
#include
<QDebug>
#include
<memory>
class
TestComboProperty
:
public
QObject
{
Q_OBJECT
...
...
@@ -9,6 +16,7 @@ private slots:
void
test_VariantEquality
();
void
test_setValue
();
void
test_stringOfValues
();
void
test_comboXML
();
};
inline
void
TestComboProperty
::
test_ComboEquality
()
...
...
@@ -79,5 +87,40 @@ inline void TestComboProperty::test_stringOfValues()
combo
.
setStringOfValues
(
stringOfValues
);
QCOMPARE
(
combo
.
stringOfValues
(),
stringOfValues
);
QCOMPARE
(
combo
.
getValue
(),
QString
(
"b1"
));
}
inline
void
TestComboProperty
::
test_comboXML
()
{
// Wwiting combo to XML
ComboProperty
combo
=
ComboProperty
()
<<
"a1"
<<
"a2"
<<
"a3"
;
QString
buffer
;
QXmlStreamWriter
writer
(
&
buffer
);
SessionWriter
::
writeVariant
(
&
writer
,
combo
.
getVariant
(),
0
);
QCOMPARE
(
buffer
,
QString
(
"<Parameter ParType=
\"
ComboProperty
\"
ParRole=
\"
0
\"
ParValue=
\"
a1
\"
/>"
));
// reading from XML
std
::
unique_ptr
<
PropertyItem
>
item
(
new
PropertyItem
);
combo
.
setValue
(
"a2"
);
item
->
setValue
(
combo
.
getVariant
());
QXmlStreamReader
reader
(
buffer
);
while
(
!
reader
.
atEnd
())
{
reader
.
readNext
();
if
(
reader
.
isStartElement
())
{
if
(
reader
.
name
()
==
SessionXML
::
ParameterTag
)
{
SessionReader
::
readProperty
(
&
reader
,
item
.
get
());
}
}
}
ComboProperty
combo_property
=
item
->
value
().
value
<
ComboProperty
>
();
QCOMPARE
(
combo_property
.
getValue
(),
QString
(
"a1"
));
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment