@@ -38,6 +38,7 @@ def setUpClass(cls):
38
38
update_modules = True )
39
39
Tns .platform_add_ios (attributes = {'--path' : cls .app_name , '--frameworkPath' : IOS_PACKAGE })
40
40
Npm .install (package = IOS_INSPECTOR_PACKAGE , option = '--save-dev' , folder = cls .app_name )
41
+ Tns .build_ios (attributes = {"--path" : cls .app_name })
41
42
42
43
def setUp (self ):
43
44
BaseClass .setUp (self )
@@ -56,33 +57,27 @@ def tearDownClass(cls):
56
57
BaseClass .tearDownClass ()
57
58
Folder .cleanup (cls .app_name )
58
59
59
- def __verify_debugger_start (self , log ):
60
+ @staticmethod
61
+ def __verify_debugger_attach (log , app_started = True ):
60
62
strings = ["Frontend client connected" , "Backend socket created" , "NativeScript debugger attached" ]
61
- Tns .wait_for_log (log_file = log , string_list = strings , timeout = 120 , check_interval = 10 , clean_log = False )
63
+ Tns .wait_for_log (log_file = log , string_list = strings , timeout = 90 , check_interval = 10 , clean_log = False )
62
64
time .sleep (10 )
63
65
output = File .read (log )
64
66
assert "Frontend socket closed" not in output
65
67
assert "Backend socket closed" not in output
66
68
assert "NativeScript debugger detached" not in output
67
69
assert Process .is_running ('NativeScript Inspector' )
68
-
69
- def __verify_debugger_attach (self , log ):
70
- strings = ["Frontend client connected" , "Backend socket created" ]
71
- Tns .wait_for_log (log_file = log , string_list = strings , timeout = 120 , check_interval = 10 , clean_log = False )
72
- time .sleep (10 )
73
- output = File .read (log )
74
- assert "NativeScript debugger attached" not in output # This is not in output when you attach to running app
75
- assert "Frontend socket closed" not in output
76
- assert "Backend socket closed" not in output
77
- assert "NativeScript debugger detached" not in output
78
- assert Process .is_running ('NativeScript Inspector' )
70
+ if app_started :
71
+ assert "Page loaded 1 time" in output , "Page not reloaded, this is bug!"
72
+ else :
73
+ assert "Page loaded 1 time" not in output , "Page reloaded, this is bug!"
79
74
80
75
def test_001_debug_ios_simulator (self ):
81
76
"""
82
77
Default `tns debug ios` starts debugger (do not stop at the first code statement)
83
78
"""
84
79
log = Tns .debug_ios (attributes = {'--path' : self .app_name , '--emulator' : '' , '--inspector' : '' })
85
- self . __verify_debugger_start (log )
80
+ DebugiOSInspectorSimulatorTests . __verify_debugger_attach (log )
86
81
87
82
# Verify app starts and do not stop on first line of code
88
83
Device .screen_match (device_name = SIMULATOR_NAME ,
@@ -95,7 +90,9 @@ def test_002_debug_ios_simulator_debug_brk(self):
95
90
96
91
log = Tns .debug_ios (
97
92
attributes = {'--path' : self .app_name , '--emulator' : '' , '--debug-brk' : '' , '--inspector' : '' })
98
- self .__verify_debugger_start (log )
93
+ DebugiOSInspectorSimulatorTests .__verify_debugger_attach (log , app_started = False )
94
+ # In this case `app_started` is False because app is not loaded when using '--debug-brk'.
95
+ # '--debug-brk' stops before app loaded.
99
96
100
97
# Verify app starts and do not stop on first line of code
101
98
Device .screen_match (device_name = SIMULATOR_NAME , tolerance = 3.0 , device_id = self .SIMULATOR_ID ,
@@ -107,22 +104,23 @@ def test_003_debug_ios_simulator_start(self):
107
104
"""
108
105
109
106
# Run the app and ensure it works
110
- log = Tns .run_ios (attributes = {'--path' : self .app_name , '--emulator' : '' , '--justlaunch' : '' , '--inspector' : '' },
107
+ log = Tns .run_ios (attributes = {'--path' : self .app_name , '--emulator' : '' , '--justlaunch' : '' },
111
108
assert_success = False , timeout = 30 )
112
109
TnsAsserts .prepared (app_name = self .app_name , platform = Platform .IOS , output = log , prepare = Prepare .SKIP )
113
110
Device .screen_match (device_name = SIMULATOR_NAME , device_id = self .SIMULATOR_ID ,
114
111
expected_image = 'livesync-hello-world_home' )
115
112
116
113
# Attach debugger
117
114
log = Tns .debug_ios (attributes = {'--path' : self .app_name , '--emulator' : '' , '--start' : '' , '--inspector' : '' })
118
- self .__verify_debugger_attach (log = log )
115
+ DebugiOSInspectorSimulatorTests .__verify_debugger_attach (log , app_started = False )
116
+ # In this case `app_started` is False because we are attaching to running app and we should not restart it.
119
117
120
118
def test_100_debug_ios_simulator_with_livesync (self ):
121
119
"""
122
120
`tns debug ios` should be able to run with livesync
123
121
"""
124
122
log = Tns .debug_ios (attributes = {'--path' : self .app_name , '--emulator' : '' , '--inspector' : '' })
125
- self . __verify_debugger_start (log )
123
+ DebugiOSInspectorSimulatorTests . __verify_debugger_attach (log )
126
124
127
125
# Verify app starts and do not stop on first line of code
128
126
Device .screen_match (device_name = SIMULATOR_NAME ,
0 commit comments