Skip to content

Logcat printer #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/man_pages/project/testing/emulate-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ emulate android

Usage | Synopsis
---|---
Run in the native emulator | `$ tns emulate android [--avd <Name>] [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
Run in Genymotion | `$ tns emulate android --geny <GenyName> [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
Run in the default Android virtual device or in a currently running emulator | `$ tns emulate android [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
Run in the native emulator | `$ tns emulate android [--avd <Name>] [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
Run in Genymotion | `$ tns emulate android --geny <GenyName> [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
Run in the default Android virtual device or in a currently running emulator | `$ tns emulate android [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`

Builds the specified project and runs it in the native emulator from the Android SDK or Genymotion. <% if(isHtml) { %>If you do not select an Android virtual device (AVD) with the `--avd` option or a Genymotion virtual device with the `--geny` option, your app runs in the default AVD or a currently running emulator, if any. <% } %>

Expand All @@ -19,6 +19,7 @@ Builds the specified project and runs it in the native emulator from the Android
* `--keyStorePassword` - Provides the password for the keystore file specified with --keyStorePath. You can use the `--keyStore*` options along with --release to produce a signed release build. You need to specify all `--keyStore*` options.
* `--keyStoreAlias` - Provides the alias for the keystore file specified with `--keyStorePath`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
* `--keyStoreAliasPassword` - Provides the password for the alias specified with `--keStoreAliasPassword`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
* `--justlaunch` - If set, does not print application output on the console. Otherwise prints the application output on the console.

### Attributes
* `<Name>` is the name of the Android virtual device that you want to use as listed by `$ android list avd`
Expand Down
7 changes: 4 additions & 3 deletions docs/man_pages/project/testing/run-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ run android

Usage | Synopsis
---|---
Run on all connected devices and running emulators | `$ tns run android [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
Run on a selected connected device or running emulator | `$ tns run android --device <Device ID> [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
Start an emulator and run the app inside it | `$ tns run android --emulator [<Emulator Options>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
Run on all connected devices and running emulators | `$ tns run android [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
Run on a selected connected device or running emulator | `$ tns run android --device <Device ID> [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
Start an emulator and run the app inside it | `$ tns run android --emulator [<Emulator Options>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`

Runs your project on a connected Android device or in a native Android emulator, if configured. This is shorthand for prepare, build and deploy.

Expand All @@ -17,6 +17,7 @@ Runs your project on a connected Android device or in a native Android emulator,
* `--keyStorePassword` - Provides the password for the keystore file specified with `--keyStorePath`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
* `--keyStoreAlias` - Provides the alias for the keystore file specified with `--keyStorePath`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
* `--keyStoreAliasPassword` - Provides the password for the alias specified with `--keStoreAliasPassword`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
* `--justlaunch` - If set, does not print application output on the console. Otherwise prints the application output on the console.

### Attributes
* `<Device ID>` is the index or name of the target device as listed by `$ tns device android`
Expand Down
5 changes: 3 additions & 2 deletions docs/man_pages/project/testing/run-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ run ios

Usage | Synopsis
---|---
Run on all connected devices | `$ tns run ios [--release]`
Run on a selected connected device | `$ tns run ios [--device <Device ID>] [--release]`
Run on all connected devices | `$ tns run ios [--release] [--justlaunch]`
Run on a selected connected device | `$ tns run ios [--device <Device ID>] [--release] [--justlaunch]`
Start an emulator and run the app inside it | `$ tns run ios --emulator [<Emulator Options>] [--release]`

Runs your project on a connected iOS device or in the iOS Simulator, if configured. This is shorthand for prepare, build, and deploy.
Expand All @@ -17,6 +17,7 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur
* `--device` - Specifies a connected device on which to run the app.
* `--emulator` - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other valid combination of emulator options as listed by `$ tns help emulate ios`. You cannot use `--device` and `--emulator` simultaneously.
* `--release` - If set, produces a release build. Otherwise, produces a debug build.
* `--justlaunch` - If set, does not print application output on the console. Otherwise prints the application output on the console.

### Attributes
* `<Device ID>` is the index or name of the target device as listed by `$ tns device ios`
Expand Down
2 changes: 2 additions & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ $injector.require("optionsService", "./services/options-service");
$injector.require("dynamicHelpProvider", "./dynamic-help-provider");
$injector.require("mobilePlatformsCapabilities", "./mobile-platforms-capabilities");
$injector.require("commandsServiceProvider", "./providers/commands-service-provider");

$injector.require("logcatPrinter", "./providers/logcat-printer");
12 changes: 12 additions & 0 deletions lib/providers/logcat-printer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
///<reference path="../.d.ts"/>
"use strict";

export class LogcatPrinter implements Mobile.ILogcatPrinter {
constructor(private $logger: ILogger) { }

public print(line: string): void {
this.$logger.out(line);
}

}
$injector.register("logcatPrinter", LogcatPrinter);
6 changes: 3 additions & 3 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export class PlatformService implements IPlatformService {
private $platformsData: IPlatformsData,
private $projectData: IProjectData,
private $projectDataService: IProjectDataService,
private $prompter: IPrompter) { }
private $prompter: IPrompter,
private $commandsService: ICommandsService) { }

public addPlatforms(platforms: string[]): IFuture<void> {
return (() => {
Expand Down Expand Up @@ -190,7 +191,6 @@ export class PlatformService implements IPlatformService {
return (() => {
platform = platform.toLowerCase();

this.preparePlatform(platform).wait();
if (options.emulator) {
this.deployOnEmulator(platform).wait();
} else {
Expand Down Expand Up @@ -242,7 +242,7 @@ export class PlatformService implements IPlatformService {
this.$devicesServices.initialize({platform: platform, deviceId: options.device}).wait();
var action = (device: Mobile.IDevice): IFuture<void> => { return device.deploy(packageFile, this.$projectData.projectId); };
this.$devicesServices.execute(action).wait();

this.$commandsService.tryExecuteCommand("device", ["run", this.$projectData.projectId]).wait();
}).future<void>()();
}

Expand Down
4 changes: 3 additions & 1 deletion test/platform-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ function createTestInjector() {
testInjector.register("commandsServiceProvider", {
registerDynamicSubCommands: () => {}
});

testInjector.register("commandsService", {
tryExecuteCommand: () => {}
});

return testInjector;
}
Expand Down
3 changes: 3 additions & 0 deletions test/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function createTestInjector() {
testInjector.register('projectDataService', stubs.ProjectDataService);
testInjector.register('prompter', {});
testInjector.register('lockfile', stubs.LockFile);
testInjector.register("commandsService", {
tryExecuteCommand: () => {}
});

return testInjector;
}
Expand Down