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
=== modified file 'libunity-2d-private/src/launcherapplication.cpp'
--- libunity-2d-private/src/launcherapplication.cpp 2012-01-18 11:50:32 +0000
+++ libunity-2d-private/src/launcherapplication.cpp 2012-01-31 09:42:25 +0000
@@ -452,6 +452,7 @@
452 m_application = NULL;452 m_application = NULL;
453 updateBamfApplicationDependentProperties();453 updateBamfApplicationDependentProperties();
454 closed();454 closed();
455 updateVisibleContextMenu();
455}456}
456457
457void458void
@@ -629,6 +630,29 @@
629}630}
630631
631void632void
633LauncherApplication::updateVisibleContextMenu()
634{
635 // There is no context menu while application is closing ? Do nothing.
636 if (m_menu && !m_menu->isVisible() && m_menu->folded())
637 return;
638
639 QList<QAction*> contextActions = m_menu->actions();
640
641 Q_FOREACH(QAction* action, contextActions) {
642 if (action->objectName() == QString("keepInLauncherAction")) {
643 action->setChecked(false);
644 action->setCheckable(false);
645 action->setText(u2dTr("Remove from launcher"));
646 }
647
648 if (action->objectName() == QString("quitAction")) {
649 m_menu->removeAction(action);
650 action->deleteLater();
651 }
652 }
653}
654
655void
632LauncherApplication::activate()656LauncherApplication::activate()
633{657{
634 if (urgent()) {658 if (urgent()) {
@@ -902,6 +926,7 @@
902 keep->setCheckable(is_running);926 keep->setCheckable(is_running);
903 keep->setChecked(sticky());927 keep->setChecked(sticky());
904 keep->setText(is_running ? u2dTr("Keep in launcher") : u2dTr("Remove from launcher"));928 keep->setText(is_running ? u2dTr("Keep in launcher") : u2dTr("Remove from launcher"));
929 keep->setObjectName("keepInLauncherAction");
905 actions.append(keep);930 actions.append(keep);
906 QObject::connect(keep, SIGNAL(triggered()), this, SLOT(onKeepTriggered()));931 QObject::connect(keep, SIGNAL(triggered()), this, SLOT(onKeepTriggered()));
907 }932 }
@@ -909,6 +934,7 @@
909 if (is_running) {934 if (is_running) {
910 QAction* quit = new QAction(m_menu);935 QAction* quit = new QAction(m_menu);
911 quit->setText(u2dTr("Quit"));936 quit->setText(u2dTr("Quit"));
937 quit->setObjectName("quitAction");
912 actions.append(quit);938 actions.append(quit);
913 QObject::connect(quit, SIGNAL(triggered()), this, SLOT(onQuitTriggered()));939 QObject::connect(quit, SIGNAL(triggered()), this, SLOT(onQuitTriggered()));
914 }940 }
915941
=== modified file 'libunity-2d-private/src/launcherapplication.h'
--- libunity-2d-private/src/launcherapplication.h 2012-01-13 15:05:44 +0000
+++ libunity-2d-private/src/launcherapplication.h 2012-01-31 09:42:25 +0000
@@ -173,7 +173,7 @@
173 template<typename T>173 template<typename T>
174 bool updateOverlayState(const QMap<QString, QVariant>& properties,174 bool updateOverlayState(const QMap<QString, QVariant>& properties,
175 const QString& propertyName, T* member);175 const QString& propertyName, T* member);
176176 void updateVisibleContextMenu();
177 QString m_dynamicQuicklistPath;177 QString m_dynamicQuicklistPath;
178 QScopedPointer<DBusMenuImporter> m_dynamicQuicklistImporter;178 QScopedPointer<DBusMenuImporter> m_dynamicQuicklistImporter;
179 QDBusServiceWatcher* m_dynamicQuicklistServiceWatcher;179 QDBusServiceWatcher* m_dynamicQuicklistServiceWatcher;
180180
=== added file 'tests/launcher/update-visible-menu.rb'
--- tests/launcher/update-visible-menu.rb 1970-01-01 00:00:00 +0000
+++ tests/launcher/update-visible-menu.rb 2012-01-31 09:42:25 +0000
@@ -0,0 +1,143 @@
1#!/usr/bin/env ruby1.8
2=begin
3/*
4 * This file is part of unity-2d
5 *
6 * Copyright 2012 Canonical Ltd.
7 *
8 * Authors:
9 * - Lohith DS <lohith.shivamurthy@canonical.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 3.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23=end
24
25require '../run-tests.rb' unless $INIT_COMPLETED
26require 'xdo/xwindow'
27require 'xdo/keyboard'
28require 'xdo/mouse'
29
30############################# Test Suite #############################
31context "Launcher visible contextual menu Tests" do
32 # Run once at the beginning of this test suite
33 startup do
34 $SUT.execute_shell_command 'killall unity-2d-launcher'
35 $SUT.execute_shell_command 'killall unity-2d-launcher'
36
37 $SUT.execute_shell_command 'killall gedit'
38 # Minimize all windows
39 XDo::XWindow.toggle_minimize_all
40
41 # Make certain application is ready for testing
42 test_fav = $SUT.execute_shell_command 'gsettings get com.canonical.Unity.Launcher favorites'
43 if test_fav.index("gedit.desktop") == nil
44 test_fav.insert(1, "'gedit.desktop', ")
45 $SUT.execute_shell_command "gsettings set com.canonical.Unity.Launcher favorites \"" + test_fav + "\""
46 end
47 end
48
49 # Run once at the end of this test suite
50 shutdown do
51 end
52
53 # Run before each test case begins
54 setup do
55 # Execute the application
56 @app = $SUT.run( :name => UNITY_2D_LAUNCHER,
57 :arguments => "-testability",
58 :sleeptime => 2 )
59 verify{ @app.Launcher() }
60
61 $SUT.execute_shell_command('gedit', :detached => true)
62 end
63
64 # Run after each test case completes
65 teardown do
66 $SUT.execute_shell_command 'killall gedit'
67 $SUT.execute_shell_command 'pkill -nf unity-2d-launcher'
68 end
69
70 #####################################################################################
71 # Test cases
72
73 # Test case objectives:
74 # * Launcher visible menu updates when app closed
75 # Pre-conditions
76 # * close running gedit windows and launch a single gedit window
77 # Test steps
78 # * Find the 'gedit' tile in the launcher
79 # * Open contextual menu
80 # * Verify that menu has 'Keep in launcher' action
81 # * Close the window through Alt-F4
82 # * Verify that the menu action 'Keep in launcher' is replaced with 'Remove from launcher'
83 # * Verify that the action 'Quit' is removed from menu
84 # * left click on 'Remove from launcher' action
85 # * Verify that application tile is removed from the launcher
86 # Post-conditions
87 # * None
88 # References
89 # * lp:784541
90 test "Launcher visible menu updates when app closed" do
91 tiles = ""
92 verify( TIMEOUT, 'Could not find the test application tile in the launcher' ) {
93 tiles = @app.Launcher().LauncherList( :name => 'main' ).children( { :running => 'true', :name => 'gedit' } )
94 }
95
96 if !tiles.empty?
97 tile = tiles[0]
98
99 y = tile['y_absolute'].to_i + 20
100
101 XDo::Mouse.move(0, y, 0, true)
102 verify_equal( 0, TIMEOUT, 'Launcher hiding with mouse on the edge, should be visible' ) {
103 @app.Unity2dPanel()['x_absolute'].to_i
104 }
105
106 XDo::Mouse.click(0, y, :right, 40)
107
108 context_menu = ""
109 verify( TIMEOUT, 'Tile contextual menu not found' ) {
110 context_menu = @app.LauncherContextualMenu()
111 }
112
113 verify_equal('Keep in launcher', TIMEOUT, "'Keep in launcher' action was expected, but not found" ) {
114 context_menu.QAction(:name => 'keepInLauncherAction')['iconText']
115 }
116
117 verify(TIMEOUT, "Quit action was expected, but not found" ) {
118 context_menu.QAction(:name => 'quitAction')
119 }
120
121 XDo::Keyboard.alt_F4
122
123 verify_equal('Remove from launcher', TIMEOUT, "'Remove from launcher' action was expected, but not found" ) {
124 context_menu.QAction(:name => 'keepInLauncherAction')['iconText']
125 }
126
127 verify_equal('false', TIMEOUT, "Remove from launcher action should be unchecked, but it is checked" ) {
128 context_menu.QAction(:name => 'keepInLauncherAction')['checked']
129 }
130
131 verify_not(TIMEOUT, "Quit action should have been removed, but not" ) {
132 context_menu.QAction(:name => 'quitAction')
133 }
134
135 XDo::Mouse.move(context_menu['x_absolute'].to_i + 20, context_menu['y_absolute'].to_i + context_menu['height'].to_i - 10, 0, true)
136 XDo::Mouse.click(nil,nil, :left)
137
138 verify_not( TIMEOUT, 'Could find the test application tile in the launcher, should not be there' ) {
139 tiles = @app.Launcher().LauncherList( :name => 'main' ).children( { :name => 'gedit' } )
140 }
141 end
142 end
143end

Subscribers

People subscribed via source and target branches