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
=== modified file 'src/view-gmenu.cpp'
--- src/view-gmenu.cpp 2014-08-25 21:00:22 +0000
+++ src/view-gmenu.cpp 2014-10-03 21:09:42 +0000
@@ -238,7 +238,7 @@
238 g_variant_new_string("accessible-desc"));238 g_variant_new_string("accessible-desc"));
239 g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string("label"));239 g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string("label"));
240 g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string("title"));240 g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string("title"));
241 g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(true));241 g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(false));
242 return g_variant_builder_end(&b);242 return g_variant_builder_end(&b);
243 }243 }
244244
@@ -419,17 +419,29 @@
419 return ret;419 return ret;
420 }420 }
421421
422 /* Show the header if there are any transfers that have begun and are
423 currently incomplete because they're either ongoing or paused. */
424 bool header_should_be_visible() const
425 {
426 for (const auto& transfer : m_model->get_all())
427 if (transfer->state != Transfer::FINISHED)
428 return true;
429
430 return false;
431 }
432
422 GVariant* create_header_state()433 GVariant* create_header_state()
423 {434 {
424 auto reffed_icon_v = get_header_icon();435 auto reffed_icon_v = get_header_icon();
425 auto title_v = g_variant_new_string(_("Transfers"));436 auto title_v = g_variant_new_string(_("Files"));
437 const bool visible = header_should_be_visible();
426438
427 GVariantBuilder b;439 GVariantBuilder b;
428 g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);440 g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT);
429 g_variant_builder_add(&b, "{sv}", "title", title_v);441 g_variant_builder_add(&b, "{sv}", "title", title_v);
430 g_variant_builder_add(&b, "{sv}", "icon", reffed_icon_v);442 g_variant_builder_add(&b, "{sv}", "icon", reffed_icon_v);
431 g_variant_builder_add(&b, "{sv}", "accessible-desc", title_v);443 g_variant_builder_add(&b, "{sv}", "accessible-desc", title_v);
432 g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(true));444 g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(visible));
433 auto ret = g_variant_builder_end (&b);445 auto ret = g_variant_builder_end (&b);
434446
435 g_variant_unref(reffed_icon_v);447 g_variant_unref(reffed_icon_v);
436448
=== modified file 'tests/manual'
--- tests/manual 2014-08-25 21:37:15 +0000
+++ tests/manual 2014-10-03 21:09:42 +0000
@@ -1,11 +1,19 @@
11
2Test-case indicator-transfer/visibility
3<dl>
4 <dt>Start downloading an image from the Browser to the Gallery.
5 (In the Browser, tap-and-hold on an image, choose 'Save image'
6 in the popup, and select 'Gallery' at the 'Open with ' prompt.</dt>
7 <dd>If the indicator wasn't already visible in the panel, it should appear as the transfer begins.</dd>
8 <dd>After the last transfer finished, the indicator should disappear from the panel.</dd>
9</dt>
10
2Test-case indicator-transfer/download-an-image11Test-case indicator-transfer/download-an-image
3<dl>12<dl>
4 <dt>Ensure indicator-transfer-service is running<dt>
5 <dd>The indicator should be visible in the panel</dd>
6 <dt>Start downloading an image from the Browser to the Gallery.13 <dt>Start downloading an image from the Browser to the Gallery.
7 (In the Browser, tap-and-hold on an image, choose 'Save image'14 (In the Browser, tap-and-hold on an image, choose 'Save image'
8 in the popup, and select 'Gallery' at the 'Open with ' prompt.</dt>15 in the popup, and select 'Gallery' at the 'Open with ' prompt.)</dt>
16 <dd>If the indicator wasn't already visible in the panel, it should appear as the transfer begins.</dd>
9 <dd>In the 'Ongoing Transfers' section, the transfer should appear</dd>17 <dd>In the 'Ongoing Transfers' section, the transfer should appear</dd>
10 <dd>In the 'Ongoing Transfers' section, a 'Pause all' button should appear</dd>18 <dd>In the 'Ongoing Transfers' section, a 'Pause all' button should appear</dd>
11 <dd>While transfer is active, the indicator's icon should indicate activity</dd>19 <dd>While transfer is active, the indicator's icon should indicate activity</dd>
@@ -13,6 +21,7 @@
13 <dd>As the transfer finishes, its menuitem should move from the 'Ongoing' to 'Successful' section</dd>21 <dd>As the transfer finishes, its menuitem should move from the 'Ongoing' to 'Successful' section</dd>
14 <dd>As the transfer finishes, the indicator's icon should change to indicate an idle state</dd>22 <dd>As the transfer finishes, the indicator's icon should change to indicate an idle state</dd>
15 <dd>As the transfer finishes, the 'Pause all' button should disappear</dd>23 <dd>As the transfer finishes, the 'Pause all' button should disappear</dd>
24 <dd>After the transfer is finished, the indicator should disappear from the panel.</dd>
16 <dt>Click on the completed transfer's menuitem</dt>25 <dt>Click on the completed transfer's menuitem</dt>
17 <dd>The gallery app should launch</dd>26 <dd>The gallery app should launch</dd>
18 <dt>Press the 'Clear all' button.</dt>27 <dt>Press the 'Clear all' button.</dt>
1928
=== modified file 'tests/test-view-gmenu.cpp'
--- tests/test-view-gmenu.cpp 2014-06-25 23:02:06 +0000
+++ tests/test-view-gmenu.cpp 2014-10-03 21:09:42 +0000
@@ -24,6 +24,7 @@
24#include <transfer/dbus-shared.h>24#include <transfer/dbus-shared.h>
25#include <transfer/view-gmenu.h>25#include <transfer/view-gmenu.h>
2626
27#include <glib/gi18n.h>
2728
28using namespace unity::indicator::transfer;29using namespace unity::indicator::transfer;
2930
@@ -268,6 +269,132 @@
268269
269/***270/***
270****271****
272**** Header
273****
274***/
275
276namespace
277{
278 bool is_header_visible(GActionGroup* action_group, const std::string& header_action_name)
279 {
280 auto dict = g_action_group_get_action_state(action_group, header_action_name.c_str());
281 g_assert(dict != nullptr);
282 g_assert(g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT));
283 auto v = g_variant_lookup_value(dict, "visible", G_VARIANT_TYPE_BOOLEAN);
284 g_assert(v != nullptr);
285 const bool is_visible = g_variant_get_boolean(v);
286 g_clear_pointer(&v, g_variant_unref);
287 g_clear_pointer(&dict, g_variant_unref);
288 return is_visible;
289 }
290}
291
292TEST_F(GMenuViewFixture, PhoneHeader)
293{
294 const std::string profile = "phone";
295
296 wait_msec();
297
298 auto connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
299
300 // SETUP: get the action group and wait for it to be populated
301 auto dbus_action_group = g_dbus_action_group_get(connection, BUS_NAME, BUS_PATH);
302 auto action_group = G_ACTION_GROUP(dbus_action_group);
303 auto names_strv = g_action_group_list_actions(action_group);
304 if (g_strv_length(names_strv) == 0)
305 {
306 g_strfreev(names_strv);
307 wait_for_signal(dbus_action_group, "action-added");
308 names_strv = g_action_group_list_actions(action_group);
309 }
310 g_clear_pointer(&names_strv, g_strfreev);
311
312 // SETUP: get the menu model and wait for it to be activated
313 auto phone_dbus_menu_model = g_dbus_menu_model_get(connection, BUS_NAME, BUS_PATH"/phone");
314 auto phone_menu_model = G_MENU_MODEL(phone_dbus_menu_model);
315 int n = g_menu_model_get_n_items(phone_menu_model);
316 if (!n)
317 {
318 // give the model a moment to populate its info
319 wait_msec(100);
320 n = g_menu_model_get_n_items(phone_menu_model);
321 }
322 EXPECT_TRUE(phone_menu_model != nullptr);
323 EXPECT_NE(0, n);
324
325 // test to confirm that a header menuitem exists
326 gchar* str = nullptr;
327 g_menu_model_get_item_attribute(phone_menu_model, 0, "x-canonical-type", "s", &str);
328 EXPECT_STREQ("com.canonical.indicator.root", str);
329 g_clear_pointer(&str, g_free);
330 g_menu_model_get_item_attribute(phone_menu_model, 0, G_MENU_ATTRIBUTE_ACTION, "s", &str);
331 const auto action_name = profile + "-header";
332 EXPECT_EQ(std::string("indicator.")+action_name, str);
333 g_clear_pointer(&str, g_free);
334
335 // cursory first look at the header
336 auto dict = g_action_group_get_action_state(action_group, action_name.c_str());
337 EXPECT_TRUE(dict != nullptr);
338 EXPECT_TRUE(g_variant_is_of_type(dict, G_VARIANT_TYPE_VARDICT));
339 auto v = g_variant_lookup_value(dict, "accessible-desc", G_VARIANT_TYPE_STRING);
340 EXPECT_TRUE(v != nullptr);
341 g_variant_unref(v);
342 v = g_variant_lookup_value(dict, "title", G_VARIANT_TYPE_STRING);
343 EXPECT_TRUE(v != nullptr);
344 EXPECT_STREQ(_("Files"), g_variant_get_string(v, nullptr));
345 g_variant_unref(v);
346 v = g_variant_lookup_value(dict, "visible", G_VARIANT_TYPE_BOOLEAN);
347 EXPECT_TRUE(g_variant_get_boolean(v));
348 EXPECT_TRUE(v != nullptr);
349 g_clear_pointer(&v, g_variant_unref);
350 g_clear_pointer(&dict, g_variant_unref);
351
352 // Visibility test #1:
353 // Change the model to all transfers finished.
354 // Confirm that the header is not visible.
355 for (auto& transfer : m_model->get_all())
356 {
357 transfer->state = Transfer::FINISHED;
358 m_model->emit_changed(transfer->id);
359 }
360
361 wait_msec(200);
362 EXPECT_FALSE(is_header_visible(action_group, action_name));
363
364 // Visibility test #2:
365 // Change the model to all transfers finished except one running.
366 // Confirm that the header is visible.
367 auto transfer = m_model->get("a");
368 transfer->state = Transfer::RUNNING;
369 m_model->emit_changed(transfer->id);
370 wait_msec(200);
371 EXPECT_TRUE(is_header_visible(action_group, action_name));
372
373 // Visibility test #3:
374 // Change the model to all transfers finished except one paused.
375 // Confirm that the header is visible.
376 transfer = m_model->get("a");
377 transfer->state = Transfer::PAUSED;
378 m_model->emit_changed(transfer->id);
379 wait_msec(200);
380 EXPECT_TRUE(is_header_visible(action_group, action_name));
381
382 // Visibility test #4:
383 // Remove all the transfers from the menu.
384 // Confirm that the header is not visible.
385 for (const auto& id : m_model->get_ids())
386 m_model->remove(id);
387 wait_msec(200);
388 EXPECT_FALSE(is_header_visible(action_group, action_name));
389
390 // cleanup
391 g_clear_object(&action_group);
392 g_clear_object(&phone_dbus_menu_model);
393 g_clear_object(&connection);
394}
395
396/***
397****
271**** GMenu398**** GMenu
272****399****
273***/400***/
@@ -296,4 +423,3 @@
296 g_clear_object(&dbus_menu_model);423 g_clear_object(&dbus_menu_model);
297 g_clear_object(&connection);424 g_clear_object(&connection);
298}425}
299

Subscribers

People subscribed via source and target branches