Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBO41 <botbob@disroot.org>2020-05-08 18:13:15 +0300
committerJonathan White <support@dmapps.us>2020-05-14 23:48:57 +0300
commitf1080d633ed72e032899fa944d07ef210fc3c184 (patch)
tree1ca0704ed27d01d09e27cc89330fcf8fd05be65a /tests
parent485852c9dbc748055e1567f5bdad997905309c7e (diff)
Add group search
* Allow searching by group using the `group:` field. * Group hierarchies can be searched by including a '/' in the search term.
Diffstat (limited to 'tests')
-rw-r--r--tests/TestEntrySearcher.cpp57
-rw-r--r--tests/TestEntrySearcher.h1
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/TestEntrySearcher.cpp b/tests/TestEntrySearcher.cpp
index 7107cff0a..3a0ac6836 100644
--- a/tests/TestEntrySearcher.cpp
+++ b/tests/TestEntrySearcher.cpp
@@ -262,3 +262,60 @@ void TestEntrySearcher::testCustomAttributesAreSearched()
m_searchResult = m_entrySearcher.search("_testAttribute:test _testProtected:testP2", m_rootGroup);
QCOMPARE(m_searchResult.count(), 2);
}
+
+void TestEntrySearcher::testGroup()
+{
+ /**
+ * Root
+ * - group1 (1 entry)
+ * - subgroup1 (2 entries)
+ * - group2
+ * - subgroup2 (1 entry)
+ */
+ Group* group1 = new Group();
+ Group* group2 = new Group();
+
+ group1->setParent(m_rootGroup);
+ group1->setName("group1");
+ group2->setParent(m_rootGroup);
+ group2->setName("group2");
+
+ Group* subgroup1 = new Group();
+ subgroup1->setName("subgroup1");
+ subgroup1->setParent(group1);
+
+ Group* subgroup2 = new Group();
+ subgroup2->setName("subgroup2");
+ subgroup2->setParent(group2);
+
+ Entry* eGroup1 = new Entry();
+ eGroup1->setTitle("Entry Group 1");
+ eGroup1->setGroup(group1);
+
+ Entry* eSub1 = new Entry();
+ eSub1->setTitle("test search term test");
+ eSub1->setGroup(subgroup1);
+
+ Entry* eSub2 = new Entry();
+ eSub2->setNotes("test test");
+ eSub2->setGroup(subgroup1);
+
+ Entry* eSub3 = new Entry();
+ eSub3->setNotes("test term test");
+ eSub3->setGroup(subgroup2);
+
+ m_searchResult = m_entrySearcher.search("group:subgroup", m_rootGroup);
+ QCOMPARE(m_searchResult.count(), 3);
+
+ m_searchResult = m_entrySearcher.search("g:subgroup1", m_rootGroup);
+ QCOMPARE(m_searchResult.count(), 2);
+
+ m_searchResult = m_entrySearcher.search("g:subgroup1 search", m_rootGroup);
+ QCOMPARE(m_searchResult.count(), 1);
+
+ m_searchResult = m_entrySearcher.search("g:*1/sub*1", m_rootGroup);
+ QCOMPARE(m_searchResult.count(), 2);
+
+ m_searchResult = m_entrySearcher.search("g:/group1 search", m_rootGroup);
+ QCOMPARE(m_searchResult.count(), 1);
+}
diff --git a/tests/TestEntrySearcher.h b/tests/TestEntrySearcher.h
index fb4312926..498a00742 100644
--- a/tests/TestEntrySearcher.h
+++ b/tests/TestEntrySearcher.h
@@ -36,6 +36,7 @@ private slots:
void testAllAttributesAreSearched();
void testSearchTermParser();
void testCustomAttributesAreSearched();
+ void testGroup();
private:
Group* m_rootGroup;