Started multipart tester

This commit is contained in:
Sylvain Berfini 2017-10-09 10:53:55 +02:00
parent 94c9ad33a5
commit f8abe9ad07
6 changed files with 88 additions and 7 deletions

View file

@ -63,7 +63,7 @@ ChatMessageModifier::Result MultipartChatMessageModifier::decode (shared_ptr<Cha
if (message->getInternalContent().getContentType().getType() == "multipart") {
string boundary = message->getInternalContent().getContentType().getParameter();
if (boundary.empty()) {
lError() << "Boundary parameter of content-type not found !";
lError() << "Boundary parameter of content-type not found: " << message->getInternalContent().getContentType().asString();
return ChatMessageModifier::Result::Error;
}

View file

@ -200,6 +200,7 @@ set(SOURCE_FILES_CXX
# conference-event-tester.cpp
conference-tester.cpp
cpim-tester.cpp
multipart-tester.cpp
events-db-tester.cpp
property-container-tester.cpp
)

View file

@ -55,6 +55,7 @@ extern test_suite_t log_collection_test_suite;
extern test_suite_t message_test_suite;
extern test_suite_t multi_call_test_suite;
extern test_suite_t multicast_call_test_suite;
extern test_suite_t multipart_test_suite;
extern test_suite_t offeranswer_test_suite;
extern test_suite_t player_test_suite;
extern test_suite_t presence_server_test_suite;

View file

@ -2482,8 +2482,6 @@ test_t message_tests[] = {
TEST_NO_TAG("Transfer message using external body url", file_transfer_using_external_body_url),
TEST_NO_TAG("Transfer 2 messages simultaneously", file_transfer_2_messages_simultaneously),
TEST_NO_TAG("Text message denied", text_message_denied),
TEST_NO_TAG("Info message", info_message),
TEST_NO_TAG("Info message with body", info_message_with_body),
TEST_NO_TAG("IsComposing notification", is_composing_notification),
TEST_NO_TAG("IMDN notifications", imdn_notifications),
TEST_NO_TAG("IM notification policy", im_notification_policy),
@ -2511,13 +2509,10 @@ test_t message_tests[] = {
TEST_NO_TAG("Database migration", database_migration),
TEST_NO_TAG("History range", history_range),
TEST_NO_TAG("History count", history_count),
TEST_NO_TAG("Crash during file transfer", crash_during_file_transfer),
#endif
TEST_NO_TAG("Text status after destroying chat room", text_status_after_destroying_chat_room),
TEST_NO_TAG("Transfer not sent if invalid url", file_transfer_not_sent_if_invalid_url),
TEST_NO_TAG("Transfer not sent if host not found", file_transfer_not_sent_if_host_not_found),
TEST_NO_TAG("Transfer not sent if url moved permanently", file_transfer_not_sent_if_url_moved_permanently),
TEST_ONE_TAG("Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom, "LeaksMemory"),
TEST_ONE_TAG("Real Time Text message", real_time_text_message, "RTT"),
TEST_ONE_TAG("Real Time Text SQL storage", real_time_text_sql_storage, "RTT"),
TEST_ONE_TAG("Real Time Text SQL storage with RTT messages not stored", real_time_text_sql_storage_rtt_disabled, "RTT"),
@ -2537,7 +2532,13 @@ test_t message_tests[] = {
TEST_ONE_TAG("Text message with custom content-type and lime", text_message_with_custom_content_type_and_lime, "LIME"),
#endif
TEST_NO_TAG("IM Encryption Engine b64", im_encryption_engine_b64),
TEST_NO_TAG("IM Encryption Engine b64 async", im_encryption_engine_b64_async)
TEST_NO_TAG("IM Encryption Engine b64 async", im_encryption_engine_b64_async),
// Crash currently
TEST_NO_TAG("Info message", info_message),
TEST_NO_TAG("Info message with body", info_message_with_body),
TEST_NO_TAG("Crash during file transfer", crash_during_file_transfer),
TEST_NO_TAG("Text status after destroying chat room", text_status_after_destroying_chat_room),
TEST_ONE_TAG("Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom, "LeaksMemory"),
};
static int message_tester_before_suite(void) {

View file

@ -0,0 +1,77 @@
/*
* cpim-tester.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "address/address.h"
#include "chat/basic-chat-room.h"
#include "chat/chat-message.h"
#include "liblinphone_tester.h"
// =============================================================================
using namespace std;
using namespace LinphonePrivate;
static void chat_message_multipart_modifier_base(bool first_file_transfer, bool second_file_transfer) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
Address paulineAddress(linphone_address_as_string_uri_only(pauline->identity));
shared_ptr<ChatRoom> marieRoom = ObjectFactory::create<BasicChatRoom>(marie->lc, paulineAddress);
shared_ptr<ChatMessage> marieMessage;
if (first_file_transfer) {
//TODO
marieMessage = marieRoom->createFileTransferMessage(NULL);
} else {
marieMessage = marieRoom->createMessage("Hello Part 1");
}
if (second_file_transfer) {
//TODO
} else {
Content content;
content.setContentType(ContentType::PlainText);
content.setBody("Hello Part 2");
marieMessage->addContent(content);
}
marieRoom->sendMessage(marieMessage);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageReceived,1));
BC_ASSERT_STRING_EQUAL(marieMessage->getInternalContent().getContentType().asString().c_str(), "multipart/mixed");
BC_ASSERT_PTR_NOT_NULL(pauline->stat.last_received_chat_message);
//TODO
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void multipart_two_text_content(void) {
chat_message_multipart_modifier_base(false, false);
}
test_t multipart_tests[] = {
TEST_NO_TAG("Chat message multipart 2 text content", multipart_two_text_content),
};
test_suite_t multipart_test_suite = {
"Multipart", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
sizeof(multipart_tests) / sizeof(multipart_tests[0]), multipart_tests
};

View file

@ -572,6 +572,7 @@ void liblinphone_tester_add_suites() {
bc_tester_add_suite(&player_test_suite);
bc_tester_add_suite(&dtmf_test_suite);
bc_tester_add_suite(&cpim_test_suite);
bc_tester_add_suite(&multipart_test_suite);
bc_tester_add_suite(&clonable_object_test_suite);
bc_tester_add_suite(&events_db_test_suite);
bc_tester_add_suite(&property_container_test_suite);