[gnote] Add helper tool to test shell search provider
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add helper tool to test shell search provider
- Date: Sun, 5 May 2013 20:11:19 +0000 (UTC)
commit b7cb2cb8f91d85cee717a793f1abd6fe0db3420e
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun May 5 17:04:48 2013 +0300
Add helper tool to test shell search provider
tools/SearchProviderTest.py | 57 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/tools/SearchProviderTest.py b/tools/SearchProviderTest.py
new file mode 100644
index 0000000..12e479b
--- /dev/null
+++ b/tools/SearchProviderTest.py
@@ -0,0 +1,57 @@
+import dbus
+
+
+def create_note(rc, title, content):
+ note = rc.CreateNamedNote(title)
+ rc.DisplayNote(note)
+ content = title + "\n\n" + content
+ rc.SetNoteContents(note, content)
+ return note
+
+def create_test_notes(rc, notes):
+ for i in range(10):
+ title = "SearchTestNote" + str(i)
+ content = "Search Provider Test (" + str(i) + ")"
+ notes.append(create_note(rc, title, content))
+ create_note(rc, "SearchResult", "If you see this, the tests have passed!")
+ rc.DisplaySearch()
+
+
+def delete_test_notes(rc, notes):
+ for note in notes:
+ rc.DeleteNote(note)
+
+
+def test_search_provider(proxy, notes):
+ results = proxy.GetInitialResultSet(["SearchTestNote"])
+ assert len(results) == 10
+ results = proxy.GetInitialResultSet(["SearchTestNote1", "SearchTestNote2", "SearchTestNote3",
"SearchTestNoteNonExistent", ""])
+ assert len(results) == 3
+ subsearch_titles = ["SearchTestNote2", "SearchTestNote3"]
+ subresults = proxy.GetSubsearchResultSet(results, subsearch_titles)
+ assert len(subresults) == 2
+ result_metas = proxy.GetResultMetas(subresults)
+ assert len(result_metas) == len(subresults)
+ for meta in result_metas:
+ assert meta["name"] in subsearch_titles
+ proxy.LaunchSearch(["test"], 123) # this shouldn't do anything, but shouldn't crash as well
+ results = proxy.GetInitialResultSet(["SearchResult"])
+ proxy.ActivateResult(results[0], ["SearchResult"], 123)
+
+def main():
+ bus = dbus.SessionBus()
+ gnote_remote_control = bus.get_object("org.gnome.Gnote", "/org/gnome/Gnote/RemoteControl")
+ rc_proxy = dbus.Interface(gnote_remote_control, "org.gnome.Gnote.RemoteControl")
+ gnote_search_provider = bus.get_object("org.gnome.Gnote", "/org/gnome/Gnote/SearchProvider")
+ search_proxy = dbus.Interface(gnote_search_provider, "org.gnome.Shell.SearchProvider2")
+
+ notes = []
+ create_test_notes(rc_proxy, notes)
+ try:
+ test_search_provider(search_proxy, notes)
+ finally:
+ delete_test_notes(rc_proxy, notes)
+
+
+if __name__ == "__main__":
+ main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]