Folks: remove dead unit tests

The unit tests did not work because creating FolksIndividual
instances with attributes is not supported unless they come from
a specific folks backend.

Removing them in preparation of changing the API of
IndividualAggregator (pass LocaleFactory for pre-computing values).
This commit is contained in:
Patrick Ohly 2012-11-26 14:34:54 +01:00
parent 0204764b98
commit f3d9383d4c

View file

@ -1007,68 +1007,8 @@ class FolksTest : public CppUnit::TestFixture {
CPPUNIT_TEST(open);
CPPUNIT_TEST(asyncError);
CPPUNIT_TEST(gvalue);
// The tests are not working because it is currently not possible
// to create FolksIndividual instances directly with some chosen
// properties. Testing the FullView and IndividualFilter thus must
// be done by putting real data into EDS and reading it via libfolks.
// See testpim.py.
// CPPUNIT_TEST(fullview);
// CPPUNIT_TEST(filter);
// aggregate() works, but doesn't do anything. Keeping it and the
// other two tests as compile test for the API.
CPPUNIT_TEST(aggregate);
CPPUNIT_TEST_SUITE_END();
FolksIndividualCXX m_contactA,
m_contactB,
m_contactC;
public:
void setUp()
{
FolksIndividualCXX contact;
FolksStructuredName *fn;
contact = FolksIndividualCXX::steal(folks_individual_new(NULL));
FolksNameDetails *nd = FOLKS_NAME_DETAILS(contact.get());
// Crashes due to bug in Vala:
// https://bugzilla.gnome.org/show_bug.cgi?id=684557
// GErrorCXX gerror;
// SYNCEVO_GLIB_CALL_SYNC(NULL, gerror,
// folks_name_details_change_full_name,
// nd,
// "Abraham Zzz");
// if (gerror) {
// gerror.throwError("folks_name_details_change_full_name(Abraham Zzz)");
// }
// Doesn't have any effect: without an associated store,
// properties in a FolksIndividual are not writable.
folks_name_details_set_full_name(nd, "Abraham Zzz");
fn = folks_name_details_get_structured_name(nd);
folks_structured_name_set_family_name(fn, "Zzz");
folks_structured_name_set_given_name(fn, "Abraham");
m_contactA = contact;
contact = FolksIndividualCXX::steal(folks_individual_new(NULL));
folks_name_details_set_full_name(FOLKS_NAME_DETAILS(contact.get()), "Benjamin Yyy");
fn = folks_name_details_get_structured_name(FOLKS_NAME_DETAILS(contact.get()));
folks_structured_name_set_family_name(fn, "Yyy");
folks_structured_name_set_given_name(fn, "Benjamin");
m_contactB = contact;
contact = FolksIndividualCXX::steal(folks_individual_new(NULL));
folks_name_details_set_full_name(FOLKS_NAME_DETAILS(contact.get()), "Charly Xxx");
fn = folks_name_details_get_structured_name(FOLKS_NAME_DETAILS(contact.get()));
folks_structured_name_set_family_name(fn, "Xxx");
folks_structured_name_set_given_name(fn, "Charly");
m_contactC = contact;
}
private:
static void asyncCB(const GError *gerror, const char *func, bool &failed, bool &done) {
done = true;
@ -1234,137 +1174,6 @@ private:
view.m_removedSignal.connect(boost::bind(individualSignal, boost::ref(out), "removed", _1, _2));
view.m_modifiedSignal.connect(boost::bind(individualSignal, boost::ref(out), "modified", _1, _2));
}
void fullview() {
boost::shared_ptr<FullView> view(FullView::create());
std::ostringstream out;
monitorView(*view, out);
// add and remove
view->addIndividual(m_contactA.get());
CPPUNIT_ASSERT_EQUAL(std::string("added: 0 Abraham Zzz\n"), out.str());
CPPUNIT_ASSERT_EQUAL(1, view->size());
out.str("");
view->removeIndividual(m_contactA);
CPPUNIT_ASSERT_EQUAL(std::string("removed: 0 Abraham Zzz\n"), out.str());
CPPUNIT_ASSERT_EQUAL(0, view->size());
out.str("");
// add three, in inverse order
view->addIndividual(m_contactC.get());
CPPUNIT_ASSERT_EQUAL(std::string("added: 0 Charly Xxx\n"), out.str());
CPPUNIT_ASSERT_EQUAL(1, view->size());
out.str("");
view->addIndividual(m_contactB.get());
CPPUNIT_ASSERT_EQUAL(std::string("added: 0 Benjamin Yyy\n"), out.str());
CPPUNIT_ASSERT_EQUAL(2, view->size());
out.str("");
view->addIndividual(m_contactA.get());
CPPUNIT_ASSERT_EQUAL(std::string("added: 0 Abraham Zzz\n"), out.str());
CPPUNIT_ASSERT_EQUAL(3, view->size());
out.str("");
// change sorting: last,first inverse
boost::shared_ptr<IndividualCompare> compare(new CompareFormattedName(true, false));
view->setCompare(compare);
// Exact sequence of events is not specified. The current
// implementation prefers to announce changes at the end of
// the array first.
CPPUNIT_ASSERT_EQUAL(std::string("removed: 2 Charly Xxx\n"
"removed: 1 Benjamin Yyy\n"
"removed: 0 Abraham Zzz\n"
"added: 0 Abraham Zzz\n"
"added: 0 Benjamin Yyy\n"
"added: 0 Charly Xxx\n"),
out.str());
CPPUNIT_ASSERT_EQUAL(3, view->size());
// TODO: insert sorted
}
void filter() {
class FilterFullName : public IndividualFilter {
std::string m_name;
bool m_negated;
public:
FilterFullName(const std::string &name,
bool negated = false) :
m_name(name),
m_negated(negated)
{
}
virtual bool matches(FolksIndividual *individual) const {
return (m_name == folks_name_details_get_full_name(FOLKS_NAME_DETAILS(individual)))
^ m_negated;
}
};
// start with full view
boost::shared_ptr<FullView> view(FullView::create());
view->addIndividual(m_contactA.get());
view->addIndividual(m_contactB.get());
view->addIndividual(m_contactC.get());
CPPUNIT_ASSERT_EQUAL(3, view->size());
boost::shared_ptr<IndividualFilter> filterFullName(static_cast<IndividualFilter *>(new FilterFullName("Benjamin Yyy")));
boost::shared_ptr<FilteredView> filter(FilteredView::create(view,
filterFullName));
std::ostringstream out;
monitorView(*filter, out);
filter->start();
CPPUNIT_ASSERT_EQUAL(std::string("added: 0 Benjamin Yyy"), out.str());
CPPUNIT_ASSERT_EQUAL(1, filter->size());
// remove all individuals
out.str("");
view->removeIndividual(m_contactA.get());
CPPUNIT_ASSERT_EQUAL(std::string(""), out.str());
CPPUNIT_ASSERT_EQUAL(2, view->size());
CPPUNIT_ASSERT_EQUAL(1, filter->size());
view->removeIndividual(m_contactB.get());
CPPUNIT_ASSERT_EQUAL(std::string("removed: 0 Benjamin Yyy"), out.str());
CPPUNIT_ASSERT_EQUAL(1, view->size());
CPPUNIT_ASSERT_EQUAL(0, filter->size());
out.str("");
view->removeIndividual(m_contactC.get());
CPPUNIT_ASSERT_EQUAL(std::string(""), out.str());
CPPUNIT_ASSERT_EQUAL(0, view->size());
CPPUNIT_ASSERT_EQUAL(0, filter->size());
// add again
view->addIndividual(m_contactA.get());
CPPUNIT_ASSERT_EQUAL(std::string(""), out.str());
CPPUNIT_ASSERT_EQUAL(1, view->size());
CPPUNIT_ASSERT_EQUAL(0, filter->size());
view->addIndividual(m_contactB.get());
CPPUNIT_ASSERT_EQUAL(std::string("added: 0 Benjamin Yyy"), out.str());
CPPUNIT_ASSERT_EQUAL(2, view->size());
CPPUNIT_ASSERT_EQUAL(1, filter->size());
out.str("");
view->addIndividual(m_contactC.get());
CPPUNIT_ASSERT_EQUAL(std::string(""), out.str());
CPPUNIT_ASSERT_EQUAL(3, view->size());
CPPUNIT_ASSERT_EQUAL(1, filter->size());
// TODO: same as above, with inverted filter
// TODO: same as above, with inverted filter and reversed order
// TODO: change sorting while we have a filter view open
}
void aggregate() {
// TODO: run with well-defined set of databases and database content
boost::shared_ptr<IndividualAggregator> aggregator(IndividualAggregator::create());
boost::shared_ptr<IndividualView> view(aggregator->getMainView());
std::ostringstream out;
monitorView(*view, out);
aggregator->start();
while (!folks_individual_aggregator_get_is_quiescent(aggregator->getFolks())) {
g_main_context_iteration(NULL, true);
}
}
};
SYNCEVOLUTION_TEST_SUITE_REGISTRATION(FolksTest);