diff options
author | Peter Burgess <pete.burgess@isode.com> | 2018-03-27 12:30:56 (GMT) |
---|---|---|
committer | Peter Burgess <pete.burgess@isode.com> | 2018-03-27 15:13:17 (GMT) |
commit | ce001ffe0d598c75df5719b9a6aa0e544594408a (patch) | |
tree | f0ea942124313ac7c3f0d6301ff34ca8c4215f48 | |
parent | 098b96c9dd9e27bf2c1067221be334b1cc209f6b (diff) | |
download | swift-ce001ffe0d598c75df5719b9a6aa0e544594408a.zip swift-ce001ffe0d598c75df5719b9a6aa0e544594408a.tar.bz2 |
Fix empty marking colour handling in MUCController
When there is a room security marking and the colours have the value ""
they should be set to the default black and white. Instead they were
being set to "", so I have updated this and uncommented the relevant unit
test.
Test-Information:
The uncommented unit test is now passing, and all other related unit
tests still pass. A MUC room with a marking but blank colour values has
been tested on a test server and works as expected.
Change-Id: I1138ca1f035f8b7c0367c36ec3a65cc857721b8c
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 4 | ||||
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp | 50 |
2 files changed, 27 insertions, 27 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 4c3f524..139f425 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -1285,10 +1285,10 @@ void MUCController::requestSecurityMarking() { auto markingBackgroundColor = roomInfoForm->getField("x-isode#roominfo_marking_bg_color"); std::string markingForegroundColorValue = "Black"; std::string markingBackgroundColorValue = "White"; - if (markingForegroundColor) { + if (markingForegroundColor && markingForegroundColor->getTextSingleValue() != "") { markingForegroundColorValue = markingForegroundColor->getTextSingleValue(); } - if (markingBackgroundColor) { + if (markingBackgroundColor && markingBackgroundColor->getTextSingleValue() != "") { markingBackgroundColorValue = markingBackgroundColor->getTextSingleValue(); } setMUCSecurityMarking(markingValue, markingForegroundColorValue, markingBackgroundColorValue); diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index 012bcd0..05ab3a7 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -674,31 +674,31 @@ TEST_F(MUCControllerTest, testSecurityMarkingRequestCompleteMarkingWithExtraForm ASSERT_EQ(std::string("Red"), window_->markingBackgroundColorValue_); } -// TEST_F(MUCControllerTest, testSecurityMarkingRequestNoColorsInMarking) { -// auto formTypeField = std::make_shared<FormField>(FormField::Type::HiddenType, "http://jabber.org/protocol/muc#roominfo"); -// auto markingField = std::make_shared<FormField>(FormField::Type::TextSingleType, "Test|Highest Possible Security"); -// auto markingForegroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, ""); -// auto markingBackgroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, ""); -// formTypeField->setName("FORM_TYPE"); -// markingField->setName("x-isode#roominfo_marking"); -// markingForegroundColorField->setName("x-isode#roominfo_marking_fg_color"); -// markingBackgroundColorField->setName("x-isode#roominfo_marking_bg_color"); - -// auto form = std::make_shared<Form>(Form::Type::ResultType); -// form->addField(formTypeField); -// form->addField(markingField); -// form->addField(markingForegroundColorField); -// form->addField(markingBackgroundColorField); - -// auto discoInfoRef = std::make_shared<DiscoInfo>(); -// discoInfoRef->addExtension(form); - -// auto infoResponse = IQ::createResult(self_, mucJID_, "test-id", discoInfoRef); -// iqChannel_->onIQReceived(infoResponse); -// ASSERT_EQ(std::string("Test|Highest Possible Security"), window_->markingValue_); -// ASSERT_EQ(std::string("Black"), window_->markingForegroundColorValue_); -// ASSERT_EQ(std::string("White"), window_->markingBackgroundColorValue_); -// } +TEST_F(MUCControllerTest, testSecurityMarkingRequestNoColorsInMarking) { + auto formTypeField = std::make_shared<FormField>(FormField::Type::HiddenType, "http://jabber.org/protocol/muc#roominfo"); + auto markingField = std::make_shared<FormField>(FormField::Type::TextSingleType, "Test|Highest Possible Security"); + auto markingForegroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, ""); + auto markingBackgroundColorField = std::make_shared<FormField>(FormField::Type::TextSingleType, ""); + formTypeField->setName("FORM_TYPE"); + markingField->setName("x-isode#roominfo_marking"); + markingForegroundColorField->setName("x-isode#roominfo_marking_fg_color"); + markingBackgroundColorField->setName("x-isode#roominfo_marking_bg_color"); + + auto form = std::make_shared<Form>(Form::Type::ResultType); + form->addField(formTypeField); + form->addField(markingField); + form->addField(markingForegroundColorField); + form->addField(markingBackgroundColorField); + + auto discoInfoRef = std::make_shared<DiscoInfo>(); + discoInfoRef->addExtension(form); + + auto infoResponse = IQ::createResult(self_, mucJID_, "test-id", discoInfoRef); + iqChannel_->onIQReceived(infoResponse); + ASSERT_EQ(std::string("Test|Highest Possible Security"), window_->markingValue_); + ASSERT_EQ(std::string("Black"), window_->markingForegroundColorValue_); + ASSERT_EQ(std::string("White"), window_->markingBackgroundColorValue_); +} TEST_F(MUCControllerTest, testSecurityMarkingRequestEmptyMarking) { setMUCSecurityMarking("", "", "", true); |