From c3caab2c7ab2b4256304e4d1687cf8d15394f31d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 7 Dec 2015 22:36:26 +0000 Subject: [PATCH] Added code and unit tests to check if a file exists and no errors occur whilst opening in the ContactDataObject. --- source/contacteditor/ContactDataObject.cpp | 12 ++++++++++++ source/tests/xestiaab_contactload.h | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 9270895..f811e61 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -26,6 +26,18 @@ ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){ } + wxFile ContactFile; + + if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){ + + return CONTACTLOAD_FILEERROR; + + } + + // Check that the vCard is a valid vCard 4.0 file. + + + return CONTACTLOAD_UNITTESTFAIL; } \ No newline at end of file diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index 090f794..f66f6d5 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -17,5 +17,22 @@ // with Xestia Address Book. If not, see #include +#include "../contacteditor/ContactDataObject.h" + +TEST(ContactLoad, ContactLoadTests){ + + + ContactDataObject TestFile; + + // Check that the file given is not missing. + + ASSERT_EQ(CONTACTLOAD_FILEMISSING, TestFile.LoadFile("MissingFile.vcf")); + + // Check that the file given does not have an error when attempting to + // open it. + + ASSERT_EQ(CONTACTLOAD_FILEERROR, TestFile.LoadFile("InvalidPermissions.vcf")); + +} // TODO: Add tests for the Contact Loading process. \ No newline at end of file -- 2.39.5