Merge lp:~aacid/unity-2d/unity-2d-shell_rtl into lp:~unity-2d-team/unity-2d/unity-2d-shell

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 971
Merge reported by: Albert Astals Cid
Merged at revision: not available
Proposed branch: lp:~aacid/unity-2d/unity-2d-shell_rtl
Merge into: lp:~unity-2d-team/unity-2d/unity-2d-shell
Diff against target: 1009 lines (+446/-205)
16 files modified
libunity-2d-private/src/inputshaperectangle.cpp (+16/-1)
libunity-2d-private/src/inputshaperectangle.h (+4/-0)
shell/Shell.qml (+27/-9)
shell/app/shelldeclarativeview.cpp (+18/-5)
shell/app/shelldeclarativeview.h (+1/-0)
shell/common/utils.js (+8/-0)
shell/dash/HomeShortcuts.qml (+7/-0)
shell/launcher/IntelliHideBehavior.qml (+18/-4)
shell/launcher/Launcher.qml (+2/-6)
shell/launcher/LauncherLoader.qml (+8/-0)
tests/getshape/getshape.cpp (+33/-4)
tests/launcher/autohide_show_tests.rb (+2/-2)
tests/launcher/autohide_show_tests_rtl.rb (+15/-15)
tests/shell/input_shaping.rb (+15/-159)
tests/shell/input_shaping_common.rb (+180/-0)
tests/shell/input_shaping_rtl.rb (+92/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d-shell_rtl
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Michał Sawicz Abstain
Lohith D Shivamurthy (community) Needs Information
Review via email: mp+90455@code.launchpad.net

Description of the change

[shell] Bring back shell to the level of RTL that current unity-2d has

Everything i can find that is missing RTL wise now seems to be fixed at https://code.launchpad.net/~haggai-eran/unity-2d/rtl-rebased/+merge/82151

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) wrote :

The dash corner input mask needs to be moved and flipped horizontally.

review: Needs Fixing
942. By Albert Astals Cid

These comments were MIA for some reason D

Revision history for this message
Gerry Boland (gerboland) wrote :

Lots of your tests fail for people on MM setups, because the TmpWindow you open at (XDo::XWindow.display_geometry[0] - 10,100) is shoved to the next monitor by Metacity, and so don't overlap the Launcher.

Could you do the maths like in test "Move window positioning to check launcher action" as that one works perfectly.

Also some of your comments don't match what's going on, e.g.:

+ # Open Terminal with position 40x100
+ xid = TmpWindow.open_window_at(XDo::XWindow.display_geometry[0] - 40, 100)

Aside from these things, everything looks good!

review: Needs Fixing
943. By Albert Astals Cid

Use a different way to overlap the windows with the launcher, should work on multimonitor according to Gerry

944. By Albert Astals Cid

Return the image with the whole desktop size

945. By Albert Astals Cid

adapt to new getshape output

946. By Albert Astals Cid

merge

947. By Albert Astals Cid

Add a workaround for home shortcuts in rtl, need it so tests pass since need to click on the [x] button

948. By Albert Astals Cid

Implement mirroring

It can be made more performant but works for now

949. By Albert Astals Cid

Add the shaping rtl tests

950. By Albert Astals Cid

Use sut and other small other tools from xdotool

951. By Albert Astals Cid

Output the file in stdout if outputfilename is -

952. By Albert Astals Cid

Make getshape work in target/host divide

953. By Albert Astals Cid

Fix anchoring in rtl

954. By Albert Astals Cid

Abstract shaping tests, they are the same wheter rtl or not, just one extra if, no need to copy the code twice

955. By Albert Astals Cid

Tauler -> Dash home

956. By Albert Astals Cid

Add header

957. By Albert Astals Cid

abstract stuff so we don't have almost the same code twice

958. By Albert Astals Cid

Make it work from run-tests.rb

959. By Albert Astals Cid

Remove one space too many

Revision history for this message
Albert Astals Cid (aacid) wrote :

Ok, i think it is ready to be reviewed again, all comments are fixed (i hope :D)

Revision history for this message
Lohith D Shivamurthy (dyams) wrote :

Hey, In his branch Haggai has swapped the left-right cursor keys while navigating in Dash. It is RTL requirement i believe.

review: Needs Information
Revision history for this message
Lohith D Shivamurthy (dyams) wrote :

Hey, it works great overall. :)

Revision history for this message
Albert Astals Cid (aacid) wrote :

@Lohith: This does not try to fix ALL of the RTL issues, just makes the shell work as unity-2d non-shell was working, as I say in the description most of Haggai's patch is still needed.

Revision history for this message
Michał Sawicz (saviq) wrote :

Wow that's a huge work on the tests, kudos!

One thing I noticed from the diff - instead of commenting out the printf(), maybe you could write it to stderr? Or just drop that line completely.

review: Needs Fixing
960. By Albert Astals Cid

Drop the printf as suggested in the MR

Revision history for this message
Albert Astals Cid (aacid) wrote :

I've dropped the printf since execute_shell_command also returns what is written to stderr.

961. By Albert Astals Cid

merge

962. By Albert Astals Cid

merge

Revision history for this message
Gerry Boland (gerboland) wrote :

Could you please my name from the copyright notices please?

The input_shaping tests needs small fixes:
- please rename input_shaping_tests.rb to input_shaping_common.rb
- please fix the require path to shell/input_shaping_common.rb. It's currently pointing to autohide stuff for the launcher.
- could you also please change
verify_true(10, "The actual shape does not match the expected shape") { identical }
to assert statements? If identical is false, it will wait 10 seconds before throwing a fail.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Removed the names of the copyright notices, except a few ones that will come once https://code.launchpad.net/~aacid/unity-2d/unity-2d_tests_for_rtl/+merge/90849 is merged (and this one will ultraconflict with it)

Also instead of changing to "assert" changed to "verify_true(0," that was an easier change, hope you're ok with that.

963. By Albert Astals Cid

Fixes comming for the MR discussion

Revision history for this message
Michał Sawicz (saviq) wrote :

* Launcher.qml
  * please move the monitoredArea Binding up into LauncherLoader.qml
* input_shaping.rb
  * you removed the Authors completely, was that on purpose?
  * we need to kill panel twice, too
  * @@panel args are not indented properly

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

* input_shaping.rb
  * wrong path to autohide_show_tests_common.rb

Revision history for this message
Michał Sawicz (saviq) wrote :

We need to wait for https://code.launchpad.net/~aacid/unity-2d/unity-2d_tests_for_rtl/+merge/90849 to be merged first and rebase this afterwards.

review: Abstain
964. By Albert Astals Cid

merge

965. By Albert Astals Cid

fix path

966. By Albert Astals Cid

Kill panel twice and indent second line of args for @@panel better

Revision history for this message
Albert Astals Cid (aacid) wrote :

Requested fixes implemented

967. By Albert Astals Cid

Move the monitoredArea binding up to LauncherLoader

968. By Albert Astals Cid

merge

Revision history for this message
Albert Astals Cid (aacid) wrote :

The merge for "tests/launcher/autohide_show_tests_common.rb" and the rtl version look crazy, something is getting confused here, have a look at the individual commits (i.e. r969) to see what is happening there.

969. By Albert Astals Cid

Merge

Revision history for this message
Albert Astals Cid (aacid) wrote :

Repushed a remerge to get a much nicer diff on tests/launcher/ files

970. By Albert Astals Cid

Make getshape still write to a file and copy it over

It is safer since execute_shell_command also returns stuff from stdout and Gerry was getting some warnings that "broke" his PNG file

971. By Albert Astals Cid

Merge

Revision history for this message
Gerry Boland (gerboland) wrote :

Ok, I'm happy to approve this for merging! Nice one

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/inputshaperectangle.cpp'
2--- libunity-2d-private/src/inputshaperectangle.cpp 2012-01-12 18:47:24 +0000
3+++ libunity-2d-private/src/inputshaperectangle.cpp 2012-02-06 16:36:19 +0000
4@@ -9,7 +9,8 @@
5
6 InputShapeRectangle::InputShapeRectangle(QObject *parent) :
7 QObject(parent),
8- m_enabled(true)
9+ m_enabled(true),
10+ m_mirrorHorizontally(false)
11 {
12 }
13
14@@ -29,6 +30,10 @@
15 }
16 }
17
18+ if (m_mirrorHorizontally) {
19+ newShape = QBitmap::fromImage(newShape.toImage().mirrored(true, false));
20+ }
21+
22 m_shape = newShape;
23 Q_EMIT shapeChanged();
24 }
25@@ -71,6 +76,16 @@
26 return QDeclarativeListProperty<InputShapeMask>(this, this, &InputShapeRectangle::appendMask);
27 }
28
29+bool InputShapeRectangle::mirrorHorizontally() const
30+{
31+ return m_mirrorHorizontally;
32+}
33+
34+void InputShapeRectangle::setMirrorHorizontally(bool mirror)
35+{
36+ m_mirrorHorizontally = mirror;
37+}
38+
39 void InputShapeRectangle::appendMask(QDeclarativeListProperty<InputShapeMask> *list, InputShapeMask *mask)
40 {
41 InputShapeRectangle* instance = qobject_cast<InputShapeRectangle*>(list->object);
42
43=== modified file 'libunity-2d-private/src/inputshaperectangle.h'
44--- libunity-2d-private/src/inputshaperectangle.h 2012-01-12 18:47:24 +0000
45+++ libunity-2d-private/src/inputshaperectangle.h 2012-02-06 16:36:19 +0000
46@@ -14,6 +14,7 @@
47 Q_OBJECT
48 Q_PROPERTY(QRect rectangle READ rectangle WRITE setRectangle NOTIFY rectangleChanged)
49 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
50+ Q_PROPERTY(bool mirrorHorizontally READ mirrorHorizontally WRITE setMirrorHorizontally)
51 Q_PROPERTY(QBitmap shape READ shape NOTIFY shapeChanged)
52 Q_PROPERTY(QDeclarativeListProperty<InputShapeMask> masks READ masks)
53 Q_CLASSINFO("DefaultProperty", "masks")
54@@ -27,6 +28,8 @@
55 void setEnabled(bool enabled);
56 QBitmap shape() const;
57 QDeclarativeListProperty<InputShapeMask> masks();
58+ bool mirrorHorizontally() const;
59+ void setMirrorHorizontally(bool mirror);
60
61 protected:
62 static void appendMask(QDeclarativeListProperty<InputShapeMask> *list, InputShapeMask *mask);
63@@ -42,6 +45,7 @@
64 private:
65 QRect m_rectangle;
66 bool m_enabled;
67+ bool m_mirrorHorizontally;
68 QBitmap m_shape;
69 QList<InputShapeMask*> m_masks;
70 };
71
72=== modified file 'shell/Shell.qml'
73--- shell/Shell.qml 2012-02-03 16:20:38 +0000
74+++ shell/Shell.qml 2012-02-06 16:36:19 +0000
75@@ -33,7 +33,13 @@
76 anchors.top: parent.top
77 anchors.bottom: parent.bottom
78 width: 65
79- x: visibilityController.shown ? 0 : -width
80+ x: {
81+ if (Utils.isLeftToRight()) {
82+ return visibilityController.shown ? 0 : -width
83+ } else {
84+ return visibilityController.shown ? screen.availableGeometry.width - width : screen.availableGeometry.width
85+ }
86+ }
87
88 KeyNavigation.right: dashLoader
89
90@@ -78,7 +84,7 @@
91 id: dashLoader
92 source: "dash/Dash.qml"
93 anchors.top: parent.top
94- x: launcherLoader.width
95+ x: Utils.isLeftToRight() ? launcherLoader.width : screen.availableGeometry.width - width - launcherLoader.width
96 onLoaded: item.focus = true
97 opacity: item.active ? 1.0 : 0.0
98 focus: item.active
99@@ -119,13 +125,24 @@
100 target: declarativeView
101
102 InputShapeRectangle {
103- // Prevent the launcher mask to ever go to negative values or be less than 1 pixel
104- // (to preserve the autohide/intellihide edge detection)
105- // FIXME: this results in a 1px wide white rectangle on the launcher edge, we should switch
106- // to cpp-based edge detection, and later XFixes barriers to get rid of that completely
107- rectangle: Qt.rect(0, launcherLoader.y,
108- -launcherLoader.x < launcherLoader.width ? launcherLoader.x + launcherLoader.width : 1,
109- launcherLoader.height)
110+ rectangle: {
111+ // FIXME: this results in a 1px wide white rectangle on the launcher edge, we should switch
112+ // to cpp-based edge detection, and later XFixes barriers to get rid of that completely
113+ var somewhatShown = Utils.isLeftToRight() ? -launcherLoader.x < launcherLoader.width : launcherLoader.x < screen.availableGeometry.width
114+ if (somewhatShown) {
115+ return Qt.rect(launcherLoader.x,
116+ launcherLoader.y,
117+ launcherLoader.width,
118+ launcherLoader.height)
119+ } else {
120+ // The outerEdgeMouseArea is one pixel bigger on each side so use it
121+ // when the launcher is hidden to have that extra pixel in the border
122+ return Qt.rect(launcherLoader.x + launcherLoader.outerEdgeMouseArea.x,
123+ launcherLoader.y,
124+ launcherLoader.outerEdgeMouseArea.width,
125+ launcherLoader.height)
126+ }
127+ }
128 enabled: launcherLoader.status == Loader.Ready
129 }
130
131@@ -136,6 +153,7 @@
132 Qt.rect(dashLoader.x, dashLoader.y, dashLoader.width - 7, dashLoader.height - 9)
133 }
134 enabled: dashLoader.status == Loader.Ready && dashLoader.item.active
135+ mirrorHorizontally: Utils.isRightToLeft()
136
137 InputShapeMask {
138 id: shape1
139
140=== modified file 'shell/app/shelldeclarativeview.cpp'
141--- shell/app/shelldeclarativeview.cpp 2012-02-06 12:21:57 +0000
142+++ shell/app/shelldeclarativeview.cpp 2012-02-06 16:36:19 +0000
143@@ -64,9 +64,7 @@
144 , m_superKeyHeld(false)
145 {
146 setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
147- /* Respect the struts manually because the window manager does not enforce struts
148- on dock windows */
149- move(QApplication::desktop()->availableGeometry(QX11Info::appScreen()).topLeft());
150+ updateShellPosition(QX11Info::appScreen());
151
152 setTransparentBackground(QX11Info::isCompositingManagerRunning());
153
154@@ -101,7 +99,11 @@
155 ShellDeclarativeView::updateShellPosition(int screen)
156 {
157 if (screen == QX11Info::appScreen()) {
158- QPoint posToMove = QApplication::desktop()->availableGeometry(screen).topLeft();
159+ const QRect availableGeometry = QApplication::desktop()->availableGeometry(screen);
160+ QPoint posToMove = availableGeometry.topLeft();
161+ if (qApp->isRightToLeft()) {
162+ posToMove.setX(availableGeometry.width() - width());
163+ }
164
165 StrutManager *strutManager = rootObject()->findChild<StrutManager*>();
166 if (strutManager && strutManager->enabled()) {
167@@ -112,7 +114,11 @@
168 break;
169
170 case Unity2dPanel::LeftEdge:
171- posToMove.rx() -= strutManager->realWidth();
172+ if (qApp->isLeftToRight()) {
173+ posToMove.rx() -= strutManager->realWidth();
174+ } else {
175+ posToMove.rx() += strutManager->realWidth();
176+ }
177 break;
178 }
179 }
180@@ -137,6 +143,13 @@
181 }
182
183 void
184+ShellDeclarativeView::resizeEvent(QResizeEvent *event)
185+{
186+ updateShellPosition(QX11Info::appScreen());
187+ Unity2DDeclarativeView::resizeEvent(event);
188+}
189+
190+void
191 ShellDeclarativeView::setWMFlags()
192 {
193 Display *display = QX11Info::display();
194
195=== modified file 'shell/app/shelldeclarativeview.h'
196--- shell/app/shelldeclarativeview.h 2012-02-03 16:24:03 +0000
197+++ shell/app/shelldeclarativeview.h 2012-02-06 16:36:19 +0000
198@@ -107,6 +107,7 @@
199 virtual void showEvent(QShowEvent *event);
200 virtual void mouseMoveEvent(QMouseEvent *event);
201 virtual void leaveEvent(QEvent *event);
202+ virtual void resizeEvent(QResizeEvent *event);
203
204 private Q_SLOTS:
205 void updateShellPosition(int screen);
206
207=== modified file 'shell/common/utils.js'
208--- shell/common/utils.js 2012-02-06 12:07:47 +0000
209+++ shell/common/utils.js 2012-02-06 16:36:19 +0000
210@@ -36,3 +36,11 @@
211 for (var key in hash) return false;
212 return true
213 }
214+
215+function isLeftToRight() {
216+ return Qt.application.layoutDirection == Qt.LeftToRight
217+}
218+
219+function isRightToLeft() {
220+ return Qt.application.layoutDirection == Qt.RightToLeft
221+}
222
223=== modified file 'shell/dash/HomeShortcuts.qml'
224--- shell/dash/HomeShortcuts.qml 2011-11-25 15:44:18 +0000
225+++ shell/dash/HomeShortcuts.qml 2012-02-06 16:36:19 +0000
226@@ -29,6 +29,13 @@
227 Grid {
228 id: buttons
229
230+ // TODO The alignment here is broken in RTL but Gerry says it's going away so we
231+ // do not care about it. Don't ask me why this transparent rectangle fixes it
232+ Rectangle {
233+ anchors.fill: parent
234+ opacity: 0
235+ }
236+
237 anchors.fill: parent
238 spacing: 51
239 columns: 4
240
241=== modified file 'shell/launcher/IntelliHideBehavior.qml'
242--- shell/launcher/IntelliHideBehavior.qml 2012-01-24 16:58:28 +0000
243+++ shell/launcher/IntelliHideBehavior.qml 2012-02-06 16:36:19 +0000
244@@ -1,6 +1,7 @@
245 import QtQuick 1.0
246 import Unity2d 1.0
247 import "../common"
248+import "../common/utils.js" as Utils
249
250 BaseBehavior {
251 id: intellihide
252@@ -50,9 +51,22 @@
253
254 WindowsIntersectMonitor {
255 id: windows
256- monitoredArea: intellihide.target ? Qt.rect(0, intellihide.target.y,
257- intellihide.target.width,
258- intellihide.target.height)
259- : Qt.rect(0, 0, 0, 0)
260+ monitoredArea: {
261+ if (intellihide.target) {
262+ if (Utils.isLeftToRight()) {
263+ return Qt.rect(0,
264+ intellihide.target.y,
265+ intellihide.target.width,
266+ intellihide.target.height)
267+ } else {
268+ return Qt.rect(screen.availableGeometry.width - intellihide.target.width,
269+ intellihide.target.y,
270+ intellihide.target.width,
271+ intellihide.target.height)
272+ }
273+ } else {
274+ return Qt.rect(0, 0, 0, 0)
275+ }
276+ }
277 }
278 }
279
280=== modified file 'shell/launcher/Launcher.qml'
281--- shell/launcher/Launcher.qml 2012-01-19 14:22:10 +0000
282+++ shell/launcher/Launcher.qml 2012-02-06 16:36:19 +0000
283@@ -29,11 +29,6 @@
284 property bool shown
285 property bool showMenus: true
286
287- Binding {
288- target: declarativeView
289- property: "monitoredArea"
290- value: Qt.rect(launcher.x, launcher.y, launcher.width, launcher.height)
291- }
292 property bool containsMouse: declarativeView.monitoredAreaContainsMouse
293
294 function hideMenu() {
295@@ -81,7 +76,8 @@
296
297 width: 1
298 height: parent.height
299- anchors.right: parent.right
300+ anchors.right: Utils.isLeftToRight() ? parent.right : undefined
301+ anchors.left: Utils.isLeftToRight() ? undefined : parent.left
302 fillMode: Image.TileVertically
303 source: "artwork/background.png"
304 }
305
306=== modified file 'shell/launcher/LauncherLoader.qml'
307--- shell/launcher/LauncherLoader.qml 2012-01-24 14:13:36 +0000
308+++ shell/launcher/LauncherLoader.qml 2012-02-06 16:36:19 +0000
309@@ -8,6 +8,7 @@
310 source: "Launcher.qml"
311 property variant visibilityController: visibilityController
312 onLoaded: item.focus = true
313+ property alias outerEdgeMouseArea: outerEdge
314
315 VisibilityController {
316 id: visibilityController
317@@ -32,6 +33,13 @@
318 }
319
320 Binding {
321+ target: declarativeView
322+ property: "monitoredArea"
323+ value: Qt.rect(launcherLoader.x, launcherLoader.item.y, launcherLoader.item.width, launcherLoader.item.height)
324+ when: launcherBehavior.status == Loader.Ready
325+ }
326+
327+ Binding {
328 target: launcherBehavior.item
329 property: "forcedVisible"
330 value: visibilityController.forceVisible
331
332=== modified file 'tests/getshape/getshape.cpp'
333--- tests/getshape/getshape.cpp 2012-01-19 16:02:51 +0000
334+++ tests/getshape/getshape.cpp 2012-02-06 16:36:19 +0000
335@@ -25,6 +25,9 @@
336 #include <QStringList>
337
338 #include <QBitmap>
339+#include <QDesktopWidget>
340+#include <QFile>
341+#include <QImageWriter>
342 #include <QRegion>
343 #include <QPainter>
344 #include <QPainterPath>
345@@ -80,19 +83,45 @@
346
347 for (int i = 0; i < count; i++) {
348 region = region.united(QRect(rects[i].x, rects[i].y, rects[i].width, rects[i].height));
349-
350- printf("%dx%d@%d,%d", rects[i].width, rects[i].height, rects[i].x, rects[i].y);
351 }
352
353 if (!outputFile.isEmpty()) {
354- QBitmap bitmap(region.boundingRect().width(), region.boundingRect().height());
355+ Atom actual_type;
356+ int actual_format;
357+ unsigned long nitems, bytes_after;
358+ unsigned char *data;
359+ const Atom atom = XInternAtom(QX11Info::display(), "_NET_WM_DESKTOP", False);
360+ const int status = XGetWindowProperty(QX11Info::display(), windowId, atom, 0, (~0L),
361+ False, AnyPropertyType, &actual_type,
362+ &actual_format, &nitems, &bytes_after,
363+ &data);
364+ int desktop = -1;
365+ if (status == Success) {
366+ if (nitems == 1) {
367+ desktop = *((int*)data);
368+ }
369+ free(data);
370+ }
371+
372+ const QDesktopWidget dw;
373+ QBitmap bitmap(dw.availableGeometry(desktop).size());
374 bitmap.fill(Qt::color0);
375 QPainter painter(&bitmap);
376 QPainterPath path;
377 path.addRegion(region);
378 painter.fillPath(path, Qt::color1);
379 painter.end();
380- if (!bitmap.save(outputFile)) {
381+
382+ if (outputFile == "-") {
383+ QFile f;
384+ if (!f.open(stdout, QIODevice::WriteOnly)) {
385+ return 4;
386+ }
387+ QImageWriter writer(&f, "PNG");
388+ if (!writer.write(bitmap.toImage())) {
389+ return 5;
390+ }
391+ } else if (!bitmap.save(outputFile)) {
392 qWarning() << "Failed to save file with path:" << outputFile;
393 return 3;
394 }
395
396=== modified file 'tests/launcher/autohide_show_tests.rb'
397--- tests/launcher/autohide_show_tests.rb 2012-02-06 12:07:47 +0000
398+++ tests/launcher/autohide_show_tests.rb 2012-02-06 16:36:19 +0000
399@@ -146,11 +146,11 @@
400 test_alt_f1_focus_unfocus_launcher()
401 end
402
403- xtest "Press Alt+F1, esc to focus/unfocus Launcher when dash is open" do
404+ test "Press Alt+F1, esc to focus/unfocus Launcher when dash is open" do
405 test_alt_f1_esc_focus_unfocus_launcher_when_dash_open()
406 end
407
408- xtest "Press Alt+F1 to focus Launcher when dash is open, Alt+F1 to unfocus" do
409+ test "Press Alt+F1 to focus Launcher when dash is open, Alt+F1 to unfocus" do
410 test_alt_f1_toggle_focus_launcher_when_dash_open()
411 end
412
413
414=== modified file 'tests/launcher/autohide_show_tests_rtl.rb'
415--- tests/launcher/autohide_show_tests_rtl.rb 2012-02-06 12:07:47 +0000
416+++ tests/launcher/autohide_show_tests_rtl.rb 2012-02-06 16:36:19 +0000
417@@ -111,63 +111,63 @@
418 #####################################################################################
419 # Test cases
420
421- xtest "Position with Empty Desktop" do
422+ test "Position with Empty Desktop" do
423 test_position_with_empty_desktop()
424 end
425
426- xtest "Position with Window not in the way" do
427+ test "Position with Window not in the way" do
428 test_position_width_window_not_in_the_way()
429 end
430
431- xtest "Position with Window in the way" do
432+ test "Position with Window in the way" do
433 test_position_with_window_in_the_way()
434 end
435
436- xtest "Move window positioning to check launcher action" do
437+ test "Move window positioning to check launcher action" do
438 test_move_window_positioning_to_check_launcher_action()
439 end
440
441- xtest "Reveal hidden Launcher with mouse" do
442+ test "Reveal hidden Launcher with mouse" do
443 test_reveal_hidden_launcher_with_mouse()
444 end
445
446- xtest "Press Super key to toggle launcher" do
447+ test "Press Super key to toggle launcher" do
448 test_press_super_to_toggle_launcher()
449 end
450
451- xtest "Hold Super key down to reveal launcher and shortcut keys" do
452+ test "Hold Super key down to reveal launcher and shortcut keys" do
453 test_hold_super_launcher_shortcuts()
454 end
455
456- xtest "Press Alt+F1 to focus Launcher" do
457+ test "Press Alt+F1 to focus Launcher" do
458 test_alt_f1_focus_launcher()
459 end
460
461- xtest "Press Alt+F1 to focus/unfocus Launcher" do
462+ test "Press Alt+F1 to focus/unfocus Launcher" do
463 test_alt_f1_focus_unfocus_launcher()
464 end
465
466- xtest "Press Alt+F1, esc to focus/unfocus Launcher when dash is open" do
467+ test "Press Alt+F1, esc to focus/unfocus Launcher when dash is open" do
468 test_alt_f1_esc_focus_unfocus_launcher_when_dash_open()
469 end
470
471- xtest "Press Alt+F1 to focus Launcher when dash is open, Alt+F1 to unfocus" do
472+ test "Press Alt+F1 to focus Launcher when dash is open, Alt+F1 to unfocus" do
473 test_alt_f1_toggle_focus_launcher_when_dash_open()
474 end
475
476- xtest "Launcher visible on show-desktop" do
477+ test "Launcher visible on show-desktop" do
478 test_launcher_visible_show_desktop()
479 end
480
481- xtest "Launcher hide delay on tile removal" do
482+ test "Launcher hide delay on tile removal" do
483 test_launcher_hide_delay_on_tile_removal()
484 end
485
486- xtest "Launcher visible after toggling dash" do
487+ test "Launcher visible after toggling dash" do
488 test_launcher_visible_after_toggling_dash()
489 end
490
491- xtest "Launcher does not hide on Esc after Alt+F1 with overlapping window" do
492+ test "Launcher does not hide on Esc after Alt+F1 with overlapping window" do
493 test_launcher_does_not_hide_on_esc_after_alt_f1_with_overlapping_window()
494 end
495
496
497=== modified file 'tests/shell/input_shaping.rb'
498--- tests/shell/input_shaping.rb 2012-02-06 12:07:47 +0000
499+++ tests/shell/input_shaping.rb 2012-02-06 16:36:19 +0000
500@@ -5,10 +5,6 @@
501 *
502 * Copyright 2011 Canonical Ltd.
503 *
504- * Authors:
505- * - Ugo Riboni <ugo.riboni@canonical.com>
506- * - Gerry Boland <gerry.boland@canonical.com>
507- *
508 * This program is free software; you can redistribute it and/or modify
509 * it under the terms of the GNU General Public License as published by
510 * the Free Software Foundation; version 3.
511@@ -30,72 +26,24 @@
512 require 'timeout'
513 require 'tmpdir'
514 require 'tempfile'
515+require $library_path + '/../../shell/input_shaping_common.rb'
516+
517 include TDriverVerify
518
519-def desktop_geometry
520- out = %x{xdotool getdisplaygeometry}
521- return out.split.collect { |coord| coord.to_i }
522-end
523-
524-# We just need a temp file name but ruby insist on creating it, so we just delete it first.
525-def tempfilename(base, extension = ".tmp")
526- maskfile = Tempfile.new([base, extension])
527- maskpath = maskfile.path
528- maskfile.close
529- maskfile.unlink
530- return maskpath
531-end
532-
533-def get_shell_shape
534- pwd = File.expand_path(File.dirname(__FILE__))
535-
536- # Try to find the shell window
537- shell_ids = XDo::XWindow::search('unity-2d-shell')
538- assert(!shell_ids.empty?, "Failed to retrieve the shell window id")
539- shell_id = shell_ids[0]
540-
541- # Get the shape of the shell window using our custom tool
542- maskpath = tempfilename('shape', '.png')
543- out = %x{#{BINARY_DIR}/tests/getshape/getshape #{shell_id} #{maskpath}}
544- assert($?.exitstatus == 0, "Failed to call getshape to get the shape of the window")
545- return maskpath
546-end
547-
548-# Compare two images using ImageMagick. Perform a pixel-by-pixel comparison and return true
549-# only if all the pixels are identical.
550-def compare_images(image1, image2)
551- # Before checking the pixels make sure the two images are the same size, otherwise some times
552- # IM will hang for a long time (probably trying to do some super clever subimage matching).
553- size1 = %x{identify -format '%wx%h' #{image1}}
554- size2 = %x{identify -format '%wx%h' #{image2}}
555- return false if size1 != size2
556-
557- # Discard the difference image and redirect stderr to stdout as IM will output the number of
558- # different pixels there for some reason.
559- difference = %x{compare #{image1} #{image2} -metric AE /dev/null 2>&1}.chop.to_i
560-
561- # If the images are too different or have different sizes IM will exit with return code 1.
562- # Unfortunately it's the same code we have when there is any error (like a wrong filename),
563- # so the best we can do is just return false
564- return false if $?.exitstatus != 0
565-
566- return difference == 0
567-end
568-
569 ############################# Test Suite #############################
570 context "Shell input shape tests" do
571 pwd = File.expand_path(File.dirname(__FILE__)) + '/'
572
573 # Run once at the beginning of this test suite
574 startup do
575- system 'killall unity-2d-shell > /dev/null 2>&1'
576- system 'killall unity-2d-shell > /dev/null 2>&1'
577- system 'killall unity-2d-panel > /dev/null 2>&1'
578+ $SUT.execute_shell_command 'killall unity-2d-shell'
579+ $SUT.execute_shell_command 'killall unity-2d-shell'
580+ $SUT.execute_shell_command 'killall unity-2d-panel'
581+ $SUT.execute_shell_command 'killall unity-2d-panel'
582
583 # Need panel running as position of shell depends on it
584- @@sut = TDriver.sut(:Id => "sut_qt")
585- @@panel = @@sut.run(:name => UNITY_2D_PANEL,
586- :arguments => "-testability" )
587+ @@panel = $SUT.run(:name => UNITY_2D_PANEL,
588+ :arguments => "-testability" )
589
590 # Minimize all windows
591 XDo::XWindow.toggle_minimize_all
592@@ -108,11 +56,10 @@
593 # Run before each test case begins
594 setup do
595 #Ensure mouse out of the way
596- XDo::Mouse.move(200,200,10,true)
597+ XDo::Mouse.move(200,200,10,true)
598
599 # Execute the application
600- @sut = TDriver.sut(:Id => "sut_qt")
601- @app = @sut.run(:name => UNITY_2D_SHELL,
602+ @app = $SUT.run(:name => UNITY_2D_SHELL,
603 :arguments => "-testability",
604 :sleeptime => 2)
605 # Make certain application is ready for testing
606@@ -121,116 +68,25 @@
607
608 # Run after each test case completes
609 teardown do
610- system "pkill -nf unity-2d-shell"
611+ $SUT.execute_shell_command 'pkill -nf unity-2d-shell'
612 end
613
614 #####################################################################################
615 # Test cases
616
617 test "Shape of launcher alone" do
618- XDo::Keyboard.alt_F1
619- maskpath = get_shell_shape()
620-
621- # Since the shape of the launcher is dependent on screen geometry, calculate what it should be
622- # then use imagemagick to create an image that contains only a black rectangle where the
623- # launcher should be.
624- screen_width, screen_height = desktop_geometry()
625- screen_height -= PANEL_HEIGHT
626- comparepath = tempfilename('shape', '.png')
627- %x{convert xc:black -background black -extent #{LAUNCHER_WIDTH}x#{screen_height} #{comparepath}}
628-
629- identical = compare_images(maskpath, comparepath)
630-
631- File.unlink(maskpath)
632- File.unlink(comparepath)
633-
634- verify_true(10, "The actual shape does not match the expected shape") { identical }
635+ test_shape_of_launcher_alone()
636 end
637
638 test "Shape of launcher and desktop mode dash" do
639- XDo::Keyboard.simulate('{SUPER}')
640- sleep 1
641- maskpath = get_shell_shape()
642-
643- # Since the shape of the launcher is dependent on screen geometry, calculate what it should be,
644- # then draw a black rectangle and compose it at the left side of the dash verification image.
645-
646- screen_width, screen_height = desktop_geometry()
647- screen_height -= PANEL_HEIGHT
648-
649- verifypath = "#{pwd}/verification/dash_desktop.png"
650- out = %x{identify -format "%wx%h" #{verifypath}}
651- verify_width = out.split("x")[0].to_i
652- verify_width += LAUNCHER_WIDTH
653-
654- comparepath = tempfilename('shape', '.png')
655-
656- %x{convert #{verifypath} \
657- -gravity northeast -extent #{verify_width}x#{screen_height}! \
658- \\( xc:black -background black -extent #{LAUNCHER_WIDTH}x#{screen_height} \\) \
659- -gravity northwest -compose over -composite #{comparepath}}
660-
661- identical = compare_images(maskpath, comparepath)
662-
663- File.unlink(maskpath)
664- File.unlink(comparepath)
665-
666- verify_true(10, "The actual shape does not match the expected shape") { identical }
667+ test_shape_of_launcher_and_desktop_mode_dash()
668 end
669
670 test "Shape of launcher and fullscreen mode dash" do
671- XDo::Keyboard.simulate('{SUPER}')
672- sleep 1
673- @app.ShellDeclarativeView()['dashMode'] = 'FullScreenMode'
674- sleep 1
675-
676- maskpath = get_shell_shape()
677-
678- # Compare with just one big rectangle filling the entire screen minus the panel area
679- screen_width, screen_height = desktop_geometry()
680- screen_height -= PANEL_HEIGHT
681- comparepath = tempfilename('shape', '.png')
682- %x{convert xc:black -background black -extent #{screen_width}x#{screen_height} #{comparepath}}
683-
684- identical = compare_images(maskpath, comparepath)
685-
686- File.unlink(maskpath)
687- File.unlink(comparepath)
688-
689- verify_true(10, "The actual shape does not match the expected shape") { identical }
690+ test_shape_of_launcher_and_fullscreen_mode_dash()
691 end
692
693 test "Shape of launcher and collapsed desktop mode dash" do
694- XDo::Keyboard.simulate('{SUPER}')
695- sleep 1
696- @app.AbstractButton(:name => 'closeShortcutsButton').tap
697- sleep 1
698-
699- maskpath = get_shell_shape()
700-
701- # Since the shape of the launcher is dependent on screen geometry, calculate what it should be,
702- # then draw a black rectangle and compose it at the left side of the dash verification image.
703-
704- screen_width, screen_height = desktop_geometry()
705- screen_height -= PANEL_HEIGHT
706-
707- verifypath = "#{pwd}/verification/dash_collapsed.png"
708- out = %x{identify -format "%wx%h" #{verifypath}}
709- verify_width = out.split("x")[0].to_i
710- verify_width += LAUNCHER_WIDTH
711-
712- comparepath = tempfilename('shape', '.png')
713-
714- %x{convert #{verifypath} \
715- -gravity northeast -extent #{verify_width}x#{screen_height}! \
716- \\( xc:black -background black -extent #{LAUNCHER_WIDTH}x#{screen_height} \\) \
717- -gravity northwest -compose over -composite #{comparepath}}
718-
719- identical = compare_images(maskpath, comparepath)
720-
721- File.unlink(maskpath)
722- File.unlink(comparepath)
723-
724- verify_true(10, "The actual shape does not match the expected shape") { identical }
725+ test_shape_of_launcher_and_collapsed_desktop_mode_dash()
726 end
727 end
728
729=== added file 'tests/shell/input_shaping_common.rb'
730--- tests/shell/input_shaping_common.rb 1970-01-01 00:00:00 +0000
731+++ tests/shell/input_shaping_common.rb 2012-02-06 16:36:19 +0000
732@@ -0,0 +1,180 @@
733+=begin
734+/*
735+ * This file is part of unity-2d
736+ *
737+ * Copyright 2011 Canonical Ltd.
738+ *
739+ * This program is free software; you can redistribute it and/or modify
740+ * it under the terms of the GNU General Public License as published by
741+ * the Free Software Foundation; version 3.
742+ *
743+ * This program is distributed in the hope that it will be useful,
744+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
745+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
746+ * GNU General Public License for more details.
747+ *
748+ * You should have received a copy of the GNU General Public License
749+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
750+ */
751+=end
752+
753+# We just need a temp file name but ruby insist on creating it, so we just delete it first.
754+def tempfilename(base, extension = ".tmp")
755+ maskfile = Tempfile.new([base, extension])
756+ maskpath = maskfile.path
757+ maskfile.close
758+ maskfile.unlink
759+ return maskpath
760+end
761+
762+def get_shell_shape
763+ # Try to find the shell window
764+ shell_ids = XDo::XWindow::search('unity-2d-shell')
765+ assert(!shell_ids.empty?, "Failed to retrieve the shell window id")
766+ shell_id = shell_ids[0]
767+
768+ # Get the shape of the shell window using our custom tool
769+ maskpath = tempfilename('shape', '.png')
770+ get_shape_command = BINARY_DIR + "/tests/getshape/getshape #{shell_id} #{maskpath}"
771+ $SUT.execute_shell_command get_shape_command
772+ $SUT.copy_from_sut(:from => '/tmp/', :file => maskpath, :to => '/tmp/')
773+ return maskpath
774+end
775+
776+# Compare two images using ImageMagick. Perform a pixel-by-pixel comparison and return true
777+# only if all the pixels are identical.
778+def compare_images(image1, image2)
779+ # Before checking the pixels make sure the two images are the same size, otherwise some times
780+ # IM will hang for a long time (probably trying to do some super clever subimage matching).
781+ size1 = %x{identify -format '%wx%h' #{image1}}
782+ size2 = %x{identify -format '%wx%h' #{image2}}
783+ return false if size1 != size2
784+
785+ # Discard the difference image and redirect stderr to stdout as IM will output the number of
786+ # different pixels there for some reason.
787+ difference = %x{compare #{image1} #{image2} -metric AE /dev/null 2>&1}.chop.to_i
788+
789+ # If the images are too different or have different sizes IM will exit with return code 1.
790+ # Unfortunately it's the same code we have when there is any error (like a wrong filename),
791+ # so the best we can do is just return false
792+ return false if $?.exitstatus != 0
793+
794+ return difference == 0
795+end
796+
797+def test_shape_of_launcher_alone(isRTL = false)
798+ XDo::Keyboard.alt_F1
799+ maskpath = get_shell_shape()
800+
801+ # Since the shape of the launcher is dependent on screen geometry, calculate what it should be
802+ # then use imagemagick to create an image that contains only a black rectangle where the
803+ # launcher should be.
804+ screen_width, screen_height = XDo::XWindow.display_geometry()
805+ screen_height -= PANEL_HEIGHT
806+ comparepath = tempfilename('shape', '.png')
807+ flopstring = ""
808+ if isRTL
809+ flopstring = "-flop"
810+ end
811+ %x{convert -size #{screen_width}x#{screen_height} xc:white -background white -draw 'rectangle 0,0 #{LAUNCHER_WIDTH-1},#{screen_height}' #{flopstring} #{comparepath}}
812+
813+ identical = compare_images(maskpath, comparepath)
814+
815+ File.unlink(maskpath)
816+ File.unlink(comparepath)
817+
818+ verify_true(0, "The actual shape does not match the expected shape") { identical }
819+end
820+
821+def test_shape_of_launcher_and_desktop_mode_dash(isRTL = false)
822+ XDo::Keyboard.simulate('{SUPER}')
823+ sleep 1
824+ maskpath = get_shell_shape()
825+
826+ # Since the shape of the launcher is dependent on screen geometry, calculate what it should be,
827+ # then draw a black rectangle and compose it at the left side of the dash verification image.
828+
829+ screen_width, screen_height = XDo::XWindow.display_geometry()
830+ screen_height -= PANEL_HEIGHT
831+
832+ pwd = File.expand_path(File.dirname(__FILE__))
833+ verifypath = pwd + "/verification/dash_desktop.png"
834+
835+ comparepath = tempfilename('shape', '.png')
836+
837+ flopstring = ""
838+ if isRTL
839+ flopstring = "-flop"
840+ end
841+ %x{convert xc:white -extent #{screen_width}x#{screen_height} #{verifypath} -geometry +#{LAUNCHER_WIDTH}+0 -composite \
842+ \\( xc:black -background black -extent #{LAUNCHER_WIDTH}x#{screen_height} \\) \
843+ -gravity northwest -compose over -composite #{flopstring} #{comparepath}}
844+
845+ identical = compare_images(maskpath, comparepath)
846+
847+ File.unlink(maskpath)
848+ File.unlink(comparepath)
849+
850+ verify_true(0, "The actual shape does not match the expected shape") { identical }
851+end
852+
853+def test_shape_of_launcher_and_fullscreen_mode_dash(isRTL = false)
854+ XDo::Keyboard.simulate('{SUPER}')
855+ sleep 1
856+ @app.ShellDeclarativeView()['dashMode'] = 'FullScreenMode'
857+ sleep 1
858+
859+ maskpath = get_shell_shape()
860+
861+ # Compare with just one big rectangle filling the entire screen minus the panel area
862+ screen_width, screen_height = XDo::XWindow.display_geometry()
863+ screen_height -= PANEL_HEIGHT
864+ comparepath = tempfilename('shape', '.png')
865+ flopstring = ""
866+ if isRTL
867+ flopstring = "-flop"
868+ end
869+ %x{convert xc:black -background black -extent #{screen_width}x#{screen_height} #{flopstring} #{comparepath}}
870+
871+ identical = compare_images(maskpath, comparepath)
872+
873+ File.unlink(maskpath)
874+ File.unlink(comparepath)
875+
876+ verify_true(0, "The actual shape does not match the expected shape") { identical }
877+end
878+
879+def test_shape_of_launcher_and_collapsed_desktop_mode_dash(isRTL = false)
880+ XDo::Keyboard.simulate('{SUPER}')
881+ sleep 1
882+ @app.AbstractButton(:name => 'closeShortcutsButton').tap
883+ sleep 1
884+
885+ maskpath = get_shell_shape()
886+
887+ # Since the shape of the launcher is dependent on screen geometry, calculate what it should be,
888+ # then draw a black rectangle and compose it at the left side of the dash verification image.
889+
890+ screen_width, screen_height = XDo::XWindow.display_geometry()
891+ screen_height -= PANEL_HEIGHT
892+
893+ pwd = File.expand_path(File.dirname(__FILE__))
894+ verifypath = pwd + "/verification/dash_collapsed.png"
895+
896+ comparepath = tempfilename('shape', '.png')
897+
898+ flopstring = ""
899+ if isRTL
900+ flopstring = "-flop"
901+ end
902+ %x{convert xc:white -extent #{screen_width}x#{screen_height} #{verifypath} -geometry +#{LAUNCHER_WIDTH}+0 -composite \
903+ \\( xc:black -background black -extent #{LAUNCHER_WIDTH}x#{screen_height} \\) \
904+ -gravity northwest -compose over -composite #{flopstring} #{comparepath}}
905+
906+ identical = compare_images(maskpath, comparepath)
907+
908+ File.unlink(maskpath)
909+ File.unlink(comparepath)
910+
911+ verify_true(0, "The actual shape does not match the expected shape") { identical }
912+end
913
914=== added file 'tests/shell/input_shaping_rtl.rb'
915--- tests/shell/input_shaping_rtl.rb 1970-01-01 00:00:00 +0000
916+++ tests/shell/input_shaping_rtl.rb 2012-02-06 16:36:19 +0000
917@@ -0,0 +1,92 @@
918+#!/usr/bin/env ruby1.8
919+=begin
920+/*
921+ * This file is part of unity-2d
922+ *
923+ * Copyright 2011 Canonical Ltd.
924+ *
925+ * This program is free software; you can redistribute it and/or modify
926+ * it under the terms of the GNU General Public License as published by
927+ * the Free Software Foundation; version 3.
928+ *
929+ * This program is distributed in the hope that it will be useful,
930+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
931+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
932+ * GNU General Public License for more details.
933+ *
934+ * You should have received a copy of the GNU General Public License
935+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
936+ */
937+=end
938+
939+require '../run-tests.rb' unless $INIT_COMPLETED
940+require 'xdo/xwindow'
941+require 'xdo/keyboard'
942+require 'xdo/mouse'
943+require 'timeout'
944+require 'tmpdir'
945+require 'tempfile'
946+require $library_path + '/../../shell/input_shaping_common.rb'
947+
948+include TDriverVerify
949+
950+############################# Test Suite #############################
951+context "Shell input shape tests" do
952+ pwd = File.expand_path(File.dirname(__FILE__)) + '/'
953+
954+ # Run once at the beginning of this test suite
955+ startup do
956+ $SUT.execute_shell_command 'killall unity-2d-shell'
957+ $SUT.execute_shell_command 'killall unity-2d-shell'
958+ $SUT.execute_shell_command 'killall unity-2d-panel'
959+ $SUT.execute_shell_command 'killall unity-2d-panel'
960+
961+ # Need panel running as position of shell depends on it
962+ @@panel = $SUT.run(:name => UNITY_2D_PANEL,
963+ :arguments => "-testability" )
964+
965+ # Minimize all windows
966+ XDo::XWindow.toggle_minimize_all
967+ end
968+
969+ # Run once at the end of this test suite
970+ shutdown do
971+ end
972+
973+ # Run before each test case begins
974+ setup do
975+ #Ensure mouse out of the way
976+ XDo::Mouse.move(200,200,10,true)
977+
978+ # Execute the application
979+ @app = $SUT.run(:name => UNITY_2D_SHELL,
980+ :arguments => "-testability,-reverse",
981+ :sleeptime => 2)
982+ # Make certain application is ready for testing
983+ verify(10){ @app.Launcher() }
984+ end
985+
986+ # Run after each test case completes
987+ teardown do
988+ $SUT.execute_shell_command 'pkill -nf unity-2d-shell'
989+ end
990+
991+ #####################################################################################
992+ # Test cases
993+
994+ test "Shape of launcher alone" do
995+ test_shape_of_launcher_alone(true)
996+ end
997+
998+ test "Shape of launcher and desktop mode dash" do
999+ test_shape_of_launcher_and_desktop_mode_dash(true)
1000+ end
1001+
1002+ test "Shape of launcher and fullscreen mode dash" do
1003+ test_shape_of_launcher_and_fullscreen_mode_dash(true)
1004+ end
1005+
1006+ test "Shape of launcher and collapsed desktop mode dash" do
1007+ test_shape_of_launcher_and_collapsed_desktop_mode_dash(true)
1008+ end
1009+end

Subscribers

People subscribed via source and target branches