Test suite often fails to "Select a Keyfile" in GNOME Disks for VeraCrypt due to missed keyboard input

intrigeri
2024-10-22T16:08:28Z

On the video I see that GNOME Disks took into account our Return keypress and is trying to unlock without the keyfile, because somehow it missed our alt+k keypress.

04:38:58.231289714: try_for: attempt 1 (0.01s elapsed of 10s)...
04:38:58.231333484: executing Python as amnesia: node6507.grabFocus()
04:38:58.259737444: execution complete
04:38:58.259869356: executing Python as amnesia: print(node6507.focused)
04:38:58.376466919: execution complete
04:38:58.376578140: try_for: success!
04:38:58.376680092: executing Python as amnesia: node6516 = node6496.child(roleName=r'push button', description=r'Unlock selected encrypted partition')
04:38:58.442335574: execution complete
04:38:58.442617268: executing Python as amnesia: node6516.doActionNamed(r'click')
04:38:59.732447907: execution complete
04:38:59.732815842: executing Python as amnesia: node6517 = node6496.dialog(r'Set options to unlock')
04:38:59.775285645: execution complete
04:38:59.775468348: executing Python as amnesia: node6518 = node6517.child(r'', roleName=r'password text')
04:38:59.805721684: execution complete
04:38:59.805868656: executing Python as amnesia: node6518.text = r'test'
04:38:59.820724500: execution complete
04:38:59.820836001: opening file /tmp/keyfile in 'write' mode
04:38:59.840210837: write complete
04:38:59.840315069: Keyboard: pressing: alt+k
04:38:59.961355123: Keyboard: pressing: Return
04:39:00.083030995: executing Python as amnesia: node6519 = node6496.child(r'Select a Keyfile', roleName=r'file chooser')
04:39:16.664088038: execution complete
    And I unlock and mount this VeraCrypt volume with GNOME Disks (failed)                                  # features/step_definitions/veracrypt.rb:207
      The Dogtail init script raised: SearchError: descendent of [application | gnome-disks]: child with name="Select a Keyfile" roleName='file chooser'
      STDOUT:

      STDERR:

       (Dogtail::Failure)
      ./features/support/helpers/dogtail.rb:93:in `run'
      ./features/support/helpers/dogtail.rb:335:in `initialize'
      ./features/support/helpers/dogtail.rb:264:in `new'
      ./features/support/helpers/dogtail.rb:264:in `call_tree_api_method'
      ./features/support/helpers/dogtail.rb:272:in `child'
      ./features/step_definitions/veracrypt.rb:280:in `/^I unlock and mount this VeraCrypt (volume|file container) with GNOME Disks$/'
      features/veracrypt.feature:51:in `And I unlock and mount this VeraCrypt volume with GNOME Disks'

The corresponding code is:

  if @veracrypt_needs_keyfile
    $vm.file_overwrite('/tmp/keyfile', 'asdf')
    # Focus the keyfiles combo box using the workaround for #15952
    # that we implemented upstream
    @screen.press('alt', 'k')
    @screen.press('Return')
    select_path_in_file_chooser(
      disks.child('Select a Keyfile', roleName: 'file chooser'),
      '/tmp/keyfile'
    )
  end

I guess we should probably check that the relevant widget is selected betweent alt+k and Return.