Merge lp:~aacid/unity-2d/fixspreadtogglingfromlauncher into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 1023
Merged at revision: 1021
Proposed branch: lp:~aacid/unity-2d/fixspreadtogglingfromlauncher
Merge into: lp:unity-2d
Diff against target: 71 lines (+44/-1)
2 files modified
spread/app/spreadmanager.cpp (+1/-1)
tests/spread/spread-tests.rb (+43/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/fixspreadtogglingfromlauncher
Reviewer Review Type Date Requested Status
Gerry Boland (community) Needs Fixing
Review via email: mp+99901@code.launchpad.net

Commit message

[spread] Make toggling the spread from the launcher work

Make the connection for onViewVisibleChanged queued, this way when we get there the window has already been shown, otherwise the forceActivateWindow fails

Description of the change

Make toggling the spread from the launcher work

Make the connection for onViewVisibleChanged queued, this way when we get there the window has already been shown, otherwise the forceActivateWindow fails

No idea why i need the loop to wait for the spread in the test, but otherwise weird things happen

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

Being pedantic, you could use "pgrep" instead of
bash -c "ps -A | grep unity-2d-spread"

Please also add the bug URL to the References section. Helps explain why we have such a test, in case manual tests are done too.

Also any reason why you don't use "spreadItem.tap" instead of "spreadItem.move_mouse; XDo::Mouse.click"

review: Needs Fixing
1022. By Albert Astals Cid

Use pgrep

1023. By Albert Astals Cid

Add bug url

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

Can't use tap because tap simulates a click (i.e. MousePressEvent), we need a real click because we are grabbing the mouse

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'spread/app/spreadmanager.cpp'
2--- spread/app/spreadmanager.cpp 2012-03-13 15:49:19 +0000
3+++ spread/app/spreadmanager.cpp 2012-03-29 11:30:25 +0000
4@@ -76,7 +76,7 @@
5 view->engine()->setBaseUrl(QUrl::fromLocalFile(unity2dDirectory() + "/spread/"));
6
7 /* Add a SpreadControl instance to the QML context */
8- connect(view, SIGNAL(visibleChanged(bool)), this, SLOT(onViewVisibleChanged(bool)));
9+ connect(view, SIGNAL(visibleChanged(bool)), this, SLOT(onViewVisibleChanged(bool)), Qt::QueuedConnection);
10 view->rootContext()->setContextProperty("control", &m_control);
11 view->rootContext()->setContextProperty("spreadManager", this);
12
13
14=== modified file 'tests/spread/spread-tests.rb'
15--- tests/spread/spread-tests.rb 2012-02-13 14:42:06 +0000
16+++ tests/spread/spread-tests.rb 2012-03-29 11:30:25 +0000
17@@ -65,6 +65,13 @@
18 #Need to kill Launcher as it does not shutdown when politely asked
19 $SUT.execute_shell_command 'pkill -nf unity-2d-shell'
20 $SUT.execute_shell_command 'pkill -nf unity-2d-spread'
21+ # Need to wait for the spread to really die, otherwise bad things happen
22+ # on the second test
23+ spread = $SUT.execute_shell_command 'pgrep unity-2d-spread'
24+ while spread != ""
25+ sleep 0.1
26+ spread = $SUT.execute_shell_command 'pgrep unity-2d-spread'
27+ end
28 end
29
30 #####################################################################################
31@@ -106,4 +113,40 @@
32 }
33 xid.close!
34 end
35+
36+ # Test case objectives:
37+ # * Check that clicking in the spread item of the launcher toggles the spread
38+ # Pre-conditions
39+ # * Desktop with no running applications
40+ # Test steps
41+ # * Verify spread is not showing
42+ # * Click in the spread item of the launcher
43+ # * Verify spread is showing
44+ # * Click in the spread item of the launcher
45+ # * Verify spread is not showing
46+ # Post-conditions
47+ # * None
48+ # References
49+ # * https://bugs.launchpad.net/unity-2d/+bug/968146
50+ test "Spread launcher item toggles the spread" do
51+ hide_mode = $SUT.execute_shell_command('gsettings get com.canonical.Unity2d.Launcher hide-mode')
52+ $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Launcher hide-mode 0'
53+
54+ verify_not(2, 'There should not be a Spread declarative view on startup') {
55+ @app_spread.SpreadView()
56+ }
57+ spreadItem = @app_shell.LauncherList( :name => 'main' ).LauncherList( :icon => "image://icons/unity-icon-theme/workspace-switcher" );
58+ spreadItem.move_mouse()
59+ XDo::Mouse.click
60+
61+ verify_equal("true", TIMEOUT, 'There should be a visible Spread declarative view after clicking on the spread item') {
62+ @app_spread.SpreadView()['visible']
63+ }
64+ sleep 2 # Do not really need it, but otherwise the animation looks weird
65+ XDo::Mouse.click
66+ verify_not(2, 'There should not be a visible Spread declarative view after clicking again on the spread item') {
67+ @app_spread.SpreadView()
68+ }
69+ $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Launcher hide-mode ' + hide_mode
70+ end
71 end

Subscribers

People subscribed via source and target branches