Merged and resolved conflicts.
[situare] / tests / ui / mainwindow / mainwindow_test.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Kaj Wallin - kaj.wallin@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22 #include <QtTest/QtTest>
23 #include <QtCore>
24 #include <QtGui>
25
26 #include "ui/mapviewscreen.h"
27 #include "ui/listviewscreen.h"
28 #include "ui/mainwindow.h"
29 //#include "facebook_service/fbauthentication/fbauthentication.h"
30
31 class testMainWindow : public QObject
32 {
33     Q_OBJECT
34 private slots:
35     void testViewSwitch();
36     void verifyStackItems();
37 //    void verifyMenuItems();  //NON-WORKING
38 };
39
40 void testMainWindow::testViewSwitch()
41 {
42     MainWindow mainwindow;
43     QStackedWidget *m_testStack = dynamic_cast<QStackedWidget*>(mainwindow.centralWidget());
44     mainwindow.toListView();
45     QCOMPARE(m_testStack->currentIndex(), 0);
46     QCOMPARE(mainwindow.windowTitle(),QString(tr("List view")));
47     mainwindow.toMapView();
48     QCOMPARE(m_testStack->currentIndex(), 1);
49     QCOMPARE(mainwindow.windowTitle(),QString(tr("Map view")));
50     mainwindow.toMapView();
51     QCOMPARE(m_testStack->currentIndex(), 1);
52     QCOMPARE(mainwindow.windowTitle(),QString(tr("Map view")));
53     mainwindow.toListView();
54     QCOMPARE(m_testStack->currentIndex(), 0);
55     QCOMPARE(mainwindow.windowTitle(),QString(tr("List view")));
56 }
57 void testMainWindow::verifyStackItems()
58 {
59     MainWindow mainwindow;
60     QStackedWidget *m_testStack = dynamic_cast<QStackedWidget*>(mainwindow.centralWidget());
61     QCOMPARE(m_testStack->count(), 2);
62     QCOMPARE(m_testStack->widget(0)->objectName(),QString(tr("List view")));
63     QCOMPARE(m_testStack->widget(1)->objectName(),QString(tr("Map view")));
64 }
65
66 /* NON-WORKING TEST
67 void testMainWindow::verifyMenuItems()
68 {
69     MainWindow mainwindow;
70     QWidget *m_testMenu = mainwindow.menuWidget();
71     qDebug() << m_testMenu->actions();
72 }
73 */
74
75 QTEST_MAIN(testMainWindow)
76 #include "mainwindow_test.moc"