6#include <QtCore/QObject>
7#include <QtTest/QtTest>
12#include <iser/CSerializableBase.h>
31 void cleanupTestCase();
34 void testModelWrapCreation();
35 void testSetBaseObject();
36 void testGetSupportedOperations();
40 void testObserverAttachment();
41 void testChangeNotification();
42 void testBeginEndChanges();
43 void testBeginEndChangeGroup();
46 void testModelDataAccess();
52 class SimpleData:
public iser::CSerializableBase
57 CF_VALUE_CHANGED = 0x1,
61 SimpleData() : m_value(0) {}
63 void SetValue(
int value)
68 changeSet.Set(CF_VALUE_CHANGED);
69 BeginChanges(changeSet);
71 EndChanges(changeSet);
75 int GetValue()
const {
return m_value; }
77 void SetText(
const QString& text)
82 changeSet.Set(CF_TEXT_CHANGED);
83 BeginChanges(changeSet);
85 EndChanges(changeSet);
89 QString GetText()
const {
return m_text; }
92 virtual int GetSupportedOperations()
const override
100 SimpleData* clone =
new SimpleData();
101 clone->m_value = m_value;
102 clone->m_text = m_text;
109 const SimpleData* other =
dynamic_cast<const SimpleData*
>(&object);
112 m_value = other->m_value;
113 m_text = other->m_text;
128 archive.SerializeValue(
"value", m_value);
129 archive.SerializeValue(
"text", m_text);
142 TestObserver() : m_beforeUpdateCount(0), m_afterUpdateCount(0) {}
144 int GetBeforeUpdateCount()
const {
return m_beforeUpdateCount; }
145 int GetAfterUpdateCount()
const {
return m_afterUpdateCount; }
150 m_beforeUpdateCount = 0;
151 m_afterUpdateCount = 0;
152 m_lastChangeSet.Clear();
156 virtual void BeforeUpdate(
imod::IModel* modelPtr)
override
158 CSingleModelObserverBase::BeforeUpdate(modelPtr);
159 m_beforeUpdateCount++;
164 m_afterUpdateCount++;
165 m_lastChangeSet = changeSet;
169 int m_beforeUpdateCount;
170 int m_afterUpdateCount;
177 TestObserver* m_observer;
Test class for TModelWrap functionality.
Basic implementation for a single model observer.
Common interface for model objects, that supports Model/Observer design pattern.
This model wrapper provides a simple connection between a concrete istd::IChangeable implementation a...
Represents an input/output persistence archive for object serialization.
Set of change flags (its IDs).
Common interface for data model objects, which can be changed.
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
@ SO_COPY
Copying from other object.
@ SO_RESET
Resetting of object state.
@ SO_CLONE
Creating of copy of this object.
Unique ownership smart pointer for interface types.