Back to index

apport  2.4
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_recoverable_crash_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 445 of file test_ui_gtk.py.

00445 
00446     def test_administrator_disabled_reporting(self):
00447         GLib.idle_add(Gtk.main_quit)
00448         self.app.ui_present_report_details(False)
00449         send_error_report = self.app.w('send_error_report')
00450         self.assertFalse(send_error_report.get_property('visible'))
00451         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 620 of file test_ui_gtk.py.

00620 
00621     def test_bug_report_installed_package(self):
00622         '''Bug report for installed package'''
00623 
00624         def c(*args):
00625             if not self.app.w('cancel_button').get_visible():
00626                 return True
00627             self.app.w('cancel_button').clicked()
00628             return False
00629 
00630         self.app.report_file = None
00631         self.app.options.package = 'bash'
00632         GLib.timeout_add_seconds(1, c)
00633         self.app.run_report_bug()
00634 
00635         self.assertEqual(self.app.report['ProblemType'], 'Bug')
00636         self.assertEqual(self.app.report['SourcePackage'], 'bash')
00637         self.assertTrue(self.app.report['Package'].startswith('bash '))
00638         self.assertNotEqual(self.app.report['Dependencies'], '')

Bug report for uninstalled package

Definition at line 639 of file test_ui_gtk.py.

00639 
00640     def test_bug_report_uninstalled_package(self):
00641         '''Bug report for uninstalled package'''
00642 
00643         def c(*args):
00644             if not self.app.w('cancel_button').get_visible():
00645                 return True
00646             self.app.w('cancel_button').clicked()
00647             return False
00648 
00649         pkg = apport.packaging.get_uninstalled_package()
00650         self.app.report_file = None
00651         self.app.options.package = pkg
00652         GLib.timeout_add_seconds(1, c)
00653         self.app.run_report_bug()
00654 
00655         self.assertEqual(self.app.report['ProblemType'], 'Bug')
00656         self.assertEqual(self.app.report['SourcePackage'],
00657                          apport.packaging.get_source(pkg))
00658         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 832 of file test_ui_gtk.py.

00832 
00833     def test_close_during_collect(self, *args):
00834         '''Close details window during information collection'''
00835 
00836         def show_details(*args):
00837             if not self.app.w('show_details').get_visible():
00838                 return True
00839             self.app.w('show_details').clicked()
00840             GLib.timeout_add(200, close)
00841             return False
00842 
00843         def close(*args):
00844             self.app.w('dialog_crash_new').destroy()
00845             return False
00846 
00847         GLib.timeout_add(200, show_details)
00848         self.app.run_crash(self.app.report_file)
00849 
00850         self.assertEqual(self.app.ui_start_upload_progress.call_count, 0)
00851 
00852 unittest.main()
def test_ui_gtk.T.test_crash_details (   self,
  args 
)
Crash report with showing details

Definition at line 499 of file test_ui_gtk.py.

00499 
00500     def test_crash_details(self, *args):
00501         '''Crash report with showing details'''
00502 
00503         self.visible_progress = None
00504 
00505         def show_details(*args):
00506             if not self.app.w('show_details').get_visible():
00507                 return True
00508             self.app.w('show_details').clicked()
00509             GLib.timeout_add(200, cont)
00510             return False
00511 
00512         def cont(*args):
00513             # wait until data collection is done and tree filled
00514             if self.app.tree_model.get_iter_first() is None:
00515                 return True
00516 
00517             self.assertTrue(self.app.w('continue_button').get_visible())
00518             self.app.w('continue_button').clicked()
00519             GLib.timeout_add(500, check_progress)
00520             return False
00521 
00522         def check_progress(*args):
00523             self.visible_progress = self.app.w(
00524                 'window_information_collection').get_property('visible')
00525             return False
00526 
00527         GLib.timeout_add(200, show_details)
00528         self.app.run_crash(self.app.report_file)
00529 
00530         # we should have reported one crash
00531         self.assertEqual(self.app.crashdb.latest_id(), 0)
00532         r = self.app.crashdb.download(0)
00533         self.assertEqual(r['ProblemType'], 'Crash')
00534         self.assertEqual(r['ExecutablePath'], '/bin/bash')
00535 
00536         # we already collected details, do not show the progress dialog again
00537         self.assertEqual(self.visible_progress, False)
00538 
00539         # data was collected
00540         self.assertTrue(r['Package'].startswith('bash '))
00541         self.assertTrue('libc' in r['Dependencies'])
00542         self.assertTrue('Stacktrace' in r)
00543 
00544         # upload dialog shown
00545         self.assertEqual(self.app.ui_start_upload_progress.call_count, 1)
00546         self.assertEqual(self.app.ui_stop_upload_progress.call_count, 1)
00547 
00548         # URL was opened
00549         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 551 of file test_ui_gtk.py.

00551 
00552     def test_crash_noaccept(self, *args):
00553         '''Crash report with non-accepting crash DB'''
00554 
00555         self.visible_progress = None
00556 
00557         def cont(*args):
00558             if not self.app.w('continue_button').get_visible():
00559                 return True
00560             self.app.w('continue_button').clicked()
00561             GLib.timeout_add(500, check_progress)
00562             return False
00563 
00564         def check_progress(*args):
00565             self.visible_progress = self.app.w(
00566                 'window_information_collection').get_property('visible')
00567             return False
00568 
00569         GLib.timeout_add_seconds(1, cont)
00570         self.app.crashdb.options['problem_types'] = ['bug']
00571         self.app.run_crash(self.app.report_file)
00572 
00573         # we should not have reported the crash
00574         self.assertEqual(self.app.crashdb.latest_id(), -1)
00575         self.assertEqual(self.app.open_url.call_count, 0)
00576 
00577         # no progress dialog for non-accepting DB
00578         self.assertEqual(self.visible_progress, False)
00579 
00580         # data was collected for whoopsie
00581         r = self.app.report
00582         self.assertEqual(r['ProblemType'], 'Crash')
00583         self.assertEqual(r['ExecutablePath'], '/bin/bash')
00584         self.assertTrue(r['Package'].startswith('bash '))
00585         self.assertTrue('libc' in r['Dependencies'])
00586         self.assertTrue('Stacktrace' in r)

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

Definition at line 455 of file test_ui_gtk.py.

00455 
00456     def test_crash_nodetails(self, *args):
00457         '''Crash report without showing details'''
00458 
00459         self.visible_progress = None
00460 
00461         def cont(*args):
00462             if not self.app.w('continue_button').get_visible():
00463                 return True
00464             self.app.w('continue_button').clicked()
00465             GLib.timeout_add(500, check_progress)
00466             return False
00467 
00468         def check_progress(*args):
00469             self.visible_progress = self.app.w(
00470                 'window_information_collection').get_property('visible')
00471             return False
00472 
00473         GLib.timeout_add_seconds(1, cont)
00474         self.app.run_crash(self.app.report_file)
00475 
00476         # we should have reported one crash
00477         self.assertEqual(self.app.crashdb.latest_id(), 0)
00478         r = self.app.crashdb.download(0)
00479         self.assertEqual(r['ProblemType'], 'Crash')
00480         self.assertEqual(r['ExecutablePath'], '/bin/bash')
00481 
00482         # should show a progress bar for info collection
00483         self.assertEqual(self.visible_progress, True)
00484 
00485         # data was collected
00486         self.assertTrue(r['Package'].startswith('bash '))
00487         self.assertTrue('libc' in r['Dependencies'])
00488         self.assertTrue('Stacktrace' in r)
00489 
00490         # upload dialog shown
00491         self.assertEqual(self.app.ui_start_upload_progress.call_count, 1)
00492         self.assertEqual(self.app.ui_stop_upload_progress.call_count, 1)
00493 
00494         # URL was opened
00495         self.assertEqual(self.app.open_url.call_count, 1)

Non-ASCII title/text in dialogs

Definition at line 799 of file test_ui_gtk.py.

00799 
00800     def test_dialog_nonascii(self):
00801         '''Non-ASCII title/text in dialogs'''
00802 
00803         def close(response):
00804             if not self.app.md:
00805                 return True
00806             self.app.md.response(response)
00807             return False
00808 
00809         # unicode arguments
00810         GLib.timeout_add(200, close, 0)
00811         self.app.ui_info_message(b'title \xe2\x99\xaa'.decode('UTF-8'), b'text \xe2\x99\xaa'.decode('UTF-8'))
00812         # byte array arguments (in Python 2)
00813         if sys.version < '3':
00814             GLib.timeout_add(200, close, 0)
00815             self.app.ui_info_message(b'title \xe2\x99\xaa', b'text \xe2\x99\xaa')
00816 
00817         # with URLs
00818         GLib.timeout_add(200, close, 0)
00819         self.app.ui_info_message('title', b'http://example.com \xe2\x99\xaa'.decode('UTF-8'))
00820         if sys.version < '3':
00821             GLib.timeout_add(200, close, 0)
00822             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 823 of file test_ui_gtk.py.

00823 
00824     def test_immediate_close(self):
00825         '''Close details window immediately'''
00826 
00827         # this reproduces https://launchpad.net/bugs/938090
00828         self.app.w('dialog_crash_new').destroy()
00829         GLib.idle_add(Gtk.main_quit)
00830         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 588 of file test_ui_gtk.py.

00588 
00589     def test_kerneloops_nodetails(self, *args):
00590         '''Kernel oops report without showing details'''
00591 
00592         def cont(*args):
00593             if not self.app.w('continue_button').get_visible():
00594                 return True
00595             self.app.w('continue_button').clicked()
00596             return False
00597 
00598         # remove the crash from setUp() and create a kernel oops
00599         os.remove(self.app.report_file)
00600         kernel_oops = subprocess.Popen([kernel_oops_path], stdin=subprocess.PIPE)
00601         kernel_oops.communicate(b'Plasma conduit phase misalignment')
00602         self.assertEqual(kernel_oops.returncode, 0)
00603 
00604         GLib.timeout_add_seconds(1, cont)
00605         self.app.run_crashes()
00606 
00607         # we should have reported one crash
00608         self.assertEqual(self.app.crashdb.latest_id(), 0)
00609         r = self.app.crashdb.download(0)
00610         self.assertEqual(r['ProblemType'], 'KernelOops')
00611         self.assertEqual(r['OopsText'], 'Plasma conduit phase misalignment')
00612 
00613         # data was collected
00614         self.assertTrue('linux' in r['Package'])
00615         self.assertTrue('Dependencies' in r)
00616         self.assertTrue('Plasma conduit' in r['Title'])
00617 
00618         # URL was opened
00619         self.assertEqual(self.app.open_url.call_count, 1)

def test_ui_gtk.T.test_missing_icon (   self,
  args 
)

Definition at line 743 of file test_ui_gtk.py.

00743 
00744     def test_missing_icon(self, *args):
00745         # LP: 937354
00746         self.app.report['ProblemType'] = 'Crash'
00747         self.app.report['Package'] = 'apport 1.2.3~0ubuntu1'
00748         self.app.get_desktop_entry.return_value = {'name': 'apport', 'icon': 'nonexistent'}
00749         GLib.idle_add(Gtk.main_quit)
00750         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'))

+-----------------------------------------------------------------+
| [ logo ] The application Foo has experienced an internal error. |
|          Developer-specified error text.                        |
|                                                                 |
|            [x] Send an error report to help fix this problem.   |
|                                                                 |
| [ Show Details ]                                   [ Continue ] |
+-----------------------------------------------------------------+

Definition at line 406 of file test_ui_gtk.py.

00406 
00407     def test_recoverable_crash_layout(self):
00408         '''
00409         +-----------------------------------------------------------------+
00410         | [ logo ] The application Foo has experienced an internal error. |
00411         |          Developer-specified error text.                        |
00412         |                                                                 |
00413         |            [x] Send an error report to help fix this problem.   |
00414         |                                                                 |
00415         | [ Show Details ]                                   [ Continue ] |
00416         +-----------------------------------------------------------------+
00417         '''
00418         self.app.report['ProblemType'] = 'RecoverableProblem'
00419         self.app.report['Package'] = 'apport 1.2.3~0ubuntu1'
00420         self.app.report['DialogBody'] = 'Some developer-specified error text.'
00421         with tempfile.NamedTemporaryFile() as fp:
00422             fp.write(b'''[Desktop Entry]
00423 Version=1.0
00424 Name=Apport
00425 Type=Application''')
00426             fp.flush()
00427             self.app.report['DesktopFile'] = fp.name
00428             GLib.idle_add(Gtk.main_quit)
00429             self.app.ui_present_report_details(True)
00430         self.assertEqual(self.app.w('dialog_crash_new').get_title(),
00431                          self.distro)
00432         msg = 'The application Apport has experienced an internal error.'
00433         self.assertEqual(self.app.w('title_label').get_text(), msg)
00434         msg = 'Some developer-specified error text.'
00435         self.assertEqual(self.app.w('subtitle_label').get_text(), msg)
00436         self.assertTrue(self.app.w('subtitle_label').get_property('visible'))
00437         send_error_report = self.app.w('send_error_report')
00438         self.assertTrue(send_error_report.get_property('visible'))
00439         self.assertTrue(send_error_report.get_active())
00440         self.assertTrue(self.app.w('show_details').get_property('visible'))
00441         self.assertTrue(self.app.w('continue_button').get_property('visible'))
00442         self.assertEqual(self.app.w('continue_button').get_label(),
00443                          _('Continue'))
00444         self.assertFalse(self.app.w('closed_button').get_property('visible'))

+-----------------------------------------------------------------+
| [ 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 751 of file test_ui_gtk.py.

00751 
00752     def test_resizing(self):
00753         '''Problem report window resizability and sizing.'''
00754 
00755         def show_details(data):
00756             if not self.app.w('show_details').get_visible():
00757                 return True
00758 
00759             data['orig_size'] = self.app.w('dialog_crash_new').get_size()
00760             data['orig_resizable'] = self.app.w('dialog_crash_new').get_resizable()
00761             self.app.w('show_details').clicked()
00762             GLib.timeout_add(200, hide_details, data)
00763             return False
00764 
00765         def hide_details(data):
00766             # wait until data collection is done and tree filled
00767             if self.app.tree_model.get_iter_first() is None:
00768                 return True
00769 
00770             data['detail_size'] = self.app.w('dialog_crash_new').get_size()
00771             data['detail_resizable'] = self.app.w('dialog_crash_new').get_resizable()
00772             self.app.w('show_details').clicked()
00773             GLib.timeout_add(200, details_hidden, data)
00774             return False
00775 
00776         def details_hidden(data):
00777             # wait until data collection is done and tree filled
00778             if self.app.w('details_scrolledwindow').get_visible():
00779                 return True
00780 
00781             data['hidden_size'] = self.app.w('dialog_crash_new').get_size()
00782             data['hidden_resizable'] = self.app.w('dialog_crash_new').get_resizable()
00783             Gtk.main_quit()
00784 
00785         data = {}
00786         GLib.timeout_add(200, show_details, data)
00787         self.app.run_crash(self.app.report_file)
00788 
00789         # when showing details, dialog should get considerably bigger
00790         self.assertGreater(data['detail_size'][1], data['orig_size'][1] + 100)
00791 
00792         # when hiding details, original size should be restored
00793         self.assertEqual(data['orig_size'], data['hidden_size'])
00794 
00795         # should only be resizable in details mode
00796         self.assertFalse(data['orig_resizable'])
00797         self.assertTrue(data['detail_resizable'])
00798         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 660 of file test_ui_gtk.py.

00660 
00661     def test_update_report(self, *args):
00662         '''Updating an existing report'''
00663 
00664         self.app.report_file = None
00665 
00666         def cont(*args):
00667             if self.app.tree_model.get_iter_first() is None:
00668                 return True
00669             self.app.w('continue_button').clicked()
00670             return False
00671 
00672         # upload empty report
00673         id = self.app.crashdb.upload({})
00674         self.assertEqual(id, 0)
00675         self.app.options.update_report = 0
00676         self.app.options.package = 'bash'
00677 
00678         GLib.timeout_add(200, cont)
00679         self.app.run_update_report()
00680 
00681         # no new bug reported
00682         self.assertEqual(self.app.crashdb.latest_id(), 0)
00683 
00684         # bug was updated
00685         r = self.app.crashdb.download(0)
00686         self.assertTrue(r['Package'].startswith('bash '))
00687         self.assertTrue('libc' in r['Dependencies'])
00688         self.assertTrue('DistroRelease' in r)
00689 
00690         # No URL in this mode
00691         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 693 of file test_ui_gtk.py.

00693 
00694     def test_update_report_different_binary_source(self, *args):
00695         '''Updating an existing report on a source package which does not have a binary of the same name'''
00696 
00697         self.app.report_file = None
00698 
00699         def cont(*args):
00700             if self.app.tree_model.get_iter_first() is None:
00701                 return True
00702             self.app.w('continue_button').clicked()
00703             return False
00704 
00705         kernel_pkg = apport.packaging.get_kernel_package()
00706         kernel_src = apport.packaging.get_source(kernel_pkg)
00707         self.assertNotEqual(kernel_pkg, kernel_src,
00708                             'this test assumes that the kernel binary package != kernel source package')
00709         self.assertNotEqual(apport.packaging.get_version(kernel_pkg), '',
00710                             'this test assumes that the kernel binary package %s is installed' % kernel_pkg)
00711         # this test assumes that the kernel source package name is not an
00712         # installed binary package
00713         self.assertRaises(ValueError, apport.packaging.get_version, kernel_src)
00714 
00715         # create source package hook, as otherwise there is nothing to collect
00716         with open(os.path.join(self.hook_dir, 'source_%s.py' % kernel_src), 'w') as f:
00717             f.write('def add_info(r, ui):\n r["MachineType"]="Laptop"\n')
00718 
00719         # upload empty report
00720         id = self.app.crashdb.upload({})
00721         self.assertEqual(id, 0)
00722 
00723         # run in update mode for that bug
00724         self.app.options.update_report = 0
00725         self.app.options.package = kernel_src
00726 
00727         GLib.timeout_add(200, cont)
00728         self.app.run_update_report()
00729 
00730         # no new bug reported
00731         self.assertEqual(self.app.crashdb.latest_id(), 0)
00732 
00733         # bug was updated
00734         r = self.app.crashdb.download(0)
00735         self.assertTrue('ProcEnviron' in r)
00736         self.assertTrue('DistroRelease' in r)
00737         self.assertTrue('Uname' in r)
00738         self.assertEqual(r['MachineType'], 'Laptop')
00739 
00740         # No URL in this mode
00741         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 458 of file test_ui_gtk.py.


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