2 * This file is part of QMAFW
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights
7 * Contact: Visa Smolander <visa.smolander@nokia.com>
9 * This software, including documentation, is protected by copyright controlled
10 * by Nokia Corporation. All rights are reserved. Copying, including
11 * reproducing, storing, adapting or translating, any or all of this material
12 * requires the prior written consent of Nokia Corporation. This material also
13 * contains confidential information which may not be disclosed to others
14 * without the prior written consent of Nokia.
18 #include "ut_MafwMmcMonitor.h"
20 #include <usb_moded-dbus.h>
25 #define private public // access private slots
26 #include "MafwMmcMonitor.h"
28 extern QStringList stubMounts;
29 extern QStringList g_dbusConnectionParams;
31 void Ut_MafwMmcMonitor::initTestCase()
35 void Ut_MafwMmcMonitor::cleanupTestCase()
39 void Ut_MafwMmcMonitor::testConstruction()
41 QFETCH(QStringList, mounts);
42 QFETCH(bool, mmcMounted);
46 MafwMmcMonitor monitor(this);
48 QVERIFY( monitor.isMounted()==mmcMounted );
50 QCOMPARE(g_dbusConnectionParams.at(0), QString(USB_MODE_SERVICE));
51 QCOMPARE(g_dbusConnectionParams.at(1), QString(USB_MODE_OBJECT));
52 QCOMPARE(g_dbusConnectionParams.at(2), QString(USB_MODE_INTERFACE));
53 QCOMPARE(g_dbusConnectionParams.at(3), QString(USB_MODE_SIGNAL_NAME));
54 QVERIFY(g_dbusConnectionParams.at(4).toUInt() > static_cast<uint>(0));
55 QVERIFY(g_dbusConnectionParams.at(5).length() > 0);
59 void Ut_MafwMmcMonitor::testConstruction_data()
61 QTest::addColumn<QStringList>("mounts");
62 QTest::addColumn<bool>("mmcMounted");
64 QTest::newRow("none") << (QStringList()) << false;
65 QTest::newRow("nommc") << (QStringList() << "file:///home/user/.mms/private" << "file:///home/user/.nokiamessaging/IM") << false;
66 QTest::newRow("mmc") << (QStringList() << "file:///home/user/MyDocs" << "file:///home/user/.nokiamessaging/IM") << true;
69 void Ut_MafwMmcMonitor::testMounts()
72 MafwMmcMonitor monitor(this);
74 QVERIFY( !monitor.isMounted() );
76 stubMounts << "file:///home/user/.mms/private" << "file:///home/user/MyDocs";
77 monitor.mountEvent( 0, (GMount*)1, &monitor );
78 QVERIFY( !monitor.isMounted() );
79 monitor.mountEvent( 0, (GMount*)2, &monitor );
80 QVERIFY( monitor.isMounted() );
82 monitor.unmountEvent( 0, (GMount*)1, &monitor );
83 QVERIFY( monitor.isMounted() );
84 monitor.unmountEvent( 0, (GMount*)2, &monitor );
85 QVERIFY( !monitor.isMounted() );
88 void Ut_MafwMmcMonitor::testPreUnmount()
90 MafwMmcMonitor monitor(this);
91 QSignalSpy spy( &monitor, SIGNAL( preUnmount() ) );
93 monitor.preUnmountEvent("pre-unmount");
94 QVERIFY( spy.size()==1 );
97 QTEST_MAIN(Ut_MafwMmcMonitor)