Merge lp:~brandontschaefer/unity/ap-panel-test-fix into lp:unity

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3276
Proposed branch: lp:~brandontschaefer/unity/ap-panel-test-fix
Merge into: lp:unity
Diff against target: 235 lines (+100/-67)
4 files modified
tests/autopilot/unity/emulators/dash.py (+20/-0)
tests/autopilot/unity/tests/test_panel.py (+65/-66)
unity-shared/OverlayWindowButtons.cpp (+11/-0)
unity-shared/OverlayWindowButtons.h (+4/-1)
To merge this branch: bzr merge lp:~brandontschaefer/unity/ap-panel-test-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Azzarone (community) Approve
Review via email: mp+156064@code.launchpad.net

Commit message

Make test_panel.py use the OverlayWindowButtons when dealing with the dash window buttons. Fixes: test_window_buttons_maximization_buttons_works_for_dash, also splits that test into these: test_window_buttons_maximize_or_restore_dash, test_window_buttons_active_inactive_states, test_window_buttons_state_switch_on_click.

Description of the change

Splits this test:
- test_window_buttons_maximization_buttons_works_for_dash

Into these 3:
- test_window_buttons_maximize_or_restore_dash
- test_window_buttons_active_inactive_states
- test_window_buttons_state_switch_on_click

While fixing the real problem of the panel window buttons being used vs the Overlay window buttons that should be used.

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

Err, did I not merge this?

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

Seems like that commit created issues, at least one of the test is failing to pass on today's runs:

http://10.97.0.1:8080/job/ps-generic-autopilot-release-testing/label=autopilot-ati/18/testReport/unity.tests.test_panel/PanelWindowButtonsTests/test_window_buttons_active_inactive_states_Single_Monitor_/

"Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/unity/tests/test_panel.py", line 541, in test_window_buttons_active_inactive_states
    unmaximize = self.unity.dash.view.window_buttons.unmaximize
  File "/usr/lib/python2.7/dist-packages/unity/emulators/dash.py", line 191, in window_buttons
    return self.__get_window_buttons().window_buttons()
  File "/usr/lib/python2.7/dist-packages/unity/emulators/dash.py", line 164, in __get_window_buttons
    assert(len(buttons) == 1)
AssertionError"

seems like
"buttons = self.get_children_by_type(OverlayWindowButtons)"

returns [] (tested on a local run, it's happening in a consistant way)

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

O dang, sorry, Ill look into that!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/unity/emulators/dash.py'
2--- tests/autopilot/unity/emulators/dash.py 2013-02-04 19:54:47 +0000
3+++ tests/autopilot/unity/emulators/dash.py 2013-03-28 20:24:29 +0000
4@@ -13,6 +13,8 @@
5 from autopilot.keybindings import KeybindingsHelper
6 from testtools.matchers import GreaterThan
7
8+from unity.emulators.panel import WindowButtons
9+
10 from unity.emulators import UnityIntrospectionObject
11 import logging
12 import dbus
13@@ -148,6 +150,12 @@
14 class DashView(UnityIntrospectionObject):
15 """The dash view."""
16
17+ def __get_window_buttons(self):
18+ """Return the overlay window buttons view."""
19+ buttons = self.get_children_by_type(OverlayWindowButtons)
20+ assert(len(buttons) == 1)
21+ return buttons[0]
22+
23 def get_searchbar(self):
24 """Get the search bar attached to this dash view."""
25 return self.get_children_by_type(SearchBar)[0]
26@@ -170,6 +178,18 @@
27 return preview_container
28 return None
29
30+ @property
31+ def window_buttons(self):
32+ return self.__get_window_buttons().window_buttons()
33+
34+
35+class OverlayWindowButtons(UnityIntrospectionObject):
36+ """The Overlay window buttons class"""
37+
38+ def window_buttons(self):
39+ buttons = self.get_children_by_type(WindowButtons)
40+ assert(len(buttons) == 1)
41+ return buttons[0]
42
43 class SearchBar(UnityIntrospectionObject):
44 """The search bar for the dash view."""
45
46=== modified file 'tests/autopilot/unity/tests/test_panel.py'
47--- tests/autopilot/unity/tests/test_panel.py 2013-02-26 16:19:15 +0000
48+++ tests/autopilot/unity/tests/test_panel.py 2013-03-28 20:24:29 +0000
49@@ -516,72 +516,71 @@
50 sleep(5)
51 self.assertThat(self.unity.dash.visible, Eventually(Equals(True)))
52
53- def test_window_buttons_maximization_buttons_works_for_dash(self):
54- """'Maximize' and 'Restore' buttons (when both enabled) must work as expected."""
55- # Mega-TODO:
56- #
57- # This test is terrible. The docstring is terrible. The test id is terrible.
58- # Someone needs to split this into several smaller tests. However, I'm
59- # not doing that in this branch. Consider this an invitation to split
60- # this test out and make it suck less.
61- #
62- # For your sanity I have annotated it with comments.
63- self.unity.dash.ensure_visible()
64- self.addCleanup(self.panel.window_buttons.close.mouse_click)
65-
66- unmaximize = self.panel.window_buttons.unmaximize
67- maximize = self.panel.window_buttons.maximize
68-
69- # "netbook" means "dash is maximised"
70- dash_maximised = (self.unity.dash.view.form_factor == "netbook")
71-
72- # this if statement will trigger only when we're on very small screens,
73- # where it doesn't make sense to have the dash anything other than
74- # maximised.
75- if dash_maximised and not unmaximize.enabled:
76- unmaximize.mouse_click()
77- # nice long sleep to make sure that any changes have time to process.
78- sleep(5)
79- self.assertThat(self.unity.dash.view.form_factor, Equals("netbook"))
80- else:
81- # we are able to resize the dash.
82- # maximise and unmaximise (restore) buttons are shown in the same place
83- # but only one is shown at once:
84- if maximize.visible:
85- active_button = maximize
86- inactive_button = unmaximize
87- else:
88- active_button = unmaximize
89- inactive_button = maximize
90-
91- self.assertThat(active_button.visible, Eventually(Equals(True)))
92- self.assertThat(active_button.sensitive, Eventually(Equals(True)))
93- self.assertThat(active_button.enabled, Eventually(Equals(True)))
94- self.assertThat(inactive_button.visible, Eventually(Equals(False)))
95-
96- self.addCleanup(inactive_button.mouse_click)
97- active_button.mouse_click()
98-
99- self.assertThat(inactive_button.visible, Eventually(Equals(True)))
100- self.assertThat(inactive_button.sensitive, Eventually(Equals(True)))
101- self.assertThat(inactive_button.enabled, Eventually(Equals(True)))
102- self.assertThat(active_button.visible, Eventually(Equals(False)))
103-
104- if dash_maximised:
105- self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("desktop")))
106- else:
107- self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("netbook")))
108-
109- self.addCleanup(active_button.mouse_click)
110- inactive_button.mouse_click()
111-
112- self.assertThat(active_button.visible, Eventually(Equals(True)))
113- self.assertThat(inactive_button.visible, Eventually(Equals(False)))
114-
115- if dash_maximised:
116- self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("netbook")))
117- else:
118- self.assertThat(self.unity.dash.view.form_factor, Eventually(Equals("desktop")))
119+ def test_window_buttons_maximize_or_restore_dash(self):
120+ """Tests that the Maximize/Restore button works for the dash."""
121+
122+ self.unity.dash.ensure_visible()
123+ self.addCleanup(self.unity.dash.ensure_hidden)
124+
125+ desired_max = not self.unity.dash.view.dash_maximized
126+ if desired_max:
127+ self.panel.window_buttons.maximize.mouse_click()
128+ else:
129+ self.panel.window_buttons.unmaximize.mouse_click()
130+
131+ self.assertThat(self.unity.dash.view.dash_maximized, Eventually(Equals(desired_max)))
132+
133+ def test_window_buttons_active_inactive_states(self):
134+ """Tests that the maximized/restore buttons are in the correct state when the
135+ dash is open. Asserting states: visible, sensitive, enabled.
136+ """
137+
138+ self.unity.dash.ensure_visible()
139+ self.addCleanup(self.unity.dash.ensure_hidden)
140+
141+ unmaximize = self.unity.dash.view.window_buttons.unmaximize
142+ maximize = self.unity.dash.view.window_buttons.maximize
143+
144+ desired_max = not self.unity.dash.view.dash_maximized
145+ if desired_max:
146+ active = maximize
147+ inactive = unmaximize
148+ else:
149+ active = unmaximize
150+ inactive = maximize
151+
152+ self.assertThat(active.visible, Eventually(Equals(True)))
153+ self.assertThat(active.sensitive, Eventually(Equals(True)))
154+ self.assertThat(active.enabled, Eventually(Equals(True)))
155+ self.assertThat(inactive.visible, Eventually(Equals(False)))
156+
157+ def test_window_buttons_state_switch_on_click(self):
158+ """Tests that when clicking the maximize/restore window button it
159+ switchs its state from either maximize to restore, or restore to
160+ maximize.
161+ """
162+
163+ self.unity.dash.ensure_visible()
164+ self.addCleanup(self.unity.dash.ensure_hidden)
165+
166+ unmaximize = self.unity.dash.view.window_buttons.unmaximize
167+ maximize = self.unity.dash.view.window_buttons.maximize
168+
169+ desired_max = not self.unity.dash.view.dash_maximized
170+ if desired_max:
171+ active = maximize
172+ inactive = unmaximize
173+ else:
174+ active = unmaximize
175+ inactive = maximize
176+
177+ active.mouse_click()
178+
179+ self.assertThat(inactive.visible, Eventually(Equals(True)))
180+ self.assertThat(inactive.sensitive, Eventually(Equals(True)))
181+ self.assertThat(inactive.enabled, Eventually(Equals(True)))
182+ self.assertThat(active.visible, Eventually(Equals(False)))
183+ self.assertThat(self.unity.dash.view.dash_maximized, Eventually(Equals(desired_max)))
184
185 def test_minimize_button_disabled_for_non_minimizable_windows(self):
186 """Minimize button must be disabled for windows that don't support minimization."""
187
188=== modified file 'unity-shared/OverlayWindowButtons.cpp'
189--- unity-shared/OverlayWindowButtons.cpp 2013-02-08 20:23:28 +0000
190+++ unity-shared/OverlayWindowButtons.cpp 2013-03-28 20:24:29 +0000
191@@ -36,6 +36,7 @@
192 : nux::BaseWindow("OverlayWindowButtons")
193 , window_buttons_(new WindowButtons())
194 {
195+ AddChild(window_buttons_.GetPointer());
196 UpdateGeometry();
197 SetBackgroundColor(nux::color::Transparent);
198 }
199@@ -86,4 +87,14 @@
200 window_buttons_->ProcessDraw(gfx_context, true);
201 }
202
203+
204+// Introspection
205+std::string OverlayWindowButtons::GetName() const
206+{
207+ return "OverlayWindowButtons";
208+}
209+
210+void OverlayWindowButtons::AddProperties(GVariantBuilder* builder)
211+{}
212+
213 } // namespace unity
214
215=== modified file 'unity-shared/OverlayWindowButtons.h'
216--- unity-shared/OverlayWindowButtons.h 2013-01-29 00:32:06 +0000
217+++ unity-shared/OverlayWindowButtons.h 2013-03-28 20:24:29 +0000
218@@ -28,7 +28,7 @@
219 namespace unity
220 {
221
222-class OverlayWindowButtons : public nux::BaseWindow
223+class OverlayWindowButtons : public nux::BaseWindow, public debug::Introspectable
224 {
225 NUX_DECLARE_OBJECT_TYPE(OverlayWindowButtons, nux::BaseWindow);
226 public:
227@@ -43,6 +43,9 @@
228 protected:
229 void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
230
231+ std::string GetName() const;
232+ void AddProperties(GVariantBuilder* builder);
233+
234 private:
235 void UpdateGeometry();
236