Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, header and unit tests to the PHOTO vCard property for ContactDataO...
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 24 Dec 2015 22:21:49 +0000 (22:21 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Thu, 24 Dec 2015 22:21:49 +0000 (22:21 +0000)
source/contacteditor/ContactDataObject.cpp
source/tests/LoadCheck-Load4.vcf
source/tests/xestiaab_contactload.h

index 0b70e28..1bc8b77 100644 (file)
@@ -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++;
 
 }
 
index a5cfde5..71a7b69 100644 (file)
@@ -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
index 1bfc52b..dea51d3 100644 (file)
@@ -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<int,std::string>::iterator TestStrIter;
+       std::map<int,wxString>::iterator TestFileIter;
+       std::map<int,int>::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
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy