mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Rename PackageManager to AppManager
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from mpos import App, PackageManager
|
||||
from mpos import App, AppManager
|
||||
|
||||
from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import _thread
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from mpos import App, PackageManager
|
||||
from mpos import App, AppManager
|
||||
|
||||
from nostr.relay_manager import RelayManager
|
||||
from nostr.message_type import ClientMessageType
|
||||
|
||||
@@ -27,7 +27,7 @@ from mpos import (
|
||||
print_screen_labels,
|
||||
DeviceInfo,
|
||||
BuildInfo,
|
||||
PackageManager
|
||||
AppManager
|
||||
)
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class TestGraphicalAboutApp(unittest.TestCase):
|
||||
print("\n=== Starting About app test ===")
|
||||
|
||||
# Start the About app
|
||||
result = PackageManager.start_app("com.micropythonos.about")
|
||||
result = AppManager.start_app("com.micropythonos.about")
|
||||
self.assertTrue(result, "Failed to start About app")
|
||||
|
||||
# Wait for UI to fully render
|
||||
@@ -146,7 +146,7 @@ class TestGraphicalAboutApp(unittest.TestCase):
|
||||
print("\n=== Starting About app OS version test ===")
|
||||
|
||||
# Start the About app
|
||||
result = PackageManager.start_app("com.micropythonos.about")
|
||||
result = AppManager.start_app("com.micropythonos.about")
|
||||
self.assertTrue(result, "Failed to start About app")
|
||||
|
||||
# Wait for UI to render
|
||||
|
||||
@@ -31,7 +31,7 @@ from mpos import (
|
||||
print_screen_labels,
|
||||
simulate_click,
|
||||
get_widget_coords,
|
||||
PackageManager
|
||||
AppManager
|
||||
)
|
||||
|
||||
@unittest.skipIf(sys.platform == 'darwin', "Camera tests not supported on macOS (no camera available)")
|
||||
@@ -117,7 +117,7 @@ class TestGraphicalCameraSettings(unittest.TestCase):
|
||||
print("\n=== Testing settings button click (no crash) ===")
|
||||
|
||||
# Start the Camera app
|
||||
result = PackageManager.start_app("com.micropythonos.camera")
|
||||
result = AppManager.start_app("com.micropythonos.camera")
|
||||
self.assertTrue(result, "Failed to start Camera app")
|
||||
|
||||
# Wait for camera to initialize and first frame to render
|
||||
@@ -251,7 +251,7 @@ class TestGraphicalCameraSettings(unittest.TestCase):
|
||||
print("\n=== Testing resolution change (no crash) ===")
|
||||
|
||||
# Start the Camera app
|
||||
result = PackageManager.start_app("com.micropythonos.camera")
|
||||
result = AppManager.start_app("com.micropythonos.camera")
|
||||
self.assertTrue(result, "Failed to start Camera app")
|
||||
|
||||
# Wait for camera to initialize
|
||||
|
||||
@@ -27,7 +27,7 @@ from mpos import (
|
||||
click_label,
|
||||
click_button,
|
||||
find_text_on_screen,
|
||||
PackageManager
|
||||
AppManager
|
||||
)
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class TestIMUCalibration(unittest.TestCase):
|
||||
print("\n=== Testing CheckIMUCalibrationActivity ===")
|
||||
|
||||
# Navigate: Launcher -> Settings -> Check IMU Calibration
|
||||
result = PackageManager.start_app("com.micropythonos.settings")
|
||||
result = AppManager.start_app("com.micropythonos.settings")
|
||||
self.assertTrue(result, "Failed to start Settings app")
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -98,7 +98,7 @@ class TestIMUCalibration(unittest.TestCase):
|
||||
print("\n=== Testing CalibrateIMUActivity Flow ===")
|
||||
|
||||
# Navigate: Launcher -> Settings -> Calibrate IMU
|
||||
result = PackageManager.start_app("com.micropythonos.settings")
|
||||
result = AppManager.start_app("com.micropythonos.settings")
|
||||
self.assertTrue(result, "Failed to start Settings app")
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -155,7 +155,7 @@ class TestIMUCalibration(unittest.TestCase):
|
||||
print("\n=== Testing Check -> Calibrate Navigation ===")
|
||||
|
||||
# Navigate to Check activity
|
||||
result = PackageManager.start_app("com.micropythonos.settings")
|
||||
result = AppManager.start_app("com.micropythonos.settings")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ from mpos import (
|
||||
click_label,
|
||||
click_button,
|
||||
find_text_on_screen,
|
||||
PackageManager
|
||||
AppManager
|
||||
)
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class TestIMUCalibrationUI(unittest.TestCase):
|
||||
print("Step 2: Opening Settings app...")
|
||||
|
||||
# Start Settings app by name
|
||||
PackageManager.start_app("com.micropythonos.settings")
|
||||
AppManager.start_app("com.micropythonos.settings")
|
||||
wait_for_render(iterations=30)
|
||||
print("Settings app opened\n")
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import time
|
||||
# This is a graphical test - needs boot and main to run first
|
||||
# Add tests directory to path for helpers
|
||||
|
||||
from mpos import wait_for_render, ui, PackageManager
|
||||
from mpos import wait_for_render, ui, AppManager
|
||||
|
||||
|
||||
class TestLaunchAllApps(unittest.TestCase):
|
||||
@@ -30,7 +30,7 @@ class TestLaunchAllApps(unittest.TestCase):
|
||||
def _discover_apps(self):
|
||||
"""Discover all installed apps."""
|
||||
# Use PackageManager to get all apps
|
||||
all_packages = PackageManager.get_app_list()
|
||||
all_packages = AppManager.get_app_list()
|
||||
|
||||
for package in all_packages:
|
||||
# Get the main activity for each app
|
||||
@@ -64,7 +64,7 @@ class TestLaunchAllApps(unittest.TestCase):
|
||||
|
||||
try:
|
||||
# Launch the app by package name
|
||||
result = PackageManager.start_app(package_name)
|
||||
result = AppManager.start_app(package_name)
|
||||
|
||||
# Wait for UI to render
|
||||
wait_for_render(iterations=5)
|
||||
@@ -188,7 +188,7 @@ class TestLaunchSpecificApps(unittest.TestCase):
|
||||
|
||||
try:
|
||||
# Launch the app by package name
|
||||
result = PackageManager.start_app(package_name)
|
||||
result = AppManager.start_app(package_name)
|
||||
wait_for_render(iterations=5)
|
||||
|
||||
# Check if start_app returned False (indicates error)
|
||||
|
||||
@@ -14,7 +14,7 @@ from mpos import (
|
||||
print_screen_labels,
|
||||
DeviceInfo,
|
||||
BuildInfo,
|
||||
PackageManager
|
||||
AppManager
|
||||
)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase):
|
||||
|
||||
def test_app_launches_successfully(self):
|
||||
"""Test that OSUpdate app launches without errors."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
|
||||
self.assertTrue(result, "Failed to start OSUpdate app")
|
||||
wait_for_render(10)
|
||||
@@ -40,7 +40,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase):
|
||||
|
||||
def test_ui_elements_exist(self):
|
||||
"""Test that all required UI elements are created."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -60,7 +60,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase):
|
||||
|
||||
def test_force_checkbox_initially_unchecked(self):
|
||||
"""Test that force update checkbox starts unchecked."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -103,7 +103,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase):
|
||||
|
||||
def test_install_button_initially_disabled(self):
|
||||
"""Test that install button starts in disabled state."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -139,7 +139,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase):
|
||||
|
||||
def test_current_version_displayed(self):
|
||||
"""Test that current OS version is displayed correctly."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -159,7 +159,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase):
|
||||
"""Test status message when wifi is not connected."""
|
||||
# This test assumes desktop mode where wifi check returns True
|
||||
# On actual hardware without wifi, it would show error
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -174,7 +174,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase):
|
||||
|
||||
def test_screenshot_initial_state(self):
|
||||
"""Capture screenshot of initial app state."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(20)
|
||||
|
||||
@@ -207,7 +207,7 @@ class TestOSUpdateGraphicalStatusMessages(unittest.TestCase):
|
||||
|
||||
def test_status_label_exists(self):
|
||||
"""Test that status label is created and visible."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -226,7 +226,7 @@ class TestOSUpdateGraphicalStatusMessages(unittest.TestCase):
|
||||
|
||||
def test_all_labels_readable(self):
|
||||
"""Test that all labels are readable (no truncation issues)."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(15)
|
||||
|
||||
@@ -264,14 +264,14 @@ class TestOSUpdateGraphicalScreenshots(unittest.TestCase):
|
||||
|
||||
def test_capture_main_screen(self):
|
||||
"""Capture screenshot of main OSUpdate screen."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(20)
|
||||
|
||||
|
||||
def test_capture_with_labels_visible(self):
|
||||
"""Capture screenshot ensuring all text is visible."""
|
||||
result = PackageManager.start_app("com.micropythonos.osupdate")
|
||||
result = AppManager.start_app("com.micropythonos.osupdate")
|
||||
self.assertTrue(result)
|
||||
wait_for_render(20)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Usage:
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mpos import ui, wait_for_render, PackageManager
|
||||
from mpos import ui, wait_for_render, AppManager
|
||||
|
||||
|
||||
class TestStartApp(unittest.TestCase):
|
||||
@@ -39,7 +39,7 @@ class TestStartApp(unittest.TestCase):
|
||||
"""Test that launching an existing app succeeds."""
|
||||
print("Testing normal app launch...")
|
||||
|
||||
result = PackageManager.start_app("com.micropythonos.launcher")
|
||||
result = AppManager.start_app("com.micropythonos.launcher")
|
||||
wait_for_render(10) # Wait for app to load
|
||||
|
||||
self.assertTrue(result, "com.micropythonos.launcher should start")
|
||||
@@ -49,7 +49,7 @@ class TestStartApp(unittest.TestCase):
|
||||
"""Test that launching a non-existent app fails gracefully."""
|
||||
print("Testing non-existent app launch...")
|
||||
|
||||
result = PackageManager.start_app("com.micropythonos.nonexistent")
|
||||
result = AppManager.start_app("com.micropythonos.nonexistent")
|
||||
|
||||
self.assertFalse(result, "com.micropythonos.nonexistent should not start")
|
||||
print("Non-existent app handled correctly")
|
||||
@@ -58,7 +58,7 @@ class TestStartApp(unittest.TestCase):
|
||||
"""Test that restarting the launcher succeeds."""
|
||||
print("Testing launcher restart...")
|
||||
|
||||
result = PackageManager.restart_launcher()
|
||||
result = AppManager.restart_launcher()
|
||||
wait_for_render(10) # Wait for launcher to load
|
||||
|
||||
self.assertTrue(result, "restart_launcher() should succeed")
|
||||
|
||||
@@ -2,7 +2,7 @@ import unittest
|
||||
import _thread
|
||||
import time
|
||||
|
||||
from mpos import App, PackageManager, TaskManager
|
||||
from mpos import App, AppManager, TaskManager
|
||||
|
||||
from websocket import WebSocketApp
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import unittest
|
||||
import _thread
|
||||
import time
|
||||
|
||||
from mpos import App, PackageManager
|
||||
from mpos import App, AppManager
|
||||
from mpos import TaskManager
|
||||
|
||||
from websocket import WebSocketApp
|
||||
|
||||
@@ -38,7 +38,7 @@ class MockPartition:
|
||||
|
||||
# Import PackageManager which is needed by UpdateChecker
|
||||
# The test runs from internal_filesystem/ directory, so we can import from lib/mpos
|
||||
from mpos import PackageManager
|
||||
from mpos import AppManager
|
||||
|
||||
# Import the actual classes we're testing
|
||||
# Tests run from internal_filesystem/, so we add the assets directory to path
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
import unittest
|
||||
|
||||
from mpos import App, PackageManager
|
||||
from mpos import App, AppManager
|
||||
|
||||
class TestCompareVersions(unittest.TestCase):
|
||||
|
||||
def test_lower_short(self):
|
||||
self.assertFalse(PackageManager.compare_versions("1" , "4"))
|
||||
self.assertFalse(AppManager.compare_versions("1" , "4"))
|
||||
|
||||
def test_lower(self):
|
||||
self.assertFalse(PackageManager.compare_versions("1.2.3" , "4.5.6"))
|
||||
self.assertFalse(AppManager.compare_versions("1.2.3" , "4.5.6"))
|
||||
|
||||
def test_equal(self):
|
||||
self.assertFalse(PackageManager.compare_versions("1.2.3" , "1.2.3"))
|
||||
self.assertFalse(AppManager.compare_versions("1.2.3" , "1.2.3"))
|
||||
|
||||
def test_higher(self):
|
||||
self.assertTrue(PackageManager.compare_versions("4.5.6", "1.2.3"))
|
||||
self.assertTrue(AppManager.compare_versions("4.5.6", "1.2.3"))
|
||||
|
||||
def test_higher_medium_and_long(self):
|
||||
self.assertTrue(PackageManager.compare_versions("4.5", "1.2.3"))
|
||||
self.assertTrue(AppManager.compare_versions("4.5", "1.2.3"))
|
||||
|
||||
def test_words(self):
|
||||
self.assertFalse(PackageManager.compare_versions("weird" , "input"))
|
||||
self.assertFalse(AppManager.compare_versions("weird" , "input"))
|
||||
|
||||
def test_one_empty(self):
|
||||
self.assertFalse(PackageManager.compare_versions("1.2.3" , ""))
|
||||
self.assertFalse(AppManager.compare_versions("1.2.3" , ""))
|
||||
|
||||
class TestPackageManager_is_installed_by_name(unittest.TestCase):
|
||||
class TestAppManager_is_installed_by_name(unittest.TestCase):
|
||||
|
||||
def test_installed_builtin(self):
|
||||
self.assertTrue(PackageManager.is_installed_by_name("com.micropythonos.appstore"))
|
||||
self.assertTrue(AppManager.is_installed_by_name("com.micropythonos.appstore"))
|
||||
|
||||
def test_installed_not_builtin(self):
|
||||
self.assertTrue(PackageManager.is_installed_by_name("com.micropythonos.helloworld"))
|
||||
self.assertTrue(AppManager.is_installed_by_name("com.micropythonos.helloworld"))
|
||||
|
||||
def test_not_installed(self):
|
||||
self.assertFalse(PackageManager.is_installed_by_name("com.micropythonos.badname"))
|
||||
self.assertFalse(AppManager.is_installed_by_name("com.micropythonos.badname"))
|
||||
|
||||
class TestPackageManager_get_app_list(unittest.TestCase):
|
||||
class TestAppManager_get_app_list(unittest.TestCase):
|
||||
|
||||
def test_get_app_list(self):
|
||||
app_list = PackageManager.get_app_list()
|
||||
app_list = AppManager.get_app_list()
|
||||
self.assertGreaterEqual(len(app_list), 13) # more if the symlinks in internal_filesystem/app aren't dangling
|
||||
|
||||
def test_get_app(self):
|
||||
app_list = PackageManager.get_app_list()
|
||||
hello_world_app = PackageManager.get("com.micropythonos.helloworld")
|
||||
app_list = AppManager.get_app_list()
|
||||
hello_world_app = AppManager.get("com.micropythonos.helloworld")
|
||||
self.assertIsInstance(hello_world_app, App)
|
||||
self.assertEqual(hello_world_app.icon_path, "apps/com.micropythonos.helloworld/res/mipmap-mdpi/icon_64x64.png")
|
||||
self.assertEqual(len(hello_world_app.icon_data), 5378)
|
||||
self.assertEqual(hello_world_app.icon_path, "apps/com.micropythonos.helloworld/res/mipmap-mdpi/icon_64x64.png")
|
||||
self.assertEqual(len(hello_world_app.icon_data), 5378)
|
||||
|
||||
@@ -8,7 +8,7 @@ class TestSysPathRestore(unittest.TestCase):
|
||||
def test_syspath_restored_after_execute_script(self):
|
||||
"""Test that sys.path is restored to original state after script execution"""
|
||||
# Import here to ensure we're in the right context
|
||||
from mpos import PackageManager
|
||||
from mpos import AppManager
|
||||
|
||||
# Capture original sys.path
|
||||
original_path = sys.path[:]
|
||||
@@ -31,7 +31,7 @@ x = 42
|
||||
# Call execute_script with cwd parameter
|
||||
# Note: This will fail because there's no Activity to start,
|
||||
# but that's fine - we're testing the sys.path restoration
|
||||
result = PackageManager.execute_script(
|
||||
result = AppManager.execute_script(
|
||||
test_script,
|
||||
is_file=False,
|
||||
classname="NonExistentClass",
|
||||
@@ -56,7 +56,7 @@ x = 42
|
||||
|
||||
def test_syspath_not_affected_when_no_cwd(self):
|
||||
"""Test that sys.path is unchanged when cwd is None"""
|
||||
from mpos import PackageManager
|
||||
from mpos import AppManager
|
||||
|
||||
# Capture original sys.path
|
||||
original_path = sys.path[:]
|
||||
@@ -66,7 +66,7 @@ x = 42
|
||||
'''
|
||||
|
||||
# Call without cwd parameter
|
||||
result = PackageManager.execute_script(
|
||||
result = AppManager.execute_script(
|
||||
test_script,
|
||||
is_file=False,
|
||||
classname="NonExistentClass",
|
||||
|
||||
@@ -3,7 +3,7 @@ import unittest
|
||||
import _thread
|
||||
import time
|
||||
|
||||
from mpos import App, PackageManager
|
||||
from mpos import App, AppManager
|
||||
from mpos import TaskManager
|
||||
|
||||
from websocket import WebSocketApp
|
||||
|
||||
Reference in New Issue
Block a user