Commit 07ad0cf7 authored by Eric Jiang's avatar Eric Jiang Committed by Jean-Baptiste Mardelle
Browse files

Add test for non-ascii list filtering (bug 432699)

parent 1b0a6e3e
......@@ -10,6 +10,8 @@
#define protected public
#include "abstractmodel/abstracttreemodel.hpp"
#include "abstractmodel/treeitem.hpp"
#include "effects/effectlist/model/effecttreemodel.hpp"
#include "effects/effectlist/model/effectfilter.hpp"
TEST_CASE("Basic tree testing", "[TreeModel]")
{
......@@ -185,3 +187,49 @@ TEST_CASE("Basic tree testing", "[TreeModel]")
state();
}
}
// Tests the logic for matching the user-supplied search string against the list
// of items. The actual logic is in AssetFilter but since it's an abstract
// class, we test EffectFilter instead.
TEST_CASE("Effect filter text-matching logic")
{
auto model = EffectTreeModel::construct("", nullptr);
EffectFilter filter{nullptr};
// rootData copied from effecttreemodel.cpp
QList<QVariant> rootData{"Name", "ID", "Type", "isFav"};
SECTION("Handles basic alphanum search")
{
auto item = TreeItem::construct(rootData, model, true);
item->setData(AssetTreeModel::IdCol, "Hello World");
item->setData(AssetTreeModel::NameCol, "This is K-denlive");
filter.setFilterName(true, "Worl");
CHECK(filter.filterName(item) == true);
filter.setFilterName(true, "Abcd");
CHECK(filter.filterName(item) == false);
// should ignore punctuation
filter.setFilterName(true, "Kden");
CHECK(filter.filterName(item) == true);
}
// Tests for bug 432699 where filtering the effects list in Chinese fails
// because the filter only works for ascii alphanum characters.
SECTION("Handles Chinese/Japanese search")
{
auto item = TreeItem::construct(rootData, model, true);
item->setData(AssetTreeModel::IdCol, "静音");
item->setData(AssetTreeModel::NameCol, "ミュート");
filter.setFilterName(true, "音");
CHECK(filter.filterName(item) == true);
filter.setFilterName(true, "默");
CHECK(filter.filterName(item) == false);
// should ignore punctuation
filter.setFilterName(true, "ミュ");
CHECK(filter.filterName(item) == true);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment