Remove alert pop-up in test scenarios to prevent main thread stalls

This commit is contained in:
Michael Starke
2019-06-17 16:32:36 +02:00
parent 9e474375bf
commit 9f43d52917
4 changed files with 20 additions and 0 deletions

View File

@@ -55,6 +55,11 @@
value = "YES"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "MPIsRunningTests"
value = "YES"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>

View File

@@ -143,6 +143,11 @@ static MPAutotypeDaemon *_sharedInstance;
if(!self.enabled) {
return;
}
if(NSApplication.sharedApplication.isRunningTests) {
return; // Do not display pop-up when running tests
}
BOOL hideAlert = NO;
if(nil != [NSUserDefaults.standardUserDefaults objectForKey:kMPSettingsKeyAutotypeHideAccessibiltyWarning]) {
hideAlert = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyAutotypeHideAccessibiltyWarning];

View File

@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (copy, readonly) NSString *applicationName;
@property (copy, readonly, nullable) NSURL *applicationSupportDirectoryURL;
@property (nullable, readonly, weak) MPAppDelegate *mp_delegate;
@property (readonly, nonatomic) BOOL isRunningTests;
- (NSURL *_Nullable)applicationSupportDirectoryURL:(BOOL)create;
- (void)relaunchAfterDelay:(CGFloat)seconds;

View File

@@ -66,4 +66,13 @@
return (MPAppDelegate *)self.delegate;
}
- (BOOL)isRunningTests {
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSString *testEnv = processInfo.environment[@"MPIsRunningTests"];
if(testEnv) {
return [testEnv isEqualToString:@"YES"];
}
return NO;
}
@end