From: Steve Brokenshire Date: Thu, 24 Dec 2015 22:21:49 +0000 (+0000) Subject: Added source code, header and unit tests to the PHOTO vCard property for ContactDataO... X-Git-Tag: release-0.09~218 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=78a23a10b1ff0a041ab18891290a160b41d94530;p=xestiaab%2F.git Added source code, header and unit tests to the PHOTO vCard property for ContactDataObject. --- diff --git a/source/contacteditor/ContactDataObject.cpp b/source/contacteditor/ContactDataObject.cpp index 0b70e28..1bc8b77 100644 --- a/source/contacteditor/ContactDataObject.cpp +++ b/source/contacteditor/ContactDataObject.cpp @@ -4229,7 +4229,7 @@ void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg while (wSTDataInfo.HasMoreTokens() == TRUE){ wxSPhotoEncoding = wSTDataInfo.GetNextToken(); - wxSPhotoData = wSTDataInfo.GetNextToken(); + wxSPhotoData = wSTDataInfo.GetNextToken(); base64enc = wxSPhotoData.mb_str(); break; @@ -4259,9 +4259,6 @@ void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens)); } - - - PhotoCount++; } diff --git a/source/tests/LoadCheck-Load4.vcf b/source/tests/LoadCheck-Load4.vcf index a5cfde5..71a7b69 100644 --- a/source/tests/LoadCheck-Load4.vcf +++ b/source/tests/LoadCheck-Load4.vcf @@ -87,4 +87,13 @@ CATEGORIES;TYPE=home;ALTID=44;PID=46;LANGUAGE=kw;PREF=48;TAC=CAT:Category Tw o,Category Three CATEGORIES;TYPE=work;ALTID=84;PID=86;LANGUAGE=kw;PREF=88;AAA=BBB:Category Fo ur,Category Five,Category Six +PHOTO;ALTID=70;PID=71;MEDIATYPE=image/png;PREF=72;MEEP=MOO:data:image/png;ba + se64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAJUlEQVQoz2NkwAb+//8PYT + AyMmLKMjGQDuilhxHudBrbM8zCDQCxHQkPeaUvawAAAABJRU5ErkJggg== +PHOTO;ALTID=20;PID=21;MEDIATYPE=image/png;PREF=22;BEEP=BOOP:data:image/png;b + ase64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAHklEQVQoz2NkYPjPgAr+o + wkwMqIpYGIgHYzqGdx6AAKNAxMN5P6+AAAAAElFTkSuQmCC +PHOTO;ALTID=90;PID=91;MEDIATYPE=image/png;PREF=92;PHOTO=YUP:data:image/png;b + ase64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAIElEQVQoz2MUm53EgApep + sxF4XfaoylgYiAdjOoZ3HoAeuQD2WdxRzcAAAAASUVORK5CYII= END:VCARD diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h index 1bfc52b..dea51d3 100644 --- a/source/tests/xestiaab_contactload.h +++ b/source/tests/xestiaab_contactload.h @@ -2304,4 +2304,165 @@ TEST(ContactLoad, CategoryTests){ } +TEST(ContactLoad, PhotoTests){ + + ContactDataObject TestFile; + + // Check that the vCard 4.0 file loads OK. + + ASSERT_EQ(CONTACTLOAD_OK, TestFile.LoadFile("LoadCheck-Load4.vcf")); + + std::map::iterator TestStrIter; + std::map::iterator TestFileIter; + std::map::iterator TestFileIntIter; + + // Start with the first photo. + + TestStrIter = TestFile.PicturesList.find(0); + ASSERT_NE(TestFile.PicturesList.end(), TestStrIter); + ASSERT_EQ("iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAJUlEQVQoz2NkwAb+//8PYTAyMmLKMjGQDuilhxHudBrbM8zCDQCxHQkPeaUvawAAAABJRU5ErkJggg==", + TestStrIter->second); + + // Check that it has the correct encoding. + + TestFileIter = TestFile.PicturesListPicEncType.find(0); + ASSERT_NE(TestFile.PicturesListPicEncType.end(), TestFileIter); + ASSERT_EQ("base64", TestFileIter->second); + + // Check that it has the correct image type. + + TestFileIter = TestFile.PicturesListPictureType.find(0); + ASSERT_NE(TestFile.PicturesListPictureType.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.PicturesListAltID.find(0); + ASSERT_NE(TestFile.PicturesListAltID.end(), TestFileIter); + ASSERT_EQ("70", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.PicturesListPID.find(0); + ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter); + ASSERT_EQ("71", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.PicturesListMediatype.find(0); + ASSERT_NE(TestFile.PicturesListMediatype.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.PicturesListPref.find(0); + ASSERT_NE(TestFile.PicturesListPref.end(), TestFileIntIter); + ASSERT_EQ(72, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.PicturesListTokens.find(0); + ASSERT_NE(TestFile.PicturesListTokens.end(), TestFileIter); + ASSERT_EQ("MEEP=MOO", TestFileIter->second); + + // Start with the second photo. + + TestStrIter = TestFile.PicturesList.find(1); + ASSERT_NE(TestFile.PicturesList.end(), TestStrIter); + ASSERT_EQ("iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAHklEQVQoz2NkYPjPgAr+owkwMqIpYGIgHYzqGdx6AAKNAxMN5P6+AAAAAElFTkSuQmCC", + TestStrIter->second); + + // Check that it has the correct encoding. + + TestFileIter = TestFile.PicturesListPicEncType.find(1); + ASSERT_NE(TestFile.PicturesListPicEncType.end(), TestFileIter); + ASSERT_EQ("base64", TestFileIter->second); + + // Check that it has the correct image type. + + TestFileIter = TestFile.PicturesListPictureType.find(1); + ASSERT_NE(TestFile.PicturesListPictureType.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.PicturesListAltID.find(1); + ASSERT_NE(TestFile.PicturesListAltID.end(), TestFileIter); + ASSERT_EQ("20", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.PicturesListPID.find(1); + ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter); + ASSERT_EQ("21", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.PicturesListMediatype.find(1); + ASSERT_NE(TestFile.PicturesListMediatype.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.PicturesListPref.find(1); + ASSERT_NE(TestFile.PicturesListPref.end(), TestFileIntIter); + ASSERT_EQ(22, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.PicturesListTokens.find(1); + ASSERT_NE(TestFile.PicturesListTokens.end(), TestFileIter); + ASSERT_EQ("BEEP=BOOP", TestFileIter->second); + + // Start with the second photo. + + TestStrIter = TestFile.PicturesList.find(2); + ASSERT_NE(TestFile.PicturesList.end(), TestStrIter); + ASSERT_EQ("iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAIAAADdHiL1AAAAIElEQVQoz2MUm53EgApepsxF4XfaoylgYiAdjOoZ3HoAeuQD2WdxRzcAAAAASUVORK5CYII=", + TestStrIter->second); + + // Check that it has the correct encoding. + + TestFileIter = TestFile.PicturesListPicEncType.find(2); + ASSERT_NE(TestFile.PicturesListPicEncType.end(), TestFileIter); + ASSERT_EQ("base64", TestFileIter->second); + + // Check that it has the correct image type. + + TestFileIter = TestFile.PicturesListPictureType.find(2); + ASSERT_NE(TestFile.PicturesListPictureType.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the ALTID section. + + TestFileIter = TestFile.PicturesListAltID.find(2); + ASSERT_NE(TestFile.PicturesListAltID.end(), TestFileIter); + ASSERT_EQ("90", TestFileIter->second); + + // Check the PID section. + + TestFileIter = TestFile.PicturesListPID.find(2); + ASSERT_NE(TestFile.PicturesListPID.end(), TestFileIter); + ASSERT_EQ("91", TestFileIter->second); + + // Check the MEDIATYPE section. + + TestFileIter = TestFile.PicturesListMediatype.find(2); + ASSERT_NE(TestFile.PicturesListMediatype.end(), TestFileIter); + ASSERT_EQ("image/png", TestFileIter->second); + + // Check the PREF section. + + TestFileIntIter = TestFile.PicturesListPref.find(2); + ASSERT_NE(TestFile.PicturesListPref.end(), TestFileIntIter); + ASSERT_EQ(92, TestFileIntIter->second); + + // Check the extra tokens. + + TestFileIter = TestFile.PicturesListTokens.find(2); + ASSERT_NE(TestFile.PicturesListTokens.end(), TestFileIter); + ASSERT_EQ("PHOTO=YUP", TestFileIter->second); + +} + // TODO: Add tests for the Contact Loading process. \ No newline at end of file