Merge lp:~barry/ubiquity/bug-792652 into lp:ubiquity

Proposed by Barry Warsaw
Status: Merged
Merged at revision: 5273
Proposed branch: lp:~barry/ubiquity/bug-792652
Merge into: lp:ubiquity
Diff against target: 120 lines (+62/-3) (has conflicts)
3 files modified
debian/changelog (+11/-0)
tests/test_language.py (+43/-3)
ubiquity/plugins/ubi-language.py (+8/-0)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~barry/ubiquity/bug-792652
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Evan (community) Approve
Review via email: mp+98209@code.launchpad.net

Description of the change

Solves LP: #792652, the "multiple clicks on Try Ubuntu crashes the installer"
problem. I'm not sure that's everything that bug 792652 is describing but
it's certainly one specific case.

To post a comment you must log in.
lp:~barry/ubiquity/bug-792652 updated
5267. By Barry Warsaw

Update master bug number

Revision history for this message
Evan (ev) wrote :

Looks good to me. I thought we might want to generalize this in plugin.only_this_page, but we do not appear to be calling into ok_handler from outside the normal flow anywhere else in the code.

review: Approve
Revision history for this message
Evan (ev) wrote :

From IRC:
[2:45pm] barry: cjwatson: branch update pushed; i'm not going to push to a different branch name
[2:48pm] cjwatson: barry: this is going to come across as a bit "oh, and another thing" - but I think it should be possible to unit-test this, and it'd be a good exercise
[2:49pm] cjwatson: you would do that by instantiating the UI widget in a test, firing the try-ubuntu-clicked event twice, and only then processing events
[2:49pm] barry: cjwatson: sure, it would be a good exercise for me to figure out how to do that. so, let me look into that.
[2:49pm] cjwatson: the wiki has details on running the test suite
[2:49pm] barry: cool. first, more tea, then i'll look at that
[2:49pm] cjwatson: in this case I guess the test case ought to go in tests/test_language.pyp
[2:49pm] cjwatson: -p
[2:50pm] cjwatson: (and I think it'd be good for other folks to see how that's done, too, UI tests being their own special black art)
[2:50pm] cjwatson: I don't especially care about separate tests for the KDE frontend - there's no framework for that as yet - but at least the GTK frontend
[2:50pm] barry: right. i've never done that before, so it's good to learn it.
[2:50pm] barry: brb
[2:51pm] cjwatson: there's a "gtkwidgets.refresh()" helper that processes any events that are pending
[2:51pm] cjwatson: you'll see it used in other tests
[2:51pm] cjwatson: the trick here may be in arranging for the backend filter to be in place

Revision history for this message
Barry Warsaw (barry) wrote :

Test added, ready for review. One caveat, from the commit message:

"One possibly questionable change is the coding: line, which is required to not
freak out Emacs."

lp:~barry/ubiquity/bug-792652 updated
5268. By Barry Warsaw

Add a test for bug 911907 by ensuring that the backend dbfilter.ok_handler is
only called once on multiple clicks of the Try Ubuntu link.

One possibly questionable change is the coding: line, which is required to not
freak out Emacs.

Revision history for this message
Colin Watson (cjwatson) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-03-19 16:54:03 +0000
3+++ debian/changelog 2012-03-19 17:02:20 +0000
4@@ -1,3 +1,4 @@
5+<<<<<<< TREE
6 ubiquity (2.9.30) UNRELEASED; urgency=low
7
8 [ Evan Dandrea ]
9@@ -18,6 +19,16 @@
10
11 -- Stéphane Graber <stgraber@ubuntu.com> Mon, 19 Mar 2012 12:22:59 -0400
12
13+=======
14+ubiquity (2.9.30) UNRELEASED; urgency=low
15+
16+ [ Barry Warsaw ]
17+ * When Try Ubuntu has been clicked once, don't respond to subsequent
18+ clicks. (LP: #911907)
19+
20+ -- Barry Warsaw <barry@ubuntu.com> Mon, 19 Mar 2012 10:34:45 -0400
21+
22+>>>>>>> MERGE-SOURCE
23 ubiquity (2.9.29) precise; urgency=low
24
25 [ Oliver Grawert ]
26
27=== modified file 'tests/test_language.py'
28--- tests/test_language.py 2012-02-15 02:51:13 +0000
29+++ tests/test_language.py 2012-03-19 17:02:20 +0000
30@@ -1,7 +1,8 @@
31 #!/usr/bin/python
32-# -*- coding: utf8; -*-
33+# -*- coding: utf-8; -*-
34
35 import unittest
36+from test.test_support import EnvironmentVarGuard
37
38 from gi.repository import Gtk
39 import mock
40@@ -18,7 +19,7 @@
41 return real_method(path, *args, **kw)
42 return side_effect
43
44-class LanguageTests(unittest.TestCase):
45+class OEMUserLanguageTests(unittest.TestCase):
46 def setUp(self):
47 for obj in ('ubiquity.misc.execute',
48 'ubiquity.misc.execute_root'):
49@@ -61,5 +62,44 @@
50 longest_length = length
51 longest = choice
52 pad = self.gtk.iconview.get_property('item-padding')
53- layout = self.gtk.iconview.create_pango_layout(longest)
54+ layout = self.gtk.iconview.create_pango_layout(longest)
55 self.assertEqual(layout.get_pixel_size()[0] + pad * 2, width)
56+
57+
58+class LanguageTests(unittest.TestCase):
59+ def setUp(self):
60+
61+ for obj in ('ubiquity.misc.execute',
62+ 'ubiquity.misc.execute_root'):
63+ patcher = mock.patch(obj)
64+ patcher.start()
65+ self.addCleanup(patcher.stop)
66+
67+ ubi_language = plugin_manager.load_plugin('ubi-language')
68+
69+ self.controller = mock.Mock()
70+ self.controller.oem_user_config = False
71+ self.controller.oem_config = False
72+ self.ubi_language = ubi_language
73+ # Set the environment variable needed in order for PageGtk to hook up
74+ # the Try Ubuntu button with the appropriate action.
75+ with EnvironmentVarGuard() as environ:
76+ environ['UBIQUITY_GREETER'] = '1'
77+ self.gtk = self.ubi_language.PageGtk(self.controller)
78+
79+ def test_try_ubuntu_clicks(self):
80+ from ubiquity import gtkwidgets
81+ # Ensure that the mock changes state correctly.
82+ self.controller.allowed_change_step.return_value = True
83+ def side_effect(*args):
84+ assert len(args) == 1 and type(args[0]) is bool
85+ self.controller.allowed_change_step.return_value = args[0]
86+ self.controller.allow_change_step.side_effect = side_effect
87+ # Multiple clicks on Try Ubuntu crash the installer. LP: #911907
88+ self.gtk.try_ubuntu.clicked()
89+ self.gtk.try_ubuntu.clicked()
90+ # Process the clicks.
91+ gtkwidgets.refresh()
92+ # When the Try Ubuntu button is clicked, the dbfilter's ok_handler()
93+ # methods should have been called only once.
94+ self.assertEqual(self.controller.dbfilter.ok_handler.call_count, 1)
95
96=== modified file 'ubiquity/plugins/ubi-language.py'
97--- ubiquity/plugins/ubi-language.py 2012-03-15 21:55:47 +0000
98+++ ubiquity/plugins/ubi-language.py 2012-03-19 17:02:20 +0000
99@@ -129,6 +129,10 @@
100
101 @plugin.only_this_page
102 def on_try_ubuntu_clicked(self, *args):
103+ if not self.controller.allowed_change_step():
104+ # The button's already been clicked once, so stop reacting to it.
105+ # LP: #911907.
106+ return
107 # Spinning cursor.
108 self.controller.allow_change_step(False)
109 # Queue quit.
110@@ -444,6 +448,10 @@
111
112 @plugin.only_this_page
113 def on_try_ubuntu_clicked(self, *args):
114+ if not self.controller.allowed_change_step():
115+ # The button's already been clicked once, so stop reacting to it.
116+ # LP: #911907.
117+ return
118 # Spinning cursor.
119 self.controller.allow_change_step(False)
120 # Queue quit.

Subscribers

People subscribed via source and target branches

to status/vote changes: