#357 Enhance the menu_launch_type subroutine.
Merged 2 months ago by adamwill. Opened 2 months ago by lruzicka.

file modified
+4
@@ -240,6 +240,10 @@ 

  'time_date', 'create_user','keyboard_layout'))

  for selection in ("hide", "maximize", "restore"):

      testtags.append(f"calculator_context_{selection}")

+ # After the change to menu_launch_type, applications should be whitelisted here

+ # to prevent the unused needles warning in case of apps_run_<application>.

+ for app in ("focuswriter", "gvim"):

+     testtags.append(f"apps_run_{app}")

  

  # retcode tracker

  ret = 0

file modified
+44 -13
@@ -6,7 +6,7 @@ 

  use Exporter;

  use lockapi;

  use testapi qw(is_serial_terminal :DEFAULT);

- our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications desktop_launch_terminal solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login/;

+ our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications desktop_launch_terminal solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login check_software_start/;

  

  

  # We introduce this global variable to hold the list of applications that have
@@ -1370,27 +1370,43 @@ 

      # Launch an application in a graphical environment, by opening a

      # launcher, typing the specified string and hitting enter. Pass

      # the string to be typed to launch whatever it is you want.

-     my ($app, $maximize) = @_;

+     # Use maximize => 1 to maximize the application after it

+     # is started.

+     # Use checkstart => 1 to check that the application has started

+     my ($application, %args) = @_;

      my $desktop = get_var("DESKTOP");

+ 

+     # The standard combo key is the "super" key, just in I3

+     # it is different.

      my $key = 'super';

      $key = 'alt-d' if ($desktop eq "i3");

+ 

+     # In KDE, we have been experiencing BZ2097208.

+     # To overcome this let's move the mouse out of the way

+     # and give the launcher some time to take the correct focus.

      if ($desktop eq "kde") {

-         # To overcome BZ2097208, let's move the mouse out of the way

-         # and give the launcher some time to take the correct focus.

          diag("Moving the mouse away from the launcher.");

          mouse_set(1, 1);

      }

+     # Open the launching mode

      wait_screen_change { send_key $key; };

-     # srsly KDE y u so slo

+     # Give enough wait time for the everything to settle,

+     # especially KDE is quite slow in responses.

      wait_still_screen 3;

-     type_very_safely $app;

-     # Wait for KDE to place focus correctly.

+     type_very_safely($application);

+     # Wait to place focus correctly.

      wait_still_screen 2;

      send_key 'ret';

      wait_still_screen 3;

-     diag("Launcher: The application $app should have been launched.");

-     # If we should maximize the application

-     if ($maximize) {

+ 

+     # If check that app is running was requested

+     # with checkstart => 1

+     if ($args{checkstart}) {

+         assert_screen("apps_run_$application");

+     }

+     # If maximizing the application was requested

+     # with maximize => 1

+     if ($args{maximize}) {

          if ($desktop eq "kde") {

              send_key('super-pgup');

          }
@@ -1398,10 +1414,9 @@ 

              send_key('super-up');

          }

          else {

-             diag('Maximizing in this desktop is not supported at the moment!');

+             record_soft_failure('Maximizing in this desktop is not supported at the moment!');

          }

          wait_still_screen 3;

-         diag("Maximizer: The application should have been maximized.");

      }

  }

  
@@ -1618,6 +1633,7 @@ 

  # launch a terminal from a desktop, using the most efficient/reliable

  # approach (not appropriate if we really need to test launching it a

  # specific way)

+ # Check, that the application has started.

  sub desktop_launch_terminal {

      my $desktop = get_var("DESKTOP");

      if ($desktop eq "i3") {
@@ -1627,7 +1643,7 @@ 

          send_key "ctrl-alt-t";

      }

      else {

-         menu_launch_type "terminal";

+         menu_launch_type("terminal", checkstart => 1);

      }

  }

  
@@ -1846,4 +1862,19 @@ 

      send_key "ret";

  }

  

+ # With Gnome Software it is a bit more complicated to check

+ # that the application has started correctly, because on first

+ # runs (most of the tests), it keeps asking about third party

+ # repositories.

+ # This subroutine handles it, so we can use it on multiple

+ # places around the test cases.

+ sub check_software_start {

+     if (check_screen("gnome_software_ignore", 10)) {

+         wait_still_screen(3);

+         # match again as the dialog might have moved a bit

+         assert_and_click("gnome_software_ignore");

+     }

+     assert_screen("desktop_package_tool_update");

+ }

+ 

  1;

@@ -10,6 +10,7 @@ 

    ],

    "properties": [],

    "tags": [

-     "apps_run_files"

+     "apps_run_files",

+     "apps_run_nautilus"

    ]

- } 

\ No newline at end of file

+ }

@@ -10,6 +10,7 @@ 

    ],

    "properties": [],

    "tags": [

-     "apps_run_files"

+     "apps_run_files",

+     "apps_run_nautilus"

    ]

- } 

\ No newline at end of file

+ }

@@ -22,12 +22,7 @@ 

      set_update_notification_timestamp();

  

      # Start the application

-     menu_launch_type("nautilus");

-     # Check it has started

-     assert_screen 'apps_run_files';

-     # Fullsize the window.

-     wait_screen_change { send_key("super-up"); };

-     wait_still_screen 3;

+     menu_launch_type("nautilus", checkstart => 1, maximize => 1);

  

      # Open the Documents directory

      assert_and_click("gnome_open_location_documents");

@@ -12,7 +12,7 @@ 

      sleep(5);

      # The full screen is not supported by any application, but it

      # is supported by several, such as Terminal.

-     menu_launch_type("terminal", "maximize");

+     menu_launch_type("terminal", maximize => 1);

      # If we see prompt, everything is ok.

      assert_screen("terminal_prompt");

  

@@ -11,9 +11,9 @@ 

      # Let us wait here for a couple of seconds to give the VM time to settle.

      # Starting right over might result in erroneous behavior.

      sleep(5);

-     menu_launch_type("text editor", "maximize");

+     menu_launch_type("text editor", maximize => 1);

      assert_screen("apps_run_texteditor");

-     menu_launch_type("files", "maximize");

+     menu_launch_type("files", maximize => 1);

      assert_screen("apps_run_files");

  

      # If we are at Nautilus switch to editor

@@ -72,16 +72,16 @@ 

      ### Switch between more applications

  

      # Start more applications.

-     menu_launch_type("clocks", "maximize");

+     menu_launch_type("clocks", maximize => 1);

      # Sometime, Clocks start with an access request,

      # deny it.

      if (check_screen('grant_access', 5)) {

          send_key('ret');

      }

      assert_screen('apps_run_clocks');

-     menu_launch_type("calculator", "maximize");

+     menu_launch_type("calculator", maximize => 1);

      assert_screen('apps_run_calculator');

-     menu_launch_type("terminal", "maximize");

+     menu_launch_type("terminal", maximize => 1);

      assert_screen('apps_run_terminal');

  

      ## Going forwards

@@ -27,9 +27,9 @@ 

      # Let us wait here for a couple of seconds to give the VM time to settle.

      # Starting right over might result in erroneous behavior.

      sleep(5);

-     menu_launch_type("files", "maximize");

+     menu_launch_type("files", maximize => 1);

      assert_screen('apps_run_files');

-     menu_launch_type("text editor", "maximize");

+     menu_launch_type("text editor", maximize => 1);

      assert_screen('apps_run_texteditor');

  

      # The focused application should be the Editor, so let's check it is

@@ -13,12 +13,8 @@ 

  

  

      # check if third party dialog appears, if so, click it away

-     if (check_screen 'gnome_software_ignore', 10) {

-         wait_still_screen 3;

-         # match again as the dialog may have moved a bit

-         assert_and_click 'gnome_software_ignore';

-     }

-     assert_screen 'desktop_package_tool_update';

+     check_software_start();

+ 

      # Register application

      register_application("gnome-software");

      # Close the application

file modified
+1 -2
@@ -31,8 +31,7 @@ 

      # Now, we will switch into the Desktop and we will try to run the application

      desktop_vt();

      wait_still_screen(3);

-     menu_launch_type("gvim");

-     assert_screen("apps_run_gvim");

+     menu_launch_type("gvim", checkstart => 1);

      # Switch off the application

      type_very_safely(":qa\n");

  

file modified
+1 -3
@@ -37,9 +37,7 @@ 

      # Switch to desktop and try to run the application.

      desktop_vt();

      wait_still_screen(3);

-     menu_launch_type("focuswriter");

-     # Check that it started

-     assert_screen("apps_run_focuswriter");

+     menu_launch_type("focuswriter", checkstart => 1);

      # Stop the application

      send_key("alt-f4");

  

@@ -45,7 +45,11 @@ 

          # According to the ticket, the 'fedora.json' file

          # which lists the available versions will be created

          # after the Software starts. Let's start it then on Gnome.

+         # Do not use the default start checks, because they could

+         # fail, check manually instead.

          menu_launch_type("software");

+         check_software_start();

+ 

          # When Software is started for the first time, it asks whether

          # a user wants to use Third Party software. We want to Ignore

          # this and proceed, so if we see that we click on Ignore.

@@ -48,9 +48,16 @@ 

  

      # Start the package manager application depending

      # on which DE we are on.

-     my $pkgmgr = "software";

-     $pkgmgr = "discover" if ($desktop eq "kde");

-     menu_launch_type($pkgmgr);

+     if ($desktop eq "gnome") {

+         # Do not do start checking through menu_launch_type as this

+         # could fail on Gnome because of the third party dialogue.

+         # Use the Software specific check instead.

+         menu_launch_type("software");

+         check_software_start();

+     }

+     else {

+         menu_launch_type("discover", checkstart => 1);

+     }

  

      # On Gnome, the upgrade is safely visible when

      # we visit the Update page by clicking on the

The previous version of menu_launch_type took the name of the
application as an argument and it started the application.
To maximize the application or to check that it has started indeed
we had to do it manually.

Now, the application also takes "maximize => 1" or "checkstart => 1"
to maximize the application or check that it has started as optional
arguments to avoid doing it manually, while it still accepts just
the name of the application and behaves like it did before.

Note that if you decide to use the checkstart argument, you
also need to update the check-needles.py script to whitelist
the application needle tag, see the example test scripts
attached to this PR.

Fixes: https://pagure.io/fedora-qa/os-autoinst-distri-fedora/issue/329

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/26266305f99b429ca7f9ecd312c6b815

will this give warnings about it not being defined, if the arg isn't passed?

also, won't this break all the things that currently do e.g. menu_launch_type("clocks", "maximize");? don't those all need to be updated in this PR?

[adamw@toolbx os-autoinst-distri-fedora (main %)]$ grep -R menu_launch_type tests/ | grep maxim
tests/applications/navigation/full_screen.pm:    menu_launch_type("terminal", "maximize");
tests/applications/navigation/navigation_details.pm:    menu_launch_type("text editor", "maximize");
tests/applications/navigation/navigation_details.pm:    menu_launch_type("files", "maximize");
tests/applications/navigation/switch_application.pm:    menu_launch_type("clocks", "maximize");
tests/applications/navigation/switch_application.pm:    menu_launch_type("calculator", "maximize");
tests/applications/navigation/switch_application.pm:    menu_launch_type("terminal", "maximize");
tests/applications/navigation/switch_workplaces.pm:    menu_launch_type("files", "maximize");
tests/applications/navigation/switch_workplaces.pm:    menu_launch_type("text editor", "maximize");

will this give warnings about it not being defined, if the arg isn't passed?

No, according to the documentation, the way maximize and checkstart arguments are passed makes them not obligatory so they can be left out. If they are left out, the subroutine behaves like it did before, just starting the application and that's it, so it should be compatible with all tests written before this change, except for those you have mentioned and that had maximize set the old way, but they are now fixed to this new syntax.

I have created a new issue and when this is merged, I will check all occurences of menu_launch_type with a subsequent request to check start or maximize and will bring them to this new syntax.

also, won't this break all the things that currently do e.g. menu_launch_type("clocks", "maximize");? don't those all need to be updated in this PR?
[adamw@toolbx os-autoinst-distri-fedora (main %)]$ grep -R menu_launch_type tests/ | grep maxim tests/applications/navigation/full_screen.pm: menu_launch_type("terminal", "maximize"); tests/applications/navigation/navigation_details.pm: menu_launch_type("text editor", "maximize"); tests/applications/navigation/navigation_details.pm: menu_launch_type("files", "maximize"); tests/applications/navigation/switch_application.pm: menu_launch_type("clocks", "maximize"); tests/applications/navigation/switch_application.pm: menu_launch_type("calculator", "maximize"); tests/applications/navigation/switch_application.pm: menu_launch_type("terminal", "maximize"); tests/applications/navigation/switch_workplaces.pm: menu_launch_type("files", "maximize"); tests/applications/navigation/switch_workplaces.pm: menu_launch_type("text editor", "maximize");

I am not sure. I did not notice any problems but I might have overlooked them as I did not run all the application tests. I will fix this anyway. Thanks for the catch.

rebased onto a55263a

2 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/b2659074dd51470e93f32fc378ab3f24

rebased onto bc7bf1a

2 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/97d9b2cfcaba42d6a16d4fedc5add28e

This above mentioned usage of menu_launch_type is fixed already.

rebased onto f5511a9

2 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/72f923cab35f4cba8923481ca7243c86

rebased onto 10a5429

2 months ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/4056b304e7ec4687a6d3ff0ce886f9e4

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/4bec072c43d746b0bc3f1f0dde794427

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/76643db03c2c42bea7002e81f091a046

1 new commit added

  • Install python3-libdnf5 package
2 months ago

2 new commits added

  • Install python3-libdnf5 package
  • Enhance the menu_launch_type subroutine.
2 months ago

2 new commits added

  • Install python3-libdnf5 package
  • Enhance the menu_launch_type subroutine.
2 months ago

1 new commit added

  • Enhance the menu_launch_type subroutine.
2 months ago

1 new commit added

  • Enhance the menu_launch_type subroutine.
2 months ago

rebased onto 1e6da70

2 months ago

The change to tests/applications/archiver/aaa_setup.pm will fail because no needle has the tag apps_run_nautilus. Either change it to menu_launch_type("files"... (and make sure that works), or add apps_run_nautilus tag to all the apps_run_files* needles.

Similarly, the changes to tests/graphical_upgrade_prerequisites.pm and tests/graphical_upgrade_run.pm won't work for GNOME because there is no needle with the tag apps_run_software. We use the desktop_package_tool_update needle to check that Software started successfully, and you can't just do a straightforward assert because it might show the third party dialog (see apps_startstop/gnome/software.pm ).

1 new commit added

  • Add tag apps_run_nautilus to apps_run_files needles.
2 months ago

1 new commit added

  • Use special start checking on Software.
2 months ago

I have added the apps_run_nautilus tag to the existing apps_run_files needles and the tests for Archiver pass, so I believe this was sufficient.

As for the second flaw, I moved the Software checkstart functionality into utils.pm and now I can start Software with menu_launch_type("software");, i.e. without checking that it started and check specifically using check_software_start();

rebased onto 891868e

2 months ago

OK, sure, this looks fine. Let's give it a shot. Thanks!

Pull-Request has been merged by adamwill

2 months ago