Skycoder42
6 years ago
18 changed files with 222 additions and 91 deletions
@ -0,0 +1,14 @@ |
|||
TEMPLATE = app |
|||
|
|||
QT += testlib mvvmdatasynccore |
|||
QT -= gui |
|||
CONFIG += console |
|||
CONFIG -= app_bundle |
|||
|
|||
TARGET = tst_datasyncsettingsaccessor |
|||
|
|||
HEADERS += \ |
|||
../../../shared/tst_isettingsaccessor.h |
|||
|
|||
SOURCES += \ |
|||
tst_datasyncsettingsaccessor.cpp |
@ -0,0 +1,57 @@ |
|||
#include <QtTest> |
|||
#include <QtMvvmDataSyncCore/DataSyncSettingsAccessor> |
|||
#include <QtDataSync/Setup> |
|||
#include "../../../shared/tst_isettingsaccessor.h" |
|||
using namespace QtDataSync; |
|||
using namespace QtMvvm; |
|||
|
|||
class DataSyncSettingsAccessorTest : public ISettingsAccessorTest |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
protected: |
|||
ISettingsAccessor *createFirst() override; |
|||
ISettingsAccessor *createSecond() override; |
|||
bool testSyncChangeSignals() override; |
|||
|
|||
private Q_SLOTS: |
|||
void initTestCase(); |
|||
void cleanupTestCase(); |
|||
|
|||
private: |
|||
QTemporaryDir tDir; |
|||
}; |
|||
|
|||
ISettingsAccessor *DataSyncSettingsAccessorTest::createFirst() |
|||
{ |
|||
return new DataSyncSettingsAccessor{this}; |
|||
} |
|||
|
|||
ISettingsAccessor *DataSyncSettingsAccessorTest::createSecond() |
|||
{ |
|||
return new DataSyncSettingsAccessor{this}; |
|||
} |
|||
|
|||
bool DataSyncSettingsAccessorTest::testSyncChangeSignals() |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
void DataSyncSettingsAccessorTest::initTestCase() |
|||
{ |
|||
Setup{}.setLocalDir(tDir.path()) |
|||
.setKeyStoreProvider(QStringLiteral("plain")) |
|||
.create(); |
|||
} |
|||
|
|||
void DataSyncSettingsAccessorTest::cleanupTestCase() |
|||
{ |
|||
delete first; |
|||
delete second; |
|||
Setup::removeSetup(DefaultSetup, true); |
|||
tDir.remove(); |
|||
} |
|||
|
|||
QTEST_MAIN(DataSyncSettingsAccessorTest) |
|||
|
|||
#include "tst_datasyncsettingsaccessor.moc" |
@ -0,0 +1,4 @@ |
|||
TEMPLATE = subdirs |
|||
|
|||
SUBDIRS += \ |
|||
datasyncsettingsaccessor |
@ -1,6 +1,7 @@ |
|||
TEMPLATE = subdirs |
|||
|
|||
SUBDIRS += \ |
|||
qmlsettingsgenerator |
|||
qmlsettingsgenerator \ |
|||
qmlmvvmcore |
|||
|
|||
equals(MSVC_VER, 14.0): SUBDIRS -= qmlsettingsgenerator |
|||
|
@ -0,0 +1,16 @@ |
|||
TEMPLATE = app |
|||
|
|||
QT += testlib mvvmcore qml |
|||
CONFIG += qmltestcase console |
|||
CONFIG -= app_bundle |
|||
|
|||
TARGET = tst_qmlmvvmcore |
|||
|
|||
SOURCES += \ |
|||
tst_qmlmvvmcore.cpp |
|||
|
|||
DISTFILES += \ |
|||
tst_qmlmvvmcore.qml |
|||
|
|||
importFiles.path = . |
|||
DEPLOYMENT += importFiles |
@ -0,0 +1,4 @@ |
|||
#include <QtCore> |
|||
#include <QtQuickTest/quicktest.h> |
|||
|
|||
QUICK_TEST_MAIN(qmlmvvmcore) |
@ -0,0 +1,61 @@ |
|||
import QtQuick 2.10 |
|||
import de.skycoder42.QtMvvm.Core 1.1 |
|||
import QtTest 1.1 |
|||
|
|||
Item { |
|||
id: root |
|||
|
|||
TestCase { |
|||
name: "Binding" |
|||
|
|||
QtObject { |
|||
id: obj |
|||
|
|||
property int prop1: 42 |
|||
property int prop2: 0 |
|||
} |
|||
|
|||
MvvmBinding { |
|||
id: bind |
|||
viewModel: obj |
|||
view: obj |
|||
viewModelProperty: "prop1" |
|||
viewProperty: "prop2" |
|||
type: MvvmBinding.SingleInit |
|||
} |
|||
|
|||
function test_1_SingleInit() { |
|||
verify(bind.isValid()); |
|||
compare(obj.prop1, 42); |
|||
compare(obj.prop2, 42); |
|||
obj.prop1 = 24; |
|||
compare(obj.prop2, 42); |
|||
obj.prop2 = 44; |
|||
compare(obj.prop1, 24); |
|||
} |
|||
|
|||
function test_2_OneWayToView() { |
|||
bind.type = MvvmBinding.OneWayToView |
|||
obj.prop1 = 33; |
|||
compare(obj.prop2, 33); |
|||
obj.prop2 = 44; |
|||
compare(obj.prop1, 33); |
|||
} |
|||
|
|||
function test_3_OneWayToViewModel() { |
|||
bind.type = MvvmBinding.OneWayToViewModel |
|||
obj.prop2 = 45; |
|||
compare(obj.prop1, 45); |
|||
obj.prop1 = 22; |
|||
compare(obj.prop2, 45); |
|||
} |
|||
|
|||
function test_4_TwoWay() { |
|||
bind.type = MvvmBinding.TwoWay |
|||
obj.prop1 = 78; |
|||
compare(obj.prop2, 78); |
|||
obj.prop2 = 87; |
|||
compare(obj.prop1, 87); |
|||
} |
|||
} |
|||
} |
@ -1,59 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<SettingsConfig allowSearch="true" allowRestore="true"> |
|||
<Include optional="true">/absolute/include/path.xml</Include> |
|||
<Include optional="false">../relative/include/path.xml</Include> |
|||
<Category title="title" |
|||
icon="file:///icon/path.svg" |
|||
tooltip="useful tip" |
|||
frontends="widgets|quick" |
|||
selectors="ios|android&xhdpi"> |
|||
<Include optional="true">/absolute/include/path.xml</Include> |
|||
<Include>../relative/include/path.xml</Include> |
|||
<Section title="another title" |
|||
icon="https://example.org/icon/path.svg" |
|||
tooltip="another tip" |
|||
frontends="widgets" |
|||
selectors="android&xhdpi"> |
|||
<Include optional="true">/absolute/include/path.xml</Include> |
|||
<Include>../relative/include/path.xml</Include> |
|||
<Group title="group title" |
|||
tooltip="hovering tool tip" |
|||
frontends="quick" |
|||
selectors="ios|android"> |
|||
<Include optional="true">/absolute/include/path.xml</Include> |
|||
<Include>../relative/include/path.xml</Include> |
|||
<Entry key="property" |
|||
type="bool" |
|||
title="&Check me" |
|||
tooltip="I am a checkbox!" |
|||
default="false" |
|||
frontends="widgets|quick" |
|||
selectors="ios|android&xhdpi"> |
|||
<SearchKey>prop</SearchKey> |
|||
<SearchKey>attrib</SearchKey> |
|||
<SearchKey>sample</SearchKey> |
|||
<Property key="text" type="string">Please do check me</Property> |
|||
<Property key="size" type="object"> |
|||
<Property key="width" type="int">42</Property> |
|||
<Property key="height" type="int">42</Property> |
|||
</Property> |
|||
<Property key="things" type="list"> |
|||
<Element type="int">42</Element> |
|||
<Element type="list"> |
|||
<Element type="string">elem 1</Element> |
|||
<Element type="string">elem 2</Element> |
|||
</Element> |
|||
<Element type="object"> |
|||
<Property key="name" type="string">baum</Property> |
|||
<Property key="number" type="int">42</Property> |
|||
</Element> |
|||
</Property> |
|||
</Entry> |
|||
<Entry key="req" type="req" title="req" /> |
|||
</Group> |
|||
<Group/> |
|||
</Section> |
|||
<Section/> |
|||
</Category> |
|||
<Category/> |
|||
</SettingsConfig> |
Loading…
Reference in new issue