Added DUI control panel applet
[mafwsubrenderer] / qmafw-gst-subtitles-renderer / unittests / ut_MafwMmcMonitor / ut_MafwMmcMonitor.cpp
1 /*
2  * This file is part of QMAFW
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights
5  * reserved.
6  *
7  * Contact: Visa Smolander <visa.smolander@nokia.com>
8  *
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.
15  *
16  */
17
18 #include "ut_MafwMmcMonitor.h"
19
20 #include <usb_moded-dbus.h>
21
22 #include <QDebug>
23 #include <QSignalSpy>
24
25 #define private public // access private slots
26 #include "MafwMmcMonitor.h"
27
28 extern QStringList stubMounts;
29 extern QStringList g_dbusConnectionParams;
30
31 void Ut_MafwMmcMonitor::initTestCase()
32 {
33 }
34
35 void Ut_MafwMmcMonitor::cleanupTestCase()
36 {
37 }
38
39 void Ut_MafwMmcMonitor::testConstruction()
40 {
41     QFETCH(QStringList, mounts);
42     QFETCH(bool, mmcMounted);
43
44     stubMounts = mounts;
45
46     MafwMmcMonitor monitor(this);
47
48     QVERIFY( monitor.isMounted()==mmcMounted );
49
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);
56
57 }
58
59 void Ut_MafwMmcMonitor::testConstruction_data()
60 {
61     QTest::addColumn<QStringList>("mounts");
62     QTest::addColumn<bool>("mmcMounted");
63
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;
67 }
68
69 void Ut_MafwMmcMonitor::testMounts()
70 {
71     stubMounts.clear();
72     MafwMmcMonitor monitor(this);
73
74     QVERIFY( !monitor.isMounted() );
75
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() );
81
82     monitor.unmountEvent( 0, (GMount*)1, &monitor );
83     QVERIFY( monitor.isMounted() );
84     monitor.unmountEvent( 0, (GMount*)2, &monitor );
85     QVERIFY( !monitor.isMounted() );
86 }
87
88 void Ut_MafwMmcMonitor::testPreUnmount()
89 {
90     MafwMmcMonitor monitor(this);
91     QSignalSpy spy( &monitor, SIGNAL( preUnmount() ) );
92
93     monitor.preUnmountEvent("pre-unmount");
94     QVERIFY( spy.size()==1 );
95 }
96
97 QTEST_MAIN(Ut_MafwMmcMonitor)