summaryrefslogtreecommitdiffstats
path: root/framework/domain/mimetreeparser/tests/interfacetest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/domain/mimetreeparser/tests/interfacetest.cpp')
-rw-r--r--framework/domain/mimetreeparser/tests/interfacetest.cpp54
1 files changed, 33 insertions, 21 deletions
diff --git a/framework/domain/mimetreeparser/tests/interfacetest.cpp b/framework/domain/mimetreeparser/tests/interfacetest.cpp
index 88691539..822d530c 100644
--- a/framework/domain/mimetreeparser/tests/interfacetest.cpp
+++ b/framework/domain/mimetreeparser/tests/interfacetest.cpp
@@ -48,34 +48,38 @@ private slots:
48 void testTextMail() 48 void testTextMail()
49 { 49 {
50 Parser parser(readMailFromFile("plaintext.mbox")); 50 Parser parser(readMailFromFile("plaintext.mbox"));
51 auto contentPart = parser.collectContentPart(); 51 auto contentPartList = parser.collectContentParts();
52 QCOMPARE(contentPartList.size(), 1);
53 auto contentPart = contentPartList[0];
52 QVERIFY((bool)contentPart); 54 QVERIFY((bool)contentPart);
53 QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); 55 QCOMPARE(contentPart->availableContents(), "plaintext");
54 auto contentList = contentPart->content(ContentPart::PlainText); 56 auto contentList = contentPart->content("plaintext");
55 QCOMPARE(contentList.size(), 1); 57 QCOMPARE(contentList.size(), 1);
56 QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/").toLocal8Bit()); 58 QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/").toLocal8Bit());
57 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); 59 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit());
58 QCOMPARE(contentList[0]->encryptions().size(), 0); 60 QCOMPARE(contentList[0]->encryptions().size(), 0);
59 QCOMPARE(contentList[0]->signatures().size(), 0); 61 QCOMPARE(contentList[0]->signatures().size(), 0);
60 62
61 contentList = contentPart->content(ContentPart::Html); 63 contentList = contentPart->content("html");
62 QCOMPARE(contentList.size(), 0); 64 QCOMPARE(contentList.size(), 0);
63 } 65 }
64 66
65 void testTextAlternative() 67 void testTextAlternative()
66 { 68 {
67 Parser parser(readMailFromFile("alternative.mbox")); 69 Parser parser(readMailFromFile("alternative.mbox"));
68 auto contentPart = parser.collectContentPart(); 70 auto contentPartList = parser.collectContentParts();
71 QCOMPARE(contentPartList.size(), 1);
72 auto contentPart = contentPartList[0];
69 QVERIFY((bool)contentPart); 73 QVERIFY((bool)contentPart);
70 QCOMPARE(contentPart->availableContents(), ContentPart::PlainText | ContentPart::Html); 74 QCOMPARE(contentPart->availableContents(), QVector<QByteArray>() << "html" << "plaintext");
71 auto contentList = contentPart->content(ContentPart::PlainText); 75 auto contentList = contentPart->content("plaintext");
72 QCOMPARE(contentList.size(), 1); 76 QCOMPARE(contentList.size(), 1);
73 QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n").toLocal8Bit()); 77 QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n").toLocal8Bit());
74 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); 78 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit());
75 QCOMPARE(contentList[0]->encryptions().size(), 0); 79 QCOMPARE(contentList[0]->encryptions().size(), 0);
76 QCOMPARE(contentList[0]->signatures().size(), 0); 80 QCOMPARE(contentList[0]->signatures().size(), 0);
77 81
78 contentList = contentPart->content(ContentPart::Html); 82 contentList = contentPart->content("html");
79 QCOMPARE(contentList.size(), 1); 83 QCOMPARE(contentList.size(), 1);
80 QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>\n\n").toLocal8Bit()); 84 QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>\n\n").toLocal8Bit());
81 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); 85 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit());
@@ -86,14 +90,16 @@ private slots:
86 void testTextHtml() 90 void testTextHtml()
87 { 91 {
88 Parser parser(readMailFromFile("html.mbox")); 92 Parser parser(readMailFromFile("html.mbox"));
89 auto contentPart = parser.collectContentPart(); 93 auto contentPartList = parser.collectContentParts();
94 QCOMPARE(contentPartList.size(), 1);
95 auto contentPart = contentPartList[0];
90 QVERIFY((bool)contentPart); 96 QVERIFY((bool)contentPart);
91 QCOMPARE(contentPart->availableContents(), ContentPart::Html); 97 QCOMPARE(contentPart->availableContents(), "html");
92 98
93 auto contentList = contentPart->content(ContentPart::PlainText); 99 auto contentList = contentPart->content("plaintext");
94 QCOMPARE(contentList.size(), 0); 100 QCOMPARE(contentList.size(), 0);
95 101
96 contentList = contentPart->content(ContentPart::Html); 102 contentList = contentPart->content("html");
97 QCOMPARE(contentList.size(), 1); 103 QCOMPARE(contentList.size(), 1);
98 QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>").toLocal8Bit()); 104 QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>").toLocal8Bit());
99 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); 105 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit());
@@ -105,10 +111,12 @@ private slots:
105 { 111 {
106 Parser parser(readMailFromFile("smime-encrypted.mbox")); 112 Parser parser(readMailFromFile("smime-encrypted.mbox"));
107 printTree(parser.d->mTree,QString()); 113 printTree(parser.d->mTree,QString());
108 auto contentPart = parser.collectContentPart(); 114 auto contentPartList = parser.collectContentParts();
115 QCOMPARE(contentPartList.size(), 1);
116 auto contentPart = contentPartList[0];
109 QVERIFY((bool)contentPart); 117 QVERIFY((bool)contentPart);
110 QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); 118 QCOMPARE(contentPart->availableContents(), "plaintext");
111 auto contentList = contentPart->content(ContentPart::PlainText); 119 auto contentList = contentPart->content("plaintext");
112 QCOMPARE(contentList.size(), 1); 120 QCOMPARE(contentList.size(), 1);
113 QCOMPARE(contentList[0]->content(), QStringLiteral("The quick brown fox jumped over the lazy dog.").toLocal8Bit()); 121 QCOMPARE(contentList[0]->content(), QStringLiteral("The quick brown fox jumped over the lazy dog.").toLocal8Bit());
114 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); 122 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit());
@@ -118,10 +126,12 @@ private slots:
118 { 126 {
119 Parser parser(readMailFromFile("openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox")); 127 Parser parser(readMailFromFile("openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox"));
120 printTree(parser.d->mTree,QString()); 128 printTree(parser.d->mTree,QString());
121 auto contentPart = parser.collectContentPart(); 129 auto contentPartList = parser.collectContentParts();
130 QCOMPARE(contentPartList.size(), 1);
131 auto contentPart = contentPartList[0];
122 QVERIFY((bool)contentPart); 132 QVERIFY((bool)contentPart);
123 QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); 133 QCOMPARE(contentPart->availableContents(), "plaintext");
124 auto contentList = contentPart->content(ContentPart::PlainText); 134 auto contentList = contentPart->content("plaintext");
125 QCOMPARE(contentList.size(), 1); 135 QCOMPARE(contentList.size(), 1);
126 QCOMPARE(contentList[0]->content(), QStringLiteral("test text").toLocal8Bit()); 136 QCOMPARE(contentList[0]->content(), QStringLiteral("test text").toLocal8Bit());
127 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); 137 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit());
@@ -131,10 +141,12 @@ private slots:
131 { 141 {
132 Parser parser(readMailFromFile("openpgp-inline-charset-encrypted.mbox")); 142 Parser parser(readMailFromFile("openpgp-inline-charset-encrypted.mbox"));
133 printTree(parser.d->mTree,QString()); 143 printTree(parser.d->mTree,QString());
134 auto contentPart = parser.collectContentPart(); 144 auto contentPartList = parser.collectContentParts();
145 QCOMPARE(contentPartList.size(), 1);
146 auto contentPart = contentPartList[0];
135 QVERIFY((bool)contentPart); 147 QVERIFY((bool)contentPart);
136 QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); 148 QCOMPARE(contentPart->availableContents(), "plaintext");
137 auto contentList = contentPart->content(ContentPart::PlainText); 149 auto contentList = contentPart->content("plaintext");
138 QCOMPARE(contentList.size(), 1); 150 QCOMPARE(contentList.size(), 1);
139 QCOMPARE(contentList[0]->content(), QStringLiteral("asdasd asd asd asdf sadf sdaf sadf äöü").toLocal8Bit()); 151 QCOMPARE(contentList[0]->content(), QStringLiteral("asdasd asd asd asdf sadf sdaf sadf äöü").toLocal8Bit());
140 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); 152 QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit());