--- /dev/null
+/*
+ * This file is part of QMAFW
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights
+ * reserved.
+ *
+ * Contact: Visa Smolander <visa.smolander@nokia.com>
+ *
+ * This software, including documentation, is protected by copyright controlled
+ * by Nokia Corporation. All rights are reserved. Copying, including
+ * reproducing, storing, adapting or translating, any or all of this material
+ * requires the prior written consent of Nokia Corporation. This material also
+ * contains confidential information which may not be disclosed to others
+ * without the prior written consent of Nokia.
+ *
+ */
+
+#include "ut_MafwMmcMonitor.h"
+
+#include <usb_moded-dbus.h>
+
+#include <QDebug>
+#include <QSignalSpy>
+
+#define private public // access private slots
+#include "MafwMmcMonitor.h"
+
+extern QStringList stubMounts;
+extern QStringList g_dbusConnectionParams;
+
+void Ut_MafwMmcMonitor::initTestCase()
+{
+}
+
+void Ut_MafwMmcMonitor::cleanupTestCase()
+{
+}
+
+void Ut_MafwMmcMonitor::testConstruction()
+{
+ QFETCH(QStringList, mounts);
+ QFETCH(bool, mmcMounted);
+
+ stubMounts = mounts;
+
+ MafwMmcMonitor monitor(this);
+
+ QVERIFY( monitor.isMounted()==mmcMounted );
+
+ QCOMPARE(g_dbusConnectionParams.at(0), QString(USB_MODE_SERVICE));
+ QCOMPARE(g_dbusConnectionParams.at(1), QString(USB_MODE_OBJECT));
+ QCOMPARE(g_dbusConnectionParams.at(2), QString(USB_MODE_INTERFACE));
+ QCOMPARE(g_dbusConnectionParams.at(3), QString(USB_MODE_SIGNAL_NAME));
+ QVERIFY(g_dbusConnectionParams.at(4).toUInt() > static_cast<uint>(0));
+ QVERIFY(g_dbusConnectionParams.at(5).length() > 0);
+
+}
+
+void Ut_MafwMmcMonitor::testConstruction_data()
+{
+ QTest::addColumn<QStringList>("mounts");
+ QTest::addColumn<bool>("mmcMounted");
+
+ QTest::newRow("none") << (QStringList()) << false;
+ QTest::newRow("nommc") << (QStringList() << "file:///home/user/.mms/private" << "file:///home/user/.nokiamessaging/IM") << false;
+ QTest::newRow("mmc") << (QStringList() << "file:///home/user/MyDocs" << "file:///home/user/.nokiamessaging/IM") << true;
+}
+
+void Ut_MafwMmcMonitor::testMounts()
+{
+ stubMounts.clear();
+ MafwMmcMonitor monitor(this);
+
+ QVERIFY( !monitor.isMounted() );
+
+ stubMounts << "file:///home/user/.mms/private" << "file:///home/user/MyDocs";
+ monitor.mountEvent( 0, (GMount*)1, &monitor );
+ QVERIFY( !monitor.isMounted() );
+ monitor.mountEvent( 0, (GMount*)2, &monitor );
+ QVERIFY( monitor.isMounted() );
+
+ monitor.unmountEvent( 0, (GMount*)1, &monitor );
+ QVERIFY( monitor.isMounted() );
+ monitor.unmountEvent( 0, (GMount*)2, &monitor );
+ QVERIFY( !monitor.isMounted() );
+}
+
+void Ut_MafwMmcMonitor::testPreUnmount()
+{
+ MafwMmcMonitor monitor(this);
+ QSignalSpy spy( &monitor, SIGNAL( preUnmount() ) );
+
+ monitor.preUnmountEvent("pre-unmount");
+ QVERIFY( spy.size()==1 );
+}
+
+QTEST_MAIN(Ut_MafwMmcMonitor)