Clear game messages when sorting

Game messages should be cleared if sorting is successful.
This commit is contained in:
Oliver Hamlet
2016-01-20 19:01:18 +00:00
parent ef8e8b6ab8
commit 83bd4248cd
2 changed files with 28 additions and 0 deletions
+5
View File
@@ -152,6 +152,11 @@ namespace loot {
BOOST_LOG_TRIVIAL(info) << '\t' << graph[vertex].Name();
plugins.push_back(graph[vertex]);
}
// Clear any existing game-specific messages, as these only relate to
// state that has been changed by sorting.
game.ClearMessages();
return plugins;
}
+23
View File
@@ -91,6 +91,29 @@ TEST_F(PluginSorter, Sort) {
EXPECT_TRUE(std::equal(begin(sorted), end(sorted), begin(expectedSortedOrder)));
}
TEST_F(PluginSorter, sortingShouldClearExistingGameMessages) {
ASSERT_NO_THROW(game.LoadPlugins(false));
game.AppendMessage(loot::Message(loot::Message::say, "1"));
ASSERT_FALSE(game.GetMessages().empty());
loot::PluginSorter ps;
std::list<loot::Plugin> sorted = ps.Sort(game, loot::Language::english, callback);
EXPECT_TRUE(game.GetMessages().empty());
}
TEST_F(PluginSorter, failedSortShouldNotClearExistingGameMessages) {
ASSERT_NO_THROW(game.LoadPlugins(false));
loot::PluginMetadata plugin("Blank.esm");
plugin.LoadAfter({loot::File("Blank - Master Dependent.esm")});
game.GetUserlist().AddPlugin(plugin);
game.AppendMessage(loot::Message(loot::Message::say, "1"));
ASSERT_FALSE(game.GetMessages().empty());
loot::PluginSorter ps;
EXPECT_ANY_THROW(ps.Sort(game, loot::Language::english, callback));
EXPECT_FALSE(game.GetMessages().empty());
}
TEST_F(PluginSorter, Sort_HeadersOnly) {
ASSERT_NO_THROW(game.LoadPlugins(true));