Merge lp:~mvo/software-center/thumbnail-test-fixes into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3200
Proposed branch: lp:~mvo/software-center/thumbnail-test-fixes
Merge into: lp:software-center
Diff against target: 261 lines (+68/-59)
3 files modified
softwarecenter/ui/gtk3/widgets/thumbnail.py (+21/-18)
tests/gtk3/test_widgets.py (+14/-4)
tests/gtk3/windows.py (+33/-37)
To merge this branch: bzr merge lp:~mvo/software-center/thumbnail-test-fixes
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+125935@code.launchpad.net

Description of the change

Tiny branch that fixes the get_test_screenshot_thumbnail_window()
function and ensures that its properly used in the automatic test.

This is a drive-by branch while trying to figure out why davmor2 sometimes
gets a "screenshot-unavailable" thumbnail even if there is clearly a
screenshot available

To post a comment you must log in.
3201. By Michael Vogt

add missing disconnect for self._on_screenshot_query_complete)

Revision history for this message
Gary Lasker (gary-lasker) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/ui/gtk3/widgets/thumbnail.py'
--- softwarecenter/ui/gtk3/widgets/thumbnail.py 2012-05-30 18:39:55 +0000
+++ softwarecenter/ui/gtk3/widgets/thumbnail.py 2012-09-24 07:25:22 +0000
@@ -162,19 +162,21 @@
162 self.loader.disconnect_by_func(162 self.loader.disconnect_by_func(
163 self._on_screenshot_download_complete)163 self._on_screenshot_download_complete)
164 self.loader.disconnect_by_func(164 self.loader.disconnect_by_func(
165 self._on_screenshot_query_complete)
166 self.loader.disconnect_by_func(
165 self._on_screenshot_load_error)167 self._on_screenshot_load_error)
166168
167 # overrides169 # overrides
168 def do_get_preferred_width(self):170 def do_get_preferred_width(self):
169 if self.data.get_n_screenshots() <= 1:171 if self.data.get_n_screenshots() <= 1:
170 pb = self.button.image.get_pixbuf()172 pb = self.main_screenshot.image.get_pixbuf()
171 if pb:173 if pb:
172 width = pb.get_width() + 20174 width = pb.get_width() + 20
173 return width, width175 return width, width
174 return 320, 320176 return 320, 320
175177
176 def do_get_preferred_height(self):178 def do_get_preferred_height(self):
177 pb = self.button.image.get_pixbuf()179 pb = self.main_screenshot.image.get_pixbuf()
178 if pb:180 if pb:
179 height = pb.get_height()181 height = pb.get_height()
180 if self.data.get_n_screenshots() <= 1:182 if self.data.get_n_screenshots() <= 1:
@@ -194,18 +196,18 @@
194 def _build_ui(self):196 def _build_ui(self):
195 self.set_border_width(3)197 self.set_border_width(3)
196 # the frame around the screenshot (placeholder)198 # the frame around the screenshot (placeholder)
197 self.screenshot = Gtk.VBox()199 self.screenshot_frame = Gtk.VBox()
198 self.pack_start(self.screenshot, True, True, 0)200 self.pack_start(self.screenshot_frame, True, True, 0)
199201
200 self.spinner = Gtk.Spinner()202 self.spinner = Gtk.Spinner()
201 self.spinner.set_size_request(*self.SPINNER_SIZE)203 self.spinner.set_size_request(*self.SPINNER_SIZE)
202 self.spinner.set_valign(Gtk.Align.CENTER)204 self.spinner.set_valign(Gtk.Align.CENTER)
203 self.spinner.set_halign(Gtk.Align.CENTER)205 self.spinner.set_halign(Gtk.Align.CENTER)
204 self.screenshot.add(self.spinner)206 self.screenshot_frame.add(self.spinner)
205207
206 # clickable screenshot button208 # main big clickable screenshot button
207 self.button = ScreenshotButton()209 self.main_screenshot = ScreenshotButton()
208 self.screenshot.pack_start(self.button, True, False, 0)210 self.screenshot_frame.pack_start(self.main_screenshot, True, False, 0)
209211
210 # unavailable layout212 # unavailable layout
211 self.unavailable = Gtk.Label(label=_(self.NOT_AVAILABLE_STRING))213 self.unavailable = Gtk.Label(label=_(self.NOT_AVAILABLE_STRING))
@@ -213,7 +215,7 @@
213 # force the label state to INSENSITIVE so we get the nice215 # force the label state to INSENSITIVE so we get the nice
214 # subtle etched in look216 # subtle etched in look
215 self.unavailable.set_state(Gtk.StateType.INSENSITIVE)217 self.unavailable.set_state(Gtk.StateType.INSENSITIVE)
216 self.screenshot.add(self.unavailable)218 self.screenshot_frame.add(self.unavailable)
217219
218 self.thumbnails = ThumbnailGallery(self)220 self.thumbnails = ThumbnailGallery(self)
219 self.thumbnails.set_margin_top(5)221 self.thumbnails.set_margin_top(5)
@@ -221,9 +223,9 @@
221 self.pack_end(self.thumbnails, False, False, 0)223 self.pack_end(self.thumbnails, False, False, 0)
222 self.thumbnails.connect(224 self.thumbnails.connect(
223 "thumb-selected", self.on_thumbnail_selected)225 "thumb-selected", self.on_thumbnail_selected)
224 self.button.connect("clicked", self.on_clicked)226 self.main_screenshot.connect("clicked", self.on_clicked)
225 self.button.connect('enter-notify-event', self._on_enter)227 self.main_screenshot.connect('enter-notify-event', self._on_enter)
226 self.button.connect('leave-notify-event', self._on_leave)228 self.main_screenshot.connect('leave-notify-event', self._on_leave)
227 self.show_all()229 self.show_all()
228230
229 def _on_enter(self, widget, event):231 def _on_enter(self, widget, event):
@@ -261,6 +263,7 @@
261 self.thumbnails.set_thumbnails_from_data(screenshots)263 self.thumbnails.set_thumbnails_from_data(screenshots)
262264
263 def _on_screenshot_download_complete(self, loader, screenshot_path):265 def _on_screenshot_download_complete(self, loader, screenshot_path):
266
264 try:267 try:
265 self.screenshot_pixbuf = GdkPixbuf.Pixbuf.new_from_file(268 self.screenshot_pixbuf = GdkPixbuf.Pixbuf.new_from_file(
266 screenshot_path)269 screenshot_path)
@@ -269,10 +272,10 @@
269 self.loader.emit('error', GObject.GError, e)272 self.loader.emit('error', GObject.GError, e)
270 return False273 return False
271274
272 #context = self.button.get_style_context()275 #context = self.main_screenshot.get_style_context()
273 tw, th = self.MAX_SIZE_CONSTRAINTS276 tw, th = self.MAX_SIZE_CONSTRAINTS
274 pb = self._downsize_pixbuf(self.screenshot_pixbuf, tw, th)277 pb = self._downsize_pixbuf(self.screenshot_pixbuf, tw, th)
275 self.button.image.set_from_pixbuf(pb)278 self.main_screenshot.image.set_from_pixbuf(pb)
276 self.ready = True279 self.ready = True
277 self.display_image()280 self.display_image()
278281
@@ -311,8 +314,8 @@
311 self.display_spinner()314 self.display_spinner()
312315
313 def display_spinner(self):316 def display_spinner(self):
314 self.button.image.clear()317 self.main_screenshot.image.clear()
315 self.button.hide()318 self.main_screenshot.hide()
316 self.unavailable.hide()319 self.unavailable.hide()
317 self.spinner.show()320 self.spinner.show()
318 self.spinner.start()321 self.spinner.start()
@@ -321,7 +324,7 @@
321 self.spinner.hide()324 self.spinner.hide()
322 self.spinner.stop()325 self.spinner.stop()
323 self.unavailable.show()326 self.unavailable.show()
324 self.button.hide()327 self.main_screenshot.hide()
325 acc = self.get_accessible()328 acc = self.get_accessible()
326 acc.set_name(_(self.NOT_AVAILABLE_STRING))329 acc.set_name(_(self.NOT_AVAILABLE_STRING))
327 acc.set_role(Atk.Role.LABEL)330 acc.set_role(Atk.Role.LABEL)
@@ -330,7 +333,7 @@
330 self.unavailable.hide()333 self.unavailable.hide()
331 self.spinner.stop()334 self.spinner.stop()
332 self.spinner.hide()335 self.spinner.hide()
333 self.button.show_all()336 self.main_screenshot.show_all()
334 self.thumbnails.show()337 self.thumbnails.show()
335338
336 def get_is_actionable(self):339 def get_is_actionable(self):
337340
=== modified file 'tests/gtk3/test_widgets.py'
--- tests/gtk3/test_widgets.py 2012-09-17 14:46:36 +0000
+++ tests/gtk3/test_widgets.py 2012-09-24 07:25:22 +0000
@@ -9,6 +9,7 @@
9 DATA_DIR,9 DATA_DIR,
10 setup_test_env,10 setup_test_env,
11 do_events,11 do_events,
12 do_events_with_sleep,
12)13)
13setup_test_env()14setup_test_env()
1415
@@ -106,10 +107,6 @@
106 win = get_test_buttons_window()107 win = get_test_buttons_window()
107 self.addCleanup(win.destroy)108 self.addCleanup(win.destroy)
108109
109 def test_screenshot_thumbnail(self):
110 win = get_test_screenshot_thumbnail_window()
111 self.addCleanup(win.destroy)
112
113 def test_videoplayer(self):110 def test_videoplayer(self):
114 win = get_test_videoplayer_window()111 win = get_test_videoplayer_window()
115 self.addCleanup(win.destroy)112 self.addCleanup(win.destroy)
@@ -118,6 +115,19 @@
118 win = get_test_window_apptreeview()115 win = get_test_window_apptreeview()
119 self.addCleanup(win.destroy)116 self.addCleanup(win.destroy)
120117
118 def test_screenshot_thumbnail(self):
119 win = get_test_screenshot_thumbnail_window()
120 self.addCleanup(win.destroy)
121 t = win.get_data("screenshot_thumbnail_widget")
122 b = win.get_data("screenshot_thumbnail_cycle_test_button")
123 for i in range(5):
124 b.clicked()
125 do_events_with_sleep(iterations=5)
126 # ensure that either the big screeshot is visible or the loading
127 # spinner
128 self.assertTrue(t.main_screenshot.get_property("visible") or
129 t.spinner.get_property("visible"))
130
121131
122132
123class TestHWRequirements(unittest.TestCase):133class TestHWRequirements(unittest.TestCase):
124134
=== modified file 'tests/gtk3/windows.py'
--- tests/gtk3/windows.py 2012-09-20 00:53:48 +0000
+++ tests/gtk3/windows.py 2012-09-24 07:25:22 +0000
@@ -1038,17 +1038,35 @@
10381038
10391039
1040def get_test_screenshot_thumbnail_window():1040def get_test_screenshot_thumbnail_window():
1041
1042 class CycleState(object):
1043 def __init__(self):
1044 self.app_n = 0
1045 self.apps = [application.Application("Movie Player", "totem"),
1046 application.Application("Comix", "comix"),
1047 application.Application("Gimp", "gimp"),
1048 #application.Application("ACE", "uace"),
1049 ]
1050
1051 def testing_cycle_apps(widget, thumb, db, cycle_state):
1052 d = cycle_state.apps[cycle_state.app_n].get_details(db)
1053
1054 if cycle_state.app_n + 1 < len(cycle_state.apps):
1055 cycle_state.app_n += 1
1056 else:
1057 cycle_state.app_n = 0
1058
1059 thumb.fetch_screenshots(d)
1060 return True
1061
1062 cycle_state = CycleState()
1063
1041 vb = Gtk.VBox(spacing=6)1064 vb = Gtk.VBox(spacing=6)
1042 win = get_test_window(child=vb)1065 win = get_test_window(child=vb)
10431066
1044 icons = Gtk.IconTheme.get_default()1067 icons = get_test_gtk3_icon_cache()
1045 icons.append_search_path("/usr/share/app-install/icons/")
1046
1047 distro = softwarecenter.distro.get_distro()1068 distro = softwarecenter.distro.get_distro()
10481069
1049 init_sc_css_provider(win, Gtk.Settings.get_default(),
1050 Gdk.Screen.get_default())
1051
1052 t = thumbnail.ScreenshotGallery(distro, icons)1070 t = thumbnail.ScreenshotGallery(distro, icons)
1053 t.connect('draw', t.draw)1071 t.connect('draw', t.draw)
1054 frame = containers.FramedBox()1072 frame = containers.FramedBox()
@@ -1056,39 +1074,17 @@
10561074
1057 win.set_data("screenshot_thumbnail_widget", t)1075 win.set_data("screenshot_thumbnail_widget", t)
10581076
1059 b = Gtk.Button('A button for focus testing')1077 b = Gtk.Button('A button for cycle testing')
1060 vb.pack_start(b, True, True, 0)1078 vb.pack_start(b, False, False, 8)
1061 win.set_data("screenshot_button_widget", b)1079 win.set_data("screenshot_button_widget", b)
1062 vb.pack_start(frame, True, True, 0)1080 vb.pack_start(frame, True, True, 0)
10631081 win.set_data("screenshot_thumbnail_cycle_test_button", b)
1064 cache = pkginfo.get_pkg_info()1082
1065 cache.open()1083 db = get_test_db()
10661084 win.show_all()
1067 xapian_base_path = "/var/cache/software-center"1085
1068 pathname = os.path.join(xapian_base_path, "xapian")1086 testing_cycle_apps(None, t, db, cycle_state)
1069 db = database.StoreDatabase(pathname, cache)1087 b.connect("clicked", testing_cycle_apps, t, db, cycle_state)
1070 db.open()
1071
1072 apps = [application.Application("Movie Player", "totem"),
1073 application.Application("Comix", "comix"),
1074 application.Application("Gimp", "gimp"),
1075 application.Application("ACE", "uace")]
1076
1077 app_n = 0
1078
1079 def testing_cycle_apps(_, thumb, apps, db):
1080 global app_n
1081 d = apps[app_n].get_details(db)
1082
1083 if app_n + 1 < len(apps):
1084 app_n += 1
1085 else:
1086 app_n = 0
1087
1088 thumb.fetch_screenshots(d)
1089 return True
1090
1091 b.connect("clicked", testing_cycle_apps, t, apps, db)
10921088
1093 return win1089 return win
10941090

Subscribers

People subscribed via source and target branches