Created new public method to MainWindow to get view index. Currently
authorKaj Wallin <kaj.wallin@ixonos.com>
Wed, 31 Mar 2010 12:46:43 +0000 (15:46 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Wed, 31 Mar 2010 12:46:43 +0000 (15:46 +0300)
this method is used by testtabs unit test.

src/ui/listviewscreen.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
tests/testUI/testtabs/testtabs
tests/testUI/testtabs/testtabs.cpp

index fbefb6b..f9578a3 100644 (file)
@@ -5,15 +5,15 @@
        Kaj Wallin - kaj.wallin@ixonos.com
 
     Situare is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
+   qt trace modify it under the terms of the GNU General Public License
     version 2 as published by the Free Software Foundation.
 
     Situare is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   qt trace MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
+   qt trace You should have received a copy of the GNU General Public License
     along with Situare; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
     USA.
index 1d8ff63..f1ac7da 100644 (file)
@@ -40,7 +40,7 @@ MainWindow::MainWindow(QWidget *parent)
     widget->setLayout(mainLayout);
     createMenus();
 
-    this->setWindowTitle(tr("View"));
+    setWindowTitle(tr("View"));
 }
 
 MainWindow::~MainWindow()
@@ -67,23 +67,28 @@ void MainWindow::createMenus()
 void MainWindow::createViews()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    situareViews = new QStackedWidget(this);
-    situareViews->addWidget(new ListViewScreen(this));
-    situareViews->addWidget(new MapViewScreen(this));
+    situareViews = new QStackedWidget;
+    situareViews->addWidget(new ListViewScreen);
+    situareViews->addWidget(new MapViewScreen);
 }
 
 void MainWindow::toListView()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    this->situareViews->setCurrentIndex(0);
+    situareViews->setCurrentIndex(0);
     infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
-    this->setWindowTitle("List");
+    setWindowTitle("List");
 }
 
 void MainWindow::toMapView()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    this->situareViews->setCurrentIndex(1);
+    situareViews->setCurrentIndex(1);
     infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
-    this->setWindowTitle("Map");
+    setWindowTitle("Map");
+}
+
+int MainWindow::getViewIndex()
+{
+    return situareViews->currentIndex();
 }
index 602f7fb..1475146 100644 (file)
@@ -45,11 +45,11 @@ public:
     ~MainWindow();
 
     /**
-    * @brief Widget Stack object for the List and Map Views
+    * @brief Public method to get current index of the view. Used for Unit testing
     *
-    * @var situareViews
+    * @fn getViewIndex
     */
-    QStackedWidget *situareViews;
+    int getViewIndex();
 
 private:
     /**
@@ -58,6 +58,12 @@ private:
     * @fn createViews
     */
     void createViews();
+    /**
+    * @brief Widget Stack object for the List and Map Views
+    *
+    * @var situareViews
+    */
+    QStackedWidget *situareViews;
 
     /**
     * @brief Private method to create the Menu items
@@ -90,13 +96,13 @@ private:
 
 public slots:
     /**
-    * @brief Private slot, which initiates toListViewAct action
+    * @brief Public slot, which initiates toListViewAct action to switch view
     *
     * @fn toListView
     */
     void toListView();
     /**
-    * @brief Private slot, which initiates toMapViewAct action
+    * @brief Public slot, which initiates toMapViewAct action to switch view
     *
     * @fn toMapView
     */
index 9ed46ce..778fc32 100755 (executable)
Binary files a/tests/testUI/testtabs/testtabs and b/tests/testUI/testtabs/testtabs differ
index 8bca579..cc96df6 100644 (file)
@@ -38,13 +38,13 @@ void testTabs::testTabChanges()
 {
     MainWindow mainwindow;
     mainwindow.toListView();
-    QCOMPARE(mainwindow.situareViews->currentIndex(), 0);
+    QCOMPARE(mainwindow.getViewIndex(), 0);
     mainwindow.toMapView();
-    QCOMPARE(mainwindow.situareViews->currentIndex(), 1);
+    QCOMPARE(mainwindow.getViewIndex(), 1);
     mainwindow.toMapView();
-    QCOMPARE(mainwindow.situareViews->currentIndex(), 1);
+    QCOMPARE(mainwindow.getViewIndex(), 1);
     mainwindow.toListView();
-    QCOMPARE(mainwindow.situareViews->currentIndex(), 0);
+    QCOMPARE(mainwindow.getViewIndex(), 0);
 }
 
 QTEST_MAIN(testTabs)