diff options
author | Tobias Markmann <tm@ayena.de> | 2016-05-04 14:15:53 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-05-04 14:43:41 (GMT) |
commit | b2d3eae9fd085cd91b3efac53dca81fd450d5393 (patch) | |
tree | 0bdb6f7359ffdd69ee81203e8faa435eaff7c633 /Swift/Controllers/UnitTest | |
parent | 6af098245b58d484d9c86c1f832588455410750b (diff) | |
download | swift-b2d3eae9fd085cd91b3efac53dca81fd450d5393.zip swift-b2d3eae9fd085cd91b3efac53dca81fd450d5393.tar.bz2 |
Fix /me message handling for highlighted messages
Test-Information:
Added a unit test to test for the fix.
Tests pass on OS X 10.11.4.
Change-Id: Ibf071ae47663bfefdc856339932de6a1fe4a642d
Diffstat (limited to 'Swift/Controllers/UnitTest')
-rw-r--r-- | Swift/Controllers/UnitTest/MockChatWindow.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index 1430f4f..f9b183d 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -19,12 +19,12 @@ namespace Swift { virtual ~MockChatWindow(); virtual std::string addMessage(const ChatMessage& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) { - lastMessageBody_ = bodyFromMessage(message); + lastAddedMessage_ = message; return "id"; } virtual std::string addAction(const ChatMessage& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) { - lastAddedActionBody_ =bodyFromMessage(message); + lastAddedAction_ = message; return "id"; } @@ -94,18 +94,27 @@ namespace Swift { virtual void setBookmarkState(RoomBookmarkState) {} static std::string bodyFromMessage(const ChatMessage& message) { + std::string body; std::shared_ptr<ChatTextMessagePart> text; + std::shared_ptr<ChatHighlightingMessagePart> highlight; foreach (std::shared_ptr<ChatMessagePart> part, message.getParts()) { if ((text = std::dynamic_pointer_cast<ChatTextMessagePart>(part))) { - return text->text; + body += text->text; + } + else if ((highlight = std::dynamic_pointer_cast<ChatHighlightingMessagePart>(part))) { + body += highlight->text; } } - return ""; + return body; + } + + void resetLastMessages() { + lastAddedMessage_ = lastAddedAction_ = lastAddedPresence_ = lastReplacedMessage_ = lastAddedSystemMessage_ = ChatMessage(); } std::string name_; - std::string lastMessageBody_; - std::string lastAddedActionBody_; + ChatMessage lastAddedMessage_; + ChatMessage lastAddedAction_; ChatMessage lastAddedPresence_; ChatMessage lastReplacedMessage_; ChatMessage lastAddedSystemMessage_; |