Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit d5b8319

Browse files
Merge pull request #1077 from telerik/vladimirov/fix-ios-logs-deploy
fix(deviceLogs): iOS device logs are not shown when deployOnDevices is used
2 parents a79e933 + ffb26fb commit d5b8319

8 files changed

+5
-63
lines changed

definitions/mobile.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ declare module Mobile {
270270
startApplication(appData: IApplicationData): Promise<void>;
271271
stopApplication(appData: IApplicationData): Promise<void>;
272272
restartApplication(appData: IApplicationData): Promise<void>;
273-
canStartApplication(): boolean;
274273
checkForApplicationUpdates(): Promise<void>;
275274
isLiveSyncSupported(appIdentifier: string): Promise<boolean>;
276275
getApplicationInfo(applicationIdentifier: string): Promise<Mobile.IApplicationInfo>;

mobile/android/android-application-manager.ts

-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ export class AndroidApplicationManager extends ApplicationManagerBase {
9292
return Promise.resolve(null);
9393
}
9494

95-
public canStartApplication(): boolean {
96-
return true;
97-
}
98-
9995
public async isLiveSyncSupported(appIdentifier: string): Promise<boolean> {
10096
const liveSyncVersion = await this.adb.sendBroadcastToDevice(LiveSyncConstants.CHECK_LIVESYNC_INTENT_NAME, { "app-id": appIdentifier });
10197
return liveSyncVersion === LiveSyncConstants.VERSION_2 || liveSyncVersion === LiveSyncConstants.VERSION_3;

mobile/application-manager-base.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ export abstract class ApplicationManagerBase extends EventEmitter implements Mob
7070

7171
public async tryStartApplication(appData: Mobile.IApplicationData): Promise<void> {
7272
try {
73-
if (this.canStartApplication()) {
74-
await this.startApplication(appData);
75-
}
73+
await this.startApplication(appData);
7674
} catch (err) {
77-
this.$logger.trace(`Unable to start application ${appData.appId}. Error is: ${err.message}`);
75+
this.$logger.trace(`Unable to start application ${appData.appId} with name ${appData.projectName}. Error is: ${err.message}`);
7876
}
7977
}
8078

@@ -86,7 +84,6 @@ export abstract class ApplicationManagerBase extends EventEmitter implements Mob
8684
public abstract async stopApplication(appData: Mobile.IApplicationData): Promise<void>;
8785
public abstract async getInstalledApplications(): Promise<string[]>;
8886
public abstract async getApplicationInfo(applicationIdentifier: string): Promise<Mobile.IApplicationInfo>;
89-
public abstract canStartApplication(): boolean;
9087
public abstract async getDebuggableApps(): Promise<Mobile.IDeviceApplicationInformation[]>;
9188
public abstract async getDebuggableAppViews(appIdentifiers: string[]): Promise<IDictionary<Mobile.IDebugWebViewInfo[]>>;
9289

mobile/ios/device/ios-application-manager.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ export class IOSApplicationManager extends ApplicationManagerBase {
1111
private device: Mobile.IDevice,
1212
private $errors: IErrors,
1313
private $iOSNotificationService: IiOSNotificationService,
14-
private $hostInfo: IHostInfo,
15-
private $staticConfig: Config.IStaticConfig,
1614
private $iosDeviceOperations: IIOSDeviceOperations,
1715
private $options: ICommonOptions,
1816
private $deviceLogProvider: Mobile.IDeviceLogProvider) {
@@ -102,6 +100,7 @@ export class IOSApplicationManager extends ApplicationManagerBase {
102100

103101
public async restartApplication(appData: Mobile.IApplicationData): Promise<void> {
104102
try {
103+
this.$deviceLogProvider.setProjectNameForDevice(this.device.deviceInfo.identifier, appData.projectName);
105104
await this.stopApplication(appData);
106105
await this.runApplicationCore(appData);
107106
} catch (err) {
@@ -123,10 +122,6 @@ export class IOSApplicationManager extends ApplicationManagerBase {
123122
await this.device.openDeviceLogStream();
124123
}
125124

126-
public canStartApplication(): boolean {
127-
return this.$hostInfo.isDarwin || (this.$hostInfo.isWindows && this.$staticConfig.enableDeviceRunCommandOnWindows);
128-
}
129-
130125
public getDebuggableApps(): Promise<Mobile.IDeviceApplicationInformation[]> {
131126
// Implement when we can find debuggable applications for iOS.
132127
return Promise.resolve([]);

mobile/ios/simulator/ios-simulator-application-manager.ts

-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase {
5454
return this.iosSim.stopApplication(this.identifier, appData.appId, appData.projectName);
5555
}
5656

57-
public canStartApplication(): boolean {
58-
return true;
59-
}
60-
6157
public async getApplicationInfo(applicationIdentifier: string): Promise<Mobile.IApplicationInfo> {
6258
let result: Mobile.IApplicationInfo = null;
6359
const plistContent = await this.getParsedPlistContent(applicationIdentifier);

services/livesync-service-base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class LiveSyncServiceBase implements ILiveSyncServiceBase {
183183
shouldRefreshApplication = false;
184184
}
185185

186-
if (device.applicationManager.canStartApplication() && !shouldRefreshApplication) {
186+
if (!shouldRefreshApplication) {
187187
await device.applicationManager.startApplication({ appId: appIdentifier, projectName: "" });
188188
}
189189
wasInstalled = false;

test/unit-tests/mobile/application-manager-base.ts

+1-27
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ class ApplicationManager extends ApplicationManagerBase {
4040
return null;
4141
}
4242

43-
public canStartApplication(): boolean {
44-
return true;
45-
}
46-
4743
public async getDebuggableApps(): Promise<Mobile.IDeviceApplicationInformation[]> {
4844
return currentlyAvailableAppsForDebugging;
4945
}
@@ -640,10 +636,9 @@ describe("ApplicationManagerBase", () => {
640636
});
641637

642638
describe("tryStartApplication", () => {
643-
it("calls startApplication, when canStartApplication returns true", async () => {
639+
it("calls startApplication", async () => {
644640
let passedApplicationData: Mobile.IApplicationData = null;
645641

646-
applicationManager.canStartApplication = () => true;
647642
applicationManager.startApplication = (appData: Mobile.IApplicationData) => {
648643
passedApplicationData = appData;
649644
return Promise.resolve();
@@ -658,18 +653,6 @@ describe("ApplicationManagerBase", () => {
658653

659654
});
660655

661-
it("does not call startApplication, when canStartApplication returns false", async () => {
662-
let isStartApplicationCalled = false;
663-
applicationManager.canStartApplication = () => false;
664-
applicationManager.startApplication = (appData: Mobile.IApplicationData) => {
665-
isStartApplicationCalled = true;
666-
return Promise.resolve();
667-
};
668-
669-
await applicationManager.tryStartApplication(applicationData);
670-
assert.isFalse(isStartApplicationCalled, "startApplication must not be called when canStartApplication returns false.");
671-
});
672-
673656
describe("does not throw Error", () => {
674657
const error = new Error("Throw!");
675658
let isStartApplicationCalled = false;
@@ -696,16 +679,7 @@ describe("ApplicationManagerBase", () => {
696679
assert.isTrue(logger.traceOutput.indexOf("Unable to start application") !== -1, "'Unable to start application' must be shown in trace output.");
697680
};
698681

699-
it("when canStartApplication throws error", async () => {
700-
applicationManager.canStartApplication = (): boolean => {
701-
throw error;
702-
};
703-
applicationManager.isApplicationInstalled = (appId: string) => Promise.resolve(true);
704-
await assertDoesNotThrow();
705-
});
706-
707682
it("when startApplications throws", async () => {
708-
applicationManager.canStartApplication = () => true;
709683
applicationManager.isApplicationInstalled = (appId: string) => Promise.resolve(true);
710684
await assertDoesNotThrow({ shouldStartApplicatinThrow: true });
711685
});

test/unit-tests/mobile/devices-service.ts

-15
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ const iOSSimulator = {
7878
},
7979
applicationManager: {
8080
getInstalledApplications: () => Promise.resolve(["com.telerik.unitTest1", "com.telerik.unitTest2"]),
81-
canStartApplication: () => true,
8281
startApplication: (packageName: string, framework: string) => Promise.resolve(),
8382
tryStartApplication: (packageName: string, framework: string) => Promise.resolve(),
8483
reinstallApplication: (packageName: string, packageFile: string) => Promise.resolve(),
@@ -218,7 +217,6 @@ describe("devicesService", () => {
218217
},
219218
applicationManager: {
220219
getInstalledApplications: () => Promise.resolve(["com.telerik.unitTest1", "com.telerik.unitTest2"]),
221-
canStartApplication: () => true,
222220
startApplication: (appData: Mobile.IApplicationData) => Promise.resolve(),
223221
tryStartApplication: (appData: Mobile.IApplicationData) => Promise.resolve(),
224222
reinstallApplication: (packageName: string, packageFile: string) => Promise.resolve(),
@@ -238,7 +236,6 @@ describe("devicesService", () => {
238236
},
239237
applicationManager: {
240238
getInstalledApplications: () => Promise.resolve(["com.telerik.unitTest1", "com.telerik.unitTest2", "com.telerik.unitTest3"]),
241-
canStartApplication: () => true,
242239
startApplication: (appData: Mobile.IApplicationData) => Promise.resolve(),
243240
tryStartApplication: (appData: Mobile.IApplicationData) => Promise.resolve(),
244241
reinstallApplication: (packageName: string, packageFile: string) => Promise.resolve(),
@@ -935,18 +932,6 @@ describe("devicesService", () => {
935932
});
936933
});
937934

938-
it("does not call startApplication when canStartApplication returns false", async () => {
939-
iOSDevice.applicationManager.canStartApplication = () => false;
940-
iOSDevice.applicationManager.startApplication = (): Promise<void> => {
941-
throw new Error("Start application must not be called for iOSDevice when canStartApplication returns false.");
942-
};
943-
944-
const results = devicesService.deployOnDevices([androidDevice.deviceInfo.identifier, iOSDevice.deviceInfo.identifier], "path", "packageName", "cordova");
945-
assert.isTrue(results.length > 0);
946-
const deployOnDevicesResults = await Promise.all(results);
947-
assert.deepEqual(deployOnDevicesResults, [undefined, undefined]);
948-
});
949-
950935
it("throws error when invalid identifier is passed", async () => {
951936
const results = devicesService.deployOnDevices(["invalidDeviceId", iOSDevice.deviceInfo.identifier], "path", "packageName", "cordova");
952937
const expectedErrorMessage = getErrorMessage(testInjector, "NotFoundDeviceByIdentifierErrorMessageWithIdentifier", "invalidDeviceId");

0 commit comments

Comments
 (0)