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

Proposed by Andrea Azzarone
Status: Merged
Approved by: Omer Akram
Approved revision: no longer in the source branch.
Merged at revision: 2619
Proposed branch: lp:~azzar1/unity/fix-1028810
Merge into: lp:unity
Diff against target: 181 lines (+68/-11)
6 files modified
dash/DashView.cpp (+5/-2)
dash/FilterExpanderLabel.cpp (+11/-8)
dash/FilterExpanderLabel.h (+2/-0)
dash/FilterRatingsButton.cpp (+2/-1)
tests/autopilot/unity/emulators/dash.py (+20/-0)
tests/autopilot/unity/tests/test_dash.py (+28/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-1028810
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Tim Penhey (community) Needs Information
Francis Ginther Abstain
jenkins (community) continuous-integration Needs Fixing
Review via email: mp+116744@code.launchpad.net

Commit message

Fix bottom-up key navigation in dash filterbar.

Description of the change

== Problem ==
Bottom - Up key navigation is broken in dash filterbar

== Test ==
AP test added.

Requires lp:~andyrock/nux/fix-gridhlayout-bu-keynav.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) wrote :

Sorry for the jenkins failure. I'm looking into this.

Revision history for this message
Francis Ginther (fginther) wrote :

Review was claimed by accident, please ignore.

review: Abstain
Revision history for this message
Tim Penhey (thumper) wrote :

  FilterExpanderLabel* filter = dynamic_cast<FilterExpanderLabel*>(child);
  if (child)
    tabs.push_back(filter->expander_view());

Did you mean "if (filter)" ?

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

> FilterExpanderLabel* filter = dynamic_cast<FilterExpanderLabel*>(child);
> if (child)
> tabs.push_back(filter->expander_view());
>
> Did you mean "if (filter)" ?

Yes. Fixing.

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

Fixed.

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

Could you split up that AP tests into smaller ones? Or split some of the logic into smaller ones so it will be easy to figure out what is causing a potential problem later on.

Such as making a test that proves that it is getting to Filter Results, then a test that shows it can tab to the first filter result ... etc.

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

> Could you split up that AP tests into smaller ones? Or split some of the logic
> into smaller ones so it will be easy to figure out what is causing a potential
> problem later on.

Hey I missed this comment, sorry!

>
> Such as making a test that proves that it is getting to Filter Results, then a
> test that shows it can tab to the first filter result ... etc.

We already have these tests.

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

Awesome then! Looks good!

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1114/console reported an error when processing this lp:~andyrock/unity/fix-1028810 branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1115/console reported an error when processing this lp:~andyrock/unity/fix-1028810 branch.
Not merging it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dash/DashView.cpp'
--- dash/DashView.cpp 2012-08-22 10:04:18 +0000
+++ dash/DashView.cpp 2012-08-22 14:09:41 +0000
@@ -29,6 +29,7 @@
29#include <UnityCore/GLibWrapper.h>29#include <UnityCore/GLibWrapper.h>
30#include <UnityCore/RadioOptionFilter.h>30#include <UnityCore/RadioOptionFilter.h>
3131
32#include "FilterExpanderLabel.h"
32#include "unity-shared/DashStyle.h"33#include "unity-shared/DashStyle.h"
33#include "unity-shared/KeyboardUtil.h"34#include "unity-shared/KeyboardUtil.h"
34#include "unity-shared/UnitySettings.h"35#include "unity-shared/UnitySettings.h"
@@ -969,9 +970,11 @@
969 if (active_lens_view_->filter_bar() && active_lens_view_->fscroll_view() &&970 if (active_lens_view_->filter_bar() && active_lens_view_->fscroll_view() &&
970 active_lens_view_->fscroll_view()->IsVisible())971 active_lens_view_->fscroll_view()->IsVisible())
971 {972 {
972 for (auto filter : active_lens_view_->filter_bar()->GetLayout()->GetChildren())973 for (auto child : active_lens_view_->filter_bar()->GetLayout()->GetChildren())
973 {974 {
974 tabs.push_back(filter);975 FilterExpanderLabel* filter = dynamic_cast<FilterExpanderLabel*>(child);
976 if (filter)
977 tabs.push_back(filter->expander_view());
975 }978 }
976 }979 }
977980
978981
=== modified file 'dash/FilterExpanderLabel.cpp'
--- dash/FilterExpanderLabel.cpp 2012-05-07 22:28:17 +0000
+++ dash/FilterExpanderLabel.cpp 2012-08-22 14:09:41 +0000
@@ -96,7 +96,6 @@
96{96{
97 expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));97 expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
98 BuildLayout();98 BuildLayout();
99 SetAcceptKeyNavFocusOnMouseDown(false);
10099
101 separator_ = new HSeparator;100 separator_ = new HSeparator;
102 separator_->SinkReference();101 separator_->SinkReference();
@@ -227,11 +226,6 @@
227 expander_view_->key_nav_focus_activate.connect(key_expand);226 expander_view_->key_nav_focus_activate.connect(key_expand);
228 cairo_label_->mouse_click.connect(mouse_expand);227 cairo_label_->mouse_click.connect(mouse_expand);
229 expand_icon_->mouse_click.connect(mouse_expand);228 expand_icon_->mouse_click.connect(mouse_expand);
230 key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
231 {
232 if(has_focus)
233 nux::GetWindowCompositor().SetKeyFocusArea(expander_view_);
234 });
235229
236 QueueRelayout();230 QueueRelayout();
237 NeedRedraw();231 NeedRedraw();
@@ -304,7 +298,7 @@
304//298//
305bool FilterExpanderLabel::AcceptKeyNavFocus()299bool FilterExpanderLabel::AcceptKeyNavFocus()
306{300{
307 return true;301 return false;
308}302}
309303
310//304//
@@ -317,9 +311,18 @@
317311
318void FilterExpanderLabel::AddProperties(GVariantBuilder* builder)312void FilterExpanderLabel::AddProperties(GVariantBuilder* builder)
319{313{
314 bool content_has_focus = false;
315 auto focus_area = nux::GetWindowCompositor().GetKeyFocusArea();
316
317 if (focus_area && contents_)
318 content_has_focus = focus_area->IsChildOf(contents_.GetPointer());
319
320 unity::variant::BuilderWrapper wrapper(builder);320 unity::variant::BuilderWrapper wrapper(builder);
321321
322 wrapper.add("expander-has-focus", expander_view_->HasKeyFocus());322 wrapper.add("expander-has-focus", (expander_view_ && expander_view_->HasKeyFocus()))
323 .add("expanded", expanded())
324 .add(GetAbsoluteGeometry())
325 .add("content-has-focus", content_has_focus);
323}326}
324327
325} // namespace dash328} // namespace dash
326329
=== modified file 'dash/FilterExpanderLabel.h'
--- dash/FilterExpanderLabel.h 2012-05-06 23:48:38 +0000
+++ dash/FilterExpanderLabel.h 2012-08-22 14:09:41 +0000
@@ -63,6 +63,8 @@
63 virtual void SetFilter(Filter::Ptr const& filter) = 0;63 virtual void SetFilter(Filter::Ptr const& filter) = 0;
64 virtual std::string GetFilterType() = 0;64 virtual std::string GetFilterType() = 0;
6565
66 nux::View* expander_view() const { return expander_view_; }
67
66 nux::Property<bool> expanded;68 nux::Property<bool> expanded;
67 nux::Property<bool> draw_separator;69 nux::Property<bool> draw_separator;
6870
6971
=== modified file 'dash/FilterRatingsButton.cpp'
--- dash/FilterRatingsButton.cpp 2012-05-06 23:48:38 +0000
+++ dash/FilterRatingsButton.cpp 2012-08-22 14:09:41 +0000
@@ -51,13 +51,14 @@
5151
52 key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)52 key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
53 {53 {
54 if (has_focus && direction != nux::KEY_NAV_NONE)54 if (has_focus)
55 focused_star_ = 0;55 focused_star_ = 0;
56 else if (!has_focus)56 else if (!has_focus)
57 focused_star_ = -1;57 focused_star_ = -1;
5858
59 QueueDraw();59 QueueDraw();
60 });60 });
61
61 key_nav_focus_activate.connect([&](nux::Area*) { filter_->rating = static_cast<float>(focused_star_+1)/num_stars; });62 key_nav_focus_activate.connect([&](nux::Area*) { filter_->rating = static_cast<float>(focused_star_+1)/num_stars; });
62 key_down.connect(sigc::mem_fun(this, &FilterRatingsButton::OnKeyDown));63 key_down.connect(sigc::mem_fun(this, &FilterRatingsButton::OnKeyDown));
63}64}
6465
=== modified file 'tests/autopilot/unity/emulators/dash.py'
--- tests/autopilot/unity/emulators/dash.py 2012-08-20 15:12:27 +0000
+++ tests/autopilot/unity/emulators/dash.py 2012-08-22 14:09:41 +0000
@@ -332,6 +332,26 @@
332class FilterExpanderLabel(UnityIntrospectionObject):332class FilterExpanderLabel(UnityIntrospectionObject):
333 """A label that expands into a filter within a filter bar."""333 """A label that expands into a filter within a filter bar."""
334334
335 def ensure_expanded(self):
336 """Expand the filter expander label, if it's not already"""
337 if not self.expanded:
338 tx = x + width / 2
339 ty = y + height / 2
340 m = Mouse()
341 m.move(tx, ty)
342 m.click()
343 self.expanded.wait_for(True)
344
345 def ensure_collapsed(self):
346 """Collapse the filter expander label, if it's not already"""
347 if self.expanded:
348 tx = x + width / 2
349 ty = y + height / 2
350 m = Mouse()
351 m.move(tx, ty)
352 m.click()
353 self.expanded.wait_for(False)
354
335355
336class CoverArt(UnityIntrospectionObject):356class CoverArt(UnityIntrospectionObject):
337 """A view which can be used to show a texture, or generate one using a thumbnailer."""357 """A view which can be used to show a texture, or generate one using a thumbnailer."""
338358
=== modified file 'tests/autopilot/unity/tests/test_dash.py'
--- tests/autopilot/unity/tests/test_dash.py 2012-08-22 08:16:02 +0000
+++ tests/autopilot/unity/tests/test_dash.py 2012-08-22 14:09:41 +0000
@@ -284,6 +284,34 @@
284 category = lens.get_focused_category()284 category = lens.get_focused_category()
285 self.assertIsNot(category, None)285 self.assertIsNot(category, None)
286286
287 def test_bottom_up_keynav_with_filter_bar(self):
288 """This test makes sure that bottom-up key navigation works well
289 in the dash filter bar.
290 """
291 self.dash.reveal_application_lens()
292 lens = self.dash.get_current_lens()
293
294 filter_bar = lens.get_filterbar()
295 filter_bar.ensure_expanded()
296
297 # Tab to fist filter expander
298 self.keyboard.press_and_release('Tab')
299 self.assertThat(lambda: filter_bar.get_focused_filter(), Eventually(NotEquals(None)))
300 old_focused_filter = filter_bar.get_focused_filter()
301 old_focused_filter.ensure_expanded()
302
303 # Tab to the next filter expander
304 self.keyboard.press_and_release('Tab')
305 self.assertThat(lambda: filter_bar.get_focused_filter(), Eventually(NotEquals(None)))
306 new_focused_filter = filter_bar.get_focused_filter()
307 self.assertNotEqual(old_focused_filter, new_focused_filter)
308 new_focused_filter.ensure_expanded()
309
310 # Move the focus up.
311 self.keyboard.press_and_release("Up")
312 self.assertThat(lambda: filter_bar.get_focused_filter(), Eventually(Equals(None)))
313 self.assertThat(old_focused_filter.content_has_focus, Eventually(Equals(True)))
314
287315
288class DashClipboardTests(DashTestCase):316class DashClipboardTests(DashTestCase):
289 """Test the Unity clipboard"""317 """Test the Unity clipboard"""