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

Proposed by Mirco Müller
Status: Work in progress
Proposed branch: lp:~unity-team/unity/unity.fix-870284
Merge into: lp:unity
Diff against target: 273 lines (+103/-6) (has conflicts)
7 files modified
plugins/unityshell/src/DashController.cpp (+25/-1)
plugins/unityshell/src/DashController.h (+3/-0)
plugins/unityshell/src/PluginAdapter.cpp (+10/-0)
plugins/unityshell/src/UBusMessages.h (+4/-0)
tests/autopilot/autopilot/keybindings.py (+6/-0)
tests/autopilot/autopilot/tests/__init__.py (+7/-0)
tests/autopilot/autopilot/tests/test_dash.py (+48/-5)
Text conflict in tests/autopilot/autopilot/keybindings.py
Text conflict in tests/autopilot/autopilot/tests/__init__.py
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix-870284
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+95376@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. It comes with alomst working autopilot regression test and UBus-messages for triggering/stopping the scale-plugin (spread).

To post a comment you must log in.

Unmerged revisions

1984. By Mirco Müller

Added correct regression test for bug-fix for LP: #870284 ... although it still fails in the last assertion.

1983. By Thomi Richards

DashCOntroller uses variant wrapper. Split spread test into two smaller tests, and now use keybinding from compiz.

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-03-01 14:54:36 +0000
4@@ -20,6 +20,7 @@
5
6 #include <NuxCore/Logger.h>
7 #include <Nux/HLayout.h>
8+#include <UnityCore/Variant.h>
9
10 #include "DashSettings.h"
11 #include "PanelStyle.h"
12@@ -42,6 +43,7 @@
13 , window_(0)
14 , visible_(false)
15 , need_show_(false)
16+ , spread_active_(false)
17 , timeline_id_(0)
18 , last_opacity_(0.0f)
19 , start_time_(0)
20@@ -129,6 +131,10 @@
21 HideDash(true);
22 }
23 });
24+ ubus_manager_.RegisterInterest(UBUS_SCALE_INITIATED,
25+ sigc::mem_fun(this, &Controller::OnScaleInitiated));
26+ ubus_manager_.RegisterInterest(UBUS_SCALE_TERMINATED,
27+ sigc::mem_fun(this, &Controller::OnScaleTerminated));
28 }
29
30 void Controller::EnsureDash()
31@@ -343,6 +349,22 @@
32 ShowDash();
33 }
34
35+void Controller::OnScaleInitiated(GVariant* variant)
36+{
37+ HideDash(true);
38+
39+ // needed so the spread is testable via autopilot, also a means to protect
40+ // against regressions for 870284
41+ spread_active_ = true;
42+}
43+
44+void Controller::OnScaleTerminated(GVariant* variant)
45+{
46+ // needed so the spread is testable via autopilot, also a means to protect
47+ // against regressions for 870284
48+ spread_active_ = false;
49+}
50+
51 gboolean Controller::CheckShortcutActivation(const char* key_string)
52 {
53 EnsureDash();
54@@ -369,7 +391,9 @@
55
56 void Controller::AddProperties(GVariantBuilder* builder)
57 {
58- g_variant_builder_add (builder, "{sv}", "visible", g_variant_new_boolean (visible_) );
59+ variant::BuilderWrapper(builder)
60+ .add("visible", visible_)
61+ .add("spread_active", spread_active_);
62 }
63
64
65
66=== modified file 'plugins/unityshell/src/DashController.h'
67--- plugins/unityshell/src/DashController.h 2012-02-15 10:54:48 +0000
68+++ plugins/unityshell/src/DashController.h 2012-03-01 14:54:36 +0000
69@@ -74,6 +74,8 @@
70 void OnExternalShowDash(GVariant* variant);
71 void OnExternalHideDash(GVariant* variant);
72 void OnActivateRequest(GVariant* variant);
73+ void OnScaleInitiated(GVariant* variant);
74+ void OnScaleTerminated(GVariant* variant);
75
76 void ShowDash();
77 void HideDash(bool restore_focus = true);
78@@ -90,6 +92,7 @@
79 nux::BaseWindow* window_;
80 bool visible_;
81 bool need_show_;
82+ bool spread_active_;
83
84 guint timeline_id_;
85 float last_opacity_;
86
87=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
88--- plugins/unityshell/src/PluginAdapter.cpp 2012-02-22 09:55:54 +0000
89+++ plugins/unityshell/src/PluginAdapter.cpp 2012-03-01 14:54:36 +0000
90@@ -20,6 +20,8 @@
91 #include <glib.h>
92 #include <sstream>
93 #include "PluginAdapter.h"
94+#include "ubus-server.h"
95+#include "UBusMessages.h"
96
97 #include <NuxCore/Logger.h>
98
99@@ -354,6 +356,10 @@
100 argument[0].value().set(m);
101
102 m_ScaleActionList.InitiateAll(argument, state);
103+
104+ ubus_server_send_message(ubus_server_get_default(),
105+ UBUS_SCALE_INITIATED,
106+ nullptr);
107 }
108
109 void
110@@ -361,6 +367,10 @@
111 {
112 CompOption::Vector argument(0);
113 m_ScaleActionList.TerminateAll(argument);
114+
115+ ubus_server_send_message(ubus_server_get_default(),
116+ UBUS_SCALE_TERMINATED,
117+ nullptr);
118 }
119
120 bool
121
122=== modified file 'plugins/unityshell/src/UBusMessages.h'
123--- plugins/unityshell/src/UBusMessages.h 2012-02-07 07:42:12 +0000
124+++ plugins/unityshell/src/UBusMessages.h 2012-03-01 14:54:36 +0000
125@@ -84,4 +84,8 @@
126 #define UBUS_SWITCHER_SHOWN "SWITCHER_SHOWN"
127 #define UBUS_SWITCHER_SELECTION_CHANGED "SWITCHER_SELECTION_CHANGED"
128
129+// Signal used to securely tell the Dash "Scale" has been triggered
130+#define UBUS_SCALE_INITIATED "SCALE_INITIATED"
131+#define UBUS_SCALE_TERMINATED "SCALE_TERMINATED"
132+
133 #endif // UBUS_MESSAGES_H
134
135=== modified file 'tests/autopilot/autopilot/keybindings.py'
136--- tests/autopilot/autopilot/keybindings.py 2012-02-29 04:43:19 +0000
137+++ tests/autopilot/autopilot/keybindings.py 2012-03-01 14:54:36 +0000
138@@ -80,8 +80,14 @@
139 "workspace/move_right": ("wall", "right_key"),
140 "workspace/move_up": ("wall", "up_key"),
141 "workspace/move_down": ("wall", "down_key"),
142+<<<<<<< TREE
143 # Window management
144 "window/minimize": ("core", "minimize_window_key"),
145+=======
146+ # Window spread:
147+ "spread/initiate": ("scale", "initiate_all_key"),
148+ "spread/cancel": "Escape",
149+>>>>>>> MERGE-SOURCE
150 }
151
152
153
154=== modified file 'tests/autopilot/autopilot/tests/__init__.py'
155--- tests/autopilot/autopilot/tests/__init__.py 2012-02-29 23:22:25 +0000
156+++ tests/autopilot/autopilot/tests/__init__.py 2012-03-01 14:54:36 +0000
157@@ -16,11 +16,18 @@
158 from autopilot.emulators.bamf import Bamf
159 from autopilot.emulators.unity.switcher import Switcher
160 from autopilot.emulators.unity.workspace import WorkspaceManager
161+<<<<<<< TREE
162 from autopilot.keybindings import KeybindingsHelper
163
164 logger = logging.getLogger(__name__)
165
166 class LoggedTestCase(TestWithScenarios, TestCase):
167+=======
168+from autopilot.keybindings import KeybindingsHelper
169+
170+
171+class LoggedTestCase(TestWithScenarios, TestCase, KeybindingsHelper):
172+>>>>>>> MERGE-SOURCE
173 """Initialize the logging for the test case."""
174
175 def setUp(self):
176
177=== modified file 'tests/autopilot/autopilot/tests/test_dash.py'
178--- tests/autopilot/autopilot/tests/test_dash.py 2012-02-27 03:56:46 +0000
179+++ tests/autopilot/autopilot/tests/test_dash.py 2012-03-01 14:54:36 +0000
180@@ -269,7 +269,7 @@
181
182
183 class DashClipboardTests(AutopilotTestCase):
184- """Test the Unity clipboard"""
185+ """Test the Unity clipboard"""
186 run_test_with = GlibRunner
187
188 def setUp(self):
189@@ -279,7 +279,7 @@
190 def tearDown(self):
191 super(DashClipboardTests, self).tearDown()
192 self.dash.ensure_hidden()
193-
194+
195 def test_ctrl_a(self):
196 """ This test if ctrl+a selects all text """
197 self.dash.ensure_hidden()
198@@ -291,7 +291,7 @@
199
200 kb.press_and_release("Ctrl+a")
201 kb.press_and_release("Delete")
202-
203+
204 searchbar = self.dash.get_searchbar()
205 self.assertEqual(searchbar.search_string, u'')
206
207@@ -344,7 +344,7 @@
208 kb.press_and_release("Ctrl+c")
209 kb.press_and_release("Ctrl+v")
210 kb.press_and_release("Ctrl+v")
211-
212+
213 searchbar = self.dash.get_searchbar()
214 self.assertEqual(searchbar.search_string, u'CopyPasteCopyPaste')
215
216@@ -361,7 +361,7 @@
217 kb.press_and_release("Ctrl+x")
218 kb.press_and_release("Ctrl+v")
219 kb.press_and_release("Ctrl+v")
220-
221+
222 searchbar = self.dash.get_searchbar()
223 self.assertEqual(searchbar.search_string, u'CutPasteCutPaste')
224
225@@ -395,3 +395,46 @@
226 searchbar = self.dash.get_searchbar()
227 self.assertEqual("hello world", searchbar.search_string)
228
229+ def test_spread(self):
230+ """Test that the spread is shown correctly."""
231+ self.dash.ensure_hidden()
232+ self.start_app("Calculator")
233+ self.start_app("Character Map")
234+
235+ self.keybinding("spread/initiate")
236+ sleep(1)
237+ self.dash.controller.refresh_state()
238+ self.assertTrue(self.dash.controller.spread_active)
239+ self.keybinding("spread/cancel")
240+
241+ def test_dash_terminates_spread(self):
242+ """A window-spread must be terminated as soon as the dash is opened."""
243+ self.keybinding("spread/initiate")
244+ sleep(1)
245+ self.dash.controller.refresh_state()
246+ self.assertTrue(self.dash.controller.spread_active)
247+ self.dash.ensure_visible()
248+
249+ self.assertTrue(self.dash.get_is_visible())
250+ self.assertFalse(self.spread.get_is_active())
251+ self.keybinding("spread/cancel")
252+ sleep(1)
253+ self.dash.ensure_hidden()
254+
255+ def test_dash_regression_870284(self):
256+ """A test verifying that the is bug-fix for LP:870284 not regressed"""
257+ mouse = Mouse()
258+ self.assertFalse(self.dash.controller.spread_active)
259+ self.dash.ensure_hidden()
260+ sleep(1)
261+ self.start_app("Calculator")
262+ self.start_app("Character Map")
263+ self.dash.ensure_visible()
264+ sleep(1)
265+ # make sure the mouse is over Dash, a position of 100/100 ensures this
266+ mouse.move(100, 100, True)
267+ sleep(1)
268+ self.keybinding("spread/initiate")
269+ sleep(1)
270+ self.assertFalse(self.dash.get_is_visible())
271+ self.assertTrue(self.dash.controller.spread_active)
272
273=== modified file 'tests/autopilot/setup.py' (properties changed: -x to +x)