Allow changing the name for a sequence in the sequence browser.
[mussa.git] / qui / test / TestSequenceDescription.cpp
1 #include <QtGui>
2 #include <QtTest/QtTest>
3
4 #include "alg/sequence.hpp"
5 #include "alg/glsequence.hpp"
6 #include "alg/annotation_colors.hpp"
7 #include "qui/seqbrowser/SequenceDescription.hpp"
8
9 #include <iostream>
10 #include <string>
11 #include <vector>
12
13 class TestSequenceDescription : public QObject
14 {
15   Q_OBJECT
16
17 private slots:
18   void testSimple() {
19     boost::shared_ptr<Sequence> seq1(new Sequence("AAGGCCTT"));
20     seq1->set_species("foo");
21     boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
22     boost::shared_ptr<GlSequence> glseq1(new GlSequence(seq1, cm));
23
24     SequenceDescription sd(glseq1, 0);
25     QVERIFY(sd.glsequence() == glseq1);
26     QVERIFY(sd.glsequence()->sequence()->get_species() == seq1->get_species());
27     sd.setName(std::string("bar"));
28     QVERIFY(sd.glsequence()->sequence()->get_species() == seq1->get_species());
29     QVERIFY(seq1->get_species() == "bar");
30   }
31   void testDeletedPointer() {
32     SequenceDescription sd;
33
34     { 
35       boost::shared_ptr<Sequence> seq1(new Sequence("AAGGCCTT"));
36       Sequence m("AAGG");
37       seq1->find_motif(m);
38       seq1->set_species("foo");
39       boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
40       boost::shared_ptr<GlSequence> glseq1(new GlSequence(seq1, cm));
41       sd.setGlSequence(glseq1);
42     }
43
44     QVERIFY(sd.name() == "foo");
45   }
46 };
47
48 QTEST_MAIN(TestSequenceDescription)
49 #include "moc_TestSequenceDescription.cxx"