Merge lp:~townsend/unity/unity.lp1046315 into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3043
Proposed branch: lp:~townsend/unity/unity.lp1046315
Merge into: lp:unity
Diff against target: 1135 lines (+349/-26)
19 files modified
dash/previews/ApplicationPreview.cpp (+21/-0)
dash/previews/GenericPreview.cpp (+13/-0)
dash/previews/MoviePreview.cpp (+14/-0)
dash/previews/MusicPreview.cpp (+11/-0)
dash/previews/Preview.cpp (+9/-7)
dash/previews/Preview.h (+7/-3)
dash/previews/PreviewContainer.cpp (+4/-3)
dash/previews/PreviewContainer.h (+3/-2)
dash/previews/PreviewInfoHintWidget.cpp (+6/-1)
dash/previews/PreviewInfoHintWidget.h (+7/-1)
dash/previews/PreviewRatingsWidget.cpp (+6/-1)
dash/previews/PreviewRatingsWidget.h (+5/-0)
dash/previews/SocialPreview.cpp (+15/-0)
dash/previews/SocialPreviewComments.cpp (+7/-0)
dash/previews/SocialPreviewComments.h (+5/-0)
tests/autopilot/unity/emulators/dash.py (+29/-1)
tests/autopilot/unity/tests/test_dash.py (+168/-6)
unity-shared/StaticCairoText.cpp (+12/-0)
unity-shared/StaticCairoText.h (+7/-1)
To merge this branch: bzr merge lp:~townsend/unity/unity.lp1046315
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Łukasz Zemczak test coverage Needs Fixing
PS Jenkins bot continuous-integration Pending
Review via email: mp+141966@code.launchpad.net

Commit message

Add support to close previews by either right, middle, or left clicking in the preview. (lp: #1046315)

Description of the change

This change is to add the capability to close a preview with just clicking a mouse button anywhere in the preview. Even though the bug says middle and right clicking, after discussing this with John Lea via email, it should be left, middle, or right clicking to close the preview.

Also, I reverterted a change I did in preview/Preview.h (PreviewInfoHintWidget::Ptr preview_info_hints_;) in order to avoid a nasty header circular dependency.

Added an AP test that iterates through various elements of the preview as well as iterates through left, middle, and right clicking.

To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looking nice. But I would also like this to have some automatic testing. Since some time we no longer accept manual test-cases as valid testing methods. This feature seems to be testable by using Autopilot - would be nice if such a test could be added. If you would need help, we can help.

review: Needs Fixing (test coverage)
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, thanks. I wasn't aware of the non-acceptance of manual tests. I will work on autmating the tests for this and will ping folks if I need help.

Revision history for this message
Christopher Townsend (townsend) wrote :

I've now added a new Autopilot test for this feature.

I also found a new bug with said new AP test and fixed that:)

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

329 + preview_container_ = new PreviewContainer();

Can we switch to use the ::Ptr typedef in PreviewContainer.h? As right now that looks like that leaks memory ;). (As I don't see a delete). Could you also put that into the init list?

Alright, so your AP test works, but it needs to be split up. Each click needs to be in its own test. ie.

-- This stuff can be in the setup function
Open Dash
(AddCleanup to close the dash)
Type Software Update
Right Click to go into Preview

--- Then make new functions for
- right clicking the IconTexture
- right clicking the Static Cairo
- etc.

As each AP test needs to test one thing, and assert one thing (Ideally).

You have everything working, and it looks good now its just refactoring them into specific tests ;).

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

384 - sigc::signal<void> request_close;
385 + sigc::signal<void> GetPreviewRequestClose() const;

Mhmmh, I see why you're using a getter here, however this could be confusing, I'd rename the method to keep the same style we use for signals (and so just "request_close()" or "preview_request_close()")

329 + preview_container_ = new PreviewContainer();

Why do you need to use a pointer here? Stack allocation should be fine...
However, it's not that clear to me why you need to create some new containers just only for the signal handling...

Revision history for this message
Christopher Townsend (townsend) wrote :

> 329 + preview_container_ = new PreviewContainer();
>
> Can we switch to use the ::Ptr typedef in PreviewContainer.h? As right now
> that looks like that leaks memory ;). (As I don't see a delete). Could you
> also put that into the init list?
I thought I tried creating preview_container statically, but I seem to recall that it didn't work. However, I'll try it again as you're right, this is a memory leak:)

>
>
> Alright, so your AP test works, but it needs to be split up. Each click needs
> to be in its own test. ie.
>
> -- This stuff can be in the setup function
> Open Dash
> (AddCleanup to close the dash)
> Type Software Update
> Right Click to go into Preview
>
>
> --- Then make new functions for
> - right clicking the IconTexture
> - right clicking the Static Cairo
> - etc.
>
>
> As each AP test needs to test one thing, and assert one thing (Ideally).
>
> You have everything working, and it looks good now its just refactoring them
> into specific tests ;).
Oh, ok. Sure, I'll split this up into one test. I was trying to avoid a bunch of code duplication, but since the rule is one test, I'll make it so.

Revision history for this message
Christopher Townsend (townsend) wrote :

> 384 - sigc::signal<void> request_close;
> 385 + sigc::signal<void> GetPreviewRequestClose() const;
>
> Mhmmh, I see why you're using a getter here, however this could be confusing,
> I'd rename the method to keep the same style we use for signals (and so just
> "request_close()" or "preview_request_close()")
Ok, will do.

>
> 329 + preview_container_ = new PreviewContainer();
>
> Why do you need to use a pointer here? Stack allocation should be fine...
> However, it's not that clear to me why you need to create some new containers
> just only for the signal handling...
I did this because I wanted all of the various instantiated classes (ie, PreviewContainer, the various derived Preview classes, PreviewInfoHintWidget, and PreviewRatingsWidget) to only have to use one single OnMouseDown() method. As you know, mem_fun() requires it's first argument (the object pointer) to match where the second argument (the function) comes from. Doing what I did is the only way I could figure out how to make this work. I agree that it seems like overkill to have to instantiate a whole class to do this. If you know of a better way, then I'm all for it:)

Revision history for this message
Christopher Townsend (townsend) wrote :

After looking at the code again, I know remember why I had to do this:

400 + PreviewContainer* preview_container_;

329 + preview_container_ = new PreviewContainer();

It's to avoid a silly circular header dependency issue between Preview.h and PreviewContainer.h.

I will take Brandon's advise and try to make the pointer of type nux::ObjectPtr.

Revision history for this message
Christopher Townsend (townsend) wrote :

I also updated the AP tests to break out testing into separate tests. There are now 15 total tests that tests left, middle, and right clicking on a few various parts of the preview.

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

Awesome, looks good to me :).

Test pass and manually testing works. Code changes look good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/ApplicationPreview.cpp'
2--- dash/previews/ApplicationPreview.cpp 2012-12-21 19:22:51 +0000
3+++ dash/previews/ApplicationPreview.cpp 2013-01-16 18:36:23 +0000
4@@ -37,6 +37,7 @@
5
6 #include "ApplicationPreview.h"
7 #include "ActionButton.h"
8+#include "PreviewInfoHintWidget.h"
9 #include "PreviewRatingsWidget.h"
10
11 namespace unity
12@@ -118,6 +119,8 @@
13
14 previews::Style& style = dash::previews::Style::Instance();
15
16+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
17+
18 nux::HLayout* image_data_layout = new nux::HLayout();
19 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
20
21@@ -144,8 +147,10 @@
22 nux::VLayout* icon_layout = new nux::VLayout();
23 icon_layout->SetSpaceBetweenChildren(3);
24 app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", 72);
25+ AddChild(app_icon_.GetPointer());
26 app_icon_->SetMinimumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());
27 app_icon_->SetMaximumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());
28+ app_icon_->mouse_click.connect(on_mouse_down);
29 icon_layout->AddView(app_icon_.GetPointer(), 0);
30
31 app_rating_ = new PreviewRatingsWidget();
32@@ -154,6 +159,7 @@
33 app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
34 app_rating_->SetRating(app_preview_model->rating);
35 app_rating_->SetReviews(app_preview_model->num_ratings);
36+ app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
37 icon_layout->AddView(app_rating_.GetPointer(), 0);
38
39 /////////////////////
40@@ -168,15 +174,19 @@
41 title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
42
43 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
44+ AddChild(title_.GetPointer());
45 title_->SetLines(-1);
46 title_->SetFont(style.title_font().c_str());
47+ title_->mouse_click.connect(on_mouse_down);
48 title_subtitle_layout_->AddView(title_.GetPointer(), 1);
49
50 if (!preview_model_->subtitle.Get().empty())
51 {
52 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
53+ AddChild(subtitle_.GetPointer());
54 subtitle_->SetFont(style.subtitle_size_font().c_str());
55 subtitle_->SetLines(-1);
56+ subtitle_->mouse_click.connect(on_mouse_down);
57 title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);
58 }
59
60@@ -186,8 +196,10 @@
61 if (!app_preview_model->license.Get().empty())
62 {
63 license_ = new StaticCairoText(app_preview_model->license, true, NUX_TRACKER_LOCATION);
64+ AddChild(license_.GetPointer());
65 license_->SetFont(style.app_license_font().c_str());
66 license_->SetLines(-1);
67+ license_->mouse_click.connect(on_mouse_down);
68 app_updated_copywrite_layout->AddView(license_.GetPointer(), 1);
69 }
70
71@@ -197,15 +209,19 @@
72 last_update << _("Last Updated") << " " << app_preview_model->last_update.Get();
73
74 last_update_ = new StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION);
75+ AddChild(last_update_.GetPointer());
76 last_update_->SetFont(style.app_last_update_font().c_str());
77+ last_update_->mouse_click.connect(on_mouse_down);
78 app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1);
79 }
80
81 if (!app_preview_model->copyright.Get().empty())
82 {
83 copywrite_ = new StaticCairoText(app_preview_model->copyright, true, NUX_TRACKER_LOCATION);
84+ AddChild(copywrite_.GetPointer());
85 copywrite_->SetFont(style.app_copywrite_font().c_str());
86 copywrite_->SetLines(-1);
87+ copywrite_->mouse_click.connect(on_mouse_down);
88 app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1);
89 }
90
91@@ -223,6 +239,7 @@
92 // Description
93 nux::ScrollView* app_info = new DetailsScrollView(NUX_TRACKER_LOCATION);
94 app_info->EnableHorizontalScrollBar(false);
95+ app_info->mouse_click.connect(on_mouse_down);
96
97 nux::VLayout* app_info_layout = new nux::VLayout();
98 app_info_layout->SetSpaceBetweenChildren(12);
99@@ -231,10 +248,12 @@
100 if (!preview_model_->description.Get().empty())
101 {
102 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
103+ AddChild(description_.GetPointer());
104 description_->SetFont(style.description_font().c_str());
105 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);
106 description_->SetLines(-style.GetDescriptionLineCount());
107 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
108+ description_->mouse_click.connect(on_mouse_down);
109 app_info_layout->AddView(description_.GetPointer());
110 }
111
112@@ -242,6 +261,7 @@
113 {
114 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
115 AddChild(preview_info_hints_.GetPointer());
116+ preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
117 app_info_layout->AddView(preview_info_hints_.GetPointer());
118 }
119 /////////////////////
120@@ -261,6 +281,7 @@
121 image_data_layout->AddView(image_.GetPointer(), 0);
122 image_data_layout->AddLayout(full_data_layout_, 1);
123
124+ mouse_click.connect(on_mouse_down);
125
126 SetLayout(image_data_layout);
127 }
128
129=== modified file 'dash/previews/GenericPreview.cpp'
130--- dash/previews/GenericPreview.cpp 2012-12-21 19:22:51 +0000
131+++ dash/previews/GenericPreview.cpp 2013-01-16 18:36:23 +0000
132@@ -32,6 +32,7 @@
133 #include <Nux/AbstractButton.h>
134
135 #include "GenericPreview.h"
136+#include "PreviewInfoHintWidget.h"
137
138 namespace unity
139 {
140@@ -110,6 +111,8 @@
141 }
142 previews::Style& style = dash::previews::Style::Instance();
143
144+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
145+
146 nux::HLayout* image_data_layout = new nux::HLayout();
147 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
148
149@@ -133,15 +136,19 @@
150 preview_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
151
152 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
153+ AddChild(title_.GetPointer());
154 title_->SetLines(-1);
155 title_->SetFont(style.title_font().c_str());
156+ title_->mouse_click.connect(on_mouse_down);
157 preview_data_layout->AddView(title_.GetPointer(), 1);
158
159 if (!preview_model_->subtitle.Get().empty())
160 {
161 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
162+ AddChild(subtitle_.GetPointer());
163 subtitle_->SetLines(-1);
164 subtitle_->SetFont(style.subtitle_size_font().c_str());
165+ subtitle_->mouse_click.connect(on_mouse_down);
166 preview_data_layout->AddView(subtitle_.GetPointer(), 1);
167 }
168 /////////////////////
169@@ -150,6 +157,7 @@
170 // Description
171 nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION);
172 preview_info->EnableHorizontalScrollBar(false);
173+ preview_info->mouse_click.connect(on_mouse_down);
174
175 nux::VLayout* preview_info_layout = new nux::VLayout();
176 preview_info_layout->SetSpaceBetweenChildren(12);
177@@ -158,10 +166,12 @@
178 if (!preview_model_->description.Get().empty())
179 {
180 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
181+ AddChild(description_.GetPointer());
182 description_->SetFont(style.description_font().c_str());
183 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);
184 description_->SetLines(-style.GetDescriptionLineCount());
185 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
186+ description_->mouse_click.connect(on_mouse_down);
187 preview_info_layout->AddView(description_.GetPointer());
188 }
189
190@@ -169,6 +179,7 @@
191 {
192 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
193 AddChild(preview_info_hints_.GetPointer());
194+ preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
195 preview_info_layout->AddView(preview_info_hints_.GetPointer());
196 }
197 /////////////////////
198@@ -189,6 +200,8 @@
199
200 image_data_layout->AddLayout(full_data_layout_, 1);
201
202+ mouse_click.connect(on_mouse_down);
203+
204 SetLayout(image_data_layout);
205 }
206
207
208=== modified file 'dash/previews/MoviePreview.cpp'
209--- dash/previews/MoviePreview.cpp 2012-12-21 19:22:51 +0000
210+++ dash/previews/MoviePreview.cpp 2013-01-16 18:36:23 +0000
211@@ -32,6 +32,7 @@
212 #include <Nux/AbstractButton.h>
213
214 #include "MoviePreview.h"
215+#include "PreviewInfoHintWidget.h"
216 #include "PreviewRatingsWidget.h"
217
218 namespace unity
219@@ -120,6 +121,8 @@
220 }
221 previews::Style& style = dash::previews::Style::Instance();
222
223+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
224+
225 nux::HLayout* image_data_layout = new nux::HLayout();
226 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
227
228@@ -143,15 +146,19 @@
229 app_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
230
231 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
232+ AddChild(title_.GetPointer());
233 title_->SetLines(-1);
234 title_->SetFont(style.title_font().c_str());
235+ title_->mouse_click.connect(on_mouse_down);
236 app_data_layout->AddView(title_.GetPointer(), 1);
237
238 if (!preview_model_->subtitle.Get().empty())
239 {
240 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
241+ AddChild(subtitle_.GetPointer());
242 subtitle_->SetLines(-1);
243 subtitle_->SetFont(style.subtitle_size_font().c_str());
244+ subtitle_->mouse_click.connect(on_mouse_down);
245 app_data_layout->AddView(subtitle_.GetPointer(), 1);
246 }
247 /////////////////////
248@@ -162,11 +169,13 @@
249 rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
250 rating_->SetRating(movie_preview_model->rating);
251 rating_->SetReviews(movie_preview_model->num_ratings);
252+ rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
253
254 /////////////////////
255 // Description
256 nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION);
257 preview_info->EnableHorizontalScrollBar(false);
258+ preview_info->mouse_click.connect(on_mouse_down);
259
260 nux::VLayout* preview_info_layout = new nux::VLayout();
261 preview_info_layout->SetSpaceBetweenChildren(12);
262@@ -176,16 +185,19 @@
263 {
264 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
265 AddChild(preview_info_hints_.GetPointer());
266+ preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
267 preview_info_layout->AddView(preview_info_hints_.GetPointer(), 0);
268 }
269
270 if (!preview_model_->description.Get().empty())
271 {
272 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
273+ AddChild(description_.GetPointer());
274 description_->SetFont(style.description_font().c_str());
275 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);
276 description_->SetLines(-style.GetDescriptionLineCount());
277 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
278+ description_->mouse_click.connect(on_mouse_down);
279 preview_info_layout->AddView(description_.GetPointer());
280 }
281 /////////////////////
282@@ -206,6 +218,8 @@
283 image_data_layout->AddView(image_.GetPointer(), 0);
284 image_data_layout->AddLayout(full_data_layout_, 1);
285
286+ mouse_click.connect(on_mouse_down);
287+
288 SetLayout(image_data_layout);
289 }
290
291
292=== modified file 'dash/previews/MusicPreview.cpp'
293--- dash/previews/MusicPreview.cpp 2012-12-21 19:22:51 +0000
294+++ dash/previews/MusicPreview.cpp 2013-01-16 18:36:23 +0000
295@@ -33,6 +33,7 @@
296 #include "MusicPreview.h"
297 #include "ActionButton.h"
298 #include "Tracks.h"
299+#include "PreviewInfoHintWidget.h"
300
301 namespace unity
302 {
303@@ -101,6 +102,8 @@
304 }
305 previews::Style& style = dash::previews::Style::Instance();
306
307+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
308+
309 nux::HLayout* image_data_layout = new nux::HLayout();
310 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
311
312@@ -124,15 +127,19 @@
313 album_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
314
315 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
316+ AddChild(title_.GetPointer());
317 title_->SetFont(style.title_font().c_str());
318 title_->SetLines(-1);
319+ title_->mouse_click.connect(on_mouse_down);
320 album_data_layout->AddView(title_.GetPointer(), 1);
321
322 if (!preview_model_->subtitle.Get().empty())
323 {
324 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
325+ AddChild(subtitle_.GetPointer());
326 subtitle_->SetFont(style.subtitle_size_font().c_str());
327 subtitle_->SetLines(-1);
328+ subtitle_->mouse_click.connect(on_mouse_down);
329 album_data_layout->AddView(subtitle_.GetPointer(), 1);
330 }
331
332@@ -147,6 +154,7 @@
333 AddChild(tracks_.GetPointer());
334 tracks_->play.connect(sigc::mem_fun(this, &MusicPreview::OnPlayTrack));
335 tracks_->pause.connect(sigc::mem_fun(this, &MusicPreview::OnPauseTrack));
336+ tracks_->mouse_click.connect(on_mouse_down);
337 }
338 /////////////////////
339
340@@ -163,6 +171,7 @@
341 hints_layout->AddSpace(0, 1);
342 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
343 AddChild(preview_info_hints_.GetPointer());
344+ preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
345 hints_layout->AddView(preview_info_hints_.GetPointer(), 0);
346
347 // If there are actions, we use a vertical layout
348@@ -194,6 +203,8 @@
349 image_data_layout->AddView(image_.GetPointer(), 0);
350 image_data_layout->AddLayout(full_data_layout_, 1);
351
352+ mouse_click.connect(on_mouse_down);
353+
354 SetLayout(image_data_layout);
355 }
356
357
358=== modified file 'dash/previews/Preview.cpp'
359--- dash/previews/Preview.cpp 2012-12-21 19:22:51 +0000
360+++ dash/previews/Preview.cpp 2013-01-16 18:36:23 +0000
361@@ -225,6 +225,7 @@
362 , title_(nullptr)
363 , subtitle_(nullptr)
364 {
365+ preview_container_ = new PreviewContainer;
366 }
367
368 Preview::~Preview()
369@@ -320,6 +321,8 @@
370
371 previews::Style& style = dash::previews::Style::Instance();
372
373+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
374+
375 std::string image_hint;
376 if (preview_model_->image.Get())
377 {
378@@ -334,13 +337,7 @@
379 cover_art->SetNoImageAvailable();
380 cover_art->SetFont(style.no_preview_image_font());
381
382- cover_art->mouse_click.connect([this] (int x, int y, unsigned long button_flags, unsigned long key_flags)
383- {
384- if (nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON1 || nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON3)
385- {
386- request_close.emit();
387- }
388- });
389+ cover_art->mouse_click.connect(on_mouse_down);
390 }
391
392 nux::Area* Preview::FindKeyFocusArea(unsigned int key_symbol,
393@@ -368,6 +365,11 @@
394 nux::GetWindowCompositor().SetKeyFocusArea(default_focus);
395 }
396
397+sigc::signal<void> Preview::request_close() const
398+{
399+ return preview_container_->request_close;
400+}
401+
402 }
403 }
404 }
405
406=== modified file 'dash/previews/Preview.h'
407--- dash/previews/Preview.h 2012-12-21 19:22:51 +0000
408+++ dash/previews/Preview.h 2013-01-16 18:36:23 +0000
409@@ -29,7 +29,6 @@
410 #include "unity-shared/Introspectable.h"
411 #include "unity-shared/PreviewStyle.h"
412 #include "unity-shared/StaticCairoText.h"
413-#include "PreviewInfoHintWidget.h"
414
415 namespace nux
416 {
417@@ -51,6 +50,7 @@
418 class CoverArt;
419 class TabIterator;
420 class PreviewInfoHintWidget;
421+class PreviewContainer;
422
423 class Preview : public nux::View, public debug::Introspectable
424 {
425@@ -67,7 +67,7 @@
426
427 static previews::Preview::Ptr PreviewForModel(dash::Preview::Ptr model);
428
429- sigc::signal<void> request_close;
430+ sigc::signal<void> request_close() const;
431
432 virtual nux::Area* FindKeyFocusArea(unsigned int key_symbol,
433 unsigned long x11_key_code,
434@@ -104,11 +104,15 @@
435 nux::ObjectPtr<StaticCairoText> title_;
436 nux::ObjectPtr<StaticCairoText> subtitle_;
437 nux::ObjectPtr<StaticCairoText> description_;
438- PreviewInfoHintWidget::Ptr preview_info_hints_;
439+ nux::ObjectPtr<PreviewInfoHintWidget> preview_info_hints_;
440
441 typedef std::unique_ptr<nux::AbstractPaintLayer> LayerPtr;
442
443 friend class PreviewContent;
444+
445+ // Need to declare this as a pointer to avoid a circular header
446+ // dependency issue between Preview.h and PreviewContainer.h
447+ nux::ObjectPtr<PreviewContainer> preview_container_;
448 };
449
450 }
451
452=== modified file 'dash/previews/PreviewContainer.cpp'
453--- dash/previews/PreviewContainer.cpp 2012-12-13 14:26:56 +0000
454+++ dash/previews/PreviewContainer.cpp 2013-01-16 18:36:23 +0000
455@@ -420,7 +420,7 @@
456
457 if (preview_view)
458 {
459- preview_view->request_close.connect([this]() { request_close.emit(); });
460+ preview_view->request_close().connect([this]() { request_close.emit(); });
461 }
462
463 preview_layout_->PushPreview(preview_view, direction);
464@@ -681,7 +681,9 @@
465
466 void PreviewContainer::OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
467 {
468- if (nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON1 || nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON3)
469+ int button = nux::GetEventButton(button_flags);
470+
471+ if (button == nux::MOUSE_BUTTON1 || button == nux::MOUSE_BUTTON2 || button == nux::MOUSE_BUTTON3)
472 {
473 request_close.emit();
474 }
475@@ -692,7 +694,6 @@
476 return layout_content_->GetAbsoluteGeometry();
477 }
478
479-
480 } // namespace previews
481 } // namespace dash
482 } // namespace unity
483
484=== modified file 'dash/previews/PreviewContainer.h'
485--- dash/previews/PreviewContainer.h 2012-11-29 10:19:01 +0000
486+++ dash/previews/PreviewContainer.h 2013-01-16 18:36:23 +0000
487@@ -83,13 +83,14 @@
488
489 nux::Geometry GetLayoutGeometry() const;
490
491+ void OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
492+
493 protected:
494 void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
495 void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
496
497 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
498 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
499- void OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
500
501 private:
502 void SetupViews();
503@@ -116,7 +117,7 @@
504 friend class PreviewContent;
505 };
506
507-} // napespace prviews
508+} // namespace previews
509 } // namespace dash
510 } // namespace unity
511
512
513=== modified file 'dash/previews/PreviewInfoHintWidget.cpp'
514--- dash/previews/PreviewInfoHintWidget.cpp 2012-12-14 12:14:34 +0000
515+++ dash/previews/PreviewInfoHintWidget.cpp 2013-01-16 18:36:23 +0000
516@@ -145,6 +145,8 @@
517
518 previews::Style& style = previews::Style::Instance();
519
520+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); };
521+
522 nux::VLayout* layout = new nux::VLayout();
523 layout->SetSpaceBetweenChildren(6);
524
525@@ -163,12 +165,14 @@
526 info_name->SetFont(style.info_hint_bold_font());
527 info_name->SetLines(-1);
528 info_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT);
529+ info_name->mouse_click.connect(on_mouse_down);
530 hint_layout->AddView(info_name.GetPointer(), 0, nux::MINOR_POSITION_CENTER);
531 }
532
533 StaticCairoTextPtr info_value(new StaticCairoText(StringFromVariant(info_hint->value), true, NUX_TRACKER_LOCATION));
534 info_value->SetFont(style.info_hint_font());
535 info_value->SetLines(-1);
536+ info_value->mouse_click.connect(on_mouse_down);
537 hint_layout->AddView(info_value.GetPointer(), 1, nux::MINOR_POSITION_CENTER);
538
539 InfoHint info_hint_views(info_name, info_value);
540@@ -177,6 +181,8 @@
541 layout->AddLayout(hint_layout, 0);
542 }
543
544+ mouse_click.connect(on_mouse_down);
545+
546 SetLayout(layout);
547 }
548
549@@ -227,7 +233,6 @@
550 View::PreLayoutManagement();
551 }
552
553-
554 } // namespace previews
555 } // namespace dash
556 } // namespace unity
557
558=== modified file 'dash/previews/PreviewInfoHintWidget.h'
559--- dash/previews/PreviewInfoHintWidget.h 2012-12-14 12:14:34 +0000
560+++ dash/previews/PreviewInfoHintWidget.h 2013-01-16 18:36:23 +0000
561@@ -27,6 +27,7 @@
562 #include <Nux/View.h>
563 #include <UnityCore/Preview.h>
564 #include "unity-shared/Introspectable.h"
565+#include "PreviewContainer.h"
566
567 namespace unity
568 {
569@@ -55,6 +56,8 @@
570
571 void PreLayoutManagement();
572
573+ sigc::signal<void> request_close() const { return preview_container_.request_close; }
574+
575 protected:
576 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
577 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
578@@ -78,9 +81,12 @@
579
580 dash::Preview::Ptr preview_model_;
581 typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
582+
583+private:
584+ PreviewContainer preview_container_;
585 };
586
587-} // napespace prviews
588+} // namespace previews
589 } // namespace dash
590 } // namespace unity
591
592
593=== modified file 'dash/previews/PreviewRatingsWidget.cpp'
594--- dash/previews/PreviewRatingsWidget.cpp 2012-12-14 12:14:34 +0000
595+++ dash/previews/PreviewRatingsWidget.cpp 2013-01-16 18:36:23 +0000
596@@ -49,14 +49,20 @@
597
598 previews::Style& style = previews::Style::Instance();
599
600+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); };
601+
602 ratings_ = new RatingsButton(18,2);
603 ratings_->SetEditable(false);
604+ ratings_->mouse_click.connect(on_mouse_down);
605 layout->AddView(ratings_);
606
607 reviews_ = new StaticCairoText("", NUX_TRACKER_LOCATION);
608 reviews_->SetFont(style.user_rating_font());
609+ reviews_->mouse_click.connect(on_mouse_down);
610 layout->AddView(reviews_);
611
612+ mouse_click.connect(on_mouse_down);
613+
614 SetLayout(layout);
615 }
616
617@@ -109,7 +115,6 @@
618 .add(GetAbsoluteGeometry());
619 }
620
621-
622 } // namespace previews
623 } // namespace dash
624 } // namespace unity
625
626=== modified file 'dash/previews/PreviewRatingsWidget.h'
627--- dash/previews/PreviewRatingsWidget.h 2012-12-14 12:14:34 +0000
628+++ dash/previews/PreviewRatingsWidget.h 2013-01-16 18:36:23 +0000
629@@ -25,6 +25,7 @@
630
631 #include <Nux/Nux.h>
632 #include <Nux/View.h>
633+#include "PreviewContainer.h"
634
635 namespace nux
636 {
637@@ -51,6 +52,8 @@
638
639 void SetReviews(int count);
640
641+ sigc::signal<void> request_close() const { return preview_container_.request_close; }
642+
643 protected:
644 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
645 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
646@@ -64,6 +67,8 @@
647 private:
648 RatingsButton* ratings_;
649 StaticCairoText* reviews_;
650+
651+ PreviewContainer preview_container_;
652 };
653
654 } // namespace previews
655
656=== modified file 'dash/previews/SocialPreview.cpp'
657--- dash/previews/SocialPreview.cpp 2012-12-21 19:22:51 +0000
658+++ dash/previews/SocialPreview.cpp 2013-01-16 18:36:23 +0000
659@@ -39,6 +39,7 @@
660 #include "SocialPreviewContent.h"
661 #include "SocialPreviewComments.h"
662 #include "ActionButton.h"
663+#include "PreviewInfoHintWidget.h"
664
665 namespace unity
666 {
667@@ -119,6 +120,8 @@
668
669 previews::Style& style = dash::previews::Style::Instance();
670
671+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
672+
673 nux::HLayout* image_data_layout = new nux::HLayout();
674 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
675
676@@ -155,7 +158,9 @@
677 nux::VLayout* icon_layout = new nux::VLayout();
678 icon_layout->SetSpaceBetweenChildren(3);
679 avatar_ = new IconTexture(social_preview_model->avatar.Get().RawPtr() ? g_icon_to_string(social_preview_model->avatar.Get().RawPtr()) : "", MIN(style.GetAvatarAreaWidth(), style.GetAvatarAreaHeight()));
680+ AddChild(avatar_.GetPointer());
681 avatar_->SetMinMaxSize(style.GetAvatarAreaWidth(), style.GetAvatarAreaHeight());
682+ avatar_->mouse_click.connect(on_mouse_down);
683 icon_layout->AddView(avatar_.GetPointer(), 0);
684
685 /////////////////////
686@@ -166,12 +171,16 @@
687 social_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
688
689 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
690+ AddChild(title_.GetPointer());
691 title_->SetLines(-1);
692 title_->SetFont(style.title_font().c_str());
693+ title_->mouse_click.connect(on_mouse_down);
694
695 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
696+ AddChild(subtitle_.GetPointer());
697 subtitle_->SetFont(style.content_font().c_str());
698 subtitle_->SetLines(-1);
699+ subtitle_->mouse_click.connect(on_mouse_down);
700
701 social_data_layout->AddView(title_.GetPointer(), 0);
702 social_data_layout->AddView(subtitle_.GetPointer(), 0);
703@@ -188,6 +197,7 @@
704 // Details
705 nux::ScrollView* social_info = new DetailsScrollView(NUX_TRACKER_LOCATION);
706 social_info->EnableHorizontalScrollBar(false);
707+ social_info->mouse_click.connect(on_mouse_down);
708
709 nux::VLayout* social_info_layout = new nux::VLayout();
710 social_info_layout->SetSpaceBetweenChildren(12);
711@@ -197,6 +207,7 @@
712 {
713 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetAvatarAreaWidth());
714 AddChild(preview_info_hints_.GetPointer());
715+ preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
716 social_info_layout->AddView(preview_info_hints_.GetPointer(), 0);
717 }
718 /////////////////////
719@@ -209,13 +220,16 @@
720 tmp_comments_hint += ":";
721
722 comments_hint_ = new StaticCairoText(tmp_comments_hint, true, NUX_TRACKER_LOCATION);
723+ AddChild(comments_hint_.GetPointer());
724 comments_hint_->SetLines(-1);
725 comments_hint_->SetFont(style.info_hint_bold_font().c_str());
726 comments_hint_->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT);
727+ comments_hint_->mouse_click.connect(on_mouse_down);
728 comments_layout->AddView(comments_hint_.GetPointer(), 0, nux::MINOR_POSITION_START);
729
730 comments_ = new SocialPreviewComments(preview_model_, NUX_TRACKER_LOCATION);
731 AddChild(comments_.GetPointer());
732+ comments_->request_close().connect([this]() { preview_container_->request_close.emit(); });
733 comments_layout->AddView(comments_.GetPointer());
734 social_info_layout->AddView(comments_layout, 0);
735 }
736@@ -237,6 +251,7 @@
737 image_data_layout->AddView(social_content_layout, 0);
738 image_data_layout->AddLayout(full_data_layout_, 1);
739
740+ mouse_click.connect(on_mouse_down);
741
742 SetLayout(image_data_layout);
743 }
744
745=== modified file 'dash/previews/SocialPreviewComments.cpp'
746--- dash/previews/SocialPreviewComments.cpp 2012-12-14 12:14:34 +0000
747+++ dash/previews/SocialPreviewComments.cpp 2013-01-16 18:36:23 +0000
748@@ -128,6 +128,8 @@
749
750 previews::Style& style = previews::Style::Instance();
751
752+ auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); };
753+
754 nux::VLayout* layout = new nux::VLayout();
755 layout->SetSpaceBetweenChildren(6);
756
757@@ -144,6 +146,7 @@
758 comment_name->SetFont(style.info_hint_bold_font());
759 comment_name->SetLines(-1);
760 comment_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);
761+ comment_name->mouse_click.connect(on_mouse_down);
762 name_layout->AddView(comment_name.GetPointer(), 0, nux::MINOR_POSITION_START);
763 }
764
765@@ -154,6 +157,7 @@
766 comment_time->SetFont(style.info_hint_font());
767 comment_time->SetLines(-1);
768 comment_time->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT);
769+ comment_time->mouse_click.connect(on_mouse_down);
770 name_layout->AddView(comment_time.GetPointer(), 0, nux::MINOR_POSITION_START);
771 }
772
773@@ -166,6 +170,7 @@
774 comment_value->SetFont(style.info_hint_font());
775 comment_value->SetLines(-7);
776 comment_value->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);
777+ comment_value->mouse_click.connect(on_mouse_down);
778 comment_layout->AddView(comment_value.GetPointer(), 1, nux::MINOR_POSITION_START);
779
780 Comment comment_views(comment_name, comment_value);
781@@ -174,6 +179,8 @@
782 layout->AddLayout(name_layout, 0);
783 layout->AddLayout(comment_layout, 1);
784 }
785+ mouse_click.connect(on_mouse_down);
786+
787 SetLayout(layout);
788
789 }
790
791=== modified file 'dash/previews/SocialPreviewComments.h'
792--- dash/previews/SocialPreviewComments.h 2012-12-14 12:14:34 +0000
793+++ dash/previews/SocialPreviewComments.h 2013-01-16 18:36:23 +0000
794@@ -29,6 +29,7 @@
795 #include "unity-shared/StaticCairoText.h"
796 #include "unity-shared/Introspectable.h"
797 #include <UnityCore/SocialPreview.h>
798+#include "PreviewContainer.h"
799
800 namespace unity
801 {
802@@ -47,6 +48,8 @@
803
804 virtual ~SocialPreviewComments();
805
806+ sigc::signal<void> request_close() const { return preview_container_.request_close; }
807+
808 protected:
809
810 typedef nux::ObjectPtr<StaticCairoText> StaticCairoTextPtr;
811@@ -69,6 +72,8 @@
812 private:
813
814 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
815+
816+ PreviewContainer preview_container_;
817 };
818
819 }
820
821=== modified file 'tests/autopilot/unity/emulators/dash.py'
822--- tests/autopilot/unity/emulators/dash.py 2012-12-03 03:51:16 +0000
823+++ tests/autopilot/unity/emulators/dash.py 2013-01-16 18:36:23 +0000
824@@ -411,7 +411,24 @@
825
826 @property
827 def cover_art(self):
828- return self.get_children_by_type(CoverArt)[0]
829+ return self.get_children_by_type(CoverArt)
830+
831+ @property
832+ def ratings_widget(self):
833+ return self.get_children_by_type(PreviewRatingsWidget)
834+
835+ @property
836+ def info_hint_widget(self):
837+ return self.get_children_by_type(PreviewInfoHintWidget)
838+
839+ @property
840+ def icon(self):
841+ return self.get_children_by_type(IconTexture)
842+
843+ @property
844+ def text_boxes(self):
845+ return self.get_children_by_type(StaticCairoText)
846+
847
848 class ApplicationPreview(Preview):
849 """A application preview of a dash lens result."""
850@@ -555,6 +572,10 @@
851 return self.get_children_by_type(IconTexture);
852
853
854+class PreviewInfoHintWidget(UnityIntrospectionObject):
855+ """A view containing additional info for a preview."""
856+
857+
858 class PreviewRatingsWidget(UnityIntrospectionObject):
859 """A view containing a rating button and user rating count."""
860
861@@ -570,3 +591,10 @@
862 class ActionButton(UnityIntrospectionObject):
863 """A preview action button."""
864
865+
866+class IconTexture(UnityIntrospectionObject):
867+ """An icon for the preview."""
868+
869+
870+class StaticCairoText(UnityIntrospectionObject):
871+ """Text boxes in the preview"""
872
873=== modified file 'tests/autopilot/unity/tests/test_dash.py'
874--- tests/autopilot/unity/tests/test_dash.py 2013-01-15 21:53:55 +0000
875+++ tests/autopilot/unity/tests/test_dash.py 2013-01-16 18:36:23 +0000
876@@ -930,7 +930,7 @@
877
878 def test_preview_refocus_close(self):
879 """Clicking on a preview element must not lose keyboard focus."""
880- cover_art = self.preview_container.current_preview.cover_art
881+ cover_art = self.preview_container.current_preview.cover_art[0]
882
883 # click the cover-art (this will set focus)
884 tx = cover_art.x + (cover_art.width / 2)
885@@ -942,23 +942,185 @@
886
887 self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
888
889+
890+class PreviewClickCancelTests(DashTestCase):
891+ """Tests that the preview closes when left, middle, and right clicking in the preview"""
892+
893+ def setUp(self):
894+ super(PreviewClickCancelTests, self).setUp()
895+ lens = self.dash.reveal_application_lens()
896+ self.addCleanup(self.dash.ensure_hidden)
897+ # Only testing an application preview for this test.
898+ self.keyboard.type("Software Updater")
899+ results_category = lens.get_category_by_name(_("Installed"))
900+ results = results_category.get_results()
901+
902+ result = results[0]
903+ result.preview()
904+ self.assertThat(self.dash.view.preview_displaying, Eventually(Equals(True)))
905+
906+ self.preview_container = self.dash.view.get_preview_container()
907+
908+ def test_left_click_on_preview_icon_cancel_preview(self):
909+ """Left click on preview icon must close preview."""
910+ icon = self.preview_container.current_preview.icon[0]
911+
912+ tx = icon.x + icon.width
913+ ty = icon.y + (icon.height / 2)
914+ self.mouse.move(tx, ty)
915+ self.mouse.click(button=1)
916+
917+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
918+
919+ def test_middle_click_on_preview_icon_cancel_preview(self):
920+ """Middle click on preview icon must close preview."""
921+ icon = self.preview_container.current_preview.icon[0]
922+
923+ tx = icon.x + icon.width
924+ ty = icon.y + (icon.height / 2)
925+ self.mouse.move(tx, ty)
926+ self.mouse.click(button=2)
927+
928+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
929+
930+ def test_right_click_on_preview_icon_cancel_preview(self):
931+ """Right click on preview icon must close preview."""
932+ icon = self.preview_container.current_preview.icon[0]
933+
934+ tx = icon.x + icon.width
935+ ty = icon.y + (icon.height / 2)
936+ self.mouse.move(tx, ty)
937+ self.mouse.click(button=3)
938+
939+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
940+
941 def test_left_click_on_preview_image_cancel_preview(self):
942 """Left click on preview image must cancel the preview."""
943- cover_art = self.preview_container.current_preview.cover_art
944+ cover_art = self.preview_container.current_preview.cover_art[0]
945
946 tx = cover_art.x + (cover_art.width / 2)
947- ty = cover_art.y + (cover_art.height / 4)
948+ ty = cover_art.y + (cover_art.height / 2)
949 self.mouse.move(tx, ty)
950 self.mouse.click(button=1)
951
952 self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
953
954+ def test_middle_click_on_preview_image_cancel_preview(self):
955+ """Middle click on preview image must cancel the preview."""
956+ cover_art = self.preview_container.current_preview.cover_art[0]
957+
958+ tx = cover_art.x + (cover_art.width / 2)
959+ ty = cover_art.y + (cover_art.height / 2)
960+ self.mouse.move(tx, ty)
961+ self.mouse.click(button=2)
962+
963+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
964+
965 def test_right_click_on_preview_image_cancel_preview(self):
966- """Right click on preview image must cancel preview."""
967- cover_art = self.preview_container.current_preview.cover_art
968+ """Right click on preview image must cancel the preview."""
969+ cover_art = self.preview_container.current_preview.cover_art[0]
970
971 tx = cover_art.x + (cover_art.width / 2)
972- ty = cover_art.y + (cover_art.height / 4)
973+ ty = cover_art.y + (cover_art.height / 2)
974+ self.mouse.move(tx, ty)
975+ self.mouse.click(button=3)
976+
977+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
978+
979+ def test_left_click_on_preview_text_cancel_preview(self):
980+ """Left click on some preview text must cancel the preview."""
981+ text = self.preview_container.current_preview.text_boxes[0]
982+
983+ tx = text.x + (text.width / 2)
984+ ty = text.y + (text.height / 2)
985+ self.mouse.move(tx, ty)
986+ self.mouse.click(button=1)
987+
988+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
989+
990+ def test_middle_click_on_preview_text_cancel_preview(self):
991+ """Middle click on some preview text must cancel the preview."""
992+ text = self.preview_container.current_preview.text_boxes[0]
993+
994+ tx = text.x + (text.width / 2)
995+ ty = text.y + (text.height / 2)
996+ self.mouse.move(tx, ty)
997+ self.mouse.click(button=2)
998+
999+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
1000+
1001+ def test_right_click_on_preview_text_cancel_preview(self):
1002+ """Right click on some preview text must cancel the preview."""
1003+ text = self.preview_container.current_preview.text_boxes[0]
1004+
1005+ tx = text.x + (text.width / 2)
1006+ ty = text.y + (text.height / 2)
1007+ self.mouse.move(tx, ty)
1008+ self.mouse.click(button=3)
1009+
1010+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
1011+
1012+ def test_left_click_on_preview_ratings_widget_cancel_preview(self):
1013+ """Left click on the ratings widget must cancel the preview."""
1014+ ratings_widget = self.preview_container.current_preview.ratings_widget[0]
1015+
1016+ tx = ratings_widget.x + (ratings_widget.width / 2)
1017+ ty = ratings_widget.y + (ratings_widget.height / 2)
1018+ self.mouse.move(tx, ty)
1019+ self.mouse.click(button=1)
1020+
1021+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
1022+
1023+ def test_middle_click_on_preview_ratings_widget_cancel_preview(self):
1024+ """Middle click on the ratings widget must cancel the preview."""
1025+ ratings_widget = self.preview_container.current_preview.ratings_widget[0]
1026+
1027+ tx = ratings_widget.x + (ratings_widget.width / 2)
1028+ ty = ratings_widget.y + (ratings_widget.height / 2)
1029+ self.mouse.move(tx, ty)
1030+ self.mouse.click(button=2)
1031+
1032+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
1033+
1034+ def test_right_click_on_preview_ratings_widget_cancel_preview(self):
1035+ """Right click on the ratings widget must cancel the preview."""
1036+ ratings_widget = self.preview_container.current_preview.ratings_widget[0]
1037+
1038+ tx = ratings_widget.x + (ratings_widget.width / 2)
1039+ ty = ratings_widget.y + (ratings_widget.height / 2)
1040+ self.mouse.move(tx, ty)
1041+ self.mouse.click(button=3)
1042+
1043+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
1044+
1045+ def test_left_click_on_preview_info_hint_cancel_preview(self):
1046+ """Left click on the info hint must cancel the preview."""
1047+ info_hint = self.preview_container.current_preview.info_hint_widget[0]
1048+
1049+ tx = info_hint.x + (info_hint.width / 2)
1050+ ty = info_hint.y + (info_hint.height / 8)
1051+ self.mouse.move(tx, ty)
1052+ self.mouse.click(button=1)
1053+
1054+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
1055+
1056+ def test_middle_click_on_preview_info_hint_cancel_preview(self):
1057+ """Middle click on the info hint must cancel the preview."""
1058+ info_hint = self.preview_container.current_preview.info_hint_widget[0]
1059+
1060+ tx = info_hint.x + (info_hint.width / 2)
1061+ ty = info_hint.y + (info_hint.height / 8)
1062+ self.mouse.move(tx, ty)
1063+ self.mouse.click(button=2)
1064+
1065+ self.assertThat(self.dash.preview_displaying, Eventually(Equals(False)))
1066+
1067+ def test_right_click_on_preview_info_hint_cancel_preview(self):
1068+ """Right click on the info hint must cancel the preview."""
1069+ info_hint = self.preview_container.current_preview.info_hint_widget[0]
1070+
1071+ tx = info_hint.x + (info_hint.width / 2)
1072+ ty = info_hint.y + (info_hint.height / 8)
1073 self.mouse.move(tx, ty)
1074 self.mouse.click(button=3)
1075
1076
1077=== modified file 'unity-shared/StaticCairoText.cpp'
1078--- unity-shared/StaticCairoText.cpp 2013-01-11 11:22:19 +0000
1079+++ unity-shared/StaticCairoText.cpp 2013-01-16 18:36:23 +0000
1080@@ -34,6 +34,7 @@
1081 #include <pango/pangocairo.h>
1082
1083 #include <UnityCore/GLibWrapper.h>
1084+#include <UnityCore/Variant.h>
1085
1086 #include "CairoTexture.h"
1087
1088@@ -492,6 +493,17 @@
1089 return list;
1090 }
1091
1092+std::string StaticCairoText::GetName() const
1093+{
1094+ return "StaticCairoText";
1095+}
1096+
1097+void StaticCairoText::AddProperties(GVariantBuilder* builder)
1098+{
1099+ unity::variant::BuilderWrapper(builder)
1100+ .add(GetGeometry());
1101+}
1102+
1103 std::string StaticCairoText::Impl::GetEffectiveFont() const
1104 {
1105 if (font_.empty())
1106
1107=== modified file 'unity-shared/StaticCairoText.h'
1108--- unity-shared/StaticCairoText.h 2012-12-14 12:14:34 +0000
1109+++ unity-shared/StaticCairoText.h 2013-01-16 18:36:23 +0000
1110@@ -26,11 +26,13 @@
1111 #include <Nux/Nux.h>
1112 #include <Nux/View.h>
1113
1114+#include "unity-shared/Introspectable.h"
1115+
1116 namespace unity
1117 {
1118 class Validator;
1119
1120-class StaticCairoText : public nux::View
1121+class StaticCairoText : public nux::View, public unity::debug::Introspectable
1122 {
1123 NUX_DECLARE_OBJECT_TYPE (StaticCairoText, nux::View);
1124 public:
1125@@ -113,6 +115,10 @@
1126 std::vector<unsigned> GetTextureStartIndices();
1127 std::vector<unsigned> GetTextureEndIndices();
1128
1129+ // From debug::Introspectable
1130+ std::string GetName() const;
1131+ void AddProperties(GVariantBuilder* builder);
1132+
1133 private:
1134 struct Impl;
1135 Impl* pimpl;