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
=== modified file 'spread/app/spreadmanager.cpp'
--- spread/app/spreadmanager.cpp 2012-03-13 15:49:19 +0000
+++ spread/app/spreadmanager.cpp 2012-03-29 11:30:25 +0000
@@ -76,7 +76,7 @@
76 view->engine()->setBaseUrl(QUrl::fromLocalFile(unity2dDirectory() + "/spread/"));76 view->engine()->setBaseUrl(QUrl::fromLocalFile(unity2dDirectory() + "/spread/"));
7777
78 /* Add a SpreadControl instance to the QML context */78 /* Add a SpreadControl instance to the QML context */
79 connect(view, SIGNAL(visibleChanged(bool)), this, SLOT(onViewVisibleChanged(bool)));79 connect(view, SIGNAL(visibleChanged(bool)), this, SLOT(onViewVisibleChanged(bool)), Qt::QueuedConnection);
80 view->rootContext()->setContextProperty("control", &m_control);80 view->rootContext()->setContextProperty("control", &m_control);
81 view->rootContext()->setContextProperty("spreadManager", this);81 view->rootContext()->setContextProperty("spreadManager", this);
8282
8383
=== modified file 'tests/spread/spread-tests.rb'
--- tests/spread/spread-tests.rb 2012-02-13 14:42:06 +0000
+++ tests/spread/spread-tests.rb 2012-03-29 11:30:25 +0000
@@ -65,6 +65,13 @@
65 #Need to kill Launcher as it does not shutdown when politely asked65 #Need to kill Launcher as it does not shutdown when politely asked
66 $SUT.execute_shell_command 'pkill -nf unity-2d-shell'66 $SUT.execute_shell_command 'pkill -nf unity-2d-shell'
67 $SUT.execute_shell_command 'pkill -nf unity-2d-spread'67 $SUT.execute_shell_command 'pkill -nf unity-2d-spread'
68 # Need to wait for the spread to really die, otherwise bad things happen
69 # on the second test
70 spread = $SUT.execute_shell_command 'pgrep unity-2d-spread'
71 while spread != ""
72 sleep 0.1
73 spread = $SUT.execute_shell_command 'pgrep unity-2d-spread'
74 end
68 end75 end
6976
70 #####################################################################################77 #####################################################################################
@@ -106,4 +113,40 @@
106 }113 }
107 xid.close!114 xid.close!
108 end115 end
116
117 # Test case objectives:
118 # * Check that clicking in the spread item of the launcher toggles the spread
119 # Pre-conditions
120 # * Desktop with no running applications
121 # Test steps
122 # * Verify spread is not showing
123 # * Click in the spread item of the launcher
124 # * Verify spread is showing
125 # * Click in the spread item of the launcher
126 # * Verify spread is not showing
127 # Post-conditions
128 # * None
129 # References
130 # * https://bugs.launchpad.net/unity-2d/+bug/968146
131 test "Spread launcher item toggles the spread" do
132 hide_mode = $SUT.execute_shell_command('gsettings get com.canonical.Unity2d.Launcher hide-mode')
133 $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Launcher hide-mode 0'
134
135 verify_not(2, 'There should not be a Spread declarative view on startup') {
136 @app_spread.SpreadView()
137 }
138 spreadItem = @app_shell.LauncherList( :name => 'main' ).LauncherList( :icon => "image://icons/unity-icon-theme/workspace-switcher" );
139 spreadItem.move_mouse()
140 XDo::Mouse.click
141
142 verify_equal("true", TIMEOUT, 'There should be a visible Spread declarative view after clicking on the spread item') {
143 @app_spread.SpreadView()['visible']
144 }
145 sleep 2 # Do not really need it, but otherwise the animation looks weird
146 XDo::Mouse.click
147 verify_not(2, 'There should not be a visible Spread declarative view after clicking again on the spread item') {
148 @app_spread.SpreadView()
149 }
150 $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Launcher hide-mode ' + hide_mode
151 end
109end152end

Subscribers

People subscribed via source and target branches