Merge lp:~dyams/unity-2d/launcher-update-visible-menu into lp:unity-2d

Proposed by Lohith D Shivamurthy
Status: Rejected
Rejected by: Gerry Boland
Proposed branch: lp:~dyams/unity-2d/launcher-update-visible-menu
Merge into: lp:unity-2d
Diff against target: 218 lines (+170/-1)
3 files modified
libunity-2d-private/src/launcherapplication.cpp (+26/-0)
libunity-2d-private/src/launcherapplication.h (+1/-1)
tests/launcher/update-visible-menu.rb (+143/-0)
To merge this branch: bzr merge lp:~dyams/unity-2d/launcher-update-visible-menu
Reviewer Review Type Date Requested Status
Gerry Boland (community) Disapprove
Albert Astals Cid (community) Needs Fixing
Review via email: mp+82897@code.launchpad.net

Description of the change

[launcher] A visible context menu should be updated properly while application is closing or launching

'Remove from launcher' action is displayed when application is not running.
'Keep in launcher' & 'Quit' actions are displayed while application is running.

Rest of the context actions remain unchanged.

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

It's possible to click a slow-starting application tile, right-click and select "Quit" all before the application starts up. Then it does not quit.

Please check how Unity behaves.

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

> It's possible to click a slow-starting application tile, right-click and
> select "Quit" all before the application starts up. Then it does not quit.
>

Agree with you. Was over-conscious :)

Actually this branch has lot of conflicts with the trunk already.
Hence I have created a new branch.

Would it be possible to accept this new branch?

https://code.launchpad.net/~dyams/unity-2d/update-launcher-context-menu

Thank you.

After your answer, I remove this branch or remove this link from the bug definition.

788. By Lohith D Shivamurthy

Do not update context menu while application is launching

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

> After your answer, I remove this branch or remove this link from the bug
> definition.

I removed my new branch. And updated this same branch. Please have a look :)

789. By Lohith D Shivamurthy

[launcher] merge with trunk

790. By Lohith D Shivamurthy

[launcher] test added

791. By Lohith D Shivamurthy

[launcher] added missing test file

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

Things that need fixing:
 * You should disconnect the triggered signal, otherwise that menu entry is not connected to any slot any more.
 * The test file copyright should be on your name not on mine
 * The test objectives and steps are there from c&p and not updated to what your test really does

Thing to discuss:
 * In updateVisibleContextMenu it might be a better idea to compare using the action object names than the action texts.

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

Something else i forgot, I am not sure why you are doing
   if (action->parent() == m_menu) {
could you clarify? Is it in case it is not the action we created? If you are removing it from the menu you might as well delete it too. Even better, if you change to checking the objectname as i suggested, you'll be "almost really sure" it is the action we created, so there is no need to do this check.

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

> Things that need fixing:
> * You should disconnect the triggered signal, otherwise that menu entry is
> not connected to any slot any more.

As I can see I have disconnected the 'onKeepTriggered' in the same update method. Did you mean any other signal/slot?

> * The test file copyright should be on your name not on mine
> * The test objectives and steps are there from c&p and not updated to what
> your test really does
>
Done
> Thing to discuss:
> * In updateVisibleContextMenu it might be a better idea to compare using the
> action object names than the action texts.
Agreed, but comparing unicode strings shouldn't harm either.

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

> Something else i forgot, I am not sure why you are doing
> if (action->parent() == m_menu) {
> could you clarify? Is it in case it is not the action we created? If you are
> removing it from the menu you might as well delete it too. Even better, if you
> change to checking the objectname as i suggested, you'll be "almost really
> sure" it is the action we created, so there is no need to do this check.
Yes, that was not necessary, but am sure i'm deleting it as soon as removing it from the menu.
action->deleteLater is there. no? Or do you mean something else?
Yes, am using object names now.

792. By Lohith D Shivamurthy

[launcher] Using object names to identify the QAction. Also fixed the tests

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

> > Things that need fixing:
> > * You should disconnect the triggered signal, otherwise that menu entry is
> > not connected to any slot any more.
>
> As I can see I have disconnected the 'onKeepTriggered' in the same update
> method. Did you mean any other signal/slot?

What I am saying is that you should not disconnect the signal. If you do when you click the "Remove from launcher" action it will do nothing.

review: Needs Fixing
793. By Lohith D Shivamurthy

[launcher] make 'Remove from launcher' action uncheckable while application is closed and leave the previous connection as it is

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

There is a problem with the test, for it to work you need to have gedit in the launcher which i don't, so the test does not work here since when the gedit is closed the tile disappears from the launcher.

I suggest you to have a look at tests/launcher/autohide_show_tests.rb where we read/set the favorites, so on starting your test you set the favorites so it always includes gedit.

Also it would be nice that after checking that the 'Remove from launcher' is there, you check it works (i.e. click on it and then see the tile is not there) since that is what was not working when you had the disconnect there in previous versions of the code.

review: Needs Fixing
794. By Lohith D Shivamurthy

[launcher] fixed tests

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

More test fixing sorry :D

My gedit opened in full screen and that made the launcher bar hide, make sure you move the mouse to the left of the screen and then wait for the launcher to show before trying to right click on the tile.

review: Needs Fixing
795. By Lohith D Shivamurthy

[launcher] fix tests to verify 'Remove from launcher' remove the tile from launcher

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

I still need this
+ XDo::Mouse.move(0, y, 0, true)
+ verify_equal( 0, TIMEOUT, 'Launcher hiding with mouse on the edge, should be visible' ) {
+ @app.Unity2dPanel()['x_absolute'].to_i
+ }
before
XDo::Mouse.click(0, y, :right, 40)
to make sure the launcher is showing

review: Needs Fixing
796. By Lohith D Shivamurthy

[launcher] make sure launcher is visible before opening the contextual menu

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

One last minor thing, i think that
  'Could not find the test application tile in the launcher'
should be something like
  'Could find the test application tile in the launcher, should not be there'

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

As per previous comment, setting "Needs Fixing"

review: Needs Fixing
797. By Lohith D Shivamurthy

[launcher] Fix verify display comments

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

I just realized there is one thing missing in this patch. It is handling the situation in which you have the application running, the menu open and then the application closes, but it is not handling the situation in which you do not have the application running, the menu is open and then the application starts, you need to update the menu in that situation too, right?

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

> I just realized there is one thing missing in this patch. It is handling the
> situation in which you have the application running, the menu open and then
> the application closes, but it is not handling the situation in which you do
> not have the application running, the menu is open and then the application
> starts, you need to update the menu in that situation too, right?
no. As you can see in the beginning of this page, I intentionally removed that code.

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

But then the menu is wrong, it still says "Remove from Launcher" when it should say "Keep in Launcher", right?

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

> But then the menu is wrong, it still says "Remove from Launcher" when it
> should say "Keep in Launcher", right?
Yes, I have put this comment in the bug too : https://bugs.launchpad.net/unity-2d/+bug/784541/comments/1

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

Doesn't make much sense to me fixing one part of the bug but not the other.

Gerry could you clarify if fixing only half of the bug is indeed enough/what we want?

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

I must side with Albert here, it does not make sense fixing one half of the bug & not the other. I would prefer if you took a little more time & perform a comprehensive fix.

Note that with the feature freeze approaching, I want to de-prioritise this task until after the freeze. So please continue with your current task.
-G

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

Branch abandoned, so rejecting this MR.

review: Disapprove

Unmerged revisions

797. By Lohith D Shivamurthy

[launcher] Fix verify display comments

796. By Lohith D Shivamurthy

[launcher] make sure launcher is visible before opening the contextual menu

795. By Lohith D Shivamurthy

[launcher] fix tests to verify 'Remove from launcher' remove the tile from launcher

794. By Lohith D Shivamurthy

[launcher] fixed tests

793. By Lohith D Shivamurthy

[launcher] make 'Remove from launcher' action uncheckable while application is closed and leave the previous connection as it is

792. By Lohith D Shivamurthy

[launcher] Using object names to identify the QAction. Also fixed the tests

791. By Lohith D Shivamurthy

[launcher] added missing test file

790. By Lohith D Shivamurthy

[launcher] test added

789. By Lohith D Shivamurthy

[launcher] merge with trunk

788. By Lohith D Shivamurthy

Do not update context menu while application is launching

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/launcherapplication.cpp'
2--- libunity-2d-private/src/launcherapplication.cpp 2012-01-18 11:50:32 +0000
3+++ libunity-2d-private/src/launcherapplication.cpp 2012-01-31 09:42:25 +0000
4@@ -452,6 +452,7 @@
5 m_application = NULL;
6 updateBamfApplicationDependentProperties();
7 closed();
8+ updateVisibleContextMenu();
9 }
10
11 void
12@@ -629,6 +630,29 @@
13 }
14
15 void
16+LauncherApplication::updateVisibleContextMenu()
17+{
18+ // There is no context menu while application is closing ? Do nothing.
19+ if (m_menu && !m_menu->isVisible() && m_menu->folded())
20+ return;
21+
22+ QList<QAction*> contextActions = m_menu->actions();
23+
24+ Q_FOREACH(QAction* action, contextActions) {
25+ if (action->objectName() == QString("keepInLauncherAction")) {
26+ action->setChecked(false);
27+ action->setCheckable(false);
28+ action->setText(u2dTr("Remove from launcher"));
29+ }
30+
31+ if (action->objectName() == QString("quitAction")) {
32+ m_menu->removeAction(action);
33+ action->deleteLater();
34+ }
35+ }
36+}
37+
38+void
39 LauncherApplication::activate()
40 {
41 if (urgent()) {
42@@ -902,6 +926,7 @@
43 keep->setCheckable(is_running);
44 keep->setChecked(sticky());
45 keep->setText(is_running ? u2dTr("Keep in launcher") : u2dTr("Remove from launcher"));
46+ keep->setObjectName("keepInLauncherAction");
47 actions.append(keep);
48 QObject::connect(keep, SIGNAL(triggered()), this, SLOT(onKeepTriggered()));
49 }
50@@ -909,6 +934,7 @@
51 if (is_running) {
52 QAction* quit = new QAction(m_menu);
53 quit->setText(u2dTr("Quit"));
54+ quit->setObjectName("quitAction");
55 actions.append(quit);
56 QObject::connect(quit, SIGNAL(triggered()), this, SLOT(onQuitTriggered()));
57 }
58
59=== modified file 'libunity-2d-private/src/launcherapplication.h'
60--- libunity-2d-private/src/launcherapplication.h 2012-01-13 15:05:44 +0000
61+++ libunity-2d-private/src/launcherapplication.h 2012-01-31 09:42:25 +0000
62@@ -173,7 +173,7 @@
63 template<typename T>
64 bool updateOverlayState(const QMap<QString, QVariant>& properties,
65 const QString& propertyName, T* member);
66-
67+ void updateVisibleContextMenu();
68 QString m_dynamicQuicklistPath;
69 QScopedPointer<DBusMenuImporter> m_dynamicQuicklistImporter;
70 QDBusServiceWatcher* m_dynamicQuicklistServiceWatcher;
71
72=== added file 'tests/launcher/update-visible-menu.rb'
73--- tests/launcher/update-visible-menu.rb 1970-01-01 00:00:00 +0000
74+++ tests/launcher/update-visible-menu.rb 2012-01-31 09:42:25 +0000
75@@ -0,0 +1,143 @@
76+#!/usr/bin/env ruby1.8
77+=begin
78+/*
79+ * This file is part of unity-2d
80+ *
81+ * Copyright 2012 Canonical Ltd.
82+ *
83+ * Authors:
84+ * - Lohith DS <lohith.shivamurthy@canonical.com>
85+ *
86+ * This program is free software; you can redistribute it and/or modify
87+ * it under the terms of the GNU General Public License as published by
88+ * the Free Software Foundation; version 3.
89+ *
90+ * This program is distributed in the hope that it will be useful,
91+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
92+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+ * GNU General Public License for more details.
94+ *
95+ * You should have received a copy of the GNU General Public License
96+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
97+ */
98+=end
99+
100+require '../run-tests.rb' unless $INIT_COMPLETED
101+require 'xdo/xwindow'
102+require 'xdo/keyboard'
103+require 'xdo/mouse'
104+
105+############################# Test Suite #############################
106+context "Launcher visible contextual menu Tests" do
107+ # Run once at the beginning of this test suite
108+ startup do
109+ $SUT.execute_shell_command 'killall unity-2d-launcher'
110+ $SUT.execute_shell_command 'killall unity-2d-launcher'
111+
112+ $SUT.execute_shell_command 'killall gedit'
113+ # Minimize all windows
114+ XDo::XWindow.toggle_minimize_all
115+
116+ # Make certain application is ready for testing
117+ test_fav = $SUT.execute_shell_command 'gsettings get com.canonical.Unity.Launcher favorites'
118+ if test_fav.index("gedit.desktop") == nil
119+ test_fav.insert(1, "'gedit.desktop', ")
120+ $SUT.execute_shell_command "gsettings set com.canonical.Unity.Launcher favorites \"" + test_fav + "\""
121+ end
122+ end
123+
124+ # Run once at the end of this test suite
125+ shutdown do
126+ end
127+
128+ # Run before each test case begins
129+ setup do
130+ # Execute the application
131+ @app = $SUT.run( :name => UNITY_2D_LAUNCHER,
132+ :arguments => "-testability",
133+ :sleeptime => 2 )
134+ verify{ @app.Launcher() }
135+
136+ $SUT.execute_shell_command('gedit', :detached => true)
137+ end
138+
139+ # Run after each test case completes
140+ teardown do
141+ $SUT.execute_shell_command 'killall gedit'
142+ $SUT.execute_shell_command 'pkill -nf unity-2d-launcher'
143+ end
144+
145+ #####################################################################################
146+ # Test cases
147+
148+ # Test case objectives:
149+ # * Launcher visible menu updates when app closed
150+ # Pre-conditions
151+ # * close running gedit windows and launch a single gedit window
152+ # Test steps
153+ # * Find the 'gedit' tile in the launcher
154+ # * Open contextual menu
155+ # * Verify that menu has 'Keep in launcher' action
156+ # * Close the window through Alt-F4
157+ # * Verify that the menu action 'Keep in launcher' is replaced with 'Remove from launcher'
158+ # * Verify that the action 'Quit' is removed from menu
159+ # * left click on 'Remove from launcher' action
160+ # * Verify that application tile is removed from the launcher
161+ # Post-conditions
162+ # * None
163+ # References
164+ # * lp:784541
165+ test "Launcher visible menu updates when app closed" do
166+ tiles = ""
167+ verify( TIMEOUT, 'Could not find the test application tile in the launcher' ) {
168+ tiles = @app.Launcher().LauncherList( :name => 'main' ).children( { :running => 'true', :name => 'gedit' } )
169+ }
170+
171+ if !tiles.empty?
172+ tile = tiles[0]
173+
174+ y = tile['y_absolute'].to_i + 20
175+
176+ XDo::Mouse.move(0, y, 0, true)
177+ verify_equal( 0, TIMEOUT, 'Launcher hiding with mouse on the edge, should be visible' ) {
178+ @app.Unity2dPanel()['x_absolute'].to_i
179+ }
180+
181+ XDo::Mouse.click(0, y, :right, 40)
182+
183+ context_menu = ""
184+ verify( TIMEOUT, 'Tile contextual menu not found' ) {
185+ context_menu = @app.LauncherContextualMenu()
186+ }
187+
188+ verify_equal('Keep in launcher', TIMEOUT, "'Keep in launcher' action was expected, but not found" ) {
189+ context_menu.QAction(:name => 'keepInLauncherAction')['iconText']
190+ }
191+
192+ verify(TIMEOUT, "Quit action was expected, but not found" ) {
193+ context_menu.QAction(:name => 'quitAction')
194+ }
195+
196+ XDo::Keyboard.alt_F4
197+
198+ verify_equal('Remove from launcher', TIMEOUT, "'Remove from launcher' action was expected, but not found" ) {
199+ context_menu.QAction(:name => 'keepInLauncherAction')['iconText']
200+ }
201+
202+ verify_equal('false', TIMEOUT, "Remove from launcher action should be unchecked, but it is checked" ) {
203+ context_menu.QAction(:name => 'keepInLauncherAction')['checked']
204+ }
205+
206+ verify_not(TIMEOUT, "Quit action should have been removed, but not" ) {
207+ context_menu.QAction(:name => 'quitAction')
208+ }
209+
210+ XDo::Mouse.move(context_menu['x_absolute'].to_i + 20, context_menu['y_absolute'].to_i + context_menu['height'].to_i - 10, 0, true)
211+ XDo::Mouse.click(nil,nil, :left)
212+
213+ verify_not( TIMEOUT, 'Could find the test application tile in the launcher, should not be there' ) {
214+ tiles = @app.Launcher().LauncherList( :name => 'main' ).children( { :name => 'gedit' } )
215+ }
216+ end
217+ end
218+end

Subscribers

People subscribed via source and target branches