Skip to content

Commit 0b98b79

Browse files
author
vhristov5555
committed
Merge remote-tracking branch 'origin/master'
2 parents 640e865 + 32d6ca9 commit 0b98b79

File tree

4 files changed

+239
-0
lines changed

4 files changed

+239
-0
lines changed

data/console-dir/main-page.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var vmModule = require("./main-view-model");
2+
3+
function pageLoaded(args) {
4+
var page = args.object;
5+
page.bindingContext = vmModule.mainViewModel;
6+
console.log("### TEST START ###");
7+
8+
var undef;
9+
var num = -1;
10+
var str = "text";
11+
var obj = { name: "John", age: 34 };
12+
13+
console.dir(true);
14+
console.dir(false);
15+
console.dir(null);
16+
console.dir(undef);
17+
18+
console.dir(num);
19+
console.dir(str);
20+
21+
console.dir(obj);
22+
23+
console.log("### TEST END ###");
24+
}
25+
exports.pageLoaded = pageLoaded;

data/console-log/main-page.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
var vmModule = require("./main-view-model");
2+
var buttonModule = require("tns-core-modules/ui/button");
3+
4+
function pageLoaded(args) {
5+
var page = args.object;
6+
page.bindingContext = vmModule.mainViewModel;
7+
console.log("### TEST START ###");
8+
console.time("Time");
9+
10+
var undef;
11+
var num = -1;
12+
var str = "text";
13+
var obj = { name: "John", age: 34 };
14+
var button = new buttonModule.Button();
15+
16+
console.log(true);
17+
console.log(false);
18+
console.log(null);
19+
console.log(undef);
20+
21+
console.log(num);
22+
console.log(str);
23+
console.log(obj);
24+
25+
console.log(`number: ${num}`);
26+
console.log(`string: ${str}`);
27+
console.log(`${str} ${num}`);
28+
29+
console.info("info");
30+
console.warn("warn");
31+
console.error("error");
32+
33+
console.assert(false, `false == true`);
34+
console.assert(true, "1 equals 1");
35+
36+
console.assert("", "empty string evaluates to 'false'");
37+
38+
console.trace("console.trace() called");
39+
40+
console.log(`${button}`);
41+
42+
console.log(num, str, obj);
43+
console.log([1, 5, 12.5, obj, str, 42]);
44+
45+
console.trace();
46+
47+
console.timeEnd("Time");
48+
console.log("### TEST END ###");
49+
}
50+
exports.pageLoaded = pageLoaded;

tests/emulator/run_android_tests.py

+75
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,81 @@ def test_100_tns_run_android_release(self):
183183
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
184184
expected_image='livesync-hello-world_js_css_xml')
185185

186+
def test_180_tns_run_android_console_logging(self):
187+
"""
188+
Test console info, warn, error, assert, trace, time and logging of different objects.
189+
"""
190+
191+
# Change main-page.js so it contains console logging
192+
source_js = os.path.join('data', 'console-log', 'main-page.js')
193+
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
194+
File.copy(src=source_js, dest=target_js)
195+
196+
log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
197+
assert_success=False)
198+
199+
strings = ['Project successfully built',
200+
'Successfully installed on device with identifier', EMULATOR_ID,
201+
'Successfully synced application',
202+
"true",
203+
"false",
204+
"null",
205+
"undefined",
206+
"-1",
207+
"text",
208+
"\"name\": \"John\",",
209+
"\"age\": 34",
210+
"number: -1",
211+
"string: text",
212+
"text -1",
213+
"info",
214+
"warn",
215+
"error",
216+
"Assertion failed: false == true",
217+
"Assertion failed: empty string evaluates to 'false'",
218+
"Trace: console.trace() called",
219+
"at pageLoaded",
220+
"Button(8)",
221+
"-1 text {",
222+
"[1, 5, 12.5, {", "\"name\": \"John\",",
223+
"\"age\": 34",
224+
"}, text, 42]",
225+
"Time:",
226+
"### TEST END ###"
227+
]
228+
229+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
230+
assert "1 equals 1" not in log
231+
232+
def test_181_tns_run_android_console_dir(self):
233+
"""
234+
Test console.dir() of different objects.
235+
"""
236+
237+
# Change main-page.js so it contains console logging
238+
source_js = os.path.join('data', 'console-dir', 'main-page.js')
239+
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
240+
File.copy(src=source_js, dest=target_js)
241+
242+
log = Tns.run_android(attributes={'--path': self.app_name, '--device': EMULATOR_ID}, wait=False,
243+
assert_success=False)
244+
strings = ['Project successfully built',
245+
'Successfully installed on device with identifier', EMULATOR_ID,
246+
'Successfully synced application',
247+
"true",
248+
"false",
249+
"null",
250+
"undefined",
251+
"-1",
252+
"text",
253+
"==== object dump start ====",
254+
"name: \"John\"",
255+
"age: \"34\"",
256+
"==== object dump end ===="
257+
]
258+
259+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10)
260+
186261
def test_200_tns_run_android_break_and_fix_app(self):
187262
"""
188263
Make changes in xml that break the app and then changes that fix the app.

tests/simulator/run_ios_tests.py

+89
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,95 @@ def test_001_tns_run_ios_js_css_xml(self):
110110
Device.screen_match(device_name=SIMULATOR_NAME,
111111
device_id=self.SIMULATOR_ID, expected_image='livesync-hello-world_home')
112112

113+
def test_180_tns_run_ios_console_log(self):
114+
"""
115+
Test console info, warn, error, assert, trace, time and logging of different objects.
116+
"""
117+
118+
# Change main-page.js so it contains console logging
119+
source_js = os.path.join('data', 'console-log', 'main-page.js')
120+
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
121+
File.copy(src=source_js, dest=target_js)
122+
123+
john_obj = "{\n" \
124+
"\"name\": \"John\",\n" \
125+
"\"age\": 34\n" \
126+
"}"
127+
128+
john_obj2 = "[\n" + "1,\n" \
129+
"5,\n" \
130+
"12.5,\n" \
131+
"{\n" \
132+
"\"name\": \"John\",\n" \
133+
"\"age\": 34\n" \
134+
"},\n" \
135+
"\"text\",\n" \
136+
"42\n" \
137+
"]"
138+
139+
log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': ''}, wait=False, assert_success=False)
140+
strings = ['Project successfully built',
141+
'Successfully installed on device with identifier', self.SIMULATOR_ID,
142+
"CONSOLE LOG",
143+
"true",
144+
"false",
145+
"null",
146+
"undefined",
147+
"-1",
148+
"text",
149+
john_obj,
150+
"number: -1",
151+
"string: text",
152+
"text -1",
153+
"CONSOLE INFO",
154+
"info",
155+
"CONSOLE WARN",
156+
"warn",
157+
"CONSOLE ERROR",
158+
"error",
159+
"false == true",
160+
"empty string evaluates to 'false'",
161+
"CONSOLE TRACE",
162+
"console.trace() called",
163+
"0: pageLoaded",
164+
"Button(8)",
165+
"-1 text {",
166+
john_obj2,
167+
"CONSOLE DEBUG Time:",
168+
"### TEST END ###"
169+
]
170+
171+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=150, check_interval=10)
172+
173+
def test_181_tns_run_ios_console_dir(self):
174+
"""
175+
Test console.dir() of different objects.
176+
"""
177+
178+
# Change main-page.js so it contains console logging
179+
source_js = os.path.join('data', 'console-dir', 'main-page.js')
180+
target_js = os.path.join(self.app_name, 'app', 'main-page.js')
181+
File.copy(src=source_js, dest=target_js)
182+
183+
john_obj = "==== object dump start ====\n" \
184+
"name: John\n" \
185+
"age: 34\n" \
186+
"==== object dump end ===="
187+
188+
log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': ''}, wait=False, assert_success=False)
189+
strings = ['Project successfully built',
190+
'Successfully installed on device with identifier', self.SIMULATOR_ID,
191+
"true",
192+
"false",
193+
"null",
194+
"undefined",
195+
"-1",
196+
"text",
197+
john_obj
198+
]
199+
200+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=150, check_interval=10)
201+
113202
def test_200_tns_run_ios_break_and_fix_app(self):
114203
"""
115204
Make changes in xml that break the app and then changes that fix the app.

0 commit comments

Comments
 (0)