Skip to content

Commit e87bc14

Browse files
committed
Fixed code review issues
1 parent 1332390 commit e87bc14

File tree

6 files changed

+14
-32
lines changed

6 files changed

+14
-32
lines changed

src/main/java/aquality/appium/mobile/application/Application.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,20 @@ public class Application implements IApplication {
1414

1515
private final ILocalizedLogger localizedLogger;
1616
private final IApplicationProfile applicationProfile;
17-
private final ITimeoutConfiguration timeouts;
1817
private Duration timeoutImpl;
1918
private final AppiumDriver appiumDriver;
2019
private final DriverService driverService;
2120

2221
public Application(AppiumDriver appiumDriver) {
23-
this.appiumDriver = appiumDriver;
24-
this.driverService = null;
25-
localizedLogger = AqualityServices.getLocalizedLogger();
26-
applicationProfile = AqualityServices.getApplicationProfile();
27-
this.timeouts = AqualityServices.get(ITimeoutConfiguration.class);
28-
this.timeoutImpl = timeouts.getImplicit();
29-
setImplicitlyWaitToDriver(timeoutImpl.getSeconds());
22+
this(null, appiumDriver);
3023
}
3124

3225
public Application(DriverService driverService, AppiumDriver appiumDriver) {
3326
this.appiumDriver = appiumDriver;
3427
this.driverService = driverService;
3528
localizedLogger = AqualityServices.getLocalizedLogger();
3629
applicationProfile = AqualityServices.getApplicationProfile();
37-
this.timeouts = AqualityServices.get(ITimeoutConfiguration.class);
30+
ITimeoutConfiguration timeouts = AqualityServices.get(ITimeoutConfiguration.class);
3831
this.timeoutImpl = timeouts.getImplicit();
3932
setImplicitlyWaitToDriver(timeoutImpl.getSeconds());
4033
}

src/main/java/aquality/appium/mobile/application/MobileModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public MobileModule(Provider<Application> applicationProvider) {
1717
@Override
1818
protected void configure() {
1919
super.configure();
20-
bind(IApplicationProfile.class).to(getBrowserProfileImplementation()).in(Singleton.class);
20+
bind(IApplicationProfile.class).to(getApplicationProfileImplementation()).in(Singleton.class);
2121
bind(IConfiguration.class).to(getConfigurationImplementation());
2222
bind(IElementFactory.class).to(getElementFactoryImplementation());
2323
}

src/main/java/aquality/appium/mobile/configuration/IConfigurationsModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public interface IConfigurationsModule extends aquality.selenium.core.configurat
88
/**
99
* @return class which implements {@link IApplicationProfile}
1010
*/
11-
default Class<? extends IApplicationProfile> getBrowserProfileImplementation() {
11+
default Class<? extends IApplicationProfile> getApplicationProfileImplementation() {
1212
return ApplicationProfile.class;
1313
}
1414

src/main/java/aquality/appium/mobile/configuration/driversettings/AndroidSettings.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,12 @@
55

66
public class AndroidSettings extends DriverSettings{
77

8-
private final ISettingsFile settingsFile;
9-
108
public AndroidSettings(ISettingsFile settingsFile){
11-
this.settingsFile = settingsFile;
9+
super(settingsFile);
1210
}
1311

1412
@Override
1513
public PlatformName getPlatformName() {
1614
return PlatformName.ANDROID;
1715
}
18-
19-
@Override
20-
protected ISettingsFile getSettingsFile() {
21-
return settingsFile;
22-
}
2316
}

src/main/java/aquality/appium/mobile/configuration/driversettings/DriverSettings.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ abstract class DriverSettings implements IDriverSettings {
1414

1515
private static final String appPathKey = "applicationPath";
1616
private static final String appCapabilityKey = "app";
17+
private final ISettingsFile settingsFile;
1718

18-
abstract ISettingsFile getSettingsFile();
19+
DriverSettings(ISettingsFile settingsFile) {
20+
this.settingsFile = settingsFile;
21+
}
1922

2023
@Override
2124
public Capabilities getCapabilities() {
@@ -29,7 +32,7 @@ public Capabilities getCapabilities() {
2932
}
3033

3134
private Map<String, Object> getCapabilitiesFromSettings(){
32-
return getSettingsFile().getMap(getDriverCapabilitiesJsonPath());
35+
return settingsFile.getMap(getDriverCapabilitiesJsonPath());
3336
}
3437

3538
private String getAbsolutePath(String relativePath) {
@@ -43,13 +46,13 @@ private String getAbsolutePath(String relativePath) {
4346
}
4447
}
4548

46-
protected boolean hasApplicationPath() {
47-
return getSettingsFile().getMap(getDriverSettingsPath()).containsKey(appPathKey);
49+
private boolean hasApplicationPath() {
50+
return settingsFile.getMap(getDriverSettingsPath()).containsKey(appPathKey);
4851
}
4952

5053
@Override
5154
public String getApplicationPath() {
52-
return String.valueOf(getSettingsFile().getValue(getDriverSettingsPath() + "/" + appPathKey));
55+
return String.valueOf(settingsFile.getValue(getDriverSettingsPath() + "/" + appPathKey));
5356
}
5457

5558
private String getDriverCapabilitiesJsonPath(){

src/main/java/aquality/appium/mobile/configuration/driversettings/IOSSettings.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,12 @@
55

66
public class IOSSettings extends DriverSettings{
77

8-
private final ISettingsFile settingsFile;
9-
108
public IOSSettings(ISettingsFile settingsFile){
11-
this.settingsFile = settingsFile;
9+
super(settingsFile);
1210
}
1311

1412
@Override
1513
public PlatformName getPlatformName() {
1614
return PlatformName.IOS;
1715
}
18-
19-
@Override
20-
protected ISettingsFile getSettingsFile() {
21-
return settingsFile;
22-
}
2316
}

0 commit comments

Comments
 (0)