use base "installedtest"; use strict; use testapi; use utils; use applications; # This test tests the basic functionality of Gedit. # ================= BASIC METHODS =================== sub start { send_key "super"; type_very_safely "gedit"; send_key "ret"; } sub stop { send_key "alt-f4"; } sub open_menu { assert_and_click "gnome-burger-menu"; wait_still_screen 2; } sub open_submenu_view { assert_and_click "gedit_submenu_view"; wait_still_screen 2; } sub open_submenu_tools { assert_and_click "gedit_submenu_tools"; wait_still_screen 2; } # ================= SPECIFIC METHODS ================ sub about { # About screen can be displayed. open_menu(); assert_and_click "gedit_about"; assert_screen "gedit_about_shown"; send_key "esc"; # Floating windows do not return focus to the text field, tab does in # case something like that happens. send_key "tab"; } sub enter_text { # Writes text into a window. my $text = "Hope is the thing with feathers - \nThat perches in the soul -\nAnd sings the tune without the words -\nAnd never stops - at all -\n\nAnd sweetest - in the Gale - is heard -\nAnd sore must be the storm -\nThat could abash the little Bird\nThat kept so many warm -\n\nI've heard it in the chillest land -\nAnd on the strangest Sea -\nYet - never - in Extremity,\nIt asked a crumb - of me.\n\n"; type_safely $text; assert_screen "gedit_text_added"; } sub enter_code { # Write some python code to test syntax highlighting. my $text = "#!/usr/bin/python\n\nfor num in range(100):\n\tprint('This is line number:')\n\tprint(num)\n"; type_safely $text; assert_screen "gedit_code_added"; } sub save_file { # Application can save file assert_and_click "gnome_save"; type_safely "poem.txt"; send_key "ret"; assert_screen "gedit_text_saved"; } sub delete_line { # Some text can be deleted. assert_and_click "gedit_line_word"; send_key "home"; send_key "shift-end"; send_key "delete"; send_key "ctrl-end"; assert_screen "gedit_line_deleted"; } sub history { # History can be used. send_key "ctrl-z"; send_key "ctrl-end"; assert_screen "gedit_text_added"; } sub display_stats { # Statistics can be displayed. open_menu(); open_submenu_tools(); assert_and_click "gedit_tools_stats"; assert_screen "gedit_stats_shown"; send_key "esc"; # Floating windows do not return focus to the text field, tab does. send_key "tab"; } sub open_file { # Opens file from the list of saved files. This will not test to # open a file using the standard Gnome dialogue. assert_and_click "gedit_open"; assert_and_click "gedit_choose_file"; assert_screen "gedit_text_added"; } sub find_text { # Searches the file to find a word. send_key "ctrl-f"; type_safely "sweetest"; send_key "ret"; # The found item is blue at first and after any action it changes to yellow. Let's move the cursor to # change it into yellow for assertion. send_key "left"; assert_screen "gedit_found_text"; } sub find_and_replace { # Replaces one word for another send_key "ctrl-h"; type_safely "Gale"; assert_and_click "gedit_replace_nothing"; type_safely "Wiend"; # We produce a typo to check the spellchecker assert_and_click "gedit_find"; assert_and_click "gedit_replace"; # Move out the floating window and put cursor at the end. assert_and_click "gedit_switchoff"; assert_screen "gedit_text_replaced"; } sub clear_highlight { # This tests that a highlight can be removed from a search result. open_menu(); assert_and_click "gedit_clear_highlight"; # Move cursor out of text. send_key "ctrl-end"; assert_screen "gedit_text_added"; } sub line_numbers { # Switches on line numbering. assert_and_click "gedit_line_options"; assert_and_click "gedit_display_linenumbers"; send_key "esc"; assert_screen "gedit_lines_numbered"; } sub goto_line { # Uses the menu to go to a specific line. open_menu(); assert_and_click "gedit_goto_line"; type_safely "8\n"; assert_screen "gedit_line_reached"; } sub highlight_line { # Highlights the current line. assert_and_click "gedit_line_options"; assert_and_click "gedit_highlight_current"; send_key "esc"; assert_screen "gedit_line_highlighted"; } sub display_margin { # Displays the right margine to monitor the file width. assert_and_click "gedit_line_options"; assert_and_click "gedit_display_margin"; send_key "esc"; assert_screen "gedit_margin_displayed" } sub new_tab { # Uses the new tab button to open a new tab assert_and_click "gedit_new_tab"; assert_screen "gedit_tab_opened"; send_key "ctrl-w"; } sub new_window { open_menu(); assert_and_click "gedit_new_window"; assert_screen "gedit_new_opened"; } sub side_panel { open_menu(); open_submenu_view(); assert_and_click "gedit_side_panel"; send_key "esc"; assert_screen "gedit_sidepanel_on"; } sub bottom_panel { open_menu(); open_submenu_view(); assert_and_click "gedit_botton_panel"; send_key "esc"; assert_screen "gedit_bottompanel_on"; } sub spellcheck { open_menu(); open_submenu_tools(); assert_and_click "gedit_check_spelling"; assert_and_click "gedit_spelling_suggestion"; assert_and_click "gedit_spelling_change"; send_key "esc"; assert_and_click "gedit_spelling_changed"; } sub highlight_misspelt_words { open_menu(); open_submenu_tools(); assert_and_click "gedit_highlight_misspelt"; send_key "esc"; assert_and_click "gedit_misspelt_highlighted"; } sub code_highlighting { assert_and_click "select_highlighting"; type_very_safely "python"; send_key "ret"; assert_screen "code_highlighted"; } sub close_without_saving { assert_and_click "gedit_close_without_saving"; } # TBD: # Tools - Check spelling # Tools - Misspelled words # Insert Date and Time # ================= TEST ROUTINE =================== sub run { my $self = shift; # Start the application start(); # Test the About menu about(); # Enter text enter_text(); # Delete line delete_line(); # Use history to undelete the line again history(); # Save the text into a file save_file(); # Use Statistics menu display_stats(); # Find a piece of text find_text(); # Clear the highlighted background clear_highlight(); # Find and replace a word find_and_replace; # Highlight misspellt words using the menu highlight_misspelt_words(); # Checkspelling of the text spellcheck(); # View the sidepanel side_panel(); # Switch off the application. stop(); # Start anew and open the saved file. start(); open_file(); # Switch on line numbering line_numbers(); # Go to a certain line goto_line(); # Highlight selected line highlight_line(); # Switch on display margin display_margin(); # Switch on bottom panel bottom_panel(); # Create a new document tab new_tab(); # Open a new window new_window(); # Enter some python code enter_code(); # Select highlighting code_highlighting(); # Stop this new instance stop(); # Switch off the application stop(); } sub test_flags { return { fatal => 1 }; } 1; # vim: set sw=4 et: