Merge lp:~gue5t/midori/completion-escape-hist into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: Cris Dywan
Approved revision: 6908
Merged at revision: 6919
Proposed branch: lp:~gue5t/midori/completion-escape-hist
Merge into: lp:midori
Diff against target: 107 lines (+59/-3)
3 files modified
midori/midori-completion.vala (+1/-1)
midori/midori-historycompletion.vala (+2/-2)
tests/completion.vala (+56/-0)
To merge this branch: bzr merge lp:~gue5t/midori/completion-escape-hist
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+253898@code.launchpad.net

Commit message

Don't entity-escape history and bookmark results in location completion

Description of the change

Changes a flag to indicate that history and bookmark results in location completion are markup.

Fixes #1435614.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Could we have a unit test for this? We have some that test the result of rendering, and also based on fake data.

review: Needs Fixing
6908. By gue5t <email address hidden>

add a test to ensure that page titles from history are properly shown in completion

Revision history for this message
gue5t gue5t (gue5t) wrote :

The change to midori-completion.vala (replacing .begin() with yield) is necessary because using .begin() in a function that's already async makes it impossible to use regular Vala "yield" to wait for the nested asynchronous action. It doesn't cause async code to become synchronous, since the yield itself is already in an async method.

Revision history for this message
Cris Dywan (kalikiana) wrote :

That seems sensible - I think it was done this way in an attempt to allow multiple completions to run at once, but that might have been racy to begin with.

Thanks a lot for adding the test!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-completion.vala'
2--- midori/midori-completion.vala 2014-03-16 12:15:50 +0000
3+++ midori/midori-completion.vala 2015-04-04 19:22:35 +0000
4@@ -168,7 +168,7 @@
5
6 foreach (var completion in completions) {
7 if (completion.can_complete (text))
8- complete_wrapped.begin (completion, text, null, cancellable);
9+ yield complete_wrapped (completion, text, null, cancellable);
10 }
11 }
12
13
14=== modified file 'midori/midori-historycompletion.vala'
15--- midori/midori-historycompletion.vala 2014-03-03 01:17:05 +0000
16+++ midori/midori-historycompletion.vala 2015-04-04 19:22:35 +0000
17@@ -11,7 +11,7 @@
18
19 namespace Midori {
20 public class HistoryCompletion : Completion {
21- HistoryDatabase? database = null;
22+ public HistoryDatabase? database = null;
23
24 public HistoryCompletion () {
25 GLib.Object (description: _("Bookmarks and History"));
26@@ -46,7 +46,7 @@
27 if (item is Midori.HistoryWebsite) {
28 var website = item as Midori.HistoryWebsite;
29 suggestions.append (new Suggestion (website.uri, website.title,
30- false, null, yield Midori.URI.get_icon_fallback (website.uri, null, cancellable), this.position));
31+ true, null, yield Midori.URI.get_icon_fallback (website.uri, null, cancellable), this.position));
32 }
33 else if (item is Midori.HistorySearch) {
34 var search = item as Midori.HistorySearch;
35
36=== modified file 'tests/completion.vala'
37--- tests/completion.vala 2014-01-27 22:57:39 +0000
38+++ tests/completion.vala 2015-04-04 19:22:35 +0000
39@@ -134,6 +134,61 @@
40 }
41 }
42
43+class HistoryMarkup : Midori.Test.Job {
44+ public static void test () { new HistoryMarkup ().run_sync (); }
45+ public override async void run (Cancellable cancellable) throws GLib.Error {
46+ var app = new Midori.App ();
47+ var autocompleter = new Midori.Autocompleter (app);
48+ assert (!autocompleter.can_complete (""));
49+
50+ var histcomp = new Midori.HistoryCompletion ();
51+ assert (!histcomp.can_complete (""));
52+
53+ //this calls histcomp.prepare (app):
54+ autocompleter.add (histcomp);
55+
56+ //any time the history completion has a db, its can_complete method returns true
57+ //assert (!histcomp.can_complete (""));
58+
59+ //remove entries from previous tests
60+ histcomp.database.clear (0);
61+
62+ histcomp.database.insert ("https://duckduckgo.com/?q=%3E&ia=about", "> (Clojure) - DuckDuckGo", 0, 0);
63+ yield autocompleter.complete ("");
64+ assert (autocompleter.model.iter_n_children (null) == 2);
65+
66+ histcomp.database.insert ("https://duckduckgo.com/", "DuckDuckGo", 0, 0);
67+ yield autocompleter.complete ("");
68+ assert (autocompleter.model.iter_n_children (null) == 3);
69+
70+ histcomp.database.insert ("http://stackoverflow.com/questions/5068951/what-do-lt-and-gt-stand-for",
71+ "html - What do &lt; and &gt; stand for? - Stack Overflow", 0, 0);
72+ yield autocompleter.complete ("");
73+ assert (autocompleter.model.iter_n_children (null) == 4);
74+
75+ Gtk.TreeIter iter;
76+ string title, expected;
77+
78+ expected = "DuckDuckGo";
79+ autocompleter.model.iter_nth_child (out iter, null, 2);
80+ autocompleter.model.get (iter, Midori.Autocompleter.Columns.MARKUP, out title);
81+ if (title != expected)
82+ error ("Expected %s but got %s", expected, title);
83+
84+ expected = "> (Clojure) - DuckDuckGo";
85+ autocompleter.model.iter_nth_child (out iter, null, 3);
86+ autocompleter.model.get (iter, Midori.Autocompleter.Columns.MARKUP, out title);
87+ if (title != expected)
88+ error ("Expected %s but got %s", expected, title);
89+
90+ expected = "html - What do &lt; and &gt; stand for? - Stack Overflow";
91+ autocompleter.model.iter_nth_child (out iter, null, 1);
92+ autocompleter.model.get (iter, Midori.Autocompleter.Columns.MARKUP, out title);
93+ if (title != expected)
94+ error ("Expected %s but got %s", expected, title);
95+ }
96+}
97+
98 void main (string[] args) {
99 Midori.Test.init (ref args);
100 Midori.App.setup (ref args, null);
101@@ -141,6 +196,7 @@
102 Test.add_func ("/completion/autocompleter", CompletionAutocompleter.test);
103 Test.add_func ("/completion/history", CompletionHistory.test);
104 Test.add_func ("/completion/location-action", completion_location_action);
105+ Test.add_func ("/completion/historymarkup", HistoryMarkup.test);
106 Test.run ();
107 }
108

Subscribers

People subscribed via source and target branches

to all changes: