Merge lp:~nick-dedekind/unity/lp1045831.menu-key-previews into lp:unity

Proposed by Nick Dedekind
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2747
Proposed branch: lp:~nick-dedekind/unity/lp1045831.menu-key-previews
Merge into: lp:unity
Diff against target: 109 lines (+35/-5)
3 files modified
dash/ResultViewGrid.cpp (+12/-0)
tests/autopilot/unity/emulators/dash.py (+8/-0)
tests/autopilot/unity/tests/test_dash.py (+15/-5)
To merge this branch: bzr merge lp:~nick-dedekind/unity/lp1045831.menu-key-previews
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Andrea Azzarone (community) Needs Fixing
Review via email: mp+125434@code.launchpad.net

Commit message

Menu key opens preview for selected item in dash lens.

Description of the change

Menu key opens preview for selected item in dash lens.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Can you add an AP test?

review: Needs Fixing
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Added key activation AP test.

Revision history for this message
Omer Akram (om26er) wrote :

58 + """Right-clicking on an application lens result must show
59 + its preview.

I think it would be better if the docstring was something like:
pressing menu key over a dash result must open its preview

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Updated AP test comment.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Looks good to me now :).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/ResultViewGrid.cpp'
2--- dash/ResultViewGrid.cpp 2012-09-20 11:07:27 +0000
3+++ dash/ResultViewGrid.cpp 2012-09-21 11:14:24 +0000
4@@ -347,6 +347,8 @@
5 case NUX_KP_ENTER:
6 direction = nux::KeyNavDirection::KEY_NAV_ENTER;
7 break;
8+ case XK_Menu:
9+ return true;
10 default:
11 direction = nux::KeyNavDirection::KEY_NAV_NONE;
12 break;
13@@ -478,6 +480,16 @@
14 ubus_.SendMessage(UBUS_RESULT_VIEW_KEYNAV_CHANGED,
15 g_variant_new("(iiii)", focused_x, focused_y, renderer_->width(), renderer_->height()));
16 selection_change.emit();
17+
18+ if (event_type == nux::NUX_KEYDOWN && event_keysym == XK_Menu)
19+ {
20+ UriActivated.emit (focused_uri_, ResultView::ActivateType::PREVIEW);
21+ int left_results = selected_index_;
22+ int right_results = (num_results - selected_index_) - 1;
23+ //FIXME - just uses y right now, needs to use the absolute position of the bottom of the result
24+ ubus_.SendMessage(UBUS_DASH_PREVIEW_INFO_PAYLOAD,
25+ g_variant_new("(iii)", mouse_last_y_, left_results, right_results));
26+ }
27 }
28
29 nux::Area* ResultViewGrid::KeyNavIteration(nux::KeyNavDirection direction)
30
31=== modified file 'tests/autopilot/unity/emulators/dash.py'
32--- tests/autopilot/unity/emulators/dash.py 2012-09-18 13:25:17 +0000
33+++ tests/autopilot/unity/emulators/dash.py 2012-09-21 11:14:24 +0000
34@@ -288,6 +288,14 @@
35 m.move(tx, ty)
36 m.click(3)
37
38+ def preview_key(self):
39+ tx = self.x + (self.width / 2)
40+ ty = self.y + (self.height / 2)
41+ m = Mouse()
42+ m.move(tx, ty)
43+
44+ k = Keyboard()
45+ k.press_and_release('Menu')
46
47 class FilterBar(UnityIntrospectionObject):
48 """A filterbar, as shown inside a lens."""
49
50=== modified file 'tests/autopilot/unity/tests/test_dash.py'
51--- tests/autopilot/unity/tests/test_dash.py 2012-09-18 13:25:17 +0000
52+++ tests/autopilot/unity/tests/test_dash.py 2012-09-21 11:14:24 +0000
53@@ -660,9 +660,7 @@
54 class PreviewInvocationTests(DashTestCase):
55 """Tests that dash previews can be opened and closed in different
56 lenses.
57-
58 """
59-
60 def test_app_lens_preview_open_close(self):
61 """Right-clicking on an application lens result must show
62 its preview.
63@@ -685,7 +683,6 @@
64 def test_files_lens_preview_open_close(self):
65 """Right-clicking on a files lens result must show its
66 preview.
67-
68 """
69 lens = self.dash.reveal_file_lens()
70 self.addCleanup(self.dash.ensure_hidden)
71@@ -704,7 +701,6 @@
72 def test_music_lens_preview_open_close(self):
73 """Right-clicking on a music lens result must show its
74 preview.
75-
76 """
77 lens = self.dash.reveal_music_lens()
78 self.addCleanup(self.dash.ensure_hidden)
79@@ -729,8 +725,8 @@
80 def test_video_lens_preview_open_close(self):
81 """Right-clicking on a video lens result must show its
82 preview.
83+ """
84
85- """
86 def get_category(lens):
87 category = lens.get_category_by_name("Recently Viewed")
88 # If there was no video played on this system this category is expected
89@@ -759,6 +755,20 @@
90
91 self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
92
93+ def test_preview_key(self):
94+ """Pressing menu key on a selected dash result must show
95+ its preview.
96+ """
97+ lens = self.dash.reveal_application_lens()
98+ self.addCleanup(self.dash.ensure_hidden)
99+
100+ category = lens.get_category_by_name("Installed")
101+ results = category.get_results()
102+ result = results[0]
103+ # result.preview_key() handles finding xy co-ords and key press
104+ result.preview_key()
105+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(True)))
106+
107
108 class PreviewNavigateTests(DashTestCase):
109 """Tests that mouse navigation works with previews."""