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

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 2412
Proposed branch: lp:~azzar1/unity/fix-979686
Merge into: lp:unity
Diff against target: 104 lines (+37/-7)
3 files modified
dash/PlacesGroup.cpp (+10/-7)
tests/autopilot/unity/emulators/dash.py (+4/-0)
tests/autopilot/unity/tests/test_dash.py (+23/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-979686
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Review via email: mp+109075@code.launchpad.net

Commit message

Fix inconsistent hover/highlight/clickable area behavior.

Description of the change

== Problem ==
Dash: Inconsistent hover/highlight/clickable area behavior

== Fix ==
Expand the HeaderView.

== Test ==
AP test added. The test doesn't work for me because self.dash.reveal_file_lens() is broken for some reasons on my machine. If I manually show the file lens during the test execution everything is ok.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

The test works and passes for me on my machine. However, i'd appreciate it if you could change your test a little bit:

First, please replace "should" in your docstring to "must".
56 + def setUp(self):
57 + super(CategoryHeaderTests, self).setUp()
58 + self.dash.reveal_file_lens()
59 + self.lens = self.dash.get_current_lens()

These lines of code don't belong in setUp(). They're not setting up the test environment for the test - they're part of the test execution. I'd be happy if you wanted to change the reveal_foo_lens methods to return the revealed lens, so this is one line instead of two. I'd also be happy if you wanted to put these lines of code into a separate method and call it from the start of your test.

Also, if this test fails, you will be leaving the dash open. Can you please add a :

self.addCleanup(self.dash.ensure_hidden) right after you reveal the application lens please? If your test passes, this is a no-op, so it's quite safe.

Finally, is there a way we can make this test leave the lens in the same state as it found it? Can we un-expand the category header as well? Maybe add a second assert, so we know that clicking in that spot will bot expand and collapse the category header? What do you think?

Cheers,

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

> Hi,
>
> The test works and passes for me on my machine. However, i'd appreciate it if
> you could change your test a little bit:
>
> First, please replace "should" in your docstring to "must".
> 56 + def setUp(self):
> 57 + super(CategoryHeaderTests, self).setUp()
> 58 + self.dash.reveal_file_lens()
> 59 + self.lens = self.dash.get_current_lens()
>
> These lines of code don't belong in setUp(). They're not setting up the test
> environment for the test - they're part of the test execution. I'd be happy if
> you wanted to change the reveal_foo_lens methods to return the revealed lens,
> so this is one line instead of two. I'd also be happy if you wanted to put
> these lines of code into a separate method and call it from the start of your
> test.
>
> Also, if this test fails, you will be leaving the dash open. Can you please
> add a :
>
> self.addCleanup(self.dash.ensure_hidden) right after you reveal the
> application lens please? If your test passes, this is a no-op, so it's quite
> safe.
>
> Finally, is there a way we can make this test leave the lens in the same state
> as it found it? Can we un-expand the category header as well? Maybe add a
> second assert, so we know that clicking in that spot will bot expand and
> collapse the category header? What do you think?
>
>
> Cheers,

Done. What do you think now?

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/PlacesGroup.cpp'
2--- dash/PlacesGroup.cpp 2012-05-07 22:28:17 +0000
3+++ dash/PlacesGroup.cpp 2012-06-11 10:35:23 +0000
4@@ -86,8 +86,12 @@
5
6 void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
7 {
8- if (GetLayout())
9+ if (IsFullRedraw() && GetLayout())
10+ {
11+ nux::GetPainter().PushPaintLayerStack();
12 GetLayout()->ProcessDraw(graphics_engine, force_draw);
13+ nux::GetPainter().PopPaintLayerStack();
14+ }
15 }
16
17 bool AcceptKeyNavFocus()
18@@ -97,12 +101,11 @@
19
20 nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
21 {
22- bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
23-
24- if (mouse_inside == false)
25+ if (event_type != nux::EVENT_MOUSE_WHEEL &&
26+ TestMousePointerInclusion(mouse_position, event_type))
27+ return this;
28+ else
29 return nullptr;
30-
31- return this;
32 }
33 };
34
35@@ -134,7 +137,7 @@
36 _group_layout->AddLayout(new nux::SpaceLayout(top_space, top_space, top_space, top_space), 0);
37
38 _header_view = new HeaderView(NUX_TRACKER_LOCATION);
39- _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FIX);
40+ _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL);
41
42 _header_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
43 _header_layout->SetLeftAndRightPadding(style.GetCategoryHeaderLeftPadding(), 0);
44
45=== modified file 'tests/autopilot/unity/emulators/dash.py'
46--- tests/autopilot/unity/emulators/dash.py 2012-05-08 16:13:17 +0000
47+++ tests/autopilot/unity/emulators/dash.py 2012-06-11 10:35:23 +0000
48@@ -103,21 +103,25 @@
49 """Reveal the application lense."""
50 logger.debug("Revealing application lens with Super+a.")
51 self._reveal_lens("lens_reveal/apps", clear_search)
52+ return self.view.get_lensview_by_name("applications.lens")
53
54 def reveal_music_lens(self, clear_search=True):
55 """Reveal the music lense."""
56 logger.debug("Revealing music lens with Super+m.")
57 self._reveal_lens("lens_reveal/music", clear_search)
58+ return self.view.get_lensview_by_name("music.lens")
59
60 def reveal_file_lens(self, clear_search=True):
61 """Reveal the file lense."""
62 logger.debug("Revealing file lens with Super+f.")
63 self._reveal_lens("lens_reveal/files", clear_search)
64+ return self.view.get_lensview_by_name("files.lens")
65
66 def reveal_command_lens(self, clear_search=True):
67 """Reveal the 'run command' lens."""
68 logger.debug("Revealing command lens with Alt+F2.")
69 self._reveal_lens("lens_reveal/command", clear_search)
70+ return self.view.get_lensview_by_name("commands.lens")
71
72 def _reveal_lens(self, binding_name, clear_search):
73 self.keybinding_hold(binding_name)
74
75=== modified file 'tests/autopilot/unity/tests/test_dash.py'
76--- tests/autopilot/unity/tests/test_dash.py 2012-05-08 16:13:17 +0000
77+++ tests/autopilot/unity/tests/test_dash.py 2012-06-11 10:35:23 +0000
78@@ -489,3 +489,26 @@
79
80 self.assertThat(self.dash.visible, Eventually(Equals(True)))
81
82+
83+class CategoryHeaderTests(DashTestCase):
84+ """Tests that category headers work.
85+ """
86+ def test_click_inside_highlight(self):
87+ """Clicking into a category highlight must expand/collapse
88+ the view.
89+ """
90+ lens = self.dash.reveal_file_lens()
91+ self.addCleanup(self.dash.ensure_hidden)
92+
93+ category = lens.get_category_by_name("Folders")
94+ is_expanded = category.is_expanded
95+
96+ self.mouse.move(self.dash.view.x + self.dash.view.width / 2,
97+ category.header_y + category.header_height / 2)
98+
99+ self.mouse.click()
100+ self.assertThat(category.is_expanded, Eventually(Equals(not is_expanded)))
101+
102+ self.mouse.click()
103+ self.assertThat(category.is_expanded, Eventually(Equals(is_expanded)))
104+