Merge lp:~mvo/software-center/lp955005 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2865
Proposed branch: lp:~mvo/software-center/lp955005
Merge into: lp:software-center
Diff against target: 174 lines (+46/-16)
3 files modified
softwarecenter/enums.py (+2/-1)
softwarecenter/ui/gtk3/views/appdetailsview.py (+18/-9)
test/gtk3/test_appdetailsview.py (+26/-6)
To merge this branch: bzr merge lp:~mvo/software-center/lp955005
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+97592@code.launchpad.net

Description of the change

This branch fixes bug #955005 and does a bit of drive-by improving the scope of the test for the
detailsview layout. Test case is:
$ ./software-center wireframesketcherstudio
and verify that there is no review_stats widget visible anymore. But for e.g. abiword this should still
be the case.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Very nice work and great test too, many thanks mvo!!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/enums.py'
2--- softwarecenter/enums.py 2012-03-13 18:35:14 +0000
3+++ softwarecenter/enums.py 2012-03-15 09:09:22 +0000
4@@ -180,10 +180,11 @@
5 FORCE_VERSION,
6 # the package is not found in the DB or cache
7 NOT_FOUND,
8+ # its purchased but not found for the current series
9+ PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES,
10 # this *needs* to be last (for test_appdetails.py) and means
11 # something went wrong and we don't have a state for this PKG
12 UNKNOWN,
13- PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES,
14 ) = range(17)
15
16 # visibility of non applications in the search results
17
18=== modified file 'softwarecenter/ui/gtk3/views/appdetailsview.py'
19--- softwarecenter/ui/gtk3/views/appdetailsview.py 2012-03-14 23:44:30 +0000
20+++ softwarecenter/ui/gtk3/views/appdetailsview.py 2012-03-15 09:09:22 +0000
21@@ -302,13 +302,11 @@
22 PkgStates.INSTALLING_PURCHASED,
23 PkgStates.REMOVING,
24 PkgStates.UPGRADING,
25+ PkgStates.ERROR,
26 AppActions.APPLY):
27 self.show()
28 elif state == PkgStates.NOT_FOUND:
29 self.hide()
30- elif state == PkgStates.ERROR:
31- # error details are set below
32- self.show()
33 else:
34 # mvo: why do we override state here again?
35 state = app_details.pkg_state
36@@ -426,7 +424,7 @@
37 self.set_label(_(u'Changing Add-ons\u2026'))
38 self.button.set_sensitive(False)
39 elif state == PkgStates.UNKNOWN:
40- self.set_button_label("")
41+ self.button.hide()
42 self.set_label(_("Error"))
43 elif state == PkgStates.ERROR:
44 # this is used when the pkg can not be installed
45@@ -439,7 +437,7 @@
46 # this is used when the pkg is not in the cache and there is no
47 # request we display the error in the summary field and hide the
48 # rest
49- pass
50+ self.button.hide()
51 elif state == PkgStates.NEEDS_SOURCE:
52 channelfile = self.app_details.channelfile
53 # it has a price and is not available
54@@ -454,9 +452,15 @@
55 # components that are not enabled or that just
56 # lack the "Packages" files (but are in sources.list)
57 self.set_button_label(_("Update Now"))
58- if (self.app_details.warning and not self.app_details.error and
59- not state in (PkgStates.INSTALLING, PkgStates.INSTALLING_PURCHASED,
60- PkgStates.REMOVING, PkgStates.UPGRADING, AppActions.APPLY)):
61+
62+ # this maybe a region or hw compatibilty warning
63+ if (self.app_details.warning and
64+ not self.app_details.error and
65+ not state in (PkgStates.INSTALLING,
66+ PkgStates.INSTALLING_PURCHASED,
67+ PkgStates.REMOVING,
68+ PkgStates.UPGRADING,
69+ AppActions.APPLY)):
70 self.set_label(self.app_details.warning)
71
72 sensitive = network_state_is_connected()
73@@ -1165,9 +1169,12 @@
74 #~ self.usage = mkit.BubbleLabel()
75 #~ vb_inner.pack_start(self.usage, True, True, 0)
76
77- # star rating widget
78+ # star rating box/widget
79 self.review_stats_widget = StarRatingsWidget()
80+ self.review_stats = Gtk.HBox()
81 vb_inner.pack_start(
82+ self.review_stats, False, False, 0)
83+ self.review_stats.pack_start(
84 self.review_stats_widget, False, False, StockEms.SMALL)
85
86 #~ vb_inner.set_property("can-focus", True)
87@@ -1375,6 +1382,7 @@
88 if pkg_error:
89 self.addon_view.hide()
90 self.reviews.hide()
91+ self.review_stats.hide()
92 self.screenshot.hide()
93 #~ self.info_header.hide()
94 self.info_vb.hide()
95@@ -1383,6 +1391,7 @@
96 else:
97 self.addon_view.show()
98 self.reviews.show()
99+ self.review_stats.show()
100 self.screenshot.show()
101 #~ self.info_header.show()
102 self.info_vb.show()
103
104=== modified file 'test/gtk3/test_appdetailsview.py'
105--- test/gtk3/test_appdetailsview.py 2012-02-23 16:40:27 +0000
106+++ test/gtk3/test_appdetailsview.py 2012-03-15 09:09:22 +0000
107@@ -51,7 +51,7 @@
108 do_events()
109 self.assertTrue(self.view.videoplayer.get_property("visible"))
110
111- def test_page_pkgstatusbar(self):
112+ def test_page_pkgstates(self):
113 # show app
114 app = Application("", "abiword")
115 self.view.show_app(app)
116@@ -68,7 +68,7 @@
117 mock_details._error_not_found = "error not found"
118 mock_details.price = "1.00"
119 mock_details.pkgname = "abiword"
120- mock_details.error = ""
121+ mock_details.error = "error-text"
122 self.view.app_details = mock_details
123
124 # the states and what labels we expect in the pkgstatusbar
125@@ -79,18 +79,25 @@
126 PkgStates.NEEDS_PURCHASE : ('US$ 1.00', u'Buy\u2026'),
127 PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED : ('Purchased on 2011-11-20', 'Install'),
128 }
129+ # this describes if a button is visible or invisible
130+ button_invisible = [ PkgStates.ERROR,
131+ PkgStates.NOT_FOUND,
132+ PkgStates.INSTALLING_PURCHASED,
133+ PkgStates.PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES,
134+ PkgStates.UNKNOWN,
135+ ]
136
137- # show a app through the various states
138+ # show a app through the various states and test if the right ui
139+ # elements are visible and have the right text
140 for var in vars(PkgStates):
141- # FIXME: this just ensures we are not crashing, also
142- # add functional tests to ensure on error we show
143- # the right info etc
144 state = getattr(PkgStates, var)
145 mock_details.pkg_state = state
146 # reset app to ensure its shown again
147 self.view.app = None
148 # show it
149 self.view.show_app(mock_app)
150+ #do_events()
151+ # check button label
152 if state in pkg_states_to_labels:
153 label, button_label = pkg_states_to_labels[state]
154 self.assertEqual(
155@@ -99,6 +106,19 @@
156 self.assertEqual(
157 self.view.pkg_statusbar.get_button_label().decode("utf-8"),
158 button_label)
159+ # check if button should be there or not
160+ if state in button_invisible:
161+ self.assertFalse(
162+ self.view.pkg_statusbar.button.get_property("visible"),
163+ "button visible error for state %s" % state)
164+ else:
165+ self.assertTrue(
166+ self.view.pkg_statusbar.button.get_property("visible"),
167+ "button visible error for state %s" % state)
168+ # regression test for #955005
169+ if state == PkgStates.NOT_FOUND:
170+ self.assertFalse(self.view.review_stats.get_property("visible"))
171+ self.assertFalse(self.view.reviews.get_property("visible"))
172
173 def test_app_icon_loading(self):
174 # get icon

Subscribers

People subscribed via source and target branches