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
f1fa2972
Commit
f1fa2972
authored
9 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
Moire tests for ModelMapper
parent
a6470e68
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tests/UnitTests/TestGUI/TestGUI.cpp
+12
-12
12 additions, 12 deletions
Tests/UnitTests/TestGUI/TestGUI.cpp
Tests/UnitTests/TestGUI/TestMapperForItem.h
+77
-26
77 additions, 26 deletions
Tests/UnitTests/TestGUI/TestMapperForItem.h
with
89 additions
and
38 deletions
Tests/UnitTests/TestGUI/TestGUI.cpp
+
12
−
12
View file @
f1fa2972
...
...
@@ -34,18 +34,18 @@ int main(int argc, char** argv) {
bool
status
(
false
);
status
|=
QTest
::
qExec
(
&
testFormFactorItems
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testFTDistributionItems
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testParameterizedItem
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testParticleItems
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testLayerRoughnessItems
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testParaCrystalItems
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testSessionModel
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testGUICoreObjectCorrespondence
,
argc
,
argv
);
status
|=
QTest
::
qExec
(
&
testSessionItem
);
//status |= QTest::qExec(&testPropertyAttributes, argc, argv);
status
|=
QTest
::
qExec
(
&
testMapperCases
,
argc
,
argv
);
//status |= QTest::qExec(&testSessionModel, argc, argv);
//
status |= QTest::qExec(&testFormFactorItems, argc, argv);
//
status |= QTest::qExec(&testFTDistributionItems, argc, argv);
//
status |= QTest::qExec(&testParameterizedItem, argc, argv);
//
status |= QTest::qExec(&testParticleItems, argc, argv);
//
status |= QTest::qExec(&testLayerRoughnessItems, argc, argv);
//
status |= QTest::qExec(&testParaCrystalItems, argc, argv);
//
status |= QTest::qExec(&testSessionModel, argc, argv);
//
status |= QTest::qExec(&testGUICoreObjectCorrespondence, argc, argv);
//
status |= QTest::qExec(&testSessionItem);
//
//status |= QTest::qExec(&testPropertyAttributes, argc, argv);
//
status |= QTest::qExec(&testMapperCases, argc, argv);
//
//status |= QTest::qExec(&testSessionModel, argc, argv);
status
|=
QTest
::
qExec
(
&
testMapperForItem
,
argc
,
argv
);
...
...
This diff is collapsed.
Click to expand it.
Tests/UnitTests/TestGUI/TestMapperForItem.h
+
77
−
26
View file @
f1fa2972
...
...
@@ -23,7 +23,6 @@ public:
,
m_onParentChangeCount
(
0
)
,
m_onChildrenChangeCount
(
0
)
,
m_mapped_item
(
0
)
,
m_reporting_item
(
0
)
{
}
void
clear
()
...
...
@@ -33,8 +32,8 @@ public:
m_onParentChangeCount
=
0
;
m_onChildrenChangeCount
=
0
;
m_mapped_item
=
0
;
m_report
ing
_item
=
0
;
m_report
ing
_name
.
clear
();
m_report
ed
_item
s
.
clear
()
;
m_report
ed
_name
s
.
clear
();
}
void
setItem
(
SessionItem
*
item
)
...
...
@@ -75,20 +74,20 @@ public:
private
:
void
onPropertyChange
(
const
QString
&
name
)
{
m_report
ing
_name
=
name
;
m_report
ed
_name
s
.
append
(
name
)
;
m_onPropertyChangeCount
++
;
}
void
onChildPropertyChange
(
SessionItem
*
item
,
const
QString
&
name
)
{
m_report
ing
_item
=
item
;
m_report
ing
_name
=
name
;
m_report
ed
_item
s
.
append
(
item
)
;
m_report
ed
_name
s
.
append
(
name
)
;
m_onChildPropertyChangeCount
++
;
}
void
onParentChange
(
SessionItem
*
item
)
{
m_report
ing
_item
=
item
;
m_report
ed
_item
s
.
append
(
item
)
;
m_onParentChangeCount
++
;
}
...
...
@@ -102,15 +101,15 @@ private:
int
m_onParentChangeCount
;
int
m_onChildrenChangeCount
;
SessionItem
*
m_mapped_item
;
SessionItem
*
m_report
ing
_item
;
QString
m_report
ing
_name
;
QList
<
SessionItem
*
>
m_report
ed
_item
s
;
QString
List
m_report
ed
_name
s
;
std
::
unique_ptr
<
ModelMapper
>
m_mapper
;
private
slots
:
void
test_onPropertyChange
();
void
test_onParentChange
();
void
test_onChildrenChange
();
};
inline
void
TestMapperForItem
::
test_onPropertyChange
()
...
...
@@ -125,8 +124,8 @@ inline void TestMapperForItem::test_onPropertyChange()
QVERIFY
(
m_onParentChangeCount
==
0
);
QVERIFY
(
m_onChildrenChangeCount
==
0
);
QVERIFY
(
m_mapped_item
==
nullptr
);
QVERIFY
(
m_report
ing
_item
==
nullptr
);
QVERIFY
(
m_report
ing
_name
.
isEmpty
());
QVERIFY
(
m_report
ed
_item
s
.
isEmpty
()
);
QVERIFY
(
m_report
ed
_name
s
.
isEmpty
());
// Mapper is looking on child; set property of child
setItem
(
layer
);
...
...
@@ -136,8 +135,8 @@ inline void TestMapperForItem::test_onPropertyChange()
QVERIFY
(
m_onParentChangeCount
==
0
);
QVERIFY
(
m_onChildrenChangeCount
==
0
);
QVERIFY
(
m_mapped_item
==
layer
);
QVERIFY
(
m_report
ing
_item
==
nullptr
);
QVERIFY
(
m_report
ing
_name
==
LayerItem
::
P_THICKNESS
);
QVERIFY
(
m_report
ed
_item
s
.
isEmpty
()
);
QVERIFY
(
(
m_report
ed_names
.
size
()
==
1
)
&&
(
m_reported
_name
s
[
0
]
==
LayerItem
::
P_THICKNESS
)
)
;
// Mapper is looking on child; set property of parent;
setItem
(
layer
);
...
...
@@ -147,21 +146,73 @@ inline void TestMapperForItem::test_onPropertyChange()
QVERIFY
(
m_onParentChangeCount
==
0
);
QVERIFY
(
m_onChildrenChangeCount
==
0
);
QVERIFY
(
m_mapped_item
==
layer
);
QVERIFY
(
m_report
ing
_item
==
nullptr
);
QVERIFY
(
m_report
ing
_name
.
isEmpty
());
QVERIFY
(
m_report
ed
_item
s
.
isEmpty
()
);
QVERIFY
(
m_report
ed
_name
s
.
isEmpty
());
// Mapper is looking on parent; set property of child;
// setItem(multilayer);
// layer->setItemValue(LayerItem::P_THICKNESS, 1.0);
// QVERIFY(m_onPropertyChangeCount == 0);
//// QVERIFY(m_onChildPropertyChangeCount == 1);
// QVERIFY(m_onParentChangeCount == 0);
// QVERIFY(m_onChildrenChangeCount == 0);
// QVERIFY(m_mapped_item == multilayer);
//// QVERIFY(m_reporting_item == layer);
// QVERIFY(m_reporting_name == LayerItem::P_THICKNESS);
setItem
(
multilayer
);
layer
->
setItemValue
(
LayerItem
::
P_THICKNESS
,
2.0
);
QVERIFY
(
m_onPropertyChangeCount
==
0
);
QVERIFY
(
m_onChildPropertyChangeCount
==
1
);
QVERIFY
(
m_onParentChangeCount
==
0
);
QVERIFY
(
m_onChildrenChangeCount
==
0
);
QVERIFY
(
m_mapped_item
==
multilayer
);
QVERIFY
(
(
m_reported_items
.
size
()
==
1
)
&&
(
m_reported_items
[
0
]
==
layer
));
QVERIFY
((
m_reported_names
.
size
()
==
1
)
&&
(
m_reported_names
[
0
]
==
LayerItem
::
P_THICKNESS
));
// Mapper is looking on parent; set property of parent;
setItem
(
multilayer
);
multilayer
->
setItemValue
(
MultiLayerItem
::
P_CROSS_CORR_LENGTH
,
2.0
);
QVERIFY
(
m_onPropertyChangeCount
==
1
);
QVERIFY
(
m_onChildPropertyChangeCount
==
0
);
QVERIFY
(
m_onParentChangeCount
==
0
);
QVERIFY
(
m_onChildrenChangeCount
==
0
);
QVERIFY
(
m_mapped_item
==
multilayer
);
QVERIFY
(
m_reported_items
.
isEmpty
());
QVERIFY
((
m_reported_names
.
size
()
==
1
)
&&
(
m_reported_names
[
0
]
==
MultiLayerItem
::
P_CROSS_CORR_LENGTH
));
}
inline
void
TestMapperForItem
::
test_onParentChange
()
{
clear
();
SampleModel
model
;
SessionItem
*
multilayer
=
model
.
insertNewItem
(
Constants
::
MultiLayerType
);
SessionItem
*
layer
=
model
.
insertNewItem
(
Constants
::
LayerType
,
model
.
indexOfItem
(
multilayer
));
// SessionItem *layer = model.insertNewItem(Constants::LayerType);
// Mapper is looking on child; changing child's parent
setItem
(
layer
);
multilayer
->
takeRow
(
layer
->
parentRow
());
// model.moveParameterizedItem(layer, multilayer);
// FIXME check onParentChange while moving an item
QVERIFY
(
m_onPropertyChangeCount
==
0
);
QVERIFY
(
m_onChildPropertyChangeCount
==
0
);
QVERIFY
(
m_onParentChangeCount
==
1
);
QVERIFY
(
m_onChildrenChangeCount
==
0
);
QVERIFY
(
m_mapped_item
==
layer
);
QVERIFY
((
m_reported_items
.
size
()
==
1
)
&&
(
m_reported_items
[
0
]
==
nullptr
));
QVERIFY
(
m_reported_names
.
isEmpty
());
}
inline
void
TestMapperForItem
::
test_onChildrenChange
()
{
clear
();
SampleModel
model
;
SessionItem
*
multilayer
=
model
.
insertNewItem
(
Constants
::
MultiLayerType
);
// Mapper is looking on child; adding new child to parent
setItem
(
multilayer
);
SessionItem
*
layer
=
model
.
insertNewItem
(
Constants
::
LayerType
,
model
.
indexOfItem
(
multilayer
));
QVERIFY
(
m_onPropertyChangeCount
==
0
);
QVERIFY
(
m_onChildPropertyChangeCount
==
2
);
QVERIFY
(
m_onParentChangeCount
==
0
);
QVERIFY
(
m_onChildrenChangeCount
==
1
);
QVERIFY
(
m_mapped_item
==
multilayer
);
QVERIFY
(
m_reported_items
.
size
()
==
2
);
QVERIFY
(
m_reported_names
.
size
()
==
2
);
}
#endif
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