ó
qxPXc           @   sj  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 m
 Z
 m Z d d l m Z d d l m Z d d l Z e
 j e
 j j e
 j j Bƒ e j j d ƒ ræ d Z d Z nH e j j e j j d	 d
 ƒ d ƒ Z e j j e j j d	 d
 ƒ d ƒ Z e j d e ƒ j Z d e j f d „  ƒ  YZ e j ƒ  d S(   s    GTK Apport user interface tests.iÿÿÿÿN(   t   GLibt   Gtk(   t   unicode_gettext(   t   patcht   APPORT_TEST_LOCALs   gtk/apport-gtks   data/kernel_oopst   APPORT_DATA_DIRs   /usr/share/apports
   apport-gtkt   kernel_oopst    t   Tc           B   sˆ  e  Z e d  „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z e j e d ƒ d „  ƒ Z d „  Z d „  Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z d „  Z d „  Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z d „  Z d „  Z d „  Z RS(   c         C   s1   t  j ƒ  } | j ƒ  | d j ƒ  d |  _ d  S(   Nt   DistroReleasei    (   t   apportt   Reportt   add_os_infot   splitt   distro(   t   klasst   r(    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt
   setUpClass&   s    
c         C   sT  t  j ƒ  |  _ |  j t j _ |  j t j d <t j d } t	 t j d <t
 ƒ  |  _ | t j d <t j j j d  i  ƒ |  j _ t j j |  j d ƒ |  j _ t j ƒ  |  j _ d |  j j d <d |  j j d <d |  j j d	 <|  j |  j j d
 <t |  j j d ƒ  } |  j j j | ƒ Wd  QXt  j ƒ  |  _ |  j t j _ |  j t j _ d  S(   Nt   APPORT_REPORT_DIRi    s
   bash.crashs	   /bin/basht   ExecutablePatht   11t   SignalR   t   CoreDumpR	   t   w(   t   tempfilet   mkdtempt
   report_dirR
   t	   fileutilst   ost   environt   syst   argvt   apport_gtk_patht   GTKUserInterfacet   appt   crashdb_implt   memoryt   CrashDatabaset   Nonet   crashdbt   patht   joint   report_fileR   t   reportR   t   opent   writet   hook_dirt	   _hook_dirt   _common_hook_dir(   t   selft   savedt   f(    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   setUp,   s&    c         C   s$   t  j |  j ƒ t  j |  j ƒ d  S(   N(   t   shutilt   rmtreeR   R.   (   R1   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   tearDownL   s    c            s\   ˆ  j  j d ƒ j t ƒ ‡  f d †  } t j | ƒ ˆ  j  j t ƒ } ˆ  j | d ƒ d S(   sB   Clicking the close button on the window does not report the crash.t   send_error_reportc             s   ˆ  j  j d ƒ j ƒ  d  S(   Nt   dialog_crash_new(   R"   R   t   destroy(   t   args(   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   cT   s    R+   N(   R"   R   t
   set_activet   TrueR    t   idle_addt   ui_present_report_detailst   assertFalse(   R1   R<   t   result(    (   R1   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_close_buttonP   s
    c         C   s•  d |  j  j d <t j t j ƒ |  j  j t ƒ |  j |  j  j	 d ƒ j
 ƒ  |  j ƒ |  j |  j  j	 d ƒ j ƒ  t d ƒ |  j ƒ |  j  j	 d ƒ } |  j | j d ƒ ƒ |  j | j ƒ  ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d	 ƒ j d ƒ ƒ |  j |  j  j	 d	 ƒ j ƒ  t d
 ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ d S(   s  
        +-----------------------------------------------------------------+
        | [ logo] YourDistro has experienced an internal error.           |
        |                                                                 |
        |            [x] Send an error report to help fix this problem.   |
        |                                                                 |
        | [ Show Details ]                                   [ Continue ] |
        +-----------------------------------------------------------------+
        t   KernelCrasht   ProblemTypeR9   t   title_labels,   Sorry, %s has experienced an internal error.R8   t   visiblet   show_detailst   continue_buttont   Continuet   closed_buttont   subtitle_labelt   ignore_future_problemsN(   R"   R+   R    R?   R   t	   main_quitR@   R>   t   assertEqualR   t	   get_titleR   t   get_textt   _t
   assertTruet   get_propertyt
   get_activet	   get_labelRA   (   R1   R8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_kernel_crash_layoutZ   s"    

""""c         C   s¤  d |  j  j d <d |  j  j d <t j t j ƒ |  j  j t ƒ |  j |  j  j	 d ƒ j
 ƒ  |  j ƒ |  j |  j  j	 d ƒ j ƒ  t d ƒ ƒ |  j  j	 d ƒ } |  j | j d ƒ ƒ |  j | j ƒ  ƒ |  j |  j  j	 d	 ƒ j d ƒ ƒ |  j |  j  j	 d
 ƒ j d ƒ ƒ |  j |  j  j	 d
 ƒ j ƒ  t d ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j ƒ  t d ƒ ƒ d S(   si  
        +-----------------------------------------------------------------+
        | [ 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 ] |
        +-----------------------------------------------------------------+
        t   PackageRE   s   apport 1.2.3~0ubuntu1R9   RF   s4   Sorry, a problem occurred while installing software.R8   RG   RH   RI   RJ   RK   RL   s   Package: apport 1.2.3~0ubuntu1N(   R"   R+   R    R?   R   RN   R@   R>   RO   R   RP   R   RQ   RR   RS   RT   RU   RV   RA   (   R1   R8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_package_crash_layoutv   s&    
""""c         C   s  d |  j  j d <d |  j  j d <d |  j  j d <t j ƒ  Q } | j d ƒ | j ƒ  | j |  j  j d <t j t	 j
 ƒ |  j  j t ƒ Wd	 QX|  j |  j  j d
 ƒ j ƒ  |  j ƒ |  j |  j  j d ƒ j ƒ  t d ƒ ƒ |  j  j d ƒ } |  j | j d ƒ ƒ |  j | j ƒ  ƒ |  j |  j  j d ƒ j d ƒ ƒ |  j |  j  j d ƒ j d ƒ ƒ |  j |  j  j d ƒ j ƒ  t d ƒ ƒ |  j |  j  j d ƒ j d ƒ ƒ |  j |  j  j d ƒ j d ƒ ƒ |  j |  j  j d ƒ j d ƒ ƒ |  j |  j  j d ƒ j ƒ  j d ƒ ƒ d	 S(   si  
        +-----------------------------------------------------------------+
        | [ 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 ] |
        +-----------------------------------------------------------------+
        t   CrashRE   t   1t   CrashCounters   apport 1.2.3~0ubuntu1RX   s8   [Desktop Entry]
Version=1.0
Name=Apport
Type=Applicationt   DesktopFileNR9   RF   s/   The application Apport has closed unexpectedly.R8   RG   RH   RI   RJ   RK   RL   RM   s   of this program version(   R"   R+   R   t   NamedTemporaryFileR-   t   flusht   nameR    R?   R   RN   R@   R>   RO   R   RP   R   RQ   RR   RS   RT   RU   RV   RA   t   endswith(   R1   t   fpR8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_regular_crash_layout•   s4    

"""""c         C   s1  t  |  j _ d |  j j d <d |  j j d <d |  j j d <d |  j j d <t j ƒ  Q } | j d	 ƒ | j ƒ  | j |  j j d
 <t	 j
 t j ƒ |  j j t  ƒ Wd QX|  j |  j j d ƒ j ƒ  |  j ƒ |  j |  j j d ƒ j ƒ  t d ƒ ƒ |  j j d ƒ } |  j | j d ƒ ƒ |  j | j ƒ  ƒ |  j |  j j d ƒ j d ƒ ƒ |  j |  j j d ƒ j d ƒ ƒ |  j |  j j d ƒ j ƒ  t d ƒ ƒ |  j |  j j d ƒ j d ƒ ƒ |  j |  j j d ƒ j d ƒ ƒ |  j |  j j d ƒ j d ƒ ƒ |  j |  j j d ƒ j ƒ  j d ƒ ƒ d S(   si  
        +-----------------------------------------------------------------+
        | [ 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 ] |
        +-----------------------------------------------------------------+
        RZ   RE   R[   R\   s   apport-bug apportt   ProcCmdlines   apport 1.2.3~0ubuntu1RX   s8   [Desktop Entry]
Version=1.0
Name=Apport
Type=ApplicationR]   NR9   RF   s/   The application Apport has closed unexpectedly.R8   RG   RH   RI   t   RelaunchRK   RL   RM   s   of this program version(   R>   R"   t   offer_restartR+   R   R^   R-   R_   R`   R    R?   R   RN   R@   RO   R   RP   R   RQ   RR   RS   RT   RU   RV   RA   Ra   (   R1   Rb   R8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt!   test_regular_crash_layout_restart¾   s8    

"""""c         C   s\  d |  j  j d <d |  j  j d <d |  j  j d <d |  j  j d <t j ƒ  Q } | j d	 ƒ | j ƒ  | j |  j  j d
 <t j t	 j
 ƒ |  j  j t ƒ Wd QX|  j |  j  j d ƒ j ƒ  |  j ƒ |  j |  j  j d ƒ j ƒ  t d ƒ ƒ |  j |  j  j d ƒ j d ƒ ƒ |  j |  j  j d ƒ j ƒ  t d ƒ ƒ |  j |  j  j d ƒ j d ƒ ƒ d S(   si  
        +-----------------------------------------------------------------+
        | [ 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 ] |
        +-----------------------------------------------------------------+
        RZ   RE   R[   R\   s   apport-bug apportRd   s   apport 1.2.3~0ubuntu1RX   s8   [Desktop Entry]
Version=1.0
Name=Apport
Type=ApplicationR]   NR9   RF   s/   The application Apport has closed unexpectedly.RI   RG   RJ   RK   (   R"   R+   R   R^   R-   R_   R`   R    R?   R   RN   R@   R>   RO   R   RP   R   RQ   RR   RS   RT   RV   RA   (   R1   Rb   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt#   test_regular_crash_layout_norestarté   s$    
%"c         C   s  d |  j  j d <d |  j  j d <d |  j  j d <t j t j ƒ |  j  j t ƒ |  j |  j  j	 d ƒ j
 ƒ  |  j ƒ |  j |  j  j	 d ƒ j ƒ  t d	 ƒ |  j ƒ |  j |  j  j	 d
 ƒ j ƒ  t d ƒ ƒ |  j |  j  j	 d
 ƒ j d ƒ ƒ |  j  j	 d ƒ } |  j | j d ƒ ƒ |  j | j ƒ  ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j ƒ  t d ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j d ƒ ƒ |  j |  j  j	 d ƒ j ƒ  j d ƒ ƒ d S(   sí  
        +---------------------------------------------------------------+
        | [ 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 ] |
        +---------------------------------------------------------------+
        RZ   RE   R[   R\   s   bash 5RX   R9   RF   s,   Sorry, %s has experienced an internal error.RL   s<   If you notice further problems, try restarting the computer.RG   R8   RH   RI   RJ   RK   RM   s   of this typeN(   R"   R+   R    R?   R   RN   R@   R>   RO   R   RP   R   RQ   RR   RS   RT   RU   RV   RA   Ra   (   R1   R8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_system_crash_layout
  s.    
"""""c         C   sG  d |  j  j d <d |  j  j d <d |  j  j d <d |  j  j d <d	 |  j  _ t j t j ƒ |  j  j t ƒ |  j	 |  j  j
 d
 ƒ j ƒ  |  j ƒ |  j	 |  j  j
 d ƒ j ƒ  t d ƒ ƒ |  j	 |  j  j
 d ƒ j ƒ  t d ƒ ƒ |  j |  j  j
 d ƒ j d ƒ ƒ |  j  j
 d ƒ } |  j | j d ƒ ƒ |  j | j ƒ  ƒ |  j |  j  j
 d ƒ j d ƒ ƒ |  j |  j  j
 d ƒ j d ƒ ƒ |  j	 |  j  j
 d ƒ j ƒ  t d ƒ ƒ |  j |  j  j
 d ƒ j d ƒ ƒ |  j  j d =t j t j ƒ |  j  j t ƒ |  j	 |  j  j
 d ƒ j ƒ  t d ƒ ƒ |  j |  j  j
 d ƒ j d ƒ ƒ d S(   sÇ  
        +-------------------------------------------------------------------+
        | [ 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 ] |
        +-------------------------------------------------------------------+
        RZ   RE   s   bash 5RX   s*   LANGUAGE=en_GB:en
SHELL=/bin/sh
TERM=xtermt   ProcEnvirons   /usr/bin/apportR   R
   R9   RF   s6   Sorry, the application apport has closed unexpectedly.RL   s<   If you notice further problems, try restarting the computer.RG   R8   RH   RI   RJ   RK   s&   Sorry, apport has closed unexpectedly.RM   N(   R"   R+   t   cur_packageR    R?   R   RN   R@   R>   RO   R   RP   R   RQ   RR   RS   RT   RU   RV   RA   (   R1   R8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt%   test_system_crash_from_console_layout/  s8    
""""t   can_examine_locallyc         G   så   d |  j  j d <d |  j  j d <t j t j ƒ t |  j  j _ |  j  j	 t
 ƒ |  j |  j  j d ƒ j d ƒ ƒ t j |  j  j d ƒ j ƒ t
 |  j  j _ |  j  j	 t
 ƒ } |  j |  j  j d ƒ j d ƒ ƒ |  j | d ƒ d S(   s9  
        +---------------------------------------------------------------------+
        | [ apport ] The application Apport has closed unexpectedly.          |
        |                                                                     |
        |            [x] Send an error report to help fix this problem.       |
        |                                                                     |
        | [ Show Details ] [ Examine locally ]  [ Leave Closed ] [ Relaunch ] |
        +---------------------------------------------------------------------+
        RZ   RE   s   bash 5RX   t   examineRG   N(   R"   R+   R    R?   R   RN   t   FalseRm   t   return_valueR@   R>   RA   R   RT   t   clickedRS   (   R1   R;   RB   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_examine_button^  s    ""c         C   s¦  d |  j _ t j t j ƒ |  j j t ƒ |  j	 |  j j
 d ƒ j ƒ  t d ƒ ƒ |  j |  j j
 d ƒ j d ƒ ƒ |  j j
 d ƒ } |  j | j d ƒ ƒ |  j | j ƒ  ƒ |  j |  j j
 d ƒ j d ƒ ƒ |  j |  j j
 d ƒ j d ƒ ƒ |  j	 |  j j
 d ƒ j ƒ  t d ƒ ƒ |  j |  j j
 d	 ƒ j d ƒ ƒ |  j |  j j
 d
 ƒ j d ƒ ƒ |  j |  j j
 d ƒ j d ƒ ƒ |  j |  j j
 d ƒ j ƒ  ƒ d S(   s  
        +-------------------------------------------------------------------+
        | [ error  ] Send problem report to the developers?                 |
        |                                                                   |
        |            +----------------------------------------------------+ |
        |            | |> ApportVersion                                   | |
        |            | ...                                                | |
        |            +----------------------------------------------------+ |
        |                                                                   |
        | [ Cancel ]                                               [ Send ] |
        +-------------------------------------------------------------------+
        RF   s&   Send problem report to the developers?RL   RG   R8   RH   RI   t   SendRK   t   cancel_buttont   details_scrolledwindowR9   N(   R&   R"   R*   R    R?   R   RN   R@   R>   RO   R   RQ   RR   RA   RT   RS   RU   RV   t   get_resizable(   R1   R8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_apport_bug_package_layoutw  s"    """"""c         C   s_   t  j t j ƒ |  j j t ƒ |  j j d ƒ } |  j | j	 d ƒ ƒ |  j | j
 ƒ  ƒ d  S(   NR8   RG   (   R    R?   R   RN   R"   R@   Ro   R   RA   RT   RU   (   R1   R8   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt%   test_administrator_disabled_reporting–  s
    t   open_urlc            s  d ˆ  _ ‡  ‡ f d †  } ‡  f d †  ‰ t j d | ƒ ˆ  j j ˆ  j j ƒ ˆ  j ˆ  j j j	 ƒ  d ƒ ˆ  j j j
 d ƒ } ˆ  j | d d ƒ ˆ  j | d d ƒ ˆ  j ˆ  j t ƒ ˆ  j | d	 j d
 ƒ ƒ ˆ  j d | d k ƒ ˆ  j d | k ƒ ˆ  j ˆ  j j j d ƒ d S(   s$   Crash report without showing detailsc             sF   ˆ  j  j d ƒ j ƒ  s t Sˆ  j  j d ƒ j ƒ  t j d ˆ ƒ t S(   NRI   iô  (   R"   R   t   get_visibleR>   Rq   R    t   timeout_addRo   (   R;   (   R1   t   check_progress(    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   cont£  s
    c             s"   ˆ  j  j d ƒ j d ƒ ˆ  _ t S(   Nt   window_information_collectionRG   (   R"   R   RT   t   visible_progressRo   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR|   ª  s    	i   i    RE   RZ   R   s	   /bin/bashRX   s   bash t   libct   Dependenciest
   StacktraceN(   R&   R   R    t   timeout_add_secondsR"   t	   run_crashR*   RO   R'   t	   latest_idt   downloadR>   RS   t
   startswithRy   t
   call_count(   R1   R;   R}   R   (    (   R1   R|   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_crash_nodetails  s    	c            s/  d ˆ _ ‡  ‡ f d †  } ‡ ‡ f d †  ‰  ‡ f d †  ‰ t j d | ƒ ˆ j j ˆ j j ƒ ˆ j ˆ j j j	 ƒ  d ƒ ˆ j j j
 d ƒ } ˆ j | d d ƒ ˆ j | d d	 ƒ ˆ j ˆ j t ƒ ˆ j | d
 j d ƒ ƒ ˆ j d | d k ƒ ˆ j d | k ƒ ˆ j ˆ j j j d ƒ d S(   s!   Crash report with showing detailsc             sF   ˆ j  j d ƒ j ƒ  s t Sˆ j  j d ƒ j ƒ  t j d ˆ  ƒ t S(   NRH   iÈ   (   R"   R   Rz   R>   Rq   R    R{   Ro   (   R;   (   R}   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyRH   É  s
    c             se   ˆ  j  j j ƒ  d  k r t Sˆ  j ˆ  j  j d ƒ j ƒ  ƒ ˆ  j  j d ƒ j ƒ  t	 j
 d ˆ ƒ t S(   NRI   iô  (   R"   t
   tree_modelt   get_iter_firstR&   R>   RS   R   Rz   Rq   R    R{   Ro   (   R;   (   R1   R|   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR}   Ð  s    c             s"   ˆ  j  j d ƒ j d ƒ ˆ  _ t S(   NR~   RG   (   R"   R   RT   R   Ro   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR|   Ú  s    	iÈ   i    RE   RZ   R   s	   /bin/bashRX   s   bash R€   R   R‚   i   N(   R&   R   R    R{   R"   R„   R*   RO   R'   R…   R†   Ro   RS   R‡   Ry   Rˆ   (   R1   R;   RH   R   (    (   R}   R1   R|   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_crash_detailsÃ  s    	
c            s*  d ˆ  _ ‡  ‡ f d †  } ‡  f d †  ‰ t j d | ƒ d g ˆ  j j j d <ˆ  j j ˆ  j j ƒ ˆ  j	 ˆ  j j j
 ƒ  d ƒ ˆ  j	 ˆ  j j j d ƒ ˆ  j	 ˆ  j t ƒ ˆ  j j } ˆ  j	 | d d	 ƒ ˆ  j	 | d
 d ƒ ˆ  j | d j d ƒ ƒ ˆ  j d | d k ƒ ˆ  j d | k ƒ d S(   s(   Crash report with non-accepting crash DBc             sF   ˆ  j  j d ƒ j ƒ  s t Sˆ  j  j d ƒ j ƒ  t j d ˆ ƒ t S(   NRI   iô  (   R"   R   Rz   R>   Rq   R    R{   Ro   (   R;   (   R1   R|   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR}   ù  s
    c             s"   ˆ  j  j d ƒ j d ƒ ˆ  _ t S(   NR~   RG   (   R"   R   RT   R   Ro   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR|      s    	i   t   bugt   problem_typesiÿÿÿÿi    RE   RZ   R   s	   /bin/bashRX   s   bash R€   R   R‚   N(   R&   R   R    Rƒ   R"   R'   t   optionsR„   R*   RO   R…   Ry   Rˆ   Ro   R+   RS   R‡   (   R1   R;   R}   R   (    (   R1   R|   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_crash_noacceptó  s    	c            s1  ‡  f d †  } t  j ˆ  j j ƒ t j t g d t j ƒ} | j d ƒ ˆ  j	 | j
 d ƒ t j d | ƒ ˆ  j j ƒ  ˆ  j	 ˆ  j j j ƒ  d ƒ ˆ  j j j d ƒ } ˆ  j	 | d d ƒ ˆ  j	 | d d ƒ ˆ  j d	 | d
 k ƒ ˆ  j d | k ƒ ˆ  j d | d k ƒ ˆ  j	 ˆ  j j j d ƒ d S(   s*   Kernel oops report without showing detailsc             s6   ˆ  j  j d ƒ j ƒ  s t Sˆ  j  j d ƒ j ƒ  t S(   NRI   (   R"   R   Rz   R>   Rq   Ro   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR}     s    t   stdins!   Plasma conduit phase misalignmenti    i   RE   t
   KernelOopst   OopsTextt   linuxRX   R   s   Plasma conduitt   TitleN(   R   t   removeR"   R*   t
   subprocesst   Popent   kernel_oops_patht   PIPEt   communicateRO   t
   returncodeR    Rƒ   t   run_crashesR'   R…   R†   RS   Ry   Rˆ   (   R1   R;   R}   R   R   (    (   R1   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_kerneloops_nodetails  s     c            s¹   d ˆ  j _ d ˆ  j j _ ‡  f d †  } t j d | ƒ ˆ  j j ƒ  ˆ  j ˆ  j j	 d d ƒ ˆ  j ˆ  j j	 d d ƒ ˆ  j
 ˆ  j j	 d j d ƒ ƒ ˆ  j ˆ  j j	 d	 d
 ƒ d S(   s    Bug report for installed packaget   bashc             s6   ˆ  j  j d ƒ j ƒ  s t Sˆ  j  j d ƒ j ƒ  t S(   NRt   (   R"   R   Rz   R>   Rq   Ro   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR<   ?  s    i   RE   t   Bugt   SourcePackageRX   s   bash R   R   N(   R&   R"   R*   R   t   packageR    Rƒ   t   run_report_bugRO   R+   RS   R‡   t   assertNotEqual(   R1   R<   (    (   R1   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt!   test_bug_report_installed_package:  s     c            s¸   t  j j ƒ  } d ˆ  j _ | ˆ  j j _ ‡  f d †  } t j	 d | ƒ ˆ  j j
 ƒ  ˆ  j ˆ  j j d d ƒ ˆ  j ˆ  j j d t  j j | ƒ ƒ ˆ  j ˆ  j j d d | ƒ d S(	   s"   Bug report for uninstalled packagec             s6   ˆ  j  j d ƒ j ƒ  s t Sˆ  j  j d ƒ j ƒ  t S(   NRt   (   R"   R   Rz   R>   Rq   Ro   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR<   S  s    i   RE   R    R¡   RX   s   %s (not installed)N(   R
   t	   packagingt   get_uninstalled_packageR&   R"   R*   R   R¢   R    Rƒ   R£   RO   R+   t
   get_source(   R1   t   pkgR<   (    (   R1   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt#   test_bug_report_uninstalled_packageL  s    c            s  d
 ˆ  j _ ‡  f d †  } ˆ  j j j i  ƒ } ˆ  j | d ƒ d ˆ  j j _ d ˆ  j j _ t	 j
 d | ƒ ˆ  j j ƒ  ˆ  j ˆ  j j j ƒ  d ƒ ˆ  j j j d ƒ } ˆ  j | d j d ƒ ƒ ˆ  j d | d k ƒ ˆ  j d	 | k ƒ ˆ  j ˆ  j j j d ƒ d
 S(   s   Updating an existing reportc             s6   ˆ  j  j j ƒ  d  k r t Sˆ  j  j d ƒ j ƒ  t S(   NRI   (   R"   RŠ   R‹   R&   R>   R   Rq   Ro   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR}   f  s    i    RŸ   iÈ   RX   s   bash R€   R   R	   N(   R&   R"   R*   R'   t   uploadRO   R   t   update_reportR¢   R    R{   t   run_update_reportR…   R†   RS   R‡   Ry   Rˆ   (   R1   R;   R}   t   idR   (    (   R1   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_update_report`  s    c            sÁ  d ˆ  j _ ‡  f d †  } t j j ƒ  } t j j | ƒ } ˆ  j | | d ƒ ˆ  j t j j | ƒ d d | ƒ ˆ  j	 t
 t j j | ƒ t t j j ˆ  j d | ƒ d ƒ  } | j d ƒ Wd QXˆ  j j j i  ƒ } ˆ  j | d	 ƒ d	 ˆ  j j _ | ˆ  j j _ t j d
 | ƒ ˆ  j j ƒ  ˆ  j ˆ  j j j ƒ  d	 ƒ ˆ  j j j d	 ƒ } ˆ  j d | k ƒ ˆ  j d | k ƒ ˆ  j d | k ƒ ˆ  j | d d ƒ ˆ  j ˆ  j j j d	 ƒ d S(   s]   Updating an existing report on a source package which does not have a binary of the same namec             s6   ˆ  j  j j ƒ  d  k r t Sˆ  j  j d ƒ j ƒ  t S(   NRI   (   R"   RŠ   R‹   R&   R>   R   Rq   Ro   (   R;   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR}   ‡  s    sI   this test assumes that the kernel binary package != kernel source packageR   s@   this test assumes that the kernel binary package %s is installeds   source_%s.pyR   s0   def add_info(r, ui):
 r["MachineType"]="Laptop"
Ni    iÈ   Rj   R	   t   Unamet   MachineTypet   Laptop(   R&   R"   R*   R
   R¦   t   get_kernel_packageR¨   R¤   t   get_versiont   assertRaisest
   ValueErrorR,   R   R(   R)   R.   R-   R'   R«   RO   R   R¬   R¢   R    R{   R­   R…   R†   RS   Ry   Rˆ   (   R1   R;   R}   t
   kernel_pkgt
   kernel_srcR3   R®   R   (    (   R1   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt*   test_update_report_different_binary_source  s0    (t   get_desktop_entryc         G   sn   d |  j  j d <d |  j  j d <d |  j  j j j _ d |  j  j j j _ t j t j	 ƒ |  j  j
 t ƒ d  S(   NRZ   RE   s   apport 1.2.3~0ubuntu1RX   t   nonexistentR
   (   R"   R+   Rº   Rp   t   getIcont   getNameR    R?   R   RN   R@   R>   (   R1   R;   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_missing_icon³  s    c            sÕ   ‡ ‡ f d †  } ‡  ‡ f d †  ‰ ‡ f d †  ‰  i  } t  j d | | ƒ ˆ j j ˆ j j ƒ ˆ j | d d | d d d ƒ ˆ j | d | d	 ƒ ˆ j | d
 ƒ ˆ j | d ƒ ˆ j | d ƒ d S(   s.   Problem report window resizability and sizing.c            s   ˆ  j  j d ƒ j ƒ  s t Sˆ  j  j d ƒ j ƒ  |  d <ˆ  j  j d ƒ j ƒ  |  d <ˆ  j  j d ƒ j ƒ  t j d ˆ |  ƒ t	 S(   NRH   R9   t	   orig_sizet   orig_resizableiÈ   (
   R"   R   Rz   R>   t   get_sizeRv   Rq   R    R{   Ro   (   t   data(   R1   t   hide_details(    s*   /usr/share/apport/testsuite/test_ui_gtk.pyRH   À  s    c            s   ˆ j  j j ƒ  d  k r t Sˆ j  j d ƒ j ƒ  |  d <ˆ j  j d ƒ j ƒ  |  d <ˆ j  j d ƒ j ƒ  t	 j
 d ˆ  |  ƒ t S(   NR9   t   detail_sizet   detail_resizableRH   iÈ   (   R"   RŠ   R‹   R&   R>   R   RÁ   Rv   Rq   R    R{   Ro   (   RÂ   (   t   details_hiddenR1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyRÃ   Ê  s    c            sb   ˆ  j  j d ƒ j ƒ  r t Sˆ  j  j d ƒ j ƒ  |  d <ˆ  j  j d ƒ j ƒ  |  d <t j ƒ  d  S(   NRu   R9   t   hidden_sizet   hidden_resizable(   R"   R   Rz   R>   RÁ   Rv   R   RN   (   RÂ   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyRÆ   Õ  s
    iÈ   RÄ   i   R¿   id   RÇ   RÀ   RÅ   RÈ   N(	   R    R{   R"   R„   R*   t   assertGreaterRO   RA   RS   (   R1   RH   RÂ   (    (   RÆ   R1   RÃ   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_resizing½  s    
	$c            sÆ   ‡  f d †  } t  j d | d ƒ ˆ  j j d j d ƒ d j d ƒ ƒ t  j d | d ƒ ˆ  j j d d ƒ t  j d | d ƒ ˆ  j j d d j d ƒ ƒ t  j d | d ƒ ˆ  j j d d ƒ d	 S(
   s   Non-ASCII title/text in dialogsc            s'   ˆ  j  j s t Sˆ  j  j j |  ƒ t S(   N(   R"   t   mdR>   t   responseRo   (   RÌ   (   R1   (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   closeð  s    iÈ   i    s	   title â™©s   UTF-8s   text â™ªt   titles   http://example.com â™ªN(   R    R{   R"   t   ui_info_messaget   decode(   R1   RÍ   (    (   R1   s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_dialog_nonasciií  s    %c         C   s@   |  j  j d ƒ j ƒ  t j t j ƒ |  j  j |  j  j ƒ d S(   s    Close details window immediatelyR9   N(	   R"   R   R:   R    R?   R   RN   R„   R*   (   R1   (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   test_immediate_close  s    (    t   __name__t
   __module__t   classmethodR   R4   R7   RC   RW   RY   Rc   Rg   Rh   Ri   Rl   R   t   objectR!   Rr   Rw   Rx   R‰   RŒ   R   Rž   R¥   Rª   R¯   R¹   R¾   RÊ   RÑ   RÒ   (    (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyR   %   s4   	 		
			)	+	!	%	/		&0%"		!2
	0	(    t   __doc__t   unittestR   R   R   t   impR
   R5   R—   t   gi.repositoryR    R   R   RR   t   mockR   t   apport.crashdb_impl.memoryt   log_set_always_fatalt   LogLevelFlagst   LEVEL_WARNINGt   LEVEL_CRITICALR   t   getR    R™   R(   R)   t   load_sourceR!   t   TestCaseR   t   main(    (    (    s*   /usr/share/apport/testsuite/test_ui_gtk.pyt   <module>   s.   	$$ÿ ÿ è