Skip to content

Commit b7435bc

Browse files
author
vhristov5555
committed
Merge remote-tracking branch 'origin/master'
2 parents 6956a73 + f2ff107 commit b7435bc

File tree

5 files changed

+58
-24
lines changed

5 files changed

+58
-24
lines changed

data/issues/nativescript-cli-3650/main-page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ function pageLoaded(args) {
66
console.log("Page loaded " + ++count + " times.");
77

88
var objTC = new TestClass();
9-
objTC.sayHey();
9+
console.log(objTC.sayHey());
1010
}
1111
exports.pageLoaded = pageLoaded;

data/plugins/sample-plugin/src/platforms/ios/src/TestClass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
@interface TestClass : NSObject
44

5-
- (void)sayHey;
5+
- (NSString *)sayHey;
66

77
@end

data/plugins/sample-plugin/src/platforms/ios/src/TestClass.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
@implementation TestClass
44

5-
- (void)sayHey{
6-
NSLog(@"Hey!");
5+
- (NSString *)sayHey{
6+
return @"Hey!";
77
}
88

99
@end

tests/device/debug_device_tests.py

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
from core.tns.tns import Tns
99
from core.tns.tns_platform_type import Platform
1010
from core.osutils.command import run
11+
from time import sleep
12+
from enum import Enum
13+
from core.osutils.process import Process
14+
15+
class DebugMode(Enum):
16+
DEFAULT = 0
17+
START = 1
1118

1219
class DebugBothPlatformsTests(BaseClass):
1320
ANDROID_DEVICES = Device.get_ids(platform=Platform.ANDROID, include_emulators=True)
@@ -40,6 +47,47 @@ def tearDown(self):
4047
def tearDownClass(cls):
4148
BaseClass.tearDownClass()
4249

50+
@staticmethod
51+
def attach_chrome(log, mode=DebugMode.DEFAULT, port="41000"):
52+
"""
53+
Attach chrome dev tools and verify logs
54+
:type log: Log file of `tns debug ios` command.
55+
"""
56+
57+
# Check initial logs
58+
strings = ["Setting up debugger proxy...", "Press Ctrl + C to terminate, or disconnect.",
59+
"Opened localhost", "To start debugging, open the following URL in Chrome"]
60+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
61+
62+
# Attach Chrome DevTools
63+
url = run(command="grep chrome-devtools " + log)
64+
text_log = File.read(log)
65+
assert "chrome-devtools://devtools/remote" in text_log, "Debug url not printed in output of 'tns debug ios'."
66+
assert "localhost:" + port in text_log, "Wrong port of debug url:" + url
67+
Chrome.start(url)
68+
69+
# Verify debugger attached
70+
strings = ["Frontend client connected", "Backend socket created"]
71+
if mode != DebugMode.START:
72+
strings.extend(["Loading inspector modules",
73+
"Finished loading inspector modules",
74+
"NativeScript debugger attached"])
75+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
76+
77+
# Verify debugger not disconnected
78+
sleep(10)
79+
output = File.read(log)
80+
assert "socket closed" not in output, "Debugger disconnected."
81+
assert "detached" not in output, "Debugger disconnected."
82+
assert not Process.is_running('NativeScript Inspector'), "iOS Inspector running instead of ChromeDev Tools."
83+
84+
@staticmethod
85+
def assert_not_detached(log):
86+
output = File.read(log)
87+
assert "socket created" in output, "Debugger not attached at all.\n Log:\n" + output
88+
assert "socket closed" not in output, "Debugger disconnected.\n Log:\n" + output
89+
assert "detached" not in output, "Debugger disconnected.\n Log:\n" + output
90+
4391
def __verify_debugger_start(self, log):
4492
strings = ['NativeScript Debugger started', 'To start debugging, open the following URL in Chrome',
4593
'chrome-devtools', 'localhost:4000']
@@ -64,12 +112,6 @@ def test_001_tns_run_android(self):
64112
for android_device_id in self.ANDROID_DEVICES:
65113
strings.append(android_device_id)
66114
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
67-
68-
# Verify app is deployed and running on all available android devices
69-
for device_id in self.ANDROID_DEVICES:
70-
Device.wait_until_app_is_running(app_id=Tns.get_app_id(self.app_name), device_id=device_id, timeout=30)
71-
72-
log = Tns.debug_android(attributes={'--path': self.app_name})
73115
self.__verify_debugger_start(log)
74116

75117
# Get Chrome URL and open it
@@ -78,14 +120,7 @@ def test_001_tns_run_android(self):
78120

79121
def test_002_tns_run_ios(self):
80122
log = Tns.debug_ios(attributes={'--path': self.app_name})
81-
strings = ['Successfully installed on device with identifier']
82-
for ios_device_id in self.IOS_DEVICES:
83-
strings.append(ios_device_id)
84-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
85-
86-
log = Tns.debug_ios(attributes={'--path': self.app_name})
87-
self.__verify_debugger_start(log)
88-
89-
# Get Chrome URL and open it
90-
url = run(command="grep chrome-devtools " + log)
91-
Chrome.start(url)
123+
self.attach_chrome(log)
124+
strings = ['Successfully started on device with identifier']
125+
Tns.wait_for_log(log_file=log, string_list= strings, clean_log=False)
126+
self.assert_not_detached(log)

tests/simulator/run_ios_tests.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,15 @@ def test_300_tns_run_ios_just_launch_and_incremental_builds(self):
351351
device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_js_css_xml')
352352

353353
def test_315_tns_run_ios_change_appResources_check_per_platform(self):
354-
#https://github.com/NativeScript/nativescript-cli/pull/3619
354+
# https://github.com/NativeScript/nativescript-cli/pull/3619
355355
output = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': ''}, wait=False, assert_success=False)
356356
strings = ['Project successfully built', 'Successfully installed on device with identifier', self.SIMULATOR_ID]
357357
Tns.wait_for_log(log_file=output, string_list=strings, timeout=150, check_interval=10)
358358

359359
source = os.path.join('data', 'issues', 'nativescript-cli-3619', 'icon-1025.png')
360360
target = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS', 'Assets.xcassets', 'AppIcon.appiconset')
361361
File.copy(source, target)
362-
strings = ['Xcode build' ]
362+
strings = ['Xcode build']
363363
Tns.wait_for_log(log_file=output, string_list=strings, clean_log=False)
364364
assert "Gradle build" not in output
365365

@@ -532,7 +532,6 @@ def test_380_tns_run_ios_plugin_dependencies(self):
532532
Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID,
533533
expected_image='livesync-hello-world_home')
534534

535-
@unittest.skip("NSLog is not shown when run the test but is show when run the same test app locally")
536535
def test_385_tns_run_ios_source_code_in_ios_part_plugin(self):
537536
"""
538537
https://github.com/NativeScript/nativescript-cli/issues/3650

0 commit comments

Comments
 (0)