set annotation draw function by type
[mussa.git] / alg / test / test_glsequence.cpp
index 120a3f6d238a664a55678f08bee4a4aa029704f8..47621af4eac63fe11154339bdb39aaa69fd1bfd8 100644 (file)
@@ -91,6 +91,33 @@ BOOST_AUTO_TEST_CASE( glsequence_find_real_sequence )
   BOOST_CHECK_EQUAL(annot[2]->size(), 1);
 }
 
+void dummy_draw_func(SeqSpanRef ref, float l, float r)
+{
+}
+  
+BOOST_AUTO_TEST_CASE( glsequence_set_annotation_drawfunc_by_type )
+{
+  ColorRef default_color(new Color(1.0, 0.0, 0.0));
+  boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
+  GlSequence s("AAAAGGGGNNNNTTTTCCC", cm);
+  //            0123456789012345678
+  s.add_annotation("Aname", "value", 0, 4);
+  s.add_annotation("Gname", "value", 4, 4);
+  s.add_annotation("Tname", "gene", 12, 4);
+  s.update_annotation_draw_function("gene", dummy_draw_func, default_color);
+
+  BOOST_CHECK_EQUAL(s.annotations().size(), 3);
+  std::vector<SeqSpanRef> annot(s.annotations().begin(), s.annotations().end());
+  // the two not updated annotations shouldn't have a drawable attached to them yet 
+  BOOST_CHECK( not annot[0]->drawable());
+  BOOST_CHECK( not annot[1]->drawable());
+  // the annotation updated must be drawable
+  BOOST_REQUIRE(annot[2]->drawable());
+  // and it must have the right draw function
+  BOOST_CHECK_EQUAL(annot[2]->drawable()->drawFunction(), dummy_draw_func);
+  BOOST_CHECK_EQUAL(annot[2]->drawable()->color(), default_color);
+}
+
 BOOST_AUTO_TEST_CASE( glsequence_renderable )
 {
   boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);