Permalink
Browse files

[tests] make StorageFactory_test compile and pass

Removed some obsolete test cases.
  • Loading branch information...
xhaakon committed Mar 10, 2014
1 parent eec853e commit 2774ac5bd988c56cb2182ae333dd423d34d1dd62
View
@@ -11,6 +11,9 @@ mtpserver.subdir = mtpserver
mtpserver.target = sub-mtpserver
mtpserver.depends = sub-mts
+mts_storage_tests.subdir = mts/platform/storage/unittests
+mts_storage_tests.depends= sub-mts
+
mts_fsstorage_plugin.subdir = mts/platform/storage/fsstorageplugin
mts_fsstorage_plugin.target = sub-mts-fsstorage-plugin
mts_fsstorage_plugin.depends = sub-mts
@@ -38,6 +41,7 @@ SUBDIRS += \
mts \
test \
mtpserver \
+ mts_storage_tests \
mts_fsstorage_plugin \
mts_fsstorage_tests \
mts_deviceinfo_tests \
@@ -1,2 +0,0 @@
-This UT is not meant for CI. Just adding to check if StorageFactory can load
- storage plug-ins without issues.
@@ -25,57 +25,49 @@
#include "storagefactory.h"
#include "mtptypes.h"
+using namespace meegomtp1dot0;
+
+static const quint32 STORAGE_ID = 0x10001;
+static const quint32 INVALID_STORAGE_ID = 0xEEEEE;
+
void StorageFactory_test::initTestCase()
{
m_storageFactory = new StorageFactory;
}
void StorageFactory_test::testStorageIds()
{
- MTPResponseCode response;
QVector<quint32> storageIds;
- response = m_storageFactory->storageIds( storageIds );
- QCOMPARE( response, MTP_RESP_OK );
- QCOMPARE( storageIds.size(), 1 );
- QCOMPARE( storageIds[0], static_cast<quint32>(1) );
+
+ QCOMPARE(m_storageFactory->storageIds(storageIds),
+ static_cast<MTPResponseCode>(MTP_RESP_OK));
+
+ QVERIFY(storageIds.size() > 0);
+
+ qSort(storageIds);
+ QCOMPARE(storageIds.at(0), STORAGE_ID);
}
void StorageFactory_test::testGetObjectHandles()
{
- MTPResponseCode response;
QVector<ObjHandle> handles;
- quint32 noOfObjects = 0;
- response = m_storageFactory->getObjectHandles( 1, static_cast<MTPObjFormatCode>(0x00000000),
- 0, noOfObjects, handles );
- QCOMPARE( response, MTP_RESP_OK );
- QCOMPARE( noOfObjects, static_cast<quint32>(2) );
- QCOMPARE( handles.size(), 2 );
- for( int i = 0 ; i < handles.size(); i++ )
- {
- QString path;
- m_storageFactory->getPath( handles[i], path );
- }
-}
-void StorageFactory_test::testMaxCapacity()
-{
- quint64 maxCapacity;
- MTPResponseCode response = m_storageFactory->maxCapacity( 1, maxCapacity );
- QCOMPARE( response, MTP_RESP_OK );
-}
+ // Try invalid storage ID first.
+ QCOMPARE(m_storageFactory->getObjectHandles(INVALID_STORAGE_ID,
+ static_cast<MTPObjFormatCode>(0x00000000), 0, handles),
+ static_cast<MTPResponseCode>(MTP_RESP_InvalidStorageID));
-void StorageFactory_test::testFreeSpace()
-{
- quint64 freeSpace;
- MTPResponseCode response = m_storageFactory->freeSpace( 1, freeSpace );
- QCOMPARE( response, MTP_RESP_OK );
-}
+ handles.clear();
-void StorageFactory_test::testStorageDescription()
-{
- QString description;
- MTPResponseCode response = m_storageFactory->storageDescription( 1, description );
- QCOMPARE( response, MTP_RESP_OK );
+ QCOMPARE(m_storageFactory->getObjectHandles(STORAGE_ID,
+ static_cast<MTPObjFormatCode>(0x00000000), 0, handles),
+ static_cast<MTPResponseCode>(MTP_RESP_OK));
+
+ foreach (ObjHandle handle, handles) {
+ QString path;
+ QCOMPARE(m_storageFactory->getPath(handle, path),
+ static_cast<MTPResponseCode>(MTP_RESP_OK));
+ }
}
void StorageFactory_test::cleanupTestCase()
@@ -27,6 +27,8 @@
#include <QtTest/QtTest>
#include <QObject>
+namespace meegomtp1dot0 {
+
class StorageFactory;
class StorageFactory_test : public QObject
@@ -37,13 +39,12 @@ private slots:
void initTestCase();
void testStorageIds();
void testGetObjectHandles();
- void testMaxCapacity();
- void testFreeSpace();
- void testStorageDescription();
void cleanupTestCase();
private:
StorageFactory *m_storageFactory;
};
+} // namespace meegomtp1dot0
+
#endif
@@ -1,30 +1,62 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Tue Oct 27 14:29:51 2009
-######################################################################
-
-CONFIG += qtestlib warn_off debug_and_release
+CONFIG += link_pkgconfig
TEMPLATE = app
TARGET = storagefactory-test
+QT += testlib xml dbus
QT -= gui
+PKGCONFIG += Qt5SystemInfo
+
DEFINES += UT_ON
-#QMAKE_CXXFLAGS += -ftest-coverage -fprofile-arcs
-#QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage
-DEPENDPATH += . \
- .. \
- ../../../common
+INCLUDEPATH += \
+ . \
+ .. \
+ ../../deviceinfo \
+ ../../.. \
+ ../../../common \
+ ../../../protocol \
+ ../../../protocol/extensions \
+ ../../../transport \
+ ../../../transport/dummy \
+ ../../../transport/usb \
+
+LIBS += -ldl
-INCLUDEPATH += . \
- .. \
- ../../../common
+HEADERS += \
+ storagefactory_test.h \
+ ../storagefactory.h \
+ ../storageplugin.h \
+ ../../deviceinfo/deviceinfo.h \
+ ../../deviceinfo/deviceinfoprovider.h \
+ ../../deviceinfo/xmlhandler.h \
+ ../../../device_interface.h \
+ ../../../protocol/mtpresponder.h \
+ ../../../protocol/objectpropertycache.h \
+ ../../../protocol/propertypod.h \
+ ../../../transport/mtptransporter.h \
+ ../../../transport/dummy/mtptransporterdummy.h \
+ ../../../transport/usb/mtptransporterusb.h \
+ ../../../transport/usb/threadio.h \
-# Input
-HEADERS += storagefactory_test.h \
- ../storagefactory.h \
- ../storageplugin.h
+SOURCES += \
+ storagefactory_test.cpp \
+ ../storagefactory.cpp \
+ ../../deviceinfo/deviceinfo.cpp \
+ ../../deviceinfo/deviceinfoprovider.cpp \
+ ../../deviceinfo/xmlhandler.cpp \
+ ../../../device_interface.cpp \
+ ../../../protocol/mtpcontainer.cpp \
+ ../../../protocol/mtpcontainerwrapper.cpp \
+ ../../../protocol/mtpextensionmanager.cpp \
+ ../../../protocol/mtpresponder.cpp \
+ ../../../protocol/mtprxcontainer.cpp \
+ ../../../protocol/mtptxcontainer.cpp \
+ ../../../protocol/objectpropertycache.cpp \
+ ../../../protocol/propertypod.cpp \
+ ../../../transport/dummy/mtptransporterdummy.cpp \
+ ../../../transport/usb/descriptor.c \
+ ../../../transport/usb/mtptransporterusb.cpp \
+ ../../../transport/usb/threadio.cpp \
-SOURCES += storagefactory_test.cpp \
- ../storagefactory.cpp
+target.path = /opt/tests/buteo-mtp/
-#clean
-QMAKE_CLEAN += $(TARGET)
+INSTALLS += target

0 comments on commit 2774ac5

Please sign in to comment.