Enable Qt4 tests
authorDiane Trout <diane@caltech.edu>
Mon, 23 Oct 2006 22:55:44 +0000 (22:55 +0000)
committerDiane Trout <diane@caltech.edu>
Mon, 23 Oct 2006 22:55:44 +0000 (22:55 +0000)
ticket:207
To fix the problem generating the moc_Test files I stopped trying
to fake the .hpp file for moc, and renamed the qui/test/Test*.cpp files to
.hpp and added a very small .cpp file which included the header and
called the QTEST_MAIN or QTEST_APPLESS_MAIN macro.
APPLESS will work even if I don't have a working X server on linux, but
some parts of Qt require that the gApp be constructed.

qui/CMakeLists.txt
qui/test/CMakeLists.txt
qui/test/TestColorSharing.hpp [new file with mode: 0644]
qui/test/TestSequenceBrowser.hpp [new file with mode: 0644]
qui/test/TestSequenceDescription.hpp [new file with mode: 0644]
qui/test/TestSequenceLocationModel.hpp [new file with mode: 0644]

index af064c7ff8142a9691257a6d4dbb76f2017e5634..d4ab6dbe95e7e7e5295e4e149e33f38711123ebf 100644 (file)
@@ -98,4 +98,4 @@ SET_TARGET_PROPERTIES(
 )
 
 
-#ADD_SUBDIRECTORY( test )
+ADD_SUBDIRECTORY( test )
index 7e279f2647b14a271722c9cbdd9e96972f22e69f..c41b2cd634c82be51948f1ff6c418965476b948d 100644 (file)
@@ -14,8 +14,8 @@ FIND_PACKAGE(Boost)
 FIND_PACKAGE(PythonLibs)
 
 SET(libs
-        mussa_core
         mussa_qui
+        mussa_core
         ${QT_LIBRARIES}
         ${OPENGL_gl_LIBRARY}
         ${BOOST_PROGRAM_OPTIONS_LIBRARY}
@@ -25,14 +25,14 @@ SET(libs
       )
 
 MACRO(MAKE_UNITTEST basename)
-  QT4_WRAP_CPP(${basename}_MOC_CXX  ${basename}.cpp)
+  QT4_WRAP_CPP(${basename}_MOC_CXX  ${basename}.hpp)
   GET_FILENAME_COMPONENT(${basename}_MOC_DIR ${${basename}_MOC_CXX} PATH)
   SET(${basename}_SRC ${basename}.cpp)
   INCLUDE_DIRECTORIES(${${basename}_MOC_DIR})
   SET_SOURCE_FILES_PROPERTIES(${${basename}_SRC} 
                               PROPERTIES COMPILE_FLAGS "-fPIC"
                              )
-  ADD_EXECUTABLE(${basename} ${${basename}_SRC})
+  ADD_EXECUTABLE(${basename} ${${basename}_MOC_CXX} ${${basename}_SRC})
   SET_TARGET_PROPERTIES(${basename} PROPERTIES COMPILE_FLAGS "-fPIC")
   TARGET_LINK_LIBRARIES(${basename} ${libs})
   ADD_TEST(${basename} ${basename})
diff --git a/qui/test/TestColorSharing.hpp b/qui/test/TestColorSharing.hpp
new file mode 100644 (file)
index 0000000..c8a0b95
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef _TEST_COLOR_SHARING_HPP_
+#define _TEST_COLOR_SHARING_HPP_
+
+#include <QtGui>
+#include <QtTest/QtTest>
+
+#include "alg/mussa.hpp"
+#include "alg/color.hpp"
+#include "qui/MussaWindow.hpp"
+
+//! do our colors get shared correctly between different windows?
+class TestColorSharing : public QObject
+{
+  Q_OBJECT
+
+private slots:
+
+  void simple2sequence() {
+    Color green(0.0, 1.0, 0.0);
+    Mussa m;
+    m.append_sequence("AAGGCCTT");
+    m.append_sequence("GGTTCCAA");
+    m.set_window(2);
+    m.set_threshold(2);
+    m.analyze();
+
+    //MussaWindow mw(&m);
+    m.add_motif("GG", green);
+  }
+};
+#endif
diff --git a/qui/test/TestSequenceBrowser.hpp b/qui/test/TestSequenceBrowser.hpp
new file mode 100644 (file)
index 0000000..0f56b6c
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _TEST_SEQUENCE_BROWSER_HPP_
+#define _TEST_SEQUENCE_BROWSER_HPP_
+
+#include <QtGui>
+#include <QtTest/QtTest>
+
+#include "alg/sequence.hpp"
+#include "qui/seqbrowser/SequenceBrowser.hpp"
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <boost/assign.hpp>
+#include <boost/shared_ptr.hpp>
+using namespace boost::assign;
+
+
+class TestSequenceBrowser : public QObject
+{
+  Q_OBJECT
+
+private slots:
+
+  void testSimplePushSequence() {
+    boost::shared_ptr<Sequence> seq1(new Sequence("AAGGCCTT"));
+    boost::shared_ptr<Sequence> seq2(new Sequence("GGCCTTAA"));
+
+    SequenceBrowser browser;
+    QVERIFY(browser.sequences().size() == 0);
+    browser.push_sequence(seq1);
+    browser.push_sequence(seq2);
+    QVERIFY(browser.sequences().size() == 2);
+    browser.clear();
+    QVERIFY(browser.sequences().size() == 0);
+  }
+
+  void testSelect() {
+    boost::shared_ptr<Sequence> seq1(new Sequence("AAGGCCTT"));
+    boost::shared_ptr<Sequence> seq2(new Sequence("GGCCTTAA"));
+
+    SequenceBrowser browser;
+    browser.push_sequence(seq1);
+    browser.push_sequence(seq2);
+    std::vector<int> path; path += 1,1;
+    std::vector<bool> rc; rc += false, false;
+    browser.link(path, rc, 2);
+  }
+};
+#endif
diff --git a/qui/test/TestSequenceDescription.hpp b/qui/test/TestSequenceDescription.hpp
new file mode 100644 (file)
index 0000000..0ca0b80
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _TEST_SEQUENCE_DESCRIPTION_HPP_
+#define _TEST_SEQUENCE_DESCRIPTION_HPP_
+
+#include <QtGui>
+#include <QtTest/QtTest>
+
+#include "alg/sequence.hpp"
+#include "alg/glsequence.hpp"
+#include "alg/annotation_colors.hpp"
+#include "qui/seqbrowser/SequenceDescription.hpp"
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+class TestSequenceDescription : public QObject
+{
+  Q_OBJECT
+
+private slots:
+  void testSimple() {
+    boost::shared_ptr<Sequence> seq1(new Sequence("AAGGCCTT"));
+    seq1->set_species("foo");
+    boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
+    boost::shared_ptr<GlSequence> glseq1(new GlSequence(seq1, cm));
+
+    SequenceDescription sd(glseq1, 0);
+    QVERIFY(sd.glsequence() == glseq1);
+    QVERIFY(sd.glsequence()->sequence()->get_species() == seq1->get_species());
+    sd.setName(std::string("bar"));
+    QVERIFY(sd.glsequence()->sequence()->get_species() == seq1->get_species());
+    QVERIFY(seq1->get_species() == "bar");
+  }
+  void testDeletedPointer() {
+    SequenceDescription sd;
+
+    { 
+      boost::shared_ptr<Sequence> seq1(new Sequence("AAGGCCTT"));
+      Sequence m("AAGG");
+      seq1->find_motif(m);
+      seq1->set_species("foo");
+      boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
+      boost::shared_ptr<GlSequence> glseq1(new GlSequence(seq1, cm));
+      sd.setGlSequence(glseq1);
+    }
+
+    QVERIFY(sd.name() == "foo");
+  }
+};
+#endif
diff --git a/qui/test/TestSequenceLocationModel.hpp b/qui/test/TestSequenceLocationModel.hpp
new file mode 100644 (file)
index 0000000..a1a774e
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _TEST_SEQUENCE_LOCATION_MODEL_HPP_
+#define _TEST_SEQUENCE_LOCATION_MODEL_HPP_
+#include "qui/SequenceLocationModel.hpp"
+#include "alg/sequence_location.hpp"
+#include "alg/sequence.hpp"
+
+#include <QtTest/QtTest>
+
+class TestSequenceLocationModel : public QObject
+{
+  Q_OBJECT
+
+private slots:
+
+  void testAddSequences() {
+    Sequence seq1("AAGGCCTT");
+    Sequence seq2("GGCCTTAA");
+
+    SequenceLocation loc1(seq1, 0, 2);
+    SequenceLocation loc2(seq2, 3, 3);
+
+    SequenceLocationModel slm;
+    QVERIFY(slm.size() == 0);
+    slm.push_back(loc1);
+    slm.push_back(loc2);
+
+    QVERIFY(slm.rowCount() == 2);
+    QVERIFY(slm.rowCount() == slm.size());
+
+  }
+
+  void testColumn() {
+    SequenceLocationModel slm;
+    QVERIFY(slm.columnCount() == 3);
+  }
+};
+#endif