mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-10 06:36:02 +00:00
ios: Speed up XCUITests by swizzling away Xcode crash check.
Change-Id: Iadda950544448d771960d35fd064f5287bce0484 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3410579 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Justin Cohen <justincohen@chromium.org>
This commit is contained in:
parent
496d522cc4
commit
30d302a8ca
@ -34,15 +34,8 @@
|
|||||||
@implementation CPTestTestCase
|
@implementation CPTestTestCase
|
||||||
|
|
||||||
+ (void)setUp {
|
+ (void)setUp {
|
||||||
// Swizzle away the handleCrashUnderSymbol callback. Without this, any time
|
[CPTestTestCase swizzleHandleCrashUnderSymbol];
|
||||||
// the host app is intentionally crashed, the test is immediately failed.
|
[CPTestTestCase swizleMayTerminateOutOfBandWithoutCrashReport];
|
||||||
SEL originalSelector = NSSelectorFromString(@"handleCrashUnderSymbol:");
|
|
||||||
SEL swizzledSelector = @selector(handleCrashUnderSymbol:);
|
|
||||||
Method originalMethod = class_getInstanceMethod(
|
|
||||||
objc_getClass("XCUIApplicationImpl"), originalSelector);
|
|
||||||
Method swizzledMethod =
|
|
||||||
class_getInstanceMethod([self class], swizzledSelector);
|
|
||||||
method_exchangeImplementations(originalMethod, swizzledMethod);
|
|
||||||
|
|
||||||
// Override EDO default error handler. Without this, the default EDO error
|
// Override EDO default error handler. Without this, the default EDO error
|
||||||
// handler will throw an error and fail the test.
|
// handler will throw an error and fail the test.
|
||||||
@ -51,12 +44,43 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Swizzle away the -[XCUIApplicationImpl handleCrashUnderSymbol:] callback.
|
||||||
|
// Without this, any time the host app is intentionally crashed, the test is
|
||||||
|
// immediately failed.
|
||||||
|
+ (void)swizzleHandleCrashUnderSymbol {
|
||||||
|
SEL originalSelector = NSSelectorFromString(@"handleCrashUnderSymbol:");
|
||||||
|
SEL swizzledSelector = @selector(handleCrashUnderSymbol:);
|
||||||
|
Method originalMethod = class_getInstanceMethod(
|
||||||
|
objc_getClass("XCUIApplicationImpl"), originalSelector);
|
||||||
|
Method swizzledMethod =
|
||||||
|
class_getInstanceMethod([self class], swizzledSelector);
|
||||||
|
method_exchangeImplementations(originalMethod, swizzledMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swizzle away the time consuming 'Checking for crash reports corresponding to'
|
||||||
|
// from -[XCUIApplicationProcess swizleMayTerminateOutOfBandWithoutCrashReport]
|
||||||
|
// that is unnecessary for these tests.
|
||||||
|
+ (void)swizleMayTerminateOutOfBandWithoutCrashReport {
|
||||||
|
SEL originalSelector =
|
||||||
|
NSSelectorFromString(@"mayTerminateOutOfBandWithoutCrashReport");
|
||||||
|
SEL swizzledSelector = @selector(mayTerminateOutOfBandWithoutCrashReport);
|
||||||
|
Method originalMethod = class_getInstanceMethod(
|
||||||
|
objc_getClass("XCUIApplicationProcess"), originalSelector);
|
||||||
|
Method swizzledMethod =
|
||||||
|
class_getInstanceMethod([self class], swizzledSelector);
|
||||||
|
method_exchangeImplementations(originalMethod, swizzledMethod);
|
||||||
|
}
|
||||||
|
|
||||||
// This gets called after tearDown, so there's no straightforward way to
|
// This gets called after tearDown, so there's no straightforward way to
|
||||||
// test that this is called. However, not swizzling this out will cause every
|
// test that this is called. However, not swizzling this out will cause every
|
||||||
// crashing test to fail.
|
// crashing test to fail.
|
||||||
- (void)handleCrashUnderSymbol:(id)arg1 {
|
- (void)handleCrashUnderSymbol:(id)arg1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)mayTerminateOutOfBandWithoutCrashReport {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setUp {
|
- (void)setUp {
|
||||||
app_ = [[XCUIApplication alloc] init];
|
app_ = [[XCUIApplication alloc] init];
|
||||||
[app_ launch];
|
[app_ launch];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user