Merge lp:~jamesh/unity/bug-1178046 into lp:~unity-team/unity/libunity-7.0-breakage

Proposed by James Henstridge
Status: Merged
Approved by: Nick Dedekind
Approved revision: no longer in the source branch.
Merged at revision: 3140
Proposed branch: lp:~jamesh/unity/bug-1178046
Merge into: lp:~unity-team/unity/libunity-7.0-breakage
Diff against target: 89 lines (+26/-10)
2 files modified
dash/previews/MoviePreview.cpp (+11/-8)
tests/test_previews_movie.cpp (+15/-2)
To merge this branch: bzr merge lp:~jamesh/unity/bug-1178046
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Nick Dedekind (community) Approve
Review via email: mp+163260@code.launchpad.net

Commit message

Hide the ratings widget in the movie preview if the rating is less than zero.

Description of the change

Hide the ratings widget in the Movie preview if the rating is < 0. We need this to fix some problems brought up in the Design review of some scope previews.

This patch is analogous to the one for bug 1170715, which covered application previews.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

LGTM.

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

although, a unit tests would be great.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/MoviePreview.cpp'
2--- dash/previews/MoviePreview.cpp 2013-01-16 15:43:38 +0000
3+++ dash/previews/MoviePreview.cpp 2013-05-13 12:26:24 +0000
4@@ -163,13 +163,15 @@
5 }
6 /////////////////////
7
8- rating_ = new PreviewRatingsWidget();
9- AddChild(rating_.GetPointer());
10- rating_->SetMaximumHeight(style.GetRatingWidgetHeight());
11- rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
12- rating_->SetRating(movie_preview_model->rating);
13- rating_->SetReviews(movie_preview_model->num_ratings);
14- rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
15+ if (movie_preview_model->rating >= 0) {
16+ rating_ = new PreviewRatingsWidget();
17+ AddChild(rating_.GetPointer());
18+ rating_->SetMaximumHeight(style.GetRatingWidgetHeight());
19+ rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
20+ rating_->SetRating(movie_preview_model->rating);
21+ rating_->SetReviews(movie_preview_model->num_ratings);
22+ rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
23+ }
24
25 /////////////////////
26 // Description
27@@ -210,7 +212,8 @@
28 ///////////////////
29
30 full_data_layout_->AddLayout(app_data_layout, 0);
31- full_data_layout_->AddView(rating_.GetPointer(), 0);
32+ if (rating_ != NULL)
33+ full_data_layout_->AddView(rating_.GetPointer(), 0);
34 full_data_layout_->AddView(preview_info, 1);
35 full_data_layout_->AddView(actions_layout, 0);
36 /////////////////////
37
38=== modified file 'tests/test_previews_movie.cpp'
39--- tests/test_previews_movie.cpp 2013-01-24 03:17:58 +0000
40+++ tests/test_previews_movie.cpp 2013-05-13 12:26:24 +0000
41@@ -63,14 +63,16 @@
42 {
43 public:
44 TestPreviewMovie()
45- : parent_window_(new nux::BaseWindow("TestPreviewMovie"))
46+ : parent_window_(new nux::BaseWindow("TestPreviewMovie")) {}
47+
48+ void create_preview_model(double rating)
49 {
50 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_movie_preview_new()));
51
52 GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
53 g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£1.00"));
54
55- unity_protocol_movie_preview_set_rating(UNITY_PROTOCOL_MOVIE_PREVIEW(proto_obj.RawPtr()), 0.8);
56+ unity_protocol_movie_preview_set_rating(UNITY_PROTOCOL_MOVIE_PREVIEW(proto_obj.RawPtr()), rating);
57 unity_protocol_movie_preview_set_num_ratings(UNITY_PROTOCOL_MOVIE_PREVIEW(proto_obj.RawPtr()), 12);
58
59 unity_protocol_preview_set_image_source_uri(proto_obj, "http://ia.media-imdb.com/images/M/MV5BMTM3NDM5MzY5Ml5BMl5BanBnXkFtZTcwNjExMDUwOA@@._V1._SY317_.jpg");
60@@ -100,6 +102,7 @@
61
62 TEST_F(TestPreviewMovie, TestCreate)
63 {
64+ create_preview_model(0.8);
65 previews::Preview::Ptr preview_view = previews::Preview::PreviewForModel(preview_model_);
66
67 EXPECT_TRUE(dynamic_cast<previews::MoviePreview*>(preview_view.GetPointer()) != NULL);
68@@ -107,6 +110,7 @@
69
70 TEST_F(TestPreviewMovie, TestUIValues)
71 {
72+ create_preview_model(0.8);
73 MockMoviePreview::Ptr preview_view(new MockMoviePreview(preview_model_));
74
75 EXPECT_EQ(preview_view->title_->GetText(), "Movie Title &amp; special char");
76@@ -135,4 +139,13 @@
77 }
78 }
79
80+TEST_F(TestPreviewMovie, TestHideRatings)
81+{
82+ create_preview_model(-1);
83+ MockMoviePreview::Ptr preview_view(new MockMoviePreview(preview_model_));
84+
85+ EXPECT_EQ(preview_view->rating_, NULL);
86+}
87+
88+
89 }

Subscribers

People subscribed via source and target branches