From: Diane Trout Date: Mon, 23 Oct 2006 22:55:44 +0000 (+0000) Subject: Enable Qt4 tests X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=c720e3a63eb049ec466a5f55566aa248f273f8b9 Enable Qt4 tests 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. --- diff --git a/qui/CMakeLists.txt b/qui/CMakeLists.txt index af064c7..d4ab6db 100644 --- a/qui/CMakeLists.txt +++ b/qui/CMakeLists.txt @@ -98,4 +98,4 @@ SET_TARGET_PROPERTIES( ) -#ADD_SUBDIRECTORY( test ) +ADD_SUBDIRECTORY( test ) diff --git a/qui/test/CMakeLists.txt b/qui/test/CMakeLists.txt index 7e279f2..c41b2cd 100644 --- a/qui/test/CMakeLists.txt +++ b/qui/test/CMakeLists.txt @@ -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 index 0000000..c8a0b95 --- /dev/null +++ b/qui/test/TestColorSharing.hpp @@ -0,0 +1,31 @@ +#ifndef _TEST_COLOR_SHARING_HPP_ +#define _TEST_COLOR_SHARING_HPP_ + +#include +#include + +#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 index 0000000..0f56b6c --- /dev/null +++ b/qui/test/TestSequenceBrowser.hpp @@ -0,0 +1,50 @@ +#ifndef _TEST_SEQUENCE_BROWSER_HPP_ +#define _TEST_SEQUENCE_BROWSER_HPP_ + +#include +#include + +#include "alg/sequence.hpp" +#include "qui/seqbrowser/SequenceBrowser.hpp" + +#include +#include +#include + +#include +#include +using namespace boost::assign; + + +class TestSequenceBrowser : public QObject +{ + Q_OBJECT + +private slots: + + void testSimplePushSequence() { + boost::shared_ptr seq1(new Sequence("AAGGCCTT")); + boost::shared_ptr 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 seq1(new Sequence("AAGGCCTT")); + boost::shared_ptr seq2(new Sequence("GGCCTTAA")); + + SequenceBrowser browser; + browser.push_sequence(seq1); + browser.push_sequence(seq2); + std::vector path; path += 1,1; + std::vector 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 index 0000000..0ca0b80 --- /dev/null +++ b/qui/test/TestSequenceDescription.hpp @@ -0,0 +1,50 @@ +#ifndef _TEST_SEQUENCE_DESCRIPTION_HPP_ +#define _TEST_SEQUENCE_DESCRIPTION_HPP_ + +#include +#include + +#include "alg/sequence.hpp" +#include "alg/glsequence.hpp" +#include "alg/annotation_colors.hpp" +#include "qui/seqbrowser/SequenceDescription.hpp" + +#include +#include +#include + +class TestSequenceDescription : public QObject +{ + Q_OBJECT + +private slots: + void testSimple() { + boost::shared_ptr seq1(new Sequence("AAGGCCTT")); + seq1->set_species("foo"); + boost::shared_ptr cm(new AnnotationColors); + boost::shared_ptr 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 seq1(new Sequence("AAGGCCTT")); + Sequence m("AAGG"); + seq1->find_motif(m); + seq1->set_species("foo"); + boost::shared_ptr cm(new AnnotationColors); + boost::shared_ptr 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 index 0000000..a1a774e --- /dev/null +++ b/qui/test/TestSequenceLocationModel.hpp @@ -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 + +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