Merge lp:~azzar1/unity/fix-1063816 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2864
Proposed branch: lp:~azzar1/unity/fix-1063816
Merge into: lp:unity
Diff against target: 184 lines (+58/-8)
5 files modified
launcher/VolumeLauncherIcon.cpp (+30/-1)
tests/test_places_group.cpp (+1/-1)
tests/test_quicklist_view.cpp (+2/-0)
tests/test_shortcut_controller.cpp (+2/-0)
tests/test_volume_launcher_icon.cpp (+23/-6)
To merge this branch: bzr merge lp:~azzar1/unity/fix-1063816
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Marco Trevisan (Treviño) Approve
Review via email: mp+130237@code.launchpad.net

Commit message

Add quicklist title for storage device launcher icons.

Description of the change

== Problem ==
Launcher - Storage device Launcher icons (e.g. USB keys) are missing quicklist title

== Fix ==
Add it.

== Test ==
Unit test added.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

It would be nice if you'd also test for QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, but overall it's good.

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> It would be nice if you'd also test for
> QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, but overall it's good.

Done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/VolumeLauncherIcon.cpp'
2--- launcher/VolumeLauncherIcon.cpp 2012-09-11 10:59:53 +0000
3+++ launcher/VolumeLauncherIcon.cpp 2012-10-18 17:15:24 +0000
4@@ -144,8 +144,11 @@
5 {
6 MenuItemsVector result;
7
8+ AppendOpenItem(result);
9+ AppendSeparatorItem(result);
10+ AppendNameItem(result);
11+ AppendSeparatorItem(result);
12 AppendUnlockFromLauncherItem(result);
13- AppendOpenItem(result);
14 AppendEjectItem(result);
15 AppendSafelyRemoveItem(result);
16 AppendUnmountItem(result);
17@@ -173,6 +176,32 @@
18 menu.push_back(menu_item);
19 }
20
21+ void AppendSeparatorItem(MenuItemsVector& menu)
22+ {
23+ glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new());
24+ dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
25+ menu.push_back(menu_item);
26+ }
27+
28+ void AppendNameItem(MenuItemsVector& menu)
29+ {
30+ std::ostringstream bold_volume_name;
31+ bold_volume_name << "<b>" << volume_->GetName() << "</b>";
32+
33+ glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new());
34+
35+ dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, bold_volume_name.str().c_str());
36+ dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
37+ dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
38+ dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, true);
39+
40+ gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) {
41+ volume_->MountAndOpenInFileManager();
42+ }));
43+
44+ menu.push_back(menu_item);
45+ }
46+
47 void AppendOpenItem(MenuItemsVector& menu)
48 {
49 glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new());
50
51=== modified file 'tests/test_places_group.cpp'
52--- tests/test_places_group.cpp 2012-09-24 18:02:19 +0000
53+++ tests/test_places_group.cpp 2012-10-18 17:15:24 +0000
54@@ -35,7 +35,7 @@
55 public:
56 MockDashStyle()
57 {
58- std::string full_path = PKGDATADIR "album_missing.png";
59+ std::string full_path = PKGDATADIR "/album_missing.png";
60 glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_size(full_path.c_str(), 20, 20, nullptr));
61 base_texture_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
62 }
63
64=== modified file 'tests/test_quicklist_view.cpp'
65--- tests/test_quicklist_view.cpp 2012-08-13 18:40:44 +0000
66+++ tests/test_quicklist_view.cpp 2012-10-18 17:15:24 +0000
67@@ -26,6 +26,7 @@
68 #include "QuicklistMenuItemLabel.h"
69 #include "QuicklistMenuItemRadio.h"
70 #include "QuicklistMenuItemSeparator.h"
71+#include "unity-shared/UnitySettings.h"
72
73 using namespace unity;
74 using namespace testing;
75@@ -75,6 +76,7 @@
76 }
77 }
78
79+ unity::Settings unity_settings;
80 nux::ObjectPtr<QuicklistView> quicklist;
81 };
82
83
84=== modified file 'tests/test_shortcut_controller.cpp'
85--- tests/test_shortcut_controller.cpp 2012-09-11 10:38:31 +0000
86+++ tests/test_shortcut_controller.cpp 2012-10-18 17:15:24 +0000
87@@ -22,6 +22,7 @@
88
89 #include "shortcuts/BaseWindowRaiser.h"
90 #include "shortcuts/ShortcutController.h"
91+#include "unity-shared/UnitySettings.h"
92 using namespace unity;
93
94 #include "test_utils.h"
95@@ -45,6 +46,7 @@
96 , controller_(hints_, base_window_raiser_)
97 {}
98
99+ Settings unity_settings;
100 std::list<shortcut::AbstractHint::Ptr> hints_;
101 MockBaseWindowRaiser::Ptr base_window_raiser_;
102 shortcut::Controller controller_;
103
104=== modified file 'tests/test_volume_launcher_icon.cpp'
105--- tests/test_volume_launcher_icon.cpp 2012-09-14 23:45:28 +0000
106+++ tests/test_volume_launcher_icon.cpp 2012-10-18 17:15:24 +0000
107@@ -236,7 +236,7 @@
108 {
109 CreateIcon();
110
111- auto menuitem = GetMenuItemAtIndex(0);
112+ auto menuitem = GetMenuItemAtIndex(4);
113
114 ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Unlock from Launcher");
115 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
116@@ -258,7 +258,7 @@
117 {
118 CreateIcon();
119
120- auto menuitem = GetMenuItemAtIndex(0);
121+ auto menuitem = GetMenuItemAtIndex(4);
122
123 ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Unlock from Launcher");
124 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
125@@ -276,7 +276,7 @@
126 {
127 CreateIcon();
128
129- auto menuitem = GetMenuItemAtIndex(1);
130+ auto menuitem = GetMenuItemAtIndex(0);
131
132 ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Open");
133 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
134@@ -288,6 +288,23 @@
135 dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0);
136 }
137
138+TEST_F(TestVolumeLauncherIcon, TestNameMenuItem)
139+{
140+ CreateIcon();
141+
142+ auto menuitem = GetMenuItemAtIndex(2);
143+
144+ EXPECT_EQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "<b>" + volume_->GetName() + "</b>");
145+ EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE));
146+ EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED));
147+ EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY));
148+
149+ EXPECT_CALL(*volume_, MountAndOpenInFileManager())
150+ .Times(1);
151+
152+ dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0);
153+}
154+
155 TEST_F(TestVolumeLauncherIcon, TestEjectMenuItem_NotEjectableVolume)
156 {
157 CreateIcon();
158@@ -303,7 +320,7 @@
159
160 CreateIcon();
161
162- auto menuitem = GetMenuItemAtIndex(2);
163+ auto menuitem = GetMenuItemAtIndex(5);
164
165 EXPECT_CALL(*volume_, EjectAndShowNotification())
166 .Times(1);
167@@ -330,7 +347,7 @@
168
169 CreateIcon();
170
171- auto menuitem = GetMenuItemAtIndex(2);
172+ auto menuitem = GetMenuItemAtIndex(5);
173
174 EXPECT_CALL(*volume_, StopDrive())
175 .Times(1);
176@@ -389,7 +406,7 @@
177
178 CreateIcon();
179
180- auto menuitem = GetMenuItemAtIndex(2);
181+ auto menuitem = GetMenuItemAtIndex(5);
182
183 EXPECT_CALL(*volume_, Unmount())
184 .Times(1);