Skip to content

Commit

Permalink
Implemented Enum for the commands executed in the cmd palette
Browse files Browse the repository at this point in the history
  • Loading branch information
midays committed Feb 7, 2024
1 parent 611a358 commit c271074
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/models/IDE/VSCodeCommandEnum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from enum import Enum


class VSCodeCommandEnum(Enum):
CLEAR_ALL_NOTIFICATIONS = "Notifications: Clear All Notifications"
FOCUS_NOTIFICATIONS = "notifications: Show Notifications"
FOCUS_ON_OUTPUT_VIEW = "Output: Focus on Output View"
FOCUS_ON_EXPLORER_VIEW = "MTA: focus on explorer view"
REFRESH_CONFIGURATIONS = "MTA: Refresh Configurations"
FOCUS_ON_PROBLEMS_VIEW = "Problems: Focus on Problems View"
17 changes: 9 additions & 8 deletions src/models/IDE/VisualStudioCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import time

from src.models.IDE.VSCodeCommandEnum import VSCodeCommandEnum
from src.models.application import Application


Expand All @@ -14,9 +15,9 @@ def __init__(self):
self.configurations = []
super().__init__()

def cmd_palette_exec_command(self, command):
def cmd_palette_exec_command(self, command: VSCodeCommandEnum):
self.press_keys("ctrl", "shift", "p")
self.type_text(command)
self.type_text(command.value)
self.press_keys("enter")

def image_locator(self, locator):
Expand Down Expand Up @@ -44,7 +45,7 @@ def open_mta_perspective(self):
"""
Opens MTA perspective in VSCode IDE
"""
self.run_command_in_cmd_palette("MTA: focus on explorer view")
self.run_command_in_cmd_palette(VSCodeCommandEnum.FOCUS_ON_EXPLORER_VIEW)

def run_simple_analysis(self):
"""
Expand Down Expand Up @@ -79,13 +80,13 @@ def run_simple_analysis(self):
self.wait_find_element(locator_type="image", locator="analysis_progress.png", timeout=240.0)

def clear_all_notifications(self):
self.run_command_in_cmd_palette("Notifications: Clear All Notifications")
self.run_command_in_cmd_palette(VSCodeCommandEnum.CLEAR_ALL_NOTIFICATIONS)

def focus_notification_in_progress(self):
self.run_command_in_cmd_palette("notifications: Show Notifications")
self.run_command_in_cmd_palette(VSCodeCommandEnum.FOCUS_NOTIFICATIONS)

def focus_terminal_output_panel(self):
self.run_command_in_cmd_palette("Output: Focus on Output View")
self.run_command_in_cmd_palette(VSCodeCommandEnum.FOCUS_ON_OUTPUT_VIEW)

def copy_terminal_output(self):
self.focus_terminal_output_panel()
Expand Down Expand Up @@ -121,7 +122,7 @@ def set_focus(self):
def refresh_configuration(self):
# Refresh configuration via command prompt
self.open_mta_perspective()
self.run_command_in_cmd_palette("MTA: Refresh Configurations")
self.run_command_in_cmd_palette(VSCodeCommandEnum.REFRESH_CONFIGURATIONS)

def open_plugin_info(self, plugin):
self.press_keys("ctrl", "shift", "x")
Expand All @@ -132,7 +133,7 @@ def open_plugin_info(self, plugin):
self.press_keys("enter")

def focus_problems_panel(self):
self.run_command_in_cmd_palette("Problems: Focus on Problems View")
self.run_command_in_cmd_palette(VSCodeCommandEnum.FOCUS_ON_PROBLEMS_VIEW)

def copy_problems_list(self):
self.focus_problems_panel()
Expand Down

0 comments on commit c271074

Please sign in to comment.