Merge lp:~macslow/unity/unity.fix-870284 into lp:unity

Proposed by Mirco Müller
Status: Rejected
Rejected by: Mirco Müller
Proposed branch: lp:~macslow/unity/unity.fix-870284
Merge into: lp:unity
Diff against target: 240 lines (+135/-0)
6 files modified
plugins/unityshell/src/DashController.cpp (+22/-0)
plugins/unityshell/src/DashController.h (+3/-0)
plugins/unityshell/src/PluginAdapter.cpp (+10/-0)
plugins/unityshell/src/UBusMessages.h (+4/-0)
tests/autopilot/autopilot/emulators/unity/spread.py (+77/-0)
tests/autopilot/autopilot/tests/test_dash.py (+19/-0)
To merge this branch: bzr merge lp:~macslow/unity/unity.fix-870284
Reviewer Review Type Date Requested Status
Tim Penhey (community) Needs Fixing
Review via email: mp+93549@code.launchpad.net

Description of the change

Using UBus to inform the Dash about the initiation of the scale-plugin (spread), thus it always closes correctly.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Hi Mirco,

Now the glorious question, how about a test?

This should be easy enough to write an auto-pilot test for. Everyone needs to start somewhere :)

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Also, since you're on it, please add also the symmetric UBUS_SCALE_TERMINATED signal, as it could be useful.

Revision history for this message
Mirco Müller (macslow) wrote :

Ok.

lp:~macslow/unity/unity.fix-870284 updated
1978. By Mirco Müller

Added autopilot-test and extended required infrastructure for catching any regressions regarding LP: #870284

1979. By Mirco Müller

Still trying to make the autopilot-test work... this is so much fun

1980. By Mirco Müller

Re-merged with trunk... solved merge-conflicts... grrrrr... hope nothing breaks

1981. By Mirco Müller

More fixing after re-merge with trunk

1982. By Mirco Müller

Further trying to get the autopilot test to work

Revision history for this message
Mirco Müller (macslow) wrote :

I've pushed the branch to lp:~unity-team/unity/unity.fix-870284 and there are a couple of updates to it.

Unmerged revisions

1982. By Mirco Müller

Further trying to get the autopilot test to work

1981. By Mirco Müller

More fixing after re-merge with trunk

1980. By Mirco Müller

Re-merged with trunk... solved merge-conflicts... grrrrr... hope nothing breaks

1979. By Mirco Müller

Still trying to make the autopilot-test work... this is so much fun

1978. By Mirco Müller

Added autopilot-test and extended required infrastructure for catching any regressions regarding LP: #870284

1977. By Mirco Müller

Inform the Dash via ubus that the scale-plugin was activated and close itself

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/DashController.cpp'
2--- plugins/unityshell/src/DashController.cpp 2012-02-21 02:46:18 +0000
3+++ plugins/unityshell/src/DashController.cpp 2012-02-28 23:27:18 +0000
4@@ -42,6 +42,7 @@
5 , window_(0)
6 , visible_(false)
7 , need_show_(false)
8+ , spread_active_(false)
9 , timeline_id_(0)
10 , last_opacity_(0.0f)
11 , start_time_(0)
12@@ -129,6 +130,10 @@
13 HideDash(true);
14 }
15 });
16+ ubus_manager_.RegisterInterest(UBUS_SCALE_INITIATED,
17+ sigc::mem_fun(this, &Controller::OnScaleInitiated));
18+ ubus_manager_.RegisterInterest(UBUS_SCALE_TERMINATED,
19+ sigc::mem_fun(this, &Controller::OnScaleTerminated));
20 }
21
22 void Controller::EnsureDash()
23@@ -343,6 +348,22 @@
24 ShowDash();
25 }
26
27+void Controller::OnScaleInitiated(GVariant* variant)
28+{
29+ HideDash(true);
30+
31+ // needed so the spread is testable via autopilot, also a means to protect
32+ // against regressions for 870284
33+ spread_active_ = true;
34+}
35+
36+void Controller::OnScaleTerminated(GVariant* variant)
37+{
38+ // needed so the spread is testable via autopilot, also a means to protect
39+ // against regressions for 870284
40+ spread_active_ = false;
41+}
42+
43 gboolean Controller::CheckShortcutActivation(const char* key_string)
44 {
45 EnsureDash();
46@@ -370,6 +391,7 @@
47 void Controller::AddProperties(GVariantBuilder* builder)
48 {
49 g_variant_builder_add (builder, "{sv}", "visible", g_variant_new_boolean (visible_) );
50+ g_variant_builder_add (builder, "{sv}", "spread_active", g_variant_new_boolean (spread_active_) );
51 }
52
53
54
55=== modified file 'plugins/unityshell/src/DashController.h'
56--- plugins/unityshell/src/DashController.h 2012-02-15 10:54:48 +0000
57+++ plugins/unityshell/src/DashController.h 2012-02-28 23:27:18 +0000
58@@ -74,6 +74,8 @@
59 void OnExternalShowDash(GVariant* variant);
60 void OnExternalHideDash(GVariant* variant);
61 void OnActivateRequest(GVariant* variant);
62+ void OnScaleInitiated(GVariant* variant);
63+ void OnScaleTerminated(GVariant* variant);
64
65 void ShowDash();
66 void HideDash(bool restore_focus = true);
67@@ -90,6 +92,7 @@
68 nux::BaseWindow* window_;
69 bool visible_;
70 bool need_show_;
71+ bool spread_active_;
72
73 guint timeline_id_;
74 float last_opacity_;
75
76=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
77--- plugins/unityshell/src/PluginAdapter.cpp 2012-02-22 09:55:54 +0000
78+++ plugins/unityshell/src/PluginAdapter.cpp 2012-02-28 23:27:18 +0000
79@@ -20,6 +20,8 @@
80 #include <glib.h>
81 #include <sstream>
82 #include "PluginAdapter.h"
83+#include "ubus-server.h"
84+#include "UBusMessages.h"
85
86 #include <NuxCore/Logger.h>
87
88@@ -354,6 +356,10 @@
89 argument[0].value().set(m);
90
91 m_ScaleActionList.InitiateAll(argument, state);
92+
93+ ubus_server_send_message(ubus_server_get_default(),
94+ UBUS_SCALE_INITIATED,
95+ nullptr);
96 }
97
98 void
99@@ -361,6 +367,10 @@
100 {
101 CompOption::Vector argument(0);
102 m_ScaleActionList.TerminateAll(argument);
103+
104+ ubus_server_send_message(ubus_server_get_default(),
105+ UBUS_SCALE_TERMINATED,
106+ nullptr);
107 }
108
109 bool
110
111=== modified file 'plugins/unityshell/src/UBusMessages.h'
112--- plugins/unityshell/src/UBusMessages.h 2012-02-07 07:42:12 +0000
113+++ plugins/unityshell/src/UBusMessages.h 2012-02-28 23:27:18 +0000
114@@ -84,4 +84,8 @@
115 #define UBUS_SWITCHER_SHOWN "SWITCHER_SHOWN"
116 #define UBUS_SWITCHER_SELECTION_CHANGED "SWITCHER_SELECTION_CHANGED"
117
118+// Signal used to securely tell the Dash "Scale" has been triggered
119+#define UBUS_SCALE_INITIATED "SCALE_INITIATED"
120+#define UBUS_SCALE_TERMINATED "SCALE_TERMINATED"
121+
122 #endif // UBUS_MESSAGES_H
123
124=== added file 'tests/autopilot/autopilot/emulators/unity/spread.py'
125--- tests/autopilot/autopilot/emulators/unity/spread.py 1970-01-01 00:00:00 +0000
126+++ tests/autopilot/autopilot/emulators/unity/spread.py 2012-02-28 23:27:18 +0000
127@@ -0,0 +1,77 @@
128+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
129+# Copyright 2012 Canonical
130+# Author: Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
131+#
132+# This program is free software: you can redistribute it and/or modify it
133+# under the terms of the GNU General Public License version 3, as published
134+# by the Free Software Foundation.
135+#
136+
137+import os
138+from compizconfig import Setting, Plugin
139+from time import sleep
140+
141+from autopilot.globals import global_context
142+from autopilot.emulators.unity import get_state_by_path
143+from autopilot.emulators.X11 import Keyboard
144+
145+import logging
146+logger = logging.getLogger(__name__)
147+
148+
149+class Spread(object):
150+ """
151+ An emulator class that makes it easier to interact with the spread of unity.
152+ """
153+
154+ def __init__(self):
155+ self.plugin = Plugin(global_context, "unityshell")
156+ self.setting = Setting(self.plugin, "show_launcher")
157+ self._keyboard = Keyboard()
158+ super(Spread, self).__init__()
159+
160+ def toggle_active(self):
161+ """
162+ Activates the spread if it is currently inactive, deactivates it otherwise.
163+ """
164+ logger.debug("Toggling spread with Super-W key-combo.")
165+ self._keyboard.press_and_release("Super+w")
166+ sleep(1)
167+
168+ def ensure_active(self):
169+ """
170+ Ensures the dash is active.
171+ """
172+ if not self.get_is_active():
173+ self.toggle_active()
174+
175+ def ensure_inactive(self):
176+ """
177+ Ensures the spread is not active.
178+ """
179+ if self.get_is_active():
180+ self.toggle_reveal()
181+
182+ def get_is_active(self):
183+ """
184+ Is the spread active?
185+ """
186+ return bool(get_state_by_path("/Unity/DashController")[0]["spread_active"])
187+
188+ def open_some_apps(self):
189+ """
190+ Open some application windows (non-blocking).
191+ """
192+ #os.spawnlp(os.P_NOWAIT, "gnome-terminal")
193+ os.spawnlp(os.P_NOWAIT, "gedit")
194+ os.spawnlp(os.P_NOWAIT, "gnome-calculator")
195+ os.spawnlp(os.P_NOWAIT, "gnome-control-center")
196+
197+ def close_some_apps(self):
198+ """
199+ Close those application windows (blocking).
200+ """
201+ #os.spawnlp(os.P_WAIT, "killall -15 gnome-terminal")
202+ os.spawnlp(os.P_WAIT, "killall -15 gedit")
203+ os.spawnlp(os.P_WAIT, "killall -15 gnome-calculator")
204+ os.spawnlp(os.P_WAIT, "killall -15 gnome-control-center")
205
206=== modified file 'tests/autopilot/autopilot/tests/test_dash.py'
207--- tests/autopilot/autopilot/tests/test_dash.py 2012-02-27 03:56:46 +0000
208+++ tests/autopilot/autopilot/tests/test_dash.py 2012-02-28 23:27:18 +0000
209@@ -10,6 +10,7 @@
210 from time import sleep
211
212 from autopilot.emulators.unity.dash import Dash
213+from autopilot.emulators.unity.spread import Spread
214 from autopilot.emulators.X11 import Keyboard, Mouse
215 from autopilot.tests import AutopilotTestCase
216 from autopilot.glibrunner import GlibRunner
217@@ -395,3 +396,21 @@
218 searchbar = self.dash.get_searchbar()
219 self.assertEqual("hello world", searchbar.search_string)
220
221+
222+ def test_spread(self):
223+ """ This test makes sure, that an active window-spread is
224+ automatically terminated as soon as the dash is opened.
225+ """
226+ kb = Keyboard()
227+ self.spread = Spread()
228+ self.dash.ensure_hidden()
229+ self.spread.open_some_apps()
230+ self.spread.ensure_inactive()
231+ self.spread.ensure_active()
232+ self.dash.toggle_reveal()
233+ self.assertTrue(self.dash.get_is_visible())
234+ self.assertFalse(self.spread.get_is_active())
235+ self.spread.close_some_apps()
236+ self.dash.toggle_reveal()
237+ self.assertFalse(self.dash.get_is_visible())
238+
239
240=== modified file 'tests/autopilot/setup.py' (properties changed: -x to +x)