<s> from __future__ import absolute_import <EOL> from traits . testing . unittest_tools import unittest <EOL> from . . constant import CANCEL <EOL> from . . gui import GUI <EOL> from . . progress_dialog import ProgressDialog <EOL> from . . toolkit import toolkit_object <EOL> ModalDialogTester = toolkit_object ( '<STR_LIT>' ) <EOL> no_modal_dialog_tester = ( ModalDialogTester . __name__ == '<STR_LIT>' ) <EOL> class TestDialog ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . gui = GUI ( ) <EOL> self . dialog = ProgressDialog ( ) <EOL> def test_create ( self ) : <EOL> self . dialog . _create ( ) <EOL> self . gui . process_events ( ) <EOL> self . dialog . destroy ( ) <EOL> def test_destroy ( self ) : <EOL> self . dialog . destroy ( ) <EOL> def test_can_cancel ( self ) : <EOL> self . dialog . can_cancel = True <EOL> self . dialog . _create ( ) <EOL> self . gui . process_events ( ) <EOL> self . dialog . destroy ( ) <EOL> def test_show_time ( self ) : <EOL> self . dialog . show_time = True <EOL> self . dialog . _create ( ) <EOL> self . gui . process_events ( ) <EOL> self . dialog . destroy ( ) <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_show_percent ( self ) : <EOL> self . dialog . show_percent = True <EOL> self . dialog . _create ( ) <EOL> self . gui . process_events ( ) <EOL> self . dialog . destroy ( ) <EOL> def test_update ( self ) : <EOL> self . dialog . min = <NUM_LIT:0> <EOL> self . dialog . max = <NUM_LIT:10> <EOL> self . dialog . open ( ) <EOL> for i in range ( <NUM_LIT:11> ) : <EOL> result = self . dialog . update ( i ) <EOL> self . gui . process_events ( ) <EOL> self . assertEqual ( result , ( True , False ) ) <EOL> self . assertIsNone ( self . dialog . control ) <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_update_no_control ( self ) : <EOL> self . dialog . min = <NUM_LIT:0> <EOL> self . dialog . max = <NUM_LIT:10> <EOL> result = self . dialog . update ( <NUM_LIT:1> ) <EOL> self . assertEqual ( result , ( None , None ) ) <EOL> def test_incomplete_update ( self ) : <EOL> self . dialog . min = <NUM_LIT:0> <EOL> self . dialog . max = <NUM_LIT:10> <EOL> self . can_cancel = True <EOL> self . dialog . open ( ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> result = self . dialog . update ( i ) <EOL> self . gui . process_events ( ) <EOL> self . assertEqual ( result , ( True , False ) ) <EOL> self . assertIsNotNone ( self . dialog . control ) <EOL> self . dialog . close ( ) <EOL> self . assertIsNone ( self . dialog . control ) <EOL> def test_change_message ( self ) : <EOL> self . dialog . min = <NUM_LIT:0> <EOL> self . dialog . max = <NUM_LIT:10> <EOL> self . dialog . open ( ) <EOL> for i in range ( <NUM_LIT:11> ) : <EOL> self . dialog . change_message ( '<STR_LIT>' . format ( i ) ) <EOL> result = self . dialog . update ( i ) <EOL> self . gui . process_events ( ) <EOL> self . assertEqual ( result , ( True , False ) ) <EOL> self . assertEqual ( self . dialog . message , '<STR_LIT>' . format ( i ) ) <EOL> self . assertIsNone ( self . dialog . control ) <EOL> def test_update_show_time ( self ) : <EOL> self . dialog . min = <NUM_LIT:0> <EOL> self . dialog . max = <NUM_LIT:10> <EOL> self . dialog . show_time = True <EOL> self . dialog . open ( ) <EOL> for i in range ( <NUM_LIT:11> ) : <EOL> result = self . dialog . update ( i ) <EOL> self . gui . process_events ( ) <EOL> self . assertEqual ( result , ( True , False ) ) <EOL> self . assertIsNone ( self . dialog . control ) <EOL> def test_update_degenerate ( self ) : <EOL> self . dialog . min = <NUM_LIT:0> <EOL> self . dialog . max = <NUM_LIT:0> <EOL> self . dialog . open ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> result = self . dialog . update ( i ) <EOL> self . gui . process_events ( ) <EOL> self . assertEqual ( result , ( True , False ) ) <EOL> self . dialog . close ( ) <EOL> def test_update_negative ( self ) : <EOL> self . dialog . min = <NUM_LIT:0> <EOL> self . dialog . max = - <NUM_LIT:10> <EOL> self . dialog . open ( ) <EOL> for i in range ( <NUM_LIT:11> ) : <EOL> result = self . dialog . update ( <NUM_LIT:1> ) <EOL> self . gui . process_events ( ) <EOL> self . assertEqual ( result , ( True , False ) ) <EOL> self . dialog . close ( ) <EOL> self . assertIsNone ( self . dialog . control ) </s>
