diff --git a/.gitignore b/.gitignore index 3cb5a81f11..c351a62d44 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ !bin/nativescript.js !vendor/*.js !resources/** +!lib/common/test/resources/**/* +lib/common/test/resources/.DS_Store *.js.map !.travis/**/* coverage @@ -80,4 +82,4 @@ lib/common/xunit.xml lib/common/test-reports.xml !lib/common/test-scripts/** !lib/common/scripts/** -config/test-deps-versions-generated.json \ No newline at end of file +config/test-deps-versions-generated.json diff --git a/Gruntfile.js b/Gruntfile.js index 69ee423df5..7c5ad3954f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -125,6 +125,7 @@ module.exports = function (grunt) { "!lib/common/bin/*.js", "!lib/common/test-scripts/**/*", "!lib/common/scripts/**/*", + "!lib/common/test/resources/**/*", "*.tgz"] }, template: { diff --git a/lib/common/.gitignore b/lib/common/.gitignore deleted file mode 100644 index 11b7500324..0000000000 --- a/lib/common/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -*.js -!vendor/*.js - -*.js.map -!vendor/*.js - -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz -*.tgz -*.tmp -*.sublime-workspace -tscommand*.tmp.txt -.tscache/ - -pids -logs -results -scratch/ -.idea/workspace.xml -.idea/tasks.xml -.idea/watcherTasks.xml - -npm-debug.log -node_modules -!Gruntfile.js -.d.ts -!bin/**/* -coverage/**/* -xunit.xml -test-reports.xml -!test-scripts/** -!scripts/** diff --git a/lib/common/mobile/android/logcat-helper.ts b/lib/common/mobile/android/logcat-helper.ts index 3d55cc23af..5cf23bd41e 100644 --- a/lib/common/mobile/android/logcat-helper.ts +++ b/lib/common/mobile/android/logcat-helper.ts @@ -49,9 +49,11 @@ export class LogcatHelper implements Mobile.ILogcatHelper { } }); - lineStream.on('data', (line: Buffer) => { - const lineText = line.toString(); - this.$deviceLogProvider.logData(lineText, this.$devicePlatformsConstants.Android, deviceIdentifier); + lineStream.on('data', (lineBuffer: Buffer) => { + const lines = (lineBuffer.toString() || '').split("\n"); + for (const line of lines) { + this.$deviceLogProvider.logData(line, this.$devicePlatformsConstants.Android, deviceIdentifier); + } }); } } diff --git a/lib/common/test/resources/appTestLogs.zip b/lib/common/test/resources/appTestLogs.zip new file mode 100644 index 0000000000..5d4131ff6f Binary files /dev/null and b/lib/common/test/resources/appTestLogs.zip differ diff --git a/lib/common/test/resources/device-log-provider-integration-tests/android/app/bundle.js b/lib/common/test/resources/device-log-provider-integration-tests/android/app/bundle.js new file mode 100644 index 0000000000..702684412d --- /dev/null +++ b/lib/common/test/resources/device-log-provider-integration-tests/android/app/bundle.js @@ -0,0 +1,328 @@ +require("./runtime.js");require("./vendor.js");module.exports = +(global["webpackJsonp"] = global["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "./ sync ^\\.\\/app\\.(css|scss|less|sass)$": +/***/ (function(module, exports, __webpack_require__) { + +var map = { + "./app.css": "./app.css" +}; + + +function webpackContext(req) { + var id = webpackContextResolve(req); + return __webpack_require__(id); +} +function webpackContextResolve(req) { + var id = map[req]; + if(!(id + 1)) { // check for number or string + var e = new Error("Cannot find module '" + req + "'"); + e.code = 'MODULE_NOT_FOUND'; + throw e; + } + return id; +} +webpackContext.keys = function webpackContextKeys() { + return Object.keys(map); +}; +webpackContext.resolve = webpackContextResolve; +module.exports = webpackContext; +webpackContext.id = "./ sync ^\\.\\/app\\.(css|scss|less|sass)$"; + +/***/ }), + +/***/ "./ sync recursive (?\n\n"; +if ( true && global._isModuleLoadedForUI && global._isModuleLoadedForUI("./app-root.xml") ) { + + module.hot.accept(); + module.hot.dispose(() => { + global.hmrRefresh({ type: "markup", path: "./app-root.xml" }); + }); +} +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./app.css": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {exports = module.exports = __webpack_require__("../node_modules/css-loader/dist/runtime/api.js")(false); +// Imports +exports.i(__webpack_require__("../node_modules/css-loader/dist/cjs.js?!../node_modules/nativescript-theme-core/css/core.light.css"), ""); + +// Module +exports.push([module.i, "/*\nIn NativeScript, the app.css file is where you place CSS rules that\nyou would like to apply to your entire application. Check out\nhttp://docs.nativescript.org/ui/styling for a full list of the CSS\nselectors and properties you can use to style UI components.\n\n/*\nIn many cases you may want to use the NativeScript core theme instead\nof writing your own CSS rules. For a full list of class names in the theme\nrefer to http://docs.nativescript.org/ui/theme. \nThe imported CSS rules must precede all other types of rules.\n*/\n\n/*\nThe following CSS rule changes the font size of all UI\ncomponents that have the btn class name.\n*/\n.btn {\n font-size: 18;\n}\n", ""]); + +; +if ( true && global._isModuleLoadedForUI && global._isModuleLoadedForUI("./app.css") ) { + + module.hot.accept(); + module.hot.dispose(() => { + global.hmrRefresh({ type: "style", path: "./app.css" }); + }); +} +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./app.js": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) { + let applicationCheckPlatform = __webpack_require__("../node_modules/tns-core-modules/application/application.js"); + if (applicationCheckPlatform.android && !global["__snapshot"]) { + __webpack_require__("../node_modules/tns-core-modules/ui/frame/frame.js"); +__webpack_require__("../node_modules/tns-core-modules/ui/frame/activity.js"); + } + + + __webpack_require__("../node_modules/nativescript-dev-webpack/load-application-css-regular.js")(); + + + if (true) { + const hmrUpdate = __webpack_require__("../node_modules/nativescript-dev-webpack/hmr/index.js").hmrUpdate; + global.__initialHmrUpdate = true; + global.__hmrSyncBackup = global.__onLiveSync; + + global.__onLiveSync = function () { + hmrUpdate(); + }; + + global.hmrRefresh = function({ type, path } = {}) { + if (global.__initialHmrUpdate) { + return; + } + + setTimeout(() => { + global.__hmrSyncBackup({ type, path }); + }); + }; + + hmrUpdate().then(() => { + global.__initialHmrUpdate = false; + }) + } + + const context = __webpack_require__("./ sync recursive (? { + console.log("HMR: Accept module '" + context.id + "' from '" + module.i + "'"); + }); + } + + __webpack_require__("../node_modules/tns-core-modules/bundle-entry-points.js"); + /* +In NativeScript, the app.js file is the entry point to your application. +You can use this file to perform app-level initialization, but the primary +purpose of the file is to pass control to the app’s first module. +*/ + +const application = __webpack_require__("../node_modules/tns-core-modules/application/application.js"); + +application.run({ moduleName: "app-root" }); + +/* +Do not place any code after the application has been started as it will not +be executed on iOS. +*/ +; +if ( true && global._isModuleLoadedForUI && global._isModuleLoadedForUI("./app.js") ) { + + module.hot.accept(); + module.hot.dispose(() => { + global.hmrRefresh({ type: "script", path: "./app.js" }); + }); +} + + + + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./main-page.js": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {/* +In NativeScript, a file with the same name as an XML file is known as +a code-behind file. The code-behind is a great place to place your view +logic, and to set up your page’s data binding. +*/ + +/* +NativeScript adheres to the CommonJS specification for dealing with +JavaScript modules. The CommonJS require() function is how you import +JavaScript modules defined in other files. +*/ +const createViewModel = __webpack_require__("./main-view-model.js").createViewModel; + +function onNavigatingTo(args) { + /* + This gets a reference this page’s UI component. You can + view the API reference of the Page to see what’s available at + https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html + */ + const page = args.object; + + /* + A page’s bindingContext is an object that should be used to perform + data binding between XML markup and JavaScript code. Properties + on the bindingContext can be accessed using the {{ }} syntax in XML. + In this example, the {{ message }} and {{ onTap }} bindings are resolved + against the object returned by createViewModel(). + + You can learn more about data binding in NativeScript at + https://docs.nativescript.org/core-concepts/data-binding. + */ + page.bindingContext = createViewModel(); +} + +/* +Exporting a function in a NativeScript code-behind file makes it accessible +to the file’s corresponding XML file. In this case, exporting the onNavigatingTo +function here makes the navigatingTo="onNavigatingTo" binding in this page’s XML +file work. +*/ +exports.onNavigatingTo = onNavigatingTo; +; +if ( true && global._isModuleLoadedForUI && global._isModuleLoadedForUI("./main-page.js") ) { + + module.hot.accept(); + module.hot.dispose(() => { + global.hmrRefresh({ type: "script", path: "./main-page.js" }); + }); +} +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./main-page.xml": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) { +module.exports = "\n\n \n \n \n \n \n \n \n