Merge lp:~charlesk/indicator-transfer/rtm-usability-fix into lp:indicator-transfer/14.10

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 29
Merged at revision: 22
Proposed branch: lp:~charlesk/indicator-transfer/rtm-usability-fix
Merge into: lp:indicator-transfer/14.10
Diff against target: 229 lines (+154/-7)
3 files modified
src/view-gmenu.cpp (+15/-3)
tests/manual (+12/-3)
tests/test-view-gmenu.cpp (+127/-1)
To merge this branch: bzr merge lp:~charlesk/indicator-transfer/rtm-usability-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Review via email: mp+237111@code.launchpad.net

Commit message

Change the indicator's label to "Files" and only show the indicator if there are unfinished transfers.

Description of the change

== Description of Change

Update label and visibility to match changes listed in <https://docs.google.com/a/canonical.com/document/d/1jHIGzAzf7kFELgOiU9J0Hd9mOa3NzTsnEglLmx_qEfk/edit#>:

1. Change the title from "Transfers" to "Files"

2. Change the visibility behavior s.t. the indicator is only visible when there are incomplete transfers.

== Checklist

> Are there any related MPs required for this MP to build/function as expected? Please list.

No

> Is your branch in sync with latest trunk? (e.g. bzr pull lp:trunk -> no changes)

Yes

> Did the code build without warnings?

Yes

> Did the tests run successfully?

Yes

> Did you perform an exploratory manual test run of your code change and any related functionality?

Yes

> Has your component test plan been executed successfully on emulator or a physical device?

Yes, mako + r68

> Please list which manual tests are germane for the reviewer in this MP.

indicator-transfer/visibility

> Did you link to the checklist URL at https://wiki.ubuntu.com/Process/Merges/Checklists/indicator-transfer to make life easier for reviewers/testers?

Yes

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Small stuff, I'll mark approved but not top approve.

review: Approve
26. By Charles Kerr

fix questionable use of 'const auto'

27. By Charles Kerr

fix syntax error in manual tests

28. By Charles Kerr

in test-view-gmenu's PhoneHeader test, improve local variablenames

29. By Charles Kerr

in test-view-gmenu.cpp, extract copy-and-pasted blocks into a function to reduce duplicated code

Revision history for this message
Charles Kerr (charlesk) wrote :

Fixed; comments inline

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/view-gmenu.cpp'
2--- src/view-gmenu.cpp 2014-08-25 21:00:22 +0000
3+++ src/view-gmenu.cpp 2014-10-03 21:09:42 +0000
4@@ -238,7 +238,7 @@
5 g_variant_new_string("accessible-desc"));
6 g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string("label"));
7 g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string("title"));
8- g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(true));
9+ g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(false));
10 return g_variant_builder_end(&b);
11 }
12
13@@ -419,17 +419,29 @@
14 return ret;
15 }
16
17+ /* Show the header if there are any transfers that have begun and are
18+ currently incomplete because they're either ongoing or paused. */
19+ bool header_should_be_visible() const
20+ {
21+ for (const auto& transfer : m_model->get_all())
22+ if (transfer->state != Transfer::FINISHED)
23+ return true;
24+
25+ return false;
26+ }
27+
28 GVariant* create_header_state()
29 {
30 auto reffed_icon_v = get_header_icon();
31- auto title_v = g_variant_new_string(_("Transfers"));
32+ auto title_v = g_variant_new_string(_("Files"));
33+ const bool visible = header_should_be_visible();
34
35 GVariantBuilder b;
36 g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
37 g_variant_builder_add(&b, "{sv}", "title", title_v);
38 g_variant_builder_add(&b, "{sv}", "icon", reffed_icon_v);
39 g_variant_builder_add(&b, "{sv}", "accessible-desc", title_v);
40- g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(true));
41+ g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(visible));
42 auto ret = g_variant_builder_end (&b);
43
44 g_variant_unref(reffed_icon_v);
45
46=== modified file 'tests/manual'
47--- tests/manual 2014-08-25 21:37:15 +0000
48+++ tests/manual 2014-10-03 21:09:42 +0000
49@@ -1,11 +1,19 @@
50
51+Test-case indicator-transfer/visibility
52+<dl>
53+ <dt>Start downloading an image from the Browser to the Gallery.
54+ (In the Browser, tap-and-hold on an image, choose 'Save image'
55+ in the popup, and select 'Gallery' at the 'Open with ' prompt.</dt>
56+ <dd>If the indicator wasn't already visible in the panel, it should appear as the transfer begins.</dd>
57+ <dd>After the last transfer finished, the indicator should disappear from the panel.</dd>
58+</dt>
59+
60 Test-case indicator-transfer/download-an-image
61 <dl>
62- <dt>Ensure indicator-transfer-service is running<dt>
63- <dd>The indicator should be visible in the panel</dd>
64 <dt>Start downloading an image from the Browser to the Gallery.
65 (In the Browser, tap-and-hold on an image, choose 'Save image'
66- in the popup, and select 'Gallery' at the 'Open with ' prompt.</dt>
67+ in the popup, and select 'Gallery' at the 'Open with ' prompt.)</dt>
68+ <dd>If the indicator wasn't already visible in the panel, it should appear as the transfer begins.</dd>
69 <dd>In the 'Ongoing Transfers' section, the transfer should appear</dd>
70 <dd>In the 'Ongoing Transfers' section, a 'Pause all' button should appear</dd>
71 <dd>While transfer is active, the indicator's icon should indicate activity</dd>
72@@ -13,6 +21,7 @@
73 <dd>As the transfer finishes, its menuitem should move from the 'Ongoing' to 'Successful' section</dd>
74 <dd>As the transfer finishes, the indicator's icon should change to indicate an idle state</dd>
75 <dd>As the transfer finishes, the 'Pause all' button should disappear</dd>
76+ <dd>After the transfer is finished, the indicator should disappear from the panel.</dd>
77 <dt>Click on the completed transfer's menuitem</dt>
78 <dd>The gallery app should launch</dd>
79 <dt>Press the 'Clear all' button.</dt>
80
81=== modified file 'tests/test-view-gmenu.cpp'
82--- tests/test-view-gmenu.cpp 2014-06-25 23:02:06 +0000
83+++ tests/test-view-gmenu.cpp 2014-10-03 21:09:42 +0000
84@@ -24,6 +24,7 @@
85 #include <transfer/dbus-shared.h>
86 #include <transfer/view-gmenu.h>
87
88+#include <glib/gi18n.h>
89
90 using namespace unity::indicator::transfer;
91
92@@ -268,6 +269,132 @@
93
94 /***
95 ****
96+**** Header
97+****
98+***/
99+
100+namespace
101+{
102+ bool is_header_visible(GActionGroup* action_group, const std::string& header_action_name)
103+ {
104+ auto dict = g_action_group_get_action_state(action_group, header_action_name.c_str());
105+ g_assert(dict != nullptr);
106+ g_assert(g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT));
107+ auto v = g_variant_lookup_value(dict, "visible", G_VARIANT_TYPE_BOOLEAN);
108+ g_assert(v != nullptr);
109+ const bool is_visible = g_variant_get_boolean(v);
110+ g_clear_pointer(&v, g_variant_unref);
111+ g_clear_pointer(&dict, g_variant_unref);
112+ return is_visible;
113+ }
114+}
115+
116+TEST_F(GMenuViewFixture, PhoneHeader)
117+{
118+ const std::string profile = "phone";
119+
120+ wait_msec();
121+
122+ auto connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
123+
124+ // SETUP: get the action group and wait for it to be populated
125+ auto dbus_action_group = g_dbus_action_group_get(connection, BUS_NAME, BUS_PATH);
126+ auto action_group = G_ACTION_GROUP(dbus_action_group);
127+ auto names_strv = g_action_group_list_actions(action_group);
128+ if (g_strv_length(names_strv) == 0)
129+ {
130+ g_strfreev(names_strv);
131+ wait_for_signal(dbus_action_group, "action-added");
132+ names_strv = g_action_group_list_actions(action_group);
133+ }
134+ g_clear_pointer(&names_strv, g_strfreev);
135+
136+ // SETUP: get the menu model and wait for it to be activated
137+ auto phone_dbus_menu_model = g_dbus_menu_model_get(connection, BUS_NAME, BUS_PATH"/phone");
138+ auto phone_menu_model = G_MENU_MODEL(phone_dbus_menu_model);
139+ int n = g_menu_model_get_n_items(phone_menu_model);
140+ if (!n)
141+ {
142+ // give the model a moment to populate its info
143+ wait_msec(100);
144+ n = g_menu_model_get_n_items(phone_menu_model);
145+ }
146+ EXPECT_TRUE(phone_menu_model != nullptr);
147+ EXPECT_NE(0, n);
148+
149+ // test to confirm that a header menuitem exists
150+ gchar* str = nullptr;
151+ g_menu_model_get_item_attribute(phone_menu_model, 0, "x-canonical-type", "s", &str);
152+ EXPECT_STREQ("com.canonical.indicator.root", str);
153+ g_clear_pointer(&str, g_free);
154+ g_menu_model_get_item_attribute(phone_menu_model, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str);
155+ const auto action_name = profile + "-header";
156+ EXPECT_EQ(std::string("indicator.")+action_name, str);
157+ g_clear_pointer(&str, g_free);
158+
159+ // cursory first look at the header
160+ auto dict = g_action_group_get_action_state(action_group, action_name.c_str());
161+ EXPECT_TRUE(dict != nullptr);
162+ EXPECT_TRUE(g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT));
163+ auto v = g_variant_lookup_value(dict, "accessible-desc", G_VARIANT_TYPE_STRING);
164+ EXPECT_TRUE(v != nullptr);
165+ g_variant_unref(v);
166+ v = g_variant_lookup_value(dict, "title", G_VARIANT_TYPE_STRING);
167+ EXPECT_TRUE(v != nullptr);
168+ EXPECT_STREQ(_("Files"), g_variant_get_string(v, nullptr));
169+ g_variant_unref(v);
170+ v = g_variant_lookup_value(dict, "visible", G_VARIANT_TYPE_BOOLEAN);
171+ EXPECT_TRUE(g_variant_get_boolean(v));
172+ EXPECT_TRUE(v != nullptr);
173+ g_clear_pointer(&v, g_variant_unref);
174+ g_clear_pointer(&dict, g_variant_unref);
175+
176+ // Visibility test #1:
177+ // Change the model to all transfers finished.
178+ // Confirm that the header is not visible.
179+ for (auto& transfer : m_model->get_all())
180+ {
181+ transfer->state = Transfer::FINISHED;
182+ m_model->emit_changed(transfer->id);
183+ }
184+
185+ wait_msec(200);
186+ EXPECT_FALSE(is_header_visible(action_group, action_name));
187+
188+ // Visibility test #2:
189+ // Change the model to all transfers finished except one running.
190+ // Confirm that the header is visible.
191+ auto transfer = m_model->get("a");
192+ transfer->state = Transfer::RUNNING;
193+ m_model->emit_changed(transfer->id);
194+ wait_msec(200);
195+ EXPECT_TRUE(is_header_visible(action_group, action_name));
196+
197+ // Visibility test #3:
198+ // Change the model to all transfers finished except one paused.
199+ // Confirm that the header is visible.
200+ transfer = m_model->get("a");
201+ transfer->state = Transfer::PAUSED;
202+ m_model->emit_changed(transfer->id);
203+ wait_msec(200);
204+ EXPECT_TRUE(is_header_visible(action_group, action_name));
205+
206+ // Visibility test #4:
207+ // Remove all the transfers from the menu.
208+ // Confirm that the header is not visible.
209+ for (const auto& id : m_model->get_ids())
210+ m_model->remove(id);
211+ wait_msec(200);
212+ EXPECT_FALSE(is_header_visible(action_group, action_name));
213+
214+ // cleanup
215+ g_clear_object(&action_group);
216+ g_clear_object(&phone_dbus_menu_model);
217+ g_clear_object(&connection);
218+}
219+
220+/***
221+****
222 **** GMenu
223 ****
224 ***/
225@@ -296,4 +423,3 @@
226 g_clear_object(&dbus_menu_model);
227 g_clear_object(&connection);
228 }
229-

Subscribers

People subscribed via source and target branches