Changeset View
Changeset View
Standalone View
Standalone View
tests/units/akonadi/akonadiserializertest.cpp
Show First 20 Lines • Show All 1994 Lines • ▼ Show 20 Line(s) | 1994 | { | |||
---|---|---|---|---|---|
1995 | QTest::addColumn<QString>("contextUid"); | 1995 | QTest::addColumn<QString>("contextUid"); | ||
1996 | QTest::addColumn<QString>("todoUid"); | 1996 | QTest::addColumn<QString>("todoUid"); | ||
1997 | QTest::addColumn<bool>("expectedResult"); | 1997 | QTest::addColumn<bool>("expectedResult"); | ||
1998 | 1998 | | |||
1999 | QTest::newRow("yes") << "context-123" << "context-123" << true; | 1999 | QTest::newRow("yes") << "context-123" << "context-123" << true; | ||
2000 | QTest::newRow("no") << "context-123" << "another-context" << false; | 2000 | QTest::newRow("no") << "context-123" << "another-context" << false; | ||
2001 | } | 2001 | } | ||
2002 | 2002 | | |||
2003 | void shouldTestIfItemRepresentsContext() | | |||
2004 | { | | |||
2005 | // GIVEN | | |||
2006 | QFETCH(QString, contextUid); | | |||
2007 | QFETCH(QString, todoUid); | | |||
2008 | QFETCH(bool, expectedResult); | | |||
2009 | | ||||
2010 | auto context = Domain::Context::Ptr::create(); | | |||
2011 | context->setProperty("todoUid", contextUid); | | |||
2012 | | ||||
2013 | KCalCore::Todo::Ptr todo(new KCalCore::Todo); | | |||
2014 | todo->setCustomProperty(s_appName, "Context", QStringLiteral("1")); | | |||
2015 | todo->setUid(todoUid); | | |||
2016 | Akonadi::Item item; | | |||
2017 | item.setPayload<KCalCore::Todo::Ptr>(todo); | | |||
2018 | | ||||
2019 | // WHEN | | |||
2020 | Akonadi::Serializer serializer; | | |||
2021 | const bool result = serializer.itemRepresentsContext(context, item); | | |||
2022 | | ||||
2023 | // THEN | | |||
2024 | QCOMPARE(result, expectedResult); | | |||
2025 | QCOMPARE(serializer.contextUid(item), todoUid); | | |||
2026 | } | | |||
2027 | | ||||
2028 | void shouldAddContextToTask_data() | 2003 | void shouldAddContextToTask_data() | ||
2029 | { | 2004 | { | ||
2030 | QTest::addColumn<Domain::Context::Ptr>("context"); | 2005 | QTest::addColumn<Domain::Context::Ptr>("context"); | ||
2031 | QTest::addColumn<Akonadi::Item>("item"); | 2006 | QTest::addColumn<Akonadi::Item>("item"); | ||
2032 | QTest::addColumn<QString>("expectedContextList"); | 2007 | QTest::addColumn<QString>("expectedContextList"); | ||
2033 | 2008 | | |||
2034 | // Create a context | 2009 | // Create a context | ||
2035 | auto context = Domain::Context::Ptr::create(); | 2010 | auto context = Domain::Context::Ptr::create(); | ||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |