Skip to content

Commit 96befb6

Browse files
authored
Merge pull request #3861 from NativeScript/kddimitrov/livesync-tool-tests
Kddimitrov/livesync tool tests
2 parents b5e0aa0 + 2f79805 commit 96befb6

File tree

6 files changed

+644
-85
lines changed

6 files changed

+644
-85
lines changed

lib/bootstrap.ts

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ $injector.require("previewCommandHelper", "./helpers/preview-command-helper");
127127

128128
$injector.requirePublicClass("localBuildService", "./services/local-build-service");
129129
$injector.requirePublicClass("liveSyncService", "./services/livesync/livesync-service");
130+
$injector.require("LiveSyncSocket", "./services/livesync/livesync-socket");
130131
$injector.requirePublicClass("androidLivesyncTool", "./services/livesync/android-livesync-tool");
131132
$injector.require("androidLiveSyncService", "./services/livesync/android-livesync-service");
132133
$injector.require("iOSLiveSyncService", "./services/livesync/ios-livesync-service");

lib/definitions/livesync.d.ts

+24-6
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ interface IAndroidNativeScriptDeviceLiveSyncService extends INativeScriptDeviceL
419419
finalizeSync(liveSyncInfo: ILiveSyncResultInfo, projectData: IProjectData): Promise<IAndroidLivesyncSyncOperationResult>;
420420
}
421421

422+
interface ILiveSyncSocket extends INetSocket {
423+
uid: string,
424+
writeAsync(data: Buffer): Promise<Boolean>
425+
}
426+
422427
interface IAndroidLivesyncTool {
423428
/**
424429
* The protocol version the current app(adnroid runtime) is using.
@@ -454,21 +459,19 @@ interface IAndroidLivesyncTool {
454459
* @param filePath - The full path to the file.
455460
* @returns {Promise<boolean>}
456461
*/
457-
removeFile(filePath: string): Promise<boolean>;
462+
removeFile(filePath: string): Promise<void>;
458463
/**
459464
* Removes files
460465
* @param filePaths - Array of files that will be removed.
461466
* @returns {Promise<boolean[]>}
462467
*/
463-
removeFiles(filePaths: string[]): Promise<boolean[]>;
468+
removeFiles(filePaths: string[]): Promise<void[]>;
464469
/**
465470
* Sends doSyncOperation that will be handled by the runtime.
466-
* @param doRefresh - Indicates if the application should be restarted. Defaults to true.
467-
* @param operationId - The identifier of the operation
468-
* @param timeout - The timeout in milliseconds
471+
* @param options
469472
* @returns {Promise<void>}
470473
*/
471-
sendDoSyncOperation(doRefresh: boolean, timeout?: number, operationId?: string): Promise<IAndroidLivesyncSyncOperationResult>;
474+
sendDoSyncOperation(options?: IDoSyncOperationOptions): Promise<IAndroidLivesyncSyncOperationResult>;
472475
/**
473476
* Generates new operation identifier.
474477
*/
@@ -491,6 +494,17 @@ interface IAndroidLivesyncTool {
491494
hasConnection(): boolean;
492495
}
493496

497+
/**
498+
* doRefresh - Indicates if the application should be refreshed. Defaults to true.
499+
* operationId - The identifier of the operation
500+
* timeout - The timeout in milliseconds
501+
*/
502+
interface IDoSyncOperationOptions {
503+
doRefresh?: boolean,
504+
timeout?: number,
505+
operationId?: string
506+
}
507+
494508
interface IAndroidLivesyncToolConfiguration {
495509
/**
496510
* The application identifier.
@@ -512,6 +526,10 @@ interface IAndroidLivesyncToolConfiguration {
512526
* If provider will call it when an error occurs.
513527
*/
514528
errorHandler?: any;
529+
/**
530+
* Time to wait for successful connection. Defaults to 30000 miliseconds.
531+
*/
532+
connectTimeout?: number;
515533
}
516534

517535
interface IAndroidLivesyncSyncOperationResult {

lib/services/livesync/android-device-livesync-sockets-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class AndroidDeviceSocketsLiveSyncService extends AndroidDeviceLiveSyncSe
5858

5959
if (liveSyncInfo.modifiedFilesData.length) {
6060
const canExecuteFastSync = !liveSyncInfo.isFullSync && this.canExecuteFastSyncForPaths(liveSyncInfo, liveSyncInfo.modifiedFilesData, projectData, this.device.deviceInfo.platform);
61-
const doSyncPromise = this.livesyncTool.sendDoSyncOperation(canExecuteFastSync, null, operationId);
61+
const doSyncPromise = this.livesyncTool.sendDoSyncOperation({ doRefresh: canExecuteFastSync, operationId});
6262

6363
const syncInterval: NodeJS.Timer = setInterval(() => {
6464
if (this.livesyncTool.isOperationInProgress(operationId)) {

0 commit comments

Comments
 (0)