Skip to content

Commit 04868e2

Browse files
committed
refactor: renamed the debug services in order to follow the livesync ones
1 parent 76d402e commit 04868e2

12 files changed

+39
-39
lines changed

lib/bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ $injector.require("preparePlatformNativeService", "./services/prepare-platform-n
2929

3030
$injector.require("debugDataService", "./services/debug-data-service");
3131
$injector.requirePublicClass("debugService", "./services/debug-service");
32-
$injector.require("iOSDebugService", "./services/ios-debug-service");
33-
$injector.require("androidDebugService", "./services/android-debug-service");
32+
$injector.require("iOSDeviceDebugService", "./services/ios-device-debug-service");
33+
$injector.require("androidDeviceDebugService", "./services/android-device-debug-service");
3434

3535
$injector.require("userSettingsService", "./services/user-settings-service");
3636
$injector.requirePublic("analyticsSettingsService", "./services/analytics-settings-service");

lib/definitions/debug.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ interface IDebugService extends IDebugServiceBase {
140140
/**
141141
* Describes actions required for debugging on specific platform (Android or iOS).
142142
*/
143-
interface IPlatformDebugService extends IPlatform, NodeJS.EventEmitter {
143+
interface IDeviceDebugService extends IPlatform, NodeJS.EventEmitter {
144144
/**
145145
* Starts debug operation.
146146
* @param {IAppDebugData} debugData Describes information for application that will be debugged.

lib/services/android-debug-service.ts renamed to lib/services/android-device-debug-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { sleep } from "../common/helpers";
22
import { DebugServiceBase } from "./debug-service-base";
33
import { LiveSyncPaths } from "../common/constants";
44

5-
export class AndroidDebugService extends DebugServiceBase implements IPlatformDebugService {
5+
export class AndroidDeviceDebugService extends DebugServiceBase implements IDeviceDebugService {
66
private _packageName: string;
77
private deviceIdentifier: string;
88

@@ -204,4 +204,4 @@ export class AndroidDebugService extends DebugServiceBase implements IPlatformDe
204204
}
205205
}
206206

207-
$injector.register("androidDebugService", AndroidDebugService, false);
207+
$injector.register("androidDeviceDebugService", AndroidDeviceDebugService, false);

lib/services/debug-service-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter } from "events";
22

3-
export abstract class DebugServiceBase extends EventEmitter implements IPlatformDebugService {
3+
export abstract class DebugServiceBase extends EventEmitter implements IDeviceDebugService {
44
constructor(
55
protected device: Mobile.IDevice,
66
protected $devicesService: Mobile.IDevicesService

lib/services/debug-service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CONNECTED_STATUS } from "../common/constants";
66
import { DebugTools, TrackActionNames } from "../constants";
77

88
export class DebugService extends EventEmitter implements IDebugService {
9-
private _platformDebugServices: IDictionary<IPlatformDebugService>;
9+
private _platformDebugServices: IDictionary<IDeviceDebugService>;
1010
constructor(private $devicesService: Mobile.IDevicesService,
1111
private $errors: IErrors,
1212
private $injector: IInjector,
@@ -51,7 +51,7 @@ export class DebugService extends EventEmitter implements IDebugService {
5151
this.$errors.failWithoutHelp(`Unsupported device OS: ${device.deviceInfo.platform}. You can debug your applications only on iOS or Android.`);
5252
}
5353

54-
// TODO: Consider to move this code to ios-debug-service
54+
// TODO: Consider to move this code to ios-device-debug-service
5555
if (this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
5656
if (device.isEmulator && !debugData.pathToAppPackage && debugOptions.debugBrk) {
5757
this.$errors.failWithoutHelp("To debug on iOS simulator you need to provide path to the app package.");
@@ -72,13 +72,13 @@ export class DebugService extends EventEmitter implements IDebugService {
7272
return debugService.debugStop();
7373
}
7474

75-
protected getDebugService(device: Mobile.IDevice): IPlatformDebugService {
75+
protected getDebugService(device: Mobile.IDevice): IDeviceDebugService {
7676
if (!this._platformDebugServices[device.deviceInfo.identifier]) {
7777
const platform = device.deviceInfo.platform;
7878
if (this.$mobileHelper.isiOSPlatform(platform)) {
79-
this._platformDebugServices[device.deviceInfo.identifier] = this.$injector.resolve("iOSDebugService", { device });
79+
this._platformDebugServices[device.deviceInfo.identifier] = this.$injector.resolve("iOSDeviceDebugService", { device });
8080
} else if (this.$mobileHelper.isAndroidPlatform(platform)) {
81-
this._platformDebugServices[device.deviceInfo.identifier] = this.$injector.resolve("androidDebugService", { device });
81+
this._platformDebugServices[device.deviceInfo.identifier] = this.$injector.resolve("androidDeviceDebugService", { device });
8282
} else {
8383
this.$errors.failWithoutHelp(DebugCommandErrors.UNSUPPORTED_DEVICE_OS_FOR_DEBUGGING);
8484
}
@@ -89,12 +89,12 @@ export class DebugService extends EventEmitter implements IDebugService {
8989
return this._platformDebugServices[device.deviceInfo.identifier];
9090
}
9191

92-
private getDebugServiceByIdentifier(deviceIdentifier: string): IPlatformDebugService {
92+
private getDebugServiceByIdentifier(deviceIdentifier: string): IDeviceDebugService {
9393
const device = this.$devicesService.getDeviceByIdentifier(deviceIdentifier);
9494
return this.getDebugService(device);
9595
}
9696

97-
private attachConnectionErrorHandlers(platformDebugService: IPlatformDebugService) {
97+
private attachConnectionErrorHandlers(platformDebugService: IDeviceDebugService) {
9898
let connectionErrorHandler = (e: Error) => this.emit(CONNECTION_ERROR_EVENT_NAME, e);
9999
connectionErrorHandler = connectionErrorHandler.bind(this);
100100
platformDebugService.on(CONNECTION_ERROR_EVENT_NAME, connectionErrorHandler);

lib/services/ios-debug-service.ts renamed to lib/services/ios-device-debug-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const inspectorAppName = "NativeScript Inspector.app";
99
const inspectorNpmPackageName = "tns-ios-inspector";
1010
const inspectorUiDir = "WebInspectorUI/";
1111

12-
export class IOSDebugService extends DebugServiceBase implements IPlatformDebugService {
12+
export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDebugService {
1313
private _lldbProcess: ChildProcess;
1414
private deviceIdentifier: string;
1515

@@ -195,4 +195,4 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
195195
}
196196
}
197197

198-
$injector.register("iOSDebugService", IOSDebugService, false);
198+
$injector.register("iOSDeviceDebugService", IOSDeviceDebugService, false);

lib/services/test-execution-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class TestExecutionService implements ITestExecutionService {
137137

138138
if (this.$options.debugBrk) {
139139
this.$logger.info('Starting debugger...');
140-
const debugService: IPlatformDebugService = this.$injector.resolve(`${platform}DebugService`);
140+
const debugService: IDeviceDebugService = this.$injector.resolve(`${platform}DebugService`);
141141
const debugData = this.getDebugData(platform, projectData, deployOptions);
142142
await debugService.debugStart(debugData, this.$options);
143143
}
@@ -172,7 +172,7 @@ class TestExecutionService implements ITestExecutionService {
172172

173173
const karmaConfig = this.getKarmaConfiguration(platform, projectData),
174174
// In case you want to debug the unit test runner, add "--inspect-brk=<port>" as a first element in the array of args.
175-
karmaRunner = this.$childProcess.spawn(process.execPath, [ path.join(__dirname, "karma-execution.js")], { stdio: ["inherit", "inherit", "inherit", "ipc"] }),
175+
karmaRunner = this.$childProcess.spawn(process.execPath, [path.join(__dirname, "karma-execution.js")], { stdio: ["inherit", "inherit", "inherit", "ipc"] }),
176176
launchKarmaTests = async (karmaData: any) => {
177177
this.$logger.trace("## Unit-testing: Parent process received message", karmaData);
178178
let port: string;

test/services/android-debug-service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { AndroidDebugService } from "../../lib/services/android-debug-service";
1+
import { AndroidDeviceDebugService } from "../../lib/services/android-device-debug-service";
22
import { Yok } from "../../lib/common/yok";
33
import * as stubs from "../stubs";
44
import { assert } from "chai";
55

66
const expectedDevToolsCommitSha = "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
77

8-
class AndroidDebugServiceInheritor extends AndroidDebugService {
8+
class AndroidDeviceDebugServiceInheritor extends AndroidDeviceDebugService {
99
constructor(protected $devicesService: Mobile.IDevicesService,
1010
$errors: IErrors,
1111
$logger: ILogger,
@@ -43,7 +43,7 @@ interface IChromeUrlTestCase {
4343
scenarioName: string;
4444
}
4545

46-
describe("androidDebugService", () => {
46+
describe("androidDeviceDebugService", () => {
4747
describe("getChromeDebugUrl", () => {
4848
const expectedPort = 12345;
4949
const customDevToolsCommit = "customDevToolsCommit";
@@ -156,8 +156,8 @@ describe("androidDebugService", () => {
156156
for (const testCase of chromUrlTestCases) {
157157
it(`returns correct url when ${testCase.scenarioName}`, () => {
158158
const testInjector = createTestInjector();
159-
const androidDebugService = testInjector.resolve<AndroidDebugServiceInheritor>(AndroidDebugServiceInheritor);
160-
const actualChromeUrl = androidDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort);
159+
const androidDeviceDebugService = testInjector.resolve<AndroidDeviceDebugServiceInheritor>(AndroidDeviceDebugServiceInheritor);
160+
const actualChromeUrl = androidDeviceDebugService.getChromeDebugUrl(testCase.debugOptions, expectedPort);
161161
assert.equal(actualChromeUrl, testCase.expectedChromeUrl);
162162
});
163163
}

test/services/android-project-service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const getDefautlBuildConfig = (): IBuildConfig => {
5151
};
5252
};
5353

54-
describe("androidDebugService", () => {
54+
describe("androidDeviceDebugService", () => {
5555
let injector: IInjector;
5656
let androidProjectService: IPlatformProjectService;
5757
let sandbox: sinon.SinonSandbox = null;
@@ -86,7 +86,7 @@ describe("androidDebugService", () => {
8686
const buildConfig = getDefautlBuildConfig();
8787

8888
//act
89-
await androidProjectService.buildProject("local/local", projectData, buildConfig, );
89+
await androidProjectService.buildProject("local/local", projectData, buildConfig);
9090

9191
//assert
9292
assert.include(childProcess.lastCommandArgs, "assembleRelease");
@@ -98,7 +98,7 @@ describe("androidDebugService", () => {
9898
buildConfig.release = false;
9999

100100
//act
101-
await androidProjectService.buildProject("local/local", projectData, buildConfig, );
101+
await androidProjectService.buildProject("local/local", projectData, buildConfig);
102102

103103
//assert
104104
assert.include(childProcess.lastCommandArgs, "assembleDebug");
@@ -110,7 +110,7 @@ describe("androidDebugService", () => {
110110
buildConfig.androidBundle = true;
111111

112112
//act
113-
await androidProjectService.buildProject("local/local", projectData, buildConfig, );
113+
await androidProjectService.buildProject("local/local", projectData, buildConfig);
114114

115115
//assert
116116
assert.include(childProcess.lastCommandArgs, "bundleRelease");
@@ -123,7 +123,7 @@ describe("androidDebugService", () => {
123123
buildConfig.release = false;
124124

125125
//act
126-
await androidProjectService.buildProject("local/local", projectData, buildConfig, );
126+
await androidProjectService.buildProject("local/local", projectData, buildConfig);
127127

128128
//assert
129129
assert.include(childProcess.lastCommandArgs, "bundleDebug");

test/services/debug-service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ describe("debugService", () => {
7474
}
7575
});
7676

77-
testInjector.register("androidDebugService", PlatformDebugService);
77+
testInjector.register("androidDeviceDebugService", PlatformDebugService);
7878

79-
testInjector.register("iOSDebugService", PlatformDebugService);
79+
testInjector.register("iOSDeviceDebugService", PlatformDebugService);
8080

8181
testInjector.register("mobileHelper", {
8282
isAndroidPlatform: (platform: string) => {
@@ -167,7 +167,7 @@ describe("debugService", () => {
167167

168168
const testInjector = getTestInjectorForTestConfiguration(testData);
169169
const expectedErrorMessage = "Platform specific error";
170-
const platformDebugService = testInjector.resolve<IPlatformDebugService>(`${platform}DebugService`);
170+
const platformDebugService = testInjector.resolve<IDeviceDebugService>(`${platform}DebugService`);
171171
platformDebugService.debug = async (debugData: IDebugData, debugOptions: IDebugOptions): Promise<any> => {
172172
throw new Error(expectedErrorMessage);
173173
};
@@ -178,11 +178,11 @@ describe("debugService", () => {
178178
await assert.isRejected(debugService.debug(debugData, null), expectedErrorMessage);
179179
};
180180

181-
it("androidDebugService's debug method fails", async () => {
181+
it("androidDeviceDebugService's debug method fails", async () => {
182182
await assertIsRejectedWhenPlatformDebugServiceFails("android");
183183
});
184184

185-
it("iOSDebugService's debug method fails", async () => {
185+
it("iOSDeviceDebugService's debug method fails", async () => {
186186
await assertIsRejectedWhenPlatformDebugServiceFails("iOS");
187187
});
188188
});
@@ -204,7 +204,7 @@ describe("debugService", () => {
204204
await assert.isFulfilled(debugService.debug(debugData, null));
205205

206206
const expectedErrorData = { deviceIdentifier: "deviceId", message: "my message", code: 2048 };
207-
const platformDebugService = testInjector.resolve<IPlatformDebugService>(`${platform}DebugService`);
207+
const platformDebugService = testInjector.resolve<IDeviceDebugService>(`${platform}DebugService`);
208208
platformDebugService.emit(CONNECTION_ERROR_EVENT_NAME, expectedErrorData);
209209
assert.deepEqual(dataRaisedForConnectionError, expectedErrorData);
210210
});

0 commit comments

Comments
 (0)