Merge lp:~kyrofa/unity-scope-snappy/launcher_scope into lp:~unity-api-team/unity-scope-snappy/trunk

Proposed by Kyle Fazzari
Status: Needs review
Proposed branch: lp:~kyrofa/unity-scope-snappy/launcher_scope
Merge into: lp:~unity-api-team/unity-scope-snappy/trunk
Diff against target: 268 lines (+197/-6)
7 files modified
Makefile (+1/-1)
debian/rules (+7/-2)
debian/unity-scope-snappy.install (+9/-3)
launcher/main.go (+39/-0)
launcher/scope/scope.go (+87/-0)
launcher/snappy-launcher.ini (+6/-0)
test/launcher/test_surface.py (+48/-0)
To merge this branch: bzr merge lp:~kyrofa/unity-scope-snappy/launcher_scope
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Unity API Team Pending
Review via email: mp+266132@code.launchpad.net

Commit message

Add basic launcher scope with debian packaging and integration tests.

Description of the change

Add basic launcher scope, along with debian packaging and integration test.

The scope has no functionality yet-- this is all just scaffolding.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

34. By Kyle Fazzari

Add basic launcher scope with debian packaging and integration tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-07-16 16:41:37 +0000
3+++ Makefile 2015-07-28 16:46:34 +0000
4@@ -5,7 +5,7 @@
5 GOFMT=gofmt -w
6
7 TOP_PACKAGE := launchpad.net/unity-scope-snappy
8-EXECUTABLES := store package-management-daemon
9+EXECUTABLES := launcher store package-management-daemon
10 PACKAGES_TO_TEST := package-management-daemon/daemon \
11 store/actions \
12 store/packages \
13
14=== added file 'data/snappy-launcher.png'
15Binary files data/snappy-launcher.png 1970-01-01 00:00:00 +0000 and data/snappy-launcher.png 2015-07-28 16:46:34 +0000 differ
16=== modified file 'debian/rules'
17--- debian/rules 2015-07-16 18:09:58 +0000
18+++ debian/rules 2015-07-28 16:46:34 +0000
19@@ -10,12 +10,13 @@
20 export PATH := $(GOPATH)/bin:$(PATH)
21
22 STORE_FILE_PATH := /usr/lib/$(DEB_HOST_MULTIARCH)/unity-scopes/snappy-store/store
23+LAUNCHER_FILE_PATH := /usr/lib/$(DEB_HOST_MULTIARCH)/unity-scopes/snappy-launcher/launcher
24
25 %:
26 dh $@ --buildsystem=golang --with=golang
27
28 # Run the tests and produce a Cobertura-compatible coverage report.
29-override_dh_auto_test: debian/snappy-store.ini debian/com.canonical.applications.WebdmPackageManager.service
30+override_dh_auto_test: debian/snappy-launcher.ini debian/snappy-store.ini debian/com.canonical.applications.WebdmPackageManager.service
31 dbus-test-runner -m 600 -t make -p integration_tests
32 dbus-test-runner -m 600 -t make -p coverage.xml
33
34@@ -23,6 +24,10 @@
35 debian/%: data/%.in
36 sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@
37
38-# Rewrite the scope.ini file to point to the multiarch location.
39+# Rewrite the snappy-store.ini file to point to the multiarch location.
40 debian/snappy-store.ini: store/snappy-store.ini
41 sed 's|ScopeRunner.*|ScopeRunner = $(STORE_FILE_PATH) --runtime %R --scope %S|g' $< > $@
42+
43+# Rewrite the snappy-launcher.ini file to point to the multiarch location.
44+debian/snappy-launcher.ini: launcher/snappy-launcher.ini
45+ sed 's|ScopeRunner.*|ScopeRunner = $(LAUNCHER_FILE_PATH) --runtime %R --scope %S|g' $< > $@
46
47=== modified file 'debian/unity-scope-snappy.install'
48--- debian/unity-scope-snappy.install 2015-07-16 18:09:58 +0000
49+++ debian/unity-scope-snappy.install 2015-07-28 16:46:34 +0000
50@@ -1,5 +1,11 @@
51 #!/usr/bin/dh-exec
52
53-usr/bin/store usr/lib/${DEB_HOST_MULTIARCH}/unity-scopes/snappy-store/
54-debian/snappy-store.ini usr/lib/${DEB_HOST_MULTIARCH}/unity-scopes/snappy-store/
55-data/snappy-store.png usr/share/unity/scopes/snappy-store/
56+# Install Snappy Store
57+usr/bin/store usr/lib/${DEB_HOST_MULTIARCH}/unity-scopes/snappy-store
58+debian/snappy-store.ini usr/lib/${DEB_HOST_MULTIARCH}/unity-scopes/snappy-store
59+data/snappy-store.png usr/share/unity/scopes/snappy-store
60+
61+# Install Snappy Launcher
62+usr/bin/launcher usr/lib/${DEB_HOST_MULTIARCH}/unity-scopes/snappy-launcher
63+debian/snappy-launcher.ini usr/lib/${DEB_HOST_MULTIARCH}/unity-scopes/snappy-launcher
64+data/snappy-launcher.png usr/share/unity/scopes/snappy-launcher
65
66=== added directory 'launcher'
67=== added file 'launcher/main.go'
68--- launcher/main.go 1970-01-01 00:00:00 +0000
69+++ launcher/main.go 2015-07-28 16:46:34 +0000
70@@ -0,0 +1,39 @@
71+/* Copyright (C) 2015 Canonical Ltd.
72+ *
73+ * This file is part of unity-scope-snappy.
74+ *
75+ * unity-scope-snappy is free software: you can redistribute it and/or modify it
76+ * under the terms of the GNU General Public License as published by the Free
77+ * Software Foundation, either version 3 of the License, or (at your option) any
78+ * later version.
79+ *
80+ * unity-scope-snappy is distributed in the hope that it will be useful, but
81+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
83+ * details.
84+ *
85+ * You should have received a copy of the GNU General Public License along with
86+ * unity-scope-snappy. If not, see <http://www.gnu.org/licenses/>.
87+ */
88+
89+package main
90+
91+import (
92+ "launchpad.net/unity-scope-snappy/internal/launchpad.net/go-unityscopes/v2"
93+ "launchpad.net/unity-scope-snappy/launcher/scope"
94+ "log"
95+)
96+
97+// main is the entry point of the scope.
98+func main() {
99+ scope, err := scope.New()
100+ if err != nil {
101+ log.Printf("snappy-launcher: Unable to create scope: %s", err)
102+ return
103+ }
104+
105+ err = scopes.Run(scope)
106+ if err != nil {
107+ log.Printf("snappy-launcher: Unable to run scope: %s", err)
108+ }
109+}
110
111=== added directory 'launcher/scope'
112=== added file 'launcher/scope/scope.go'
113--- launcher/scope/scope.go 1970-01-01 00:00:00 +0000
114+++ launcher/scope/scope.go 2015-07-28 16:46:34 +0000
115@@ -0,0 +1,87 @@
116+/* Copyright (C) 2015 Canonical Ltd.
117+ *
118+ * This file is part of unity-scope-snappy.
119+ *
120+ * unity-scope-snappy is free software: you can redistribute it and/or modify it
121+ * under the terms of the GNU General Public License as published by the Free
122+ * Software Foundation, either version 3 of the License, or (at your option) any
123+ * later version.
124+ *
125+ * unity-scope-snappy is distributed in the hope that it will be useful, but
126+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
127+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
128+ * details.
129+ *
130+ * You should have received a copy of the GNU General Public License along with
131+ * unity-scope-snappy. If not, see <http://www.gnu.org/licenses/>.
132+ */
133+
134+package scope
135+
136+import (
137+ "fmt"
138+ "launchpad.net/unity-scope-snappy/internal/launchpad.net/go-unityscopes/v2"
139+ "log"
140+)
141+
142+// template for the grid layout of the search results.
143+const layout = `{
144+ "schema-version": 1,
145+ "template": {
146+ "category-layout": "grid",
147+ "card-size": "small"
148+ },
149+ "components": {
150+ "title": "title",
151+ "art" : {
152+ "field": "art"
153+ },
154+ "subtitle": "subtitle"
155+ }
156+}`
157+
158+// Scope is the struct representing the scope itself.
159+type Scope struct {}
160+
161+// New creates a new Snappy Launcher scope.
162+func New() (*Scope, error) {
163+ return &Scope{}, nil
164+}
165+
166+func (scope *Scope) SetScopeBase(base *scopes.ScopeBase) {
167+ // Do nothing
168+}
169+
170+func (scope Scope) Search(query *scopes.CannedQuery, metadata *scopes.SearchMetadata, reply *scopes.SearchReply, cancelled <-chan bool) error {
171+ //createDepartments(query, reply)
172+
173+ return nil
174+}
175+
176+func (scope Scope) Preview(result *scopes.Result, metadata *scopes.ActionMetadata, reply *scopes.PreviewReply, cancelled <-chan bool) error {
177+ return nil
178+}
179+
180+// createDepartments is used to create a set of static departments for the
181+// scope.
182+//
183+// It accepts a query to be executed when the department is selected, and a
184+// reply onto which the new departments will be registered.
185+func createDepartments(query *scopes.CannedQuery, reply *scopes.SearchReply) error {
186+ rootDepartment, err := scopes.NewDepartment("", query, "All Categories")
187+ if err != nil {
188+ return fmt.Errorf(`Unable to create "All Categories" department: %s`, err)
189+ }
190+
191+ reply.RegisterDepartments(rootDepartment)
192+
193+ return nil
194+}
195+
196+// scopeError prints an error to stderr as well as returning an actual error.
197+// This is used because the errors returned from the scope functions don't seem
198+// to be handled, logged, or otherwise displayed to the user in any way.
199+func scopeError(format string, a ...interface{}) error {
200+ log.Printf(format, a...)
201+ return fmt.Errorf(format, a...)
202+}
203
204=== added file 'launcher/snappy-launcher.ini'
205--- launcher/snappy-launcher.ini 1970-01-01 00:00:00 +0000
206+++ launcher/snappy-launcher.ini 2015-07-28 16:46:34 +0000
207@@ -0,0 +1,6 @@
208+[ScopeConfig]
209+DisplayName = Snappy Launcher
210+Description = A scope to view and launch snap and legacy applications
211+Author = Canonical
212+Icon = /usr/share/unity/scopes/snappy-launcher/snappy-launcher.png
213+ScopeRunner = $GOPATH/bin/launcher --runtime %R --scope %S
214
215=== added directory 'test/launcher'
216=== added file 'test/launcher/__init__.py'
217=== added file 'test/launcher/test_surface.py'
218--- test/launcher/test_surface.py 1970-01-01 00:00:00 +0000
219+++ test/launcher/test_surface.py 2015-07-28 16:46:34 +0000
220@@ -0,0 +1,48 @@
221+#!/usr/bin/env python3
222+
223+# Copyright (C) 2015 Canonical Ltd.
224+#
225+# This file is part of unity-scope-snappy.
226+#
227+# unity-scope-snappy is free software: you can redistribute it and/or modify it
228+# under the terms of the GNU General Public License as published by the Free
229+# Software Foundation, either version 3 of the License, or (at your option) any
230+# later version.
231+#
232+# unity-scope-snappy is distributed in the hope that it will be useful, but
233+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
234+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
235+# details.
236+#
237+# You should have received a copy of the GNU General Public License along with
238+# unity-scope-snappy. If not, see <http://www.gnu.org/licenses/>.
239+
240+import os
241+import sys
242+import unittest
243+
244+from scope_harness.testing import ScopeHarnessTestCase
245+from scope_harness import (ScopeHarness,
246+ Parameters)
247+
248+class TestInitialSurface(ScopeHarnessTestCase):
249+ """Test the initial surfacing of the launcher scope (no search query).
250+ """
251+
252+ def setUp(self):
253+ """Run the Snappy Launcher using the harness.
254+ """
255+
256+ self.harness = ScopeHarness.new_from_scope_list(Parameters([
257+ "{}/../../launcher/snappy-launcher.ini".format(os.path.dirname(os.path.realpath(__file__)))
258+ ]))
259+ self.view = self.harness.results_view
260+ self.view.active_scope = "snappy-launcher"
261+ self.view.search_query = ""
262+
263+ def testScopeProperties(self):
264+ """Test the scope properties from the .ini file"""
265+
266+ self.assertEqual(self.view.scope_id, "snappy-launcher")
267+ self.assertEqual(self.view.display_name, "Snappy Launcher")
268+ self.assertEqual(self.view.description, "A scope to view and launch snap and legacy applications")

Subscribers

People subscribed via source and target branches