Merge lp:~larryprice/libertine-scope/no-apps into lp:libertine-scope

Proposed by Larry Price
Status: Merged
Approved by: Christopher Townsend
Approved revision: 57
Merged at revision: 48
Proposed branch: lp:~larryprice/libertine-scope/no-apps
Merge into: lp:libertine-scope
Prerequisite: lp:~larryprice/libertine-scope/minor-cmake-updates
Diff against target: 210 lines (+87/-11)
6 files modified
libertine-scope/query.cpp (+45/-2)
libertine-scope/query.h (+4/-0)
tests/fake_container.cpp (+0/-1)
tests/fake_libertine.cpp (+0/-6)
tests/fake_libertine.h (+2/-2)
tests/test_query.cpp (+36/-0)
To merge this branch: bzr merge lp:~larryprice/libertine-scope/no-apps
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+297244@code.launchpad.net

Commit message

Show a message when no apps are available due to filters or no apps installed.

Description of the change

Show a message when no apps are available due to filters or no apps installed.

To post a comment you must log in.
54. By Larry Price

Merge

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

FAILED: Continuous integration, rev:53
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/31/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/37
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/21
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/21
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/21
    FAILURE: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/21/console
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/31/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/37
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/38
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/38
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/31
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/31/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/31
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/31/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/31
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/31/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/31
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/31/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/31/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:54
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/33/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/39
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/23
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/23
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/23
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/23
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/33/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/39
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/40
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/40
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/33
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/33/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/33
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/33/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/33
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/33/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/33
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/33/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/33/rebuild

review: Approve (continuous-integration)
55. By Larry Price

Show different messages based on filters or no apps available.

56. By Larry Price

style update

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
57. By Larry Price

Fixing hint string locations

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:57
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/37/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/44
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/26
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/26
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/26
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/26
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/37/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/44
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/45
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/45
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/38
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/38/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/38
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/38/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/38
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/38/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/38
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/38/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-scope-ci/37/rebuild

review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libertine-scope/query.cpp'
2--- libertine-scope/query.cpp 2016-06-13 21:11:38 +0000
3+++ libertine-scope/query.cpp 2016-06-14 16:50:00 +0000
4@@ -35,8 +35,6 @@
5
6 namespace
7 {
8-static const auto NO_X_APPS_DESCRIPTION = _("Update filters or use the Libertine GUI to install applications.");
9-static const auto NO_X_APPS_TITLE = _("No X Apps available");
10 static const auto ROOT_DEPT_TITLE = _("X Apps");
11 static const auto HIDDEN_DEPT_TITLE = _("Hidden X Apps");
12 static const auto DESCRIPTION_FIELD = "description";
13@@ -94,9 +92,28 @@
14 }
15 }
16 )";
17+
18+
19+static const auto CATEGORY_HINT = R"(
20+ {
21+ "schema-version": 1,
22+ "template": {
23+ "category-layout": "grid",
24+ "card-size": "large",
25+ "card-layout": "horizontal"
26+ },
27+ "components": {
28+ "title": "title"
29+ }
30+ }
31+)";
32 } // anonymous namespace
33
34
35+std::string const Query::NO_RESULTS_HINT = _("No XApps available. Install new applications with the Libertine Manager.");
36+std::string const Query::ALL_RESULTS_FILTERED_HINT = _("All XApps hidden. Reset filters or check the Hidden XApps department.");
37+
38+
39 Query::
40 Query(usc::CannedQuery const& query,
41 usc::SearchMetadata const& metadata,
42@@ -172,6 +189,18 @@
43
44
45 void Query::
46+show_hint(usc::SearchReplyProxy const& reply,
47+ std::string const& reason) const
48+{
49+ auto hint_category = reply->register_category("hint", "", "", usc::CategoryRenderer(CATEGORY_HINT));
50+ usc::CategorisedResult res(hint_category);
51+ res.set_uri(usc::CannedQuery(query()).to_uri());
52+ res.set_title(reason);
53+ reply->push(res);
54+}
55+
56+
57+void Query::
58 run(usc::SearchReplyProxy const& reply)
59 {
60 if (!hidden_->empty())
61@@ -187,6 +216,8 @@
62 }
63
64 QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive);
65+ bool has_no_apps = true,
66+ all_filtered = true;
67
68 for (auto const& container: libertine_->get_container_list())
69 {
70@@ -197,6 +228,7 @@
71
72 for (auto const& app: container->app_launchers())
73 {
74+ has_no_apps = false;
75 if (!(search_query.isEmpty() || QString::fromStdString(app.name()).contains(search_query)))
76 {
77 continue;
78@@ -239,6 +271,17 @@
79 {
80 return;
81 }
82+
83+ all_filtered = false;
84 }
85 }
86+
87+ if (has_no_apps)
88+ {
89+ show_hint(reply, NO_RESULTS_HINT);
90+ }
91+ else if (all_filtered)
92+ {
93+ show_hint(reply, ALL_RESULTS_FILTERED_HINT);
94+ }
95 }
96
97=== modified file 'libertine-scope/query.h'
98--- libertine-scope/query.h 2016-06-13 21:11:38 +0000
99+++ libertine-scope/query.h 2016-06-14 16:50:00 +0000
100@@ -45,9 +45,13 @@
101 void
102 run(unity::scopes::SearchReplyProxy const& reply) override;
103
104+ static std::string const NO_RESULTS_HINT;
105+ static std::string const ALL_RESULTS_FILTERED_HINT;
106+
107 private:
108 QStringList get_hidden_department() const;
109 QStringList make_filters(unity::scopes::SearchReplyProxy const& reply) const;
110+ void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const;
111 void parse_blacklist(const std::string& data_dir);
112
113 Libertine::UPtr libertine_;
114
115=== modified file 'tests/fake_container.cpp'
116--- tests/fake_container.cpp 2016-06-09 15:07:27 +0000
117+++ tests/fake_container.cpp 2016-06-14 16:50:00 +0000
118@@ -42,7 +42,6 @@
119 }
120 };
121
122-
123 FakeContainer::
124 FakeContainer(std::string const& json_string)
125 : Container("fake-container", "fake-container")
126
127=== modified file 'tests/fake_libertine.cpp'
128--- tests/fake_libertine.cpp 2016-01-19 00:16:56 +0000
129+++ tests/fake_libertine.cpp 2016-06-14 16:50:00 +0000
130@@ -25,12 +25,6 @@
131 }
132
133
134-FakeLibertine::
135-~FakeLibertine()
136-{
137-}
138-
139-
140 Libertine::ContainerList const& FakeLibertine::
141 get_container_list() const
142 {
143
144=== modified file 'tests/fake_libertine.h'
145--- tests/fake_libertine.h 2016-01-19 21:10:09 +0000
146+++ tests/fake_libertine.h 2016-06-14 16:50:00 +0000
147@@ -27,9 +27,9 @@
148 : public Libertine
149 {
150 public:
151- ~FakeLibertine();
152+ virtual ~FakeLibertine() = default;
153
154- Libertine::ContainerList const&
155+ virtual Libertine::ContainerList const&
156 get_container_list() const override;
157
158 static Libertine::UPtr
159
160=== modified file 'tests/test_query.cpp'
161--- tests/test_query.cpp 2016-06-13 18:06:36 +0000
162+++ tests/test_query.cpp 2016-06-14 16:50:00 +0000
163@@ -101,6 +101,12 @@
164 }
165
166
167+MATCHER_P(ResultTitleMatch, title, "")
168+{
169+ return arg.contains("title") && arg["title"] == unity::scopes::Variant(title);
170+}
171+
172+
173 class TestQueryFixture : public ::testing::Test
174 {
175 public:
176@@ -250,4 +256,34 @@
177 }, hidden, blacklist);
178 query.run(proxy);
179 }
180+
181+
182+TEST_F(TestQueryFixture, showsHintWhenAllAppsFiltered)
183+{
184+ expect_registry();
185+
186+ EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category));
187+ EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::ALL_RESULTS_FILTERED_HINT)))).WillOnce(testing::Return(true));
188+
189+ EXPECT_CALL(*hidden, app_is_hidden(testing::_)).WillRepeatedly(testing::Return(true));
190+
191+ Query query(canned_query, metadata, []() {
192+ return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS);
193+ }, hidden, blacklist);
194+ query.run(proxy);
195+}
196+
197+
198+TEST_F(TestQueryFixture, showsHintWhenNoAppsInContainer)
199+{
200+ expect_registry();
201+
202+ EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category));
203+ EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::NO_RESULTS_HINT)))).WillOnce(testing::Return(true));
204+
205+ Query query(canned_query, metadata, []() {
206+ return FakeLibertine::make_fake("");
207+ }, hidden, blacklist);
208+ query.run(proxy);
209+}
210 } // anonymous namespace

Subscribers

People subscribed via source and target branches