| 1 | #include "mmtest.h" |
| 2 | #include <gstreamermm.h> |
| 3 | |
| 4 | using namespace Gst; |
| 5 | using Glib::RefPtr; |
| 6 | |
| 7 | TEST(IteratorTest, AssignmentOperatorShouldCopyIterator) |
| 8 | { |
| 9 | Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create_element("fakesink"); |
| 10 | |
| 11 | Gst::Iterator<Gst::Pad> iter = element->iterate_pads(); |
| 12 | Gst::Iterator<Gst::Pad> iter2; |
| 13 | iter2 = iter; |
| 14 | |
| 15 | while (iter.next()) |
| 16 | { |
| 17 | ASSERT_STREQ("sink", iter->get_name().c_str()); |
| 18 | } |
| 19 | |
| 20 | while(iter2.next()) |
| 21 | { |
| 22 | ASSERT_STREQ("sink", iter2->get_name().c_str()); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | |
| 27 | TEST(IteratorTest, BeginShouldResetIterator) |
| 28 | { |
| 29 | Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create_element("fakesink"); |
| 30 | |
| 31 | Gst::Iterator<Gst::Pad> iter = element->iterate_pads(); |
| 32 | |
| 33 | while (iter.next()) |
| 34 | { |
| 35 | ASSERT_STREQ("sink", iter->get_name().c_str()); |
| 36 | } |
| 37 | |
| 38 | iter.begin(); |
| 39 | while (iter.next()) |
| 40 | { |
| 41 | ASSERT_STREQ("sink", iter->get_name().c_str()); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | TEST(IteratorTest, CopyConstructorShouldCopyIteratorAndItsState) |
| 46 | { |
| 47 | Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create_element("fakesink"); |
| 48 | |
| 49 | Gst::Iterator<Gst::Pad> iter = element->iterate_pads(); |
| 50 | |
| 51 | while (iter.next()) |
| 52 | { |
| 53 | ASSERT_STREQ("sink", iter->get_name().c_str()); |
| 54 | } |
| 55 | |
| 56 | ASSERT_FALSE(iter.next()); |
| 57 | |
| 58 | Gst::Iterator<Gst::Pad> iter2 = iter; |
| 59 | |
| 60 | ASSERT_FALSE(iter.next()); |
| 61 | } |
| 62 |