458 lines
16 KiB
Python
458 lines
16 KiB
Python
"""
|
|
Activity Bar Tests
|
|
|
|
Tests for the in-game activity bar including:
|
|
- Layout modes (horizontal/vertical/grid)
|
|
- Dragging and positioning
|
|
- Plugin drawer
|
|
- Pinned plugins
|
|
- Opacity and visibility
|
|
"""
|
|
|
|
|
|
class ActivityBarTests:
|
|
"""Test suite for activity bar."""
|
|
|
|
name = "Activity Bar"
|
|
icon = "📊"
|
|
description = "Tests in-game activity bar layouts, dragging, drawer, and pinned plugins"
|
|
|
|
def __init__(self):
|
|
self.tests = {
|
|
'initialization': self.test_initialization,
|
|
'layout_modes': self.test_layout_modes,
|
|
'dragging': self.test_dragging,
|
|
'drawer_functionality': self.test_drawer_functionality,
|
|
'pinned_plugins': self.test_pinned_plugins,
|
|
'opacity_control': self.test_opacity_control,
|
|
'auto_hide': self.test_auto_hide,
|
|
'settings_dialog': self.test_settings_dialog,
|
|
'mini_widgets': self.test_mini_widgets,
|
|
'config_persistence': self.test_config_persistence,
|
|
}
|
|
|
|
def test_initialization(self) -> dict:
|
|
"""Test activity bar initialization."""
|
|
try:
|
|
from core.activity_bar import ActivityBar, ActivityBarConfig
|
|
|
|
issues = []
|
|
|
|
# Check config defaults
|
|
config = ActivityBarConfig()
|
|
if not config.enabled:
|
|
issues.append("Activity bar disabled by default")
|
|
|
|
if config.size < 32 or config.size > 96:
|
|
issues.append(f"Default icon size ({config.size}) outside recommended range (32-96)")
|
|
|
|
if config.opacity < 0.2 or config.opacity > 1.0:
|
|
issues.append(f"Default opacity ({config.opacity}) outside valid range (0.2-1.0)")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'warning'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': f"ActivityBar initializes correctly (size={config.size}, opacity={config.opacity})",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error initializing ActivityBar: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_layout_modes(self) -> dict:
|
|
"""Test different layout modes."""
|
|
try:
|
|
from core.activity_bar import ActivityBarLayout
|
|
|
|
expected_modes = ['HORIZONTAL', 'VERTICAL', 'GRID']
|
|
available_modes = [m.name for m in ActivityBarLayout]
|
|
|
|
missing = set(expected_modes) - set(available_modes)
|
|
|
|
if missing:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Missing layout modes: {missing}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
# Check layout values
|
|
if ActivityBarLayout.HORIZONTAL.value != 'horizontal':
|
|
return {
|
|
'passed': False,
|
|
'message': "HORIZONTAL layout has incorrect value",
|
|
'severity': 'error'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': f"All layout modes available: {available_modes}",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking layout modes: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_dragging(self) -> dict:
|
|
"""Test activity bar dragging functionality."""
|
|
try:
|
|
from core.activity_bar import ActivityBar
|
|
|
|
issues = []
|
|
|
|
# Check drag-related methods
|
|
if not hasattr(ActivityBar, 'mousePressEvent'):
|
|
issues.append("mousePressEvent not implemented")
|
|
|
|
if not hasattr(ActivityBar, 'mouseMoveEvent'):
|
|
issues.append("mouseMoveEvent not implemented")
|
|
|
|
if not hasattr(ActivityBar, 'mouseReleaseEvent'):
|
|
issues.append("mouseReleaseEvent not implemented")
|
|
|
|
# Check for drag state
|
|
if not hasattr(ActivityBar, '_dragging'):
|
|
issues.append("_dragging state variable not defined")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'error'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': "Dragging functionality implemented",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking dragging: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_drawer_functionality(self) -> dict:
|
|
"""Test plugin drawer functionality."""
|
|
try:
|
|
from core.activity_bar import ActivityBar
|
|
|
|
issues = []
|
|
recommendations = []
|
|
|
|
# Check drawer setup
|
|
if not hasattr(ActivityBar, '_setup_drawer'):
|
|
issues.append("_setup_drawer method missing")
|
|
|
|
if not hasattr(ActivityBar, '_toggle_drawer'):
|
|
issues.append("_toggle_drawer method missing")
|
|
|
|
if not hasattr(ActivityBar, 'drawer'):
|
|
issues.append("drawer attribute not defined")
|
|
|
|
# Check drawer state
|
|
if not hasattr(ActivityBar, 'drawer_open'):
|
|
issues.append("drawer_open state not tracked")
|
|
|
|
# Check drawer refresh
|
|
if not hasattr(ActivityBar, '_refresh_drawer'):
|
|
recommendations.append("Consider implementing _refresh_drawer for dynamic updates")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'error',
|
|
'recommendation': recommendations[0] if recommendations else None
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': "Drawer functionality present",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking drawer: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_pinned_plugins(self) -> dict:
|
|
"""Test pinned plugins functionality."""
|
|
try:
|
|
from core.activity_bar import ActivityBar, ActivityBarConfig
|
|
|
|
issues = []
|
|
recommendations = []
|
|
|
|
# Check pinned plugins config
|
|
config = ActivityBarConfig()
|
|
if not hasattr(config, 'pinned_plugins'):
|
|
issues.append("pinned_plugins not in config")
|
|
|
|
# Check refresh method
|
|
if not hasattr(ActivityBar, '_refresh_pinned_plugins'):
|
|
issues.append("_refresh_pinned_plugins method missing")
|
|
|
|
# Check pinned buttons tracking
|
|
if not hasattr(ActivityBar, 'pinned_buttons'):
|
|
issues.append("pinned_buttons dictionary not defined")
|
|
|
|
# Check create button method
|
|
if not hasattr(ActivityBar, '_create_plugin_button'):
|
|
recommendations.append("Consider separating plugin button creation logic")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'error'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': "Pinned plugins functionality present",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking pinned plugins: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_opacity_control(self) -> dict:
|
|
"""Test opacity control."""
|
|
try:
|
|
from core.activity_bar import ActivityBar, ActivityBarConfig
|
|
|
|
issues = []
|
|
|
|
config = ActivityBarConfig()
|
|
|
|
# Check opacity in config
|
|
if not hasattr(config, 'opacity'):
|
|
issues.append("opacity not in config")
|
|
|
|
# Check opacity range
|
|
if hasattr(config, 'opacity'):
|
|
if config.opacity < 0.1 or config.opacity > 1.0:
|
|
issues.append(f"Config opacity {config.opacity} outside valid range (0.1-1.0)")
|
|
|
|
# Check apply config
|
|
if not hasattr(ActivityBar, '_apply_config'):
|
|
issues.append("_apply_config method missing")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'warning'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': f"Opacity control present (default: {config.opacity})",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking opacity: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_auto_hide(self) -> dict:
|
|
"""Test auto-hide functionality."""
|
|
try:
|
|
from core.activity_bar import ActivityBar, ActivityBarConfig
|
|
|
|
issues = []
|
|
recommendations = []
|
|
|
|
config = ActivityBarConfig()
|
|
|
|
# Check auto_hide in config
|
|
if not hasattr(config, 'auto_hide'):
|
|
issues.append("auto_hide not in config")
|
|
|
|
if not hasattr(config, 'always_visible'):
|
|
issues.append("always_visible not in config")
|
|
|
|
# Check auto-hide methods
|
|
if not hasattr(ActivityBar, '_auto_hide'):
|
|
issues.append("_auto_hide method missing")
|
|
|
|
if not hasattr(ActivityBar, 'enterEvent'):
|
|
issues.append("enterEvent not implemented for hover detection")
|
|
|
|
if not hasattr(ActivityBar, 'leaveEvent'):
|
|
issues.append("leaveEvent not implemented for hover detection")
|
|
|
|
# Check hide timer
|
|
if not hasattr(ActivityBar, 'hide_timer'):
|
|
recommendations.append("Consider using QTimer for auto-hide delay")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'warning'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': f"Auto-hide present (default: auto_hide={config.auto_hide}, always_visible={config.always_visible})",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking auto-hide: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_settings_dialog(self) -> dict:
|
|
"""Test settings dialog."""
|
|
try:
|
|
from core.activity_bar import ActivityBarSettingsDialog, ActivityBar
|
|
|
|
issues = []
|
|
|
|
# Check settings dialog exists
|
|
if not ActivityBarSettingsDialog:
|
|
issues.append("ActivityBarSettingsDialog not found")
|
|
|
|
# Check show settings method
|
|
if not hasattr(ActivityBar, 'show_settings_dialog'):
|
|
issues.append("show_settings_dialog method missing")
|
|
|
|
# Check dialog UI setup
|
|
if not hasattr(ActivityBarSettingsDialog, '_setup_ui'):
|
|
issues.append("Settings dialog missing _setup_ui method")
|
|
|
|
# Check get_config method
|
|
if not hasattr(ActivityBarSettingsDialog, 'get_config'):
|
|
issues.append("Settings dialog missing get_config method")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'warning'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': "Settings dialog present",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking settings dialog: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_mini_widgets(self) -> dict:
|
|
"""Test mini widgets functionality."""
|
|
try:
|
|
from core.activity_bar import ActivityBar
|
|
|
|
issues = []
|
|
recommendations = []
|
|
|
|
# Check mini widgets tracking
|
|
if not hasattr(ActivityBar, 'mini_widgets'):
|
|
recommendations.append("Consider implementing mini_widgets dictionary for widget tracking")
|
|
|
|
# Check widget_requested signal
|
|
if not hasattr(ActivityBar, 'widget_requested'):
|
|
issues.append("widget_requested signal not defined")
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'warning',
|
|
'recommendation': recommendations[0] if recommendations else None
|
|
}
|
|
|
|
return {
|
|
'passed': len(issues) == 0,
|
|
'message': "Mini widgets signal present" if not issues else "Partial mini widgets support",
|
|
'severity': 'info'
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking mini widgets: {e}",
|
|
'severity': 'error'
|
|
}
|
|
|
|
def test_config_persistence(self) -> dict:
|
|
"""Test configuration persistence."""
|
|
try:
|
|
from core.activity_bar import ActivityBar, ActivityBarConfig
|
|
|
|
issues = []
|
|
|
|
# Check load config
|
|
if not hasattr(ActivityBar, '_load_config'):
|
|
issues.append("_load_config method missing")
|
|
|
|
if not hasattr(ActivityBar, '_save_config'):
|
|
issues.append("_save_config method missing")
|
|
|
|
# Check config path
|
|
import inspect
|
|
load_source = inspect.getsource(ActivityBar._load_config) if hasattr(ActivityBar, '_load_config') else ""
|
|
if 'config/activity_bar.json' not in load_source:
|
|
recommendations = ["Consider using config/activity_bar.json for settings"]
|
|
else:
|
|
recommendations = []
|
|
|
|
if issues:
|
|
return {
|
|
'passed': False,
|
|
'message': "; ".join(issues),
|
|
'severity': 'warning'
|
|
}
|
|
|
|
return {
|
|
'passed': True,
|
|
'message': "Config persistence implemented",
|
|
'severity': 'info',
|
|
'recommendation': recommendations[0] if recommendations else None
|
|
}
|
|
|
|
except Exception as e:
|
|
return {
|
|
'passed': False,
|
|
'message': f"Error checking config persistence: {e}",
|
|
'severity': 'error'
|
|
}
|