Back to index

apport  2.3
Public Member Functions | Public Attributes
test_ui_gtk.T Class Reference

List of all members.

Public Member Functions

def setUpClass
def setUp
def tearDown
def test_close_button
def test_kernel_crash_layout
def test_package_crash_layout
def test_regular_crash_layout
def test_regular_crash_layout_restart
def test_hang_layout
def test_system_crash_layout
def test_system_crash_from_console_layout
def test_examine_button
def test_apport_bug_package_layout
def test_administrator_disabled_reporting
def test_crash_nodetails
def test_crash_details
def test_crash_noaccept
def test_kerneloops_nodetails
def test_bug_report_installed_package
def test_bug_report_uninstalled_package
def test_update_report
def test_update_report_different_binary_source
def test_missing_icon
def test_resizing
def test_dialog_nonascii
def test_immediate_close
def test_close_during_collect

Public Attributes

 report_dir
 app
 hook_dir
 visible_progress

Detailed Description

Definition at line 38 of file test_ui_gtk.py.


Member Function Documentation

def test_ui_gtk.T.setUp (   self)

Definition at line 45 of file test_ui_gtk.py.

00045 
00046     def setUp(self):
00047         self.report_dir = tempfile.mkdtemp()
00048         apport.fileutils.report_dir = self.report_dir
00049         os.environ['APPORT_REPORT_DIR'] = self.report_dir
00050         # do not cause eternal hangs because of error dialog boxes
00051         os.environ['APPORT_DISABLE_DISTRO_CHECK'] = '1'
00052 
00053         saved = sys.argv[0]
00054         # Work around GTKUserInterface using basename to find the GtkBuilder UI
00055         # file.
00056         sys.argv[0] = apport_gtk_path
00057         self.app = GTKUserInterface()
00058         sys.argv[0] = saved
00059 
00060         # use in-memory crashdb
00061         self.app.crashdb = apport.crashdb_impl.memory.CrashDatabase(None, {})
00062 
00063         # test report
00064         self.app.report_file = os.path.join(self.report_dir, 'bash.crash')
00065 
00066         self.app.report = apport.Report()
00067         self.app.report['ExecutablePath'] = '/bin/bash'
00068         self.app.report['Signal'] = '11'
00069         self.app.report['CoreDump'] = b'\x01\x02'
00070         self.app.report['DistroRelease'] = self.distro
00071         with open(self.app.report_file, 'wb') as f:
00072             self.app.report.write(f)
00073 
00074         # disable package hooks, as they might ask for sudo password and other
00075         # interactive bits; allow tests to install their own hooks
00076         self.hook_dir = tempfile.mkdtemp()
00077         apport.report._hook_dir = self.hook_dir
00078         apport.report._common_hook_dir = self.hook_dir

def test_ui_gtk.T.setUpClass (   klass)

Definition at line 40 of file test_ui_gtk.py.

00040 
00041     def setUpClass(klass):
00042         r = apport.Report()
00043         r.add_os_info()
00044         klass.distro = r['DistroRelease'].split()[0]

def test_ui_gtk.T.tearDown (   self)

Definition at line 79 of file test_ui_gtk.py.

00079 
00080     def tearDown(self):
00081         shutil.rmtree(self.report_dir)
00082         shutil.rmtree(self.hook_dir)

Definition at line 406 of file test_ui_gtk.py.

00406 
00407     def test_administrator_disabled_reporting(self):
00408         GLib.idle_add(Gtk.main_quit)
00409         self.app.ui_present_report_details(False)
00410         send_error_report = self.app.w('send_error_report')
00411         self.assertFalse(send_error_report.get_property('visible'))
00412         self.assertFalse(send_error_report.get_active())

+-------------------------------------------------------------------+
| [ error  ] Send problem report to the developers?                 |
|                                                                   |
|            +----------------------------------------------------+ |
|            | |> ApportVersion                                   | |
|            | ...                                                | |
|            +----------------------------------------------------+ |
|                                                                   |
| [ Cancel ]                                               [ Send ] |
+-------------------------------------------------------------------+

Definition at line 375 of file test_ui_gtk.py.

00375 
00376     def test_apport_bug_package_layout(self):
00377         '''
00378         +-------------------------------------------------------------------+
00379         | [ error  ] Send problem report to the developers?                 |
00380         |                                                                   |
00381         |            +----------------------------------------------------+ |
00382         |            | |> ApportVersion                                   | |
00383         |            | ...                                                | |
00384         |            +----------------------------------------------------+ |
00385         |                                                                   |
00386         | [ Cancel ]                                               [ Send ] |
00387         +-------------------------------------------------------------------+
00388         '''
00389         self.app.report_file = None
00390         GLib.idle_add(Gtk.main_quit)
00391         self.app.ui_present_report_details(True)
00392         self.assertEqual(self.app.w('title_label').get_text(),
00393                          _('Send problem report to the developers?'))
00394         self.assertFalse(self.app.w('subtitle_label').get_property('visible'))
00395         send_error_report = self.app.w('send_error_report')
00396         self.assertFalse(send_error_report.get_property('visible'))
00397         self.assertTrue(send_error_report.get_active())
00398         self.assertFalse(self.app.w('show_details').get_property('visible'))
00399         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00400         self.assertEqual(self.app.w('continue_button').get_label(),
00401                          _('Send'))
00402         self.assertFalse(self.app.w('closed_button').get_property('visible'))
00403         self.assertTrue(self.app.w('cancel_button').get_property('visible'))
00404         self.assertTrue(self.app.w('details_scrolledwindow').get_property('visible'))
00405         self.assertTrue(self.app.w('dialog_crash_new').get_resizable())

Bug report for installed package

Definition at line 581 of file test_ui_gtk.py.

00581 
00582     def test_bug_report_installed_package(self):
00583         '''Bug report for installed package'''
00584 
00585         def c(*args):
00586             if not self.app.w('cancel_button').get_visible():
00587                 return True
00588             self.app.w('cancel_button').clicked()
00589             return False
00590 
00591         self.app.report_file = None
00592         self.app.options.package = 'bash'
00593         GLib.timeout_add_seconds(1, c)
00594         self.app.run_report_bug()
00595 
00596         self.assertEqual(self.app.report['ProblemType'], 'Bug')
00597         self.assertEqual(self.app.report['SourcePackage'], 'bash')
00598         self.assertTrue(self.app.report['Package'].startswith('bash '))
00599         self.assertNotEqual(self.app.report['Dependencies'], '')

Bug report for uninstalled package

Definition at line 600 of file test_ui_gtk.py.

00600 
00601     def test_bug_report_uninstalled_package(self):
00602         '''Bug report for uninstalled package'''
00603 
00604         def c(*args):
00605             if not self.app.w('cancel_button').get_visible():
00606                 return True
00607             self.app.w('cancel_button').clicked()
00608             return False
00609 
00610         pkg = apport.packaging.get_uninstalled_package()
00611         self.app.report_file = None
00612         self.app.options.package = pkg
00613         GLib.timeout_add_seconds(1, c)
00614         self.app.run_report_bug()
00615 
00616         self.assertEqual(self.app.report['ProblemType'], 'Bug')
00617         self.assertEqual(self.app.report['SourcePackage'],
00618                          apport.packaging.get_source(pkg))
00619         self.assertEqual(self.app.report['Package'], '%s (not installed)' % pkg)

Clicking the close button on the window does not report the crash.

Definition at line 83 of file test_ui_gtk.py.

00083 
00084     def test_close_button(self):
00085         '''Clicking the close button on the window does not report the crash.'''
00086 
00087         def c(*args):
00088             self.app.w('dialog_crash_new').destroy()
00089         self.app.w('send_error_report').set_active(True)
00090         GLib.idle_add(c)
00091         result = self.app.ui_present_report_details(True)
00092         self.assertFalse(result['report'])

def test_ui_gtk.T.test_close_during_collect (   self,
  args 
)
Close details window during information collection

Definition at line 793 of file test_ui_gtk.py.

00793 
00794     def test_close_during_collect(self, *args):
00795         '''Close details window during information collection'''
00796 
00797         def show_details(*args):
00798             if not self.app.w('show_details').get_visible():
00799                 return True
00800             self.app.w('show_details').clicked()
00801             GLib.timeout_add(200, close)
00802             return False
00803 
00804         def close(*args):
00805             self.app.w('dialog_crash_new').destroy()
00806             return False
00807 
00808         GLib.timeout_add(200, show_details)
00809         self.app.run_crash(self.app.report_file)
00810 
00811         self.assertEqual(self.app.ui_start_upload_progress.call_count, 0)
00812 
00813 unittest.main()
def test_ui_gtk.T.test_crash_details (   self,
  args 
)
Crash report with showing details

Definition at line 460 of file test_ui_gtk.py.

00460 
00461     def test_crash_details(self, *args):
00462         '''Crash report with showing details'''
00463 
00464         self.visible_progress = None
00465 
00466         def show_details(*args):
00467             if not self.app.w('show_details').get_visible():
00468                 return True
00469             self.app.w('show_details').clicked()
00470             GLib.timeout_add(200, cont)
00471             return False
00472 
00473         def cont(*args):
00474             # wait until data collection is done and tree filled
00475             if self.app.tree_model.get_iter_first() is None:
00476                 return True
00477 
00478             self.assertTrue(self.app.w('continue_button').get_visible())
00479             self.app.w('continue_button').clicked()
00480             GLib.timeout_add(500, check_progress)
00481             return False
00482 
00483         def check_progress(*args):
00484             self.visible_progress = self.app.w(
00485                 'window_information_collection').get_property('visible')
00486             return False
00487 
00488         GLib.timeout_add(200, show_details)
00489         self.app.run_crash(self.app.report_file)
00490 
00491         # we should have reported one crash
00492         self.assertEqual(self.app.crashdb.latest_id(), 0)
00493         r = self.app.crashdb.download(0)
00494         self.assertEqual(r['ProblemType'], 'Crash')
00495         self.assertEqual(r['ExecutablePath'], '/bin/bash')
00496 
00497         # we already collected details, do not show the progress dialog again
00498         self.assertEqual(self.visible_progress, False)
00499 
00500         # data was collected
00501         self.assertTrue(r['Package'].startswith('bash '))
00502         self.assertTrue('libc' in r['Dependencies'])
00503         self.assertTrue('Stacktrace' in r)
00504 
00505         # upload dialog shown
00506         self.assertEqual(self.app.ui_start_upload_progress.call_count, 1)
00507         self.assertEqual(self.app.ui_stop_upload_progress.call_count, 1)
00508 
00509         # URL was opened
00510         self.assertEqual(self.app.open_url.call_count, 1)

def test_ui_gtk.T.test_crash_noaccept (   self,
  args 
)
Crash report with non-accepting crash DB

Definition at line 512 of file test_ui_gtk.py.

00512 
00513     def test_crash_noaccept(self, *args):
00514         '''Crash report with non-accepting crash DB'''
00515 
00516         self.visible_progress = None
00517 
00518         def cont(*args):
00519             if not self.app.w('continue_button').get_visible():
00520                 return True
00521             self.app.w('continue_button').clicked()
00522             GLib.timeout_add(500, check_progress)
00523             return False
00524 
00525         def check_progress(*args):
00526             self.visible_progress = self.app.w(
00527                 'window_information_collection').get_property('visible')
00528             return False
00529 
00530         GLib.timeout_add_seconds(1, cont)
00531         self.app.crashdb.options['problem_types'] = ['bug']
00532         self.app.run_crash(self.app.report_file)
00533 
00534         # we should not have reported the crash
00535         self.assertEqual(self.app.crashdb.latest_id(), -1)
00536         self.assertEqual(self.app.open_url.call_count, 0)
00537 
00538         # no progress dialog for non-accepting DB
00539         self.assertEqual(self.visible_progress, False)
00540 
00541         # data was collected for whoopsie
00542         r = self.app.report
00543         self.assertEqual(r['ProblemType'], 'Crash')
00544         self.assertEqual(r['ExecutablePath'], '/bin/bash')
00545         self.assertTrue(r['Package'].startswith('bash '))
00546         self.assertTrue('libc' in r['Dependencies'])
00547         self.assertTrue('Stacktrace' in r)

def test_ui_gtk.T.test_crash_nodetails (   self,
  args 
)
Crash report without showing details

Definition at line 416 of file test_ui_gtk.py.

00416 
00417     def test_crash_nodetails(self, *args):
00418         '''Crash report without showing details'''
00419 
00420         self.visible_progress = None
00421 
00422         def cont(*args):
00423             if not self.app.w('continue_button').get_visible():
00424                 return True
00425             self.app.w('continue_button').clicked()
00426             GLib.timeout_add(500, check_progress)
00427             return False
00428 
00429         def check_progress(*args):
00430             self.visible_progress = self.app.w(
00431                 'window_information_collection').get_property('visible')
00432             return False
00433 
00434         GLib.timeout_add_seconds(1, cont)
00435         self.app.run_crash(self.app.report_file)
00436 
00437         # we should have reported one crash
00438         self.assertEqual(self.app.crashdb.latest_id(), 0)
00439         r = self.app.crashdb.download(0)
00440         self.assertEqual(r['ProblemType'], 'Crash')
00441         self.assertEqual(r['ExecutablePath'], '/bin/bash')
00442 
00443         # should show a progress bar for info collection
00444         self.assertEqual(self.visible_progress, True)
00445 
00446         # data was collected
00447         self.assertTrue(r['Package'].startswith('bash '))
00448         self.assertTrue('libc' in r['Dependencies'])
00449         self.assertTrue('Stacktrace' in r)
00450 
00451         # upload dialog shown
00452         self.assertEqual(self.app.ui_start_upload_progress.call_count, 1)
00453         self.assertEqual(self.app.ui_stop_upload_progress.call_count, 1)
00454 
00455         # URL was opened
00456         self.assertEqual(self.app.open_url.call_count, 1)

Non-ASCII title/text in dialogs

Definition at line 760 of file test_ui_gtk.py.

00760 
00761     def test_dialog_nonascii(self):
00762         '''Non-ASCII title/text in dialogs'''
00763 
00764         def close(response):
00765             if not self.app.md:
00766                 return True
00767             self.app.md.response(response)
00768             return False
00769 
00770         # unicode arguments
00771         GLib.timeout_add(200, close, 0)
00772         self.app.ui_info_message(b'title \xe2\x99\xaa'.decode('UTF-8'), b'text \xe2\x99\xaa'.decode('UTF-8'))
00773         # byte array arguments (in Python 2)
00774         if sys.version < '3':
00775             GLib.timeout_add(200, close, 0)
00776             self.app.ui_info_message(b'title \xe2\x99\xaa', b'text \xe2\x99\xaa')
00777 
00778         # with URLs
00779         GLib.timeout_add(200, close, 0)
00780         self.app.ui_info_message('title', b'http://example.com \xe2\x99\xaa'.decode('UTF-8'))
00781         if sys.version < '3':
00782             GLib.timeout_add(200, close, 0)
00783             self.app.ui_info_message('title', b'http://example.com \xe2\x99\xaa')

def test_ui_gtk.T.test_examine_button (   self,
  args 
)
+---------------------------------------------------------------------+
| [ apport ] The application Apport has closed unexpectedly.          |
|                                                                     |
|            [x] Send an error report to help fix this problem.       |
|                                                                     |
| [ Show Details ] [ Examine locally ]  [ Leave Closed ] [ Relaunch ] |
+---------------------------------------------------------------------+

Definition at line 351 of file test_ui_gtk.py.

00351 
00352     def test_examine_button(self, *args):
00353         '''
00354         +---------------------------------------------------------------------+
00355         | [ apport ] The application Apport has closed unexpectedly.          |
00356         |                                                                     |
00357         |            [x] Send an error report to help fix this problem.       |
00358         |                                                                     |
00359         | [ Show Details ] [ Examine locally ]  [ Leave Closed ] [ Relaunch ] |
00360         +---------------------------------------------------------------------+
00361         '''
00362         self.app.report['ProblemType'] = 'Crash'
00363         self.app.report['Package'] = 'bash 5'
00364 
00365         GLib.idle_add(Gtk.main_quit)
00366         self.app.can_examine_locally.return_value = False
00367         self.app.ui_present_report_details(True)
00368         self.assertFalse(self.app.w('examine').get_property('visible'))
00369 
00370         GLib.idle_add(self.app.w('examine').clicked)
00371         self.app.can_examine_locally.return_value = True
00372         result = self.app.ui_present_report_details(True)
00373         self.assertTrue(self.app.w('examine').get_property('visible'))
00374         self.assertTrue(result['examine'])

+-----------------------------------------------------------------+
| [ apport ] The application Apport has stopped responding.       |
|                                                                 |
|            [x] Send an error report to help fix this problem.   |
|                                                                 |
| [ Show Details ]                 [ Force Closed ]  [ Relaunch ] |
+-----------------------------------------------------------------+

Definition at line 230 of file test_ui_gtk.py.

00230 
00231     def test_hang_layout(self):
00232         '''
00233         +-----------------------------------------------------------------+
00234         | [ apport ] The application Apport has stopped responding.       |
00235         |                                                                 |
00236         |            [x] Send an error report to help fix this problem.   |
00237         |                                                                 |
00238         | [ Show Details ]                 [ Force Closed ]  [ Relaunch ] |
00239         +-----------------------------------------------------------------+
00240         '''
00241         self.app.report['ProblemType'] = 'Hang'
00242         self.app.report['ProcCmdline'] = 'apport-bug apport'
00243         self.app.report['Package'] = 'apport 1.2.3~0ubuntu1'
00244         with tempfile.NamedTemporaryFile() as fp:
00245             fp.write(b'''[Desktop Entry]
00246 Version=1.0
00247 Name=Apport
00248 Type=Application''')
00249             fp.flush()
00250             self.app.report['DesktopFile'] = fp.name
00251             GLib.idle_add(Gtk.main_quit)
00252             self.app.ui_present_report_details(True)
00253         self.assertEqual(self.app.w('dialog_crash_new').get_title(), self.distro)
00254         self.assertEqual(self.app.w('title_label').get_text(),
00255                          _('The application Apport has stopped responding.'))
00256         send_error_report = self.app.w('send_error_report')
00257         self.assertTrue(send_error_report.get_property('visible'))
00258         self.assertTrue(send_error_report.get_active())
00259         self.assertTrue(self.app.w('show_details').get_property('visible'))
00260         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00261         self.assertEqual(self.app.w('continue_button').get_label(),
00262                          _('Relaunch'))
00263         self.assertTrue(self.app.w('closed_button').get_property('visible'))
00264         self.assertEqual(self.app.w('closed_button').get_label(),
00265                          _('Force Closed'))
00266         self.assertFalse(self.app.w('subtitle_label').get_property('visible'))
00267         self.assertFalse(self.app.w('ignore_future_problems').get_property('visible'))

Close details window immediately

Definition at line 784 of file test_ui_gtk.py.

00784 
00785     def test_immediate_close(self):
00786         '''Close details window immediately'''
00787 
00788         # this reproduces https://launchpad.net/bugs/938090
00789         self.app.w('dialog_crash_new').destroy()
00790         GLib.idle_add(Gtk.main_quit)
00791         self.app.run_crash(self.app.report_file)

+-----------------------------------------------------------------+
| [ logo] YourDistro has experienced an internal error.           |
|                                                                 |
|            [x] Send an error report to help fix this problem.   |
|                                                                 |
| [ Show Details ]                                   [ Continue ] |
+-----------------------------------------------------------------+

Definition at line 93 of file test_ui_gtk.py.

00093 
00094     def test_kernel_crash_layout(self):
00095         '''
00096         +-----------------------------------------------------------------+
00097         | [ logo] YourDistro has experienced an internal error.           |
00098         |                                                                 |
00099         |            [x] Send an error report to help fix this problem.   |
00100         |                                                                 |
00101         | [ Show Details ]                                   [ Continue ] |
00102         +-----------------------------------------------------------------+
00103         '''
00104         self.app.report['ProblemType'] = 'KernelCrash'
00105         GLib.idle_add(Gtk.main_quit)
00106         self.app.ui_present_report_details(True)
00107         self.assertEqual(self.app.w('dialog_crash_new').get_title(), self.distro)
00108         self.assertEqual(self.app.w('title_label').get_text(),
00109                          _('Sorry, %s has experienced an internal error.') % self.distro)
00110         send_error_report = self.app.w('send_error_report')
00111         self.assertTrue(send_error_report.get_property('visible'))
00112         self.assertTrue(send_error_report.get_active())
00113         self.assertTrue(self.app.w('show_details').get_property('visible'))
00114         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00115         self.assertEqual(self.app.w('continue_button').get_label(),
00116                          _('Continue'))
00117         self.assertFalse(self.app.w('closed_button').get_property('visible'))
00118         self.assertFalse(self.app.w('subtitle_label').get_property('visible'))
00119         self.assertFalse(self.app.w('ignore_future_problems').get_property('visible'))

def test_ui_gtk.T.test_kerneloops_nodetails (   self,
  args 
)
Kernel oops report without showing details

Definition at line 549 of file test_ui_gtk.py.

00549 
00550     def test_kerneloops_nodetails(self, *args):
00551         '''Kernel oops report without showing details'''
00552 
00553         def cont(*args):
00554             if not self.app.w('continue_button').get_visible():
00555                 return True
00556             self.app.w('continue_button').clicked()
00557             return False
00558 
00559         # remove the crash from setUp() and create a kernel oops
00560         os.remove(self.app.report_file)
00561         kernel_oops = subprocess.Popen([kernel_oops_path], stdin=subprocess.PIPE)
00562         kernel_oops.communicate(b'Plasma conduit phase misalignment')
00563         self.assertEqual(kernel_oops.returncode, 0)
00564 
00565         GLib.timeout_add_seconds(1, cont)
00566         self.app.run_crashes()
00567 
00568         # we should have reported one crash
00569         self.assertEqual(self.app.crashdb.latest_id(), 0)
00570         r = self.app.crashdb.download(0)
00571         self.assertEqual(r['ProblemType'], 'KernelOops')
00572         self.assertEqual(r['OopsText'], 'Plasma conduit phase misalignment')
00573 
00574         # data was collected
00575         self.assertTrue('linux' in r['Package'])
00576         self.assertTrue('Dependencies' in r)
00577         self.assertTrue('Plasma conduit' in r['Title'])
00578 
00579         # URL was opened
00580         self.assertEqual(self.app.open_url.call_count, 1)

def test_ui_gtk.T.test_missing_icon (   self,
  args 
)

Definition at line 704 of file test_ui_gtk.py.

00704 
00705     def test_missing_icon(self, *args):
00706         # LP: 937354
00707         self.app.report['ProblemType'] = 'Crash'
00708         self.app.report['Package'] = 'apport 1.2.3~0ubuntu1'
00709         self.app.get_desktop_entry.return_value = {'name': 'apport', 'icon': 'nonexistent'}
00710         GLib.idle_add(Gtk.main_quit)
00711         self.app.ui_present_report_details(True)

+-----------------------------------------------------------------+
| [ error  ] Sorry, a problem occurred while installing software. |
|            Package: apport 1.2.3~0ubuntu1                       |
|                                                                 |
|            [x] Send an error report to help fix this problem.   |
|                                                                 |
| [ Show Details ]                                   [ Continue ] |
+-----------------------------------------------------------------+

Definition at line 120 of file test_ui_gtk.py.

00120 
00121     def test_package_crash_layout(self):
00122         '''
00123         +-----------------------------------------------------------------+
00124         | [ error  ] Sorry, a problem occurred while installing software. |
00125         |            Package: apport 1.2.3~0ubuntu1                       |
00126         |                                                                 |
00127         |            [x] Send an error report to help fix this problem.   |
00128         |                                                                 |
00129         | [ Show Details ]                                   [ Continue ] |
00130         +-----------------------------------------------------------------+
00131         '''
00132         self.app.report['ProblemType'] = 'Package'
00133         self.app.report['Package'] = 'apport 1.2.3~0ubuntu1'
00134         GLib.idle_add(Gtk.main_quit)
00135         self.app.ui_present_report_details(True)
00136         self.assertEqual(self.app.w('dialog_crash_new').get_title(), self.distro)
00137         self.assertEqual(self.app.w('title_label').get_text(),
00138                          _('Sorry, a problem occurred while installing software.'))
00139         send_error_report = self.app.w('send_error_report')
00140         self.assertTrue(send_error_report.get_property('visible'))
00141         self.assertTrue(send_error_report.get_active())
00142         self.assertTrue(self.app.w('show_details').get_property('visible'))
00143         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00144         self.assertEqual(self.app.w('continue_button').get_label(),
00145                          _('Continue'))
00146         self.assertFalse(self.app.w('closed_button').get_property('visible'))
00147         self.assertTrue(self.app.w('subtitle_label').get_property('visible'))
00148         self.assertEqual(self.app.w('subtitle_label').get_text(),
00149                          _('Package: apport 1.2.3~0ubuntu1'))

+-----------------------------------------------------------------+
| [ apport ] The application Apport has closed unexpectedly.      |
|                                                                 |
|            [x] Send an error report to help fix this problem.   |
|            [ ] Ignore future problems of this program version.  |
|                                                                 |
| [ Show Details ]                                   [ Continue ] |
+-----------------------------------------------------------------+

Definition at line 150 of file test_ui_gtk.py.

00150 
00151     def test_regular_crash_layout(self):
00152         '''
00153         +-----------------------------------------------------------------+
00154         | [ apport ] The application Apport has closed unexpectedly.      |
00155         |                                                                 |
00156         |            [x] Send an error report to help fix this problem.   |
00157         |            [ ] Ignore future problems of this program version.  |
00158         |                                                                 |
00159         | [ Show Details ]                                   [ Continue ] |
00160         +-----------------------------------------------------------------+
00161         '''
00162         self.app.report['ProblemType'] = 'Crash'
00163         self.app.report['CrashCounter'] = '1'
00164         self.app.report['Package'] = 'apport 1.2.3~0ubuntu1'
00165         with tempfile.NamedTemporaryFile() as fp:
00166             fp.write(b'''[Desktop Entry]
00167 Version=1.0
00168 Name=Apport
00169 Type=Application''')
00170             fp.flush()
00171             self.app.report['DesktopFile'] = fp.name
00172             GLib.idle_add(Gtk.main_quit)
00173             self.app.ui_present_report_details(True)
00174         self.assertEqual(self.app.w('dialog_crash_new').get_title(), self.distro)
00175         self.assertEqual(self.app.w('title_label').get_text(),
00176                          _('The application Apport has closed unexpectedly.'))
00177         send_error_report = self.app.w('send_error_report')
00178         self.assertTrue(send_error_report.get_property('visible'))
00179         self.assertTrue(send_error_report.get_active())
00180         self.assertTrue(self.app.w('show_details').get_property('visible'))
00181         # no ProcCmdline, cannot restart
00182         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00183         self.assertEqual(self.app.w('continue_button').get_label(),
00184                          _('Continue'))
00185         self.assertFalse(self.app.w('closed_button').get_property('visible'))
00186         self.assertFalse(self.app.w('subtitle_label').get_property('visible'))
00187         self.assertTrue(self.app.w('ignore_future_problems').get_property('visible'))
00188         self.assertTrue(self.app.w('ignore_future_problems').get_label().endswith(
00189             'of this program version'))

+-----------------------------------------------------------------+
| [ apport ] The application Apport has closed unexpectedly.      |
|                                                                 |
|            [x] Send an error report to help fix this problem.   |
|            [ ] Ignore future problems of this program version.  |
|                                                                 |
| [ Show Details ]                 [ Leave Closed ]  [ Relaunch ] |
+-----------------------------------------------------------------+

Definition at line 190 of file test_ui_gtk.py.

00190 
00191     def test_regular_crash_layout_restart(self):
00192         '''
00193         +-----------------------------------------------------------------+
00194         | [ apport ] The application Apport has closed unexpectedly.      |
00195         |                                                                 |
00196         |            [x] Send an error report to help fix this problem.   |
00197         |            [ ] Ignore future problems of this program version.  |
00198         |                                                                 |
00199         | [ Show Details ]                 [ Leave Closed ]  [ Relaunch ] |
00200         +-----------------------------------------------------------------+
00201         '''
00202         self.app.report['ProblemType'] = 'Crash'
00203         self.app.report['CrashCounter'] = '1'
00204         self.app.report['ProcCmdline'] = 'apport-bug apport'
00205         self.app.report['Package'] = 'apport 1.2.3~0ubuntu1'
00206         with tempfile.NamedTemporaryFile() as fp:
00207             fp.write(b'''[Desktop Entry]
00208 Version=1.0
00209 Name=Apport
00210 Type=Application''')
00211             fp.flush()
00212             self.app.report['DesktopFile'] = fp.name
00213             GLib.idle_add(Gtk.main_quit)
00214             self.app.ui_present_report_details(True)
00215         self.assertEqual(self.app.w('dialog_crash_new').get_title(), self.distro)
00216         self.assertEqual(self.app.w('title_label').get_text(),
00217                          _('The application Apport has closed unexpectedly.'))
00218         send_error_report = self.app.w('send_error_report')
00219         self.assertTrue(send_error_report.get_property('visible'))
00220         self.assertTrue(send_error_report.get_active())
00221         self.assertTrue(self.app.w('show_details').get_property('visible'))
00222         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00223         self.assertEqual(self.app.w('continue_button').get_label(),
00224                          _('Relaunch'))
00225         self.assertTrue(self.app.w('closed_button').get_property('visible'))
00226         self.assertFalse(self.app.w('subtitle_label').get_property('visible'))
00227         self.assertTrue(self.app.w('ignore_future_problems').get_property('visible'))
00228         self.assertTrue(self.app.w('ignore_future_problems').get_label().endswith(
00229             'of this program version'))

Problem report window resizability and sizing.

Definition at line 712 of file test_ui_gtk.py.

00712 
00713     def test_resizing(self):
00714         '''Problem report window resizability and sizing.'''
00715 
00716         def show_details(data):
00717             if not self.app.w('show_details').get_visible():
00718                 return True
00719 
00720             data['orig_size'] = self.app.w('dialog_crash_new').get_size()
00721             data['orig_resizable'] = self.app.w('dialog_crash_new').get_resizable()
00722             self.app.w('show_details').clicked()
00723             GLib.timeout_add(200, hide_details, data)
00724             return False
00725 
00726         def hide_details(data):
00727             # wait until data collection is done and tree filled
00728             if self.app.tree_model.get_iter_first() is None:
00729                 return True
00730 
00731             data['detail_size'] = self.app.w('dialog_crash_new').get_size()
00732             data['detail_resizable'] = self.app.w('dialog_crash_new').get_resizable()
00733             self.app.w('show_details').clicked()
00734             GLib.timeout_add(200, details_hidden, data)
00735             return False
00736 
00737         def details_hidden(data):
00738             # wait until data collection is done and tree filled
00739             if self.app.w('details_scrolledwindow').get_visible():
00740                 return True
00741 
00742             data['hidden_size'] = self.app.w('dialog_crash_new').get_size()
00743             data['hidden_resizable'] = self.app.w('dialog_crash_new').get_resizable()
00744             Gtk.main_quit()
00745 
00746         data = {}
00747         GLib.timeout_add(200, show_details, data)
00748         self.app.run_crash(self.app.report_file)
00749 
00750         # when showing details, dialog should get considerably bigger
00751         self.assertGreater(data['detail_size'][1], data['orig_size'][1] + 100)
00752 
00753         # when hiding details, original size should be restored
00754         self.assertEqual(data['orig_size'], data['hidden_size'])
00755 
00756         # should only be resizable in details mode
00757         self.assertFalse(data['orig_resizable'])
00758         self.assertTrue(data['detail_resizable'])
00759         self.assertFalse(data['hidden_resizable'])

+-------------------------------------------------------------------+
| [ ubuntu ] Sorry, the application apport has closed unexpectedly. |
|            If you notice further problems, try restarting the     |
|            computer                                               |
|                                                                   |
|            [x] Send an error report to help fix this problem.     |
|                                                                   |
| [ Show Details ]                                     [ Continue ] |
+-------------------------------------------------------------------+

Definition at line 304 of file test_ui_gtk.py.

00304 
00305     def test_system_crash_from_console_layout(self):
00306         '''
00307         +-------------------------------------------------------------------+
00308         | [ ubuntu ] Sorry, the application apport has closed unexpectedly. |
00309         |            If you notice further problems, try restarting the     |
00310         |            computer                                               |
00311         |                                                                   |
00312         |            [x] Send an error report to help fix this problem.     |
00313         |                                                                   |
00314         | [ Show Details ]                                     [ Continue ] |
00315         +-------------------------------------------------------------------+
00316         '''
00317         self.app.report['ProblemType'] = 'Crash'
00318         self.app.report['Package'] = 'bash 5'
00319         self.app.report['ProcEnviron'] = ('LANGUAGE=en_GB:en\n'
00320                                           'SHELL=/bin/sh\n'
00321                                           'TERM=xterm')
00322         self.app.report['ExecutablePath'] = '/usr/bin/apport'
00323         # This will be set by apport/ui.py in load_report()
00324         self.app.cur_package = 'apport'
00325         GLib.idle_add(Gtk.main_quit)
00326         self.app.ui_present_report_details(True)
00327         self.assertEqual(self.app.w('dialog_crash_new').get_title(), self.distro)
00328         self.assertEqual(self.app.w('title_label').get_text(),
00329                          _('Sorry, the application apport has closed unexpectedly.'))
00330         self.assertEqual(self.app.w('subtitle_label').get_text(),
00331                          _('If you notice further problems, try restarting the computer.'))
00332         self.assertTrue(self.app.w('subtitle_label').get_property('visible'))
00333         send_error_report = self.app.w('send_error_report')
00334         self.assertTrue(send_error_report.get_property('visible'))
00335         self.assertTrue(send_error_report.get_active())
00336         self.assertTrue(self.app.w('show_details').get_property('visible'))
00337         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00338         self.assertEqual(self.app.w('continue_button').get_label(),
00339                          _('Continue'))
00340         self.assertFalse(self.app.w('closed_button').get_property('visible'))
00341 
00342         del self.app.report['ExecutablePath']
00343         GLib.idle_add(Gtk.main_quit)
00344         self.app.ui_present_report_details(True)
00345         self.assertEqual(self.app.w('title_label').get_text(),
00346                          _('Sorry, apport has closed unexpectedly.'))
00347 
00348         # no crash counter
00349         self.assertFalse(self.app.w('ignore_future_problems').get_property('visible'))

+---------------------------------------------------------------+
| [ logo ] Sorry, YourDistro has experienced an internal error. |
|          If you notice further problems, try restarting the   |
|          computer                                             |
|                                                               |
|            [x] Send an error report to help fix this problem. |
|            [ ] Ignore future problems of this type.           |
|                                                               |
| [ Show Details ]                                 [ Continue ] |
+---------------------------------------------------------------+

Definition at line 268 of file test_ui_gtk.py.

00268 
00269     def test_system_crash_layout(self):
00270         '''
00271         +---------------------------------------------------------------+
00272         | [ logo ] Sorry, YourDistro has experienced an internal error. |
00273         |          If you notice further problems, try restarting the   |
00274         |          computer                                             |
00275         |                                                               |
00276         |            [x] Send an error report to help fix this problem. |
00277         |            [ ] Ignore future problems of this type.           |
00278         |                                                               |
00279         | [ Show Details ]                                 [ Continue ] |
00280         +---------------------------------------------------------------+
00281         '''
00282         self.app.report['ProblemType'] = 'Crash'
00283         self.app.report['CrashCounter'] = '1'
00284         self.app.report['Package'] = 'bash 5'
00285         GLib.idle_add(Gtk.main_quit)
00286         self.app.ui_present_report_details(True)
00287         self.assertEqual(self.app.w('dialog_crash_new').get_title(), self.distro)
00288         self.assertEqual(self.app.w('title_label').get_text(),
00289                          _('Sorry, %s has experienced an internal error.') % self.distro)
00290         self.assertEqual(self.app.w('subtitle_label').get_text(),
00291                          _('If you notice further problems, try restarting the computer.'))
00292         self.assertTrue(self.app.w('subtitle_label').get_property('visible'))
00293         send_error_report = self.app.w('send_error_report')
00294         self.assertTrue(send_error_report.get_property('visible'))
00295         self.assertTrue(send_error_report.get_active())
00296         self.assertTrue(self.app.w('show_details').get_property('visible'))
00297         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00298         self.assertEqual(self.app.w('continue_button').get_label(),
00299                          _('Continue'))
00300         self.assertFalse(self.app.w('closed_button').get_property('visible'))
00301         self.assertTrue(self.app.w('ignore_future_problems').get_property('visible'))
00302         self.assertTrue(self.app.w('ignore_future_problems').get_label().endswith(
00303             'of this type'))

def test_ui_gtk.T.test_update_report (   self,
  args 
)
Updating an existing report

Definition at line 621 of file test_ui_gtk.py.

00621 
00622     def test_update_report(self, *args):
00623         '''Updating an existing report'''
00624 
00625         self.app.report_file = None
00626 
00627         def cont(*args):
00628             if self.app.tree_model.get_iter_first() is None:
00629                 return True
00630             self.app.w('continue_button').clicked()
00631             return False
00632 
00633         # upload empty report
00634         id = self.app.crashdb.upload({})
00635         self.assertEqual(id, 0)
00636         self.app.options.update_report = 0
00637         self.app.options.package = 'bash'
00638 
00639         GLib.timeout_add(200, cont)
00640         self.app.run_update_report()
00641 
00642         # no new bug reported
00643         self.assertEqual(self.app.crashdb.latest_id(), 0)
00644 
00645         # bug was updated
00646         r = self.app.crashdb.download(0)
00647         self.assertTrue(r['Package'].startswith('bash '))
00648         self.assertTrue('libc' in r['Dependencies'])
00649         self.assertTrue('DistroRelease' in r)
00650 
00651         # No URL in this mode
00652         self.assertEqual(self.app.open_url.call_count, 0)

Updating an existing report on a source package which does not have a binary of the same name

Definition at line 654 of file test_ui_gtk.py.

00654 
00655     def test_update_report_different_binary_source(self, *args):
00656         '''Updating an existing report on a source package which does not have a binary of the same name'''
00657 
00658         self.app.report_file = None
00659 
00660         def cont(*args):
00661             if self.app.tree_model.get_iter_first() is None:
00662                 return True
00663             self.app.w('continue_button').clicked()
00664             return False
00665 
00666         kernel_pkg = apport.packaging.get_kernel_package()
00667         kernel_src = apport.packaging.get_source(kernel_pkg)
00668         self.assertNotEqual(kernel_pkg, kernel_src,
00669                             'this test assumes that the kernel binary package != kernel source package')
00670         self.assertNotEqual(apport.packaging.get_version(kernel_pkg), '',
00671                             'this test assumes that the kernel binary package %s is installed' % kernel_pkg)
00672         # this test assumes that the kernel source package name is not an
00673         # installed binary package
00674         self.assertRaises(ValueError, apport.packaging.get_version, kernel_src)
00675 
00676         # create source package hook, as otherwise there is nothing to collect
00677         with open(os.path.join(self.hook_dir, 'source_%s.py' % kernel_src), 'w') as f:
00678             f.write('def add_info(r, ui):\n r["MachineType"]="Laptop"\n')
00679 
00680         # upload empty report
00681         id = self.app.crashdb.upload({})
00682         self.assertEqual(id, 0)
00683 
00684         # run in update mode for that bug
00685         self.app.options.update_report = 0
00686         self.app.options.package = kernel_src
00687 
00688         GLib.timeout_add(200, cont)
00689         self.app.run_update_report()
00690 
00691         # no new bug reported
00692         self.assertEqual(self.app.crashdb.latest_id(), 0)
00693 
00694         # bug was updated
00695         r = self.app.crashdb.download(0)
00696         self.assertTrue('ProcEnviron' in r)
00697         self.assertTrue('DistroRelease' in r)
00698         self.assertTrue('Uname' in r)
00699         self.assertEqual(r['MachineType'], 'Laptop')
00700 
00701         # No URL in this mode
00702         self.assertEqual(self.app.open_url.call_count, 0)


Member Data Documentation

Definition at line 56 of file test_ui_gtk.py.

Definition at line 75 of file test_ui_gtk.py.

Definition at line 46 of file test_ui_gtk.py.

Definition at line 419 of file test_ui_gtk.py.


The documentation for this class was generated from the following file: