Skip to content

Commit

Permalink
Allow selecting test mode with command-line argument
Browse files Browse the repository at this point in the history
Useful for local development.
  • Loading branch information
DemiMarie committed Dec 2, 2024
1 parent 5502758 commit 4201a3a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions qubes_menu/appmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ def __init__(self, qapp, dispatcher):
self.appmenu_position: str = 'mouse'

def _add_cli_options(self):
self.add_main_option(
"mock-qubes",
ord("m"),
GLib.OptionFlags.NONE,
GLib.OptionArg.NONE,
"Use fake Qubes object (FOR TESTING AND DEBUGGING ONLY)",
None,
)

self.add_main_option(
"keep-visible",
ord("k"),
Expand Down Expand Up @@ -168,6 +177,18 @@ def parse_options(self, options: Dict[str, Any]):
self.initial_page = PAGE_LIST[int(options["page"])]
if "background" in options:
self.start_in_background = True
if "mock-qubes" in options:
from qubesadmin.tests.mock_app import MockQubesComplete, MockDispatcher, MockQube
self.qapp = MockQubesComplete()

self.qapp._qubes['test-vm2'] = MockQube(name="test-vm2", qapp=self.qapp,
features={'menu-favorites': ''})
self.qapp._qubes['dom0'].features['menu-initial-page'] = 'favorites_page'
self.qapp._qubes['dom0'].features['menu-sort-running'] = '1'
self.qapp._qubes['dom0'].features['menu-position'] = 'top-left'
self.qapp.update_vm_calls()

self.dispatcher = MockDispatcher(self.qapp)

@staticmethod
def _do_power_button(_widget):
Expand Down

0 comments on commit 4201a3a

Please sign in to comment.