forked from beeware/toga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
90 lines (65 loc) · 2.65 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from pathlib import Path
import pytest
from toga_iOS.libs import (
NSFileManager,
NSSearchPathDirectory,
NSSearchPathDomainMask,
UIApplication,
)
from .dialogs import DialogsMixin
from .probe import BaseProbe
class AppProbe(BaseProbe, DialogsMixin):
supports_key = False
def __init__(self, app):
super().__init__()
self.app = app
self.native = self.app._impl.native
assert isinstance(self.native, UIApplication)
def get_path(self, search_path):
file_manager = NSFileManager.defaultManager
urls = file_manager.URLsForDirectory(
search_path, inDomains=NSSearchPathDomainMask.User
)
return Path(urls[0].path)
@property
def config_path(self):
return self.get_path(NSSearchPathDirectory.ApplicationSupport) / "Config"
@property
def data_path(self):
return self.get_path(NSSearchPathDirectory.Documents)
@property
def cache_path(self):
return self.get_path(NSSearchPathDirectory.Cache)
@property
def logs_path(self):
return self.get_path(NSSearchPathDirectory.ApplicationSupport) / "Logs"
def assert_app_icon(self, icon):
pytest.xfail("iOS apps don't have app icons at runtime")
def assert_system_menus(self):
pytest.skip("Menus not implemented on iOS")
def activate_menu_about(self):
pytest.skip("Menus not implemented on iOS")
def activate_menu_visit_homepage(self):
pytest.skip("Menus not implemented on iOS")
def assert_menu_item(self, path, enabled):
pytest.skip("Menus not implemented on iOS")
def assert_menu_order(self, path, expected):
pytest.skip("Menus not implemented on iOS")
def enter_background(self):
self.native.delegate.applicationWillResignActive(self.native)
self.native.delegate.applicationDidEnterBackground(self.native)
def enter_foreground(self):
self.native.delegate.applicationWillEnterForeground(self.native)
def terminate(self):
self.native.delegate.applicationWillTerminate(self.native)
def rotate(self):
self.native = self.app._impl.native
self.native.delegate.application(self.native, didChangeStatusBarOrientation=0)
def has_status_icon(self, status_icon):
pytest.xfail("Status icons not implemented on iOS")
def status_menu_items(self, status_icon):
pytest.xfail("Status icons not implemented on iOS")
def activate_status_icon_button(self, item_id):
pytest.xfail("Status icons not implemented on iOS")
def activate_status_menu_item(self, item_id, title):
pytest.xfail("Status icons not implemented on iOS")