mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
iOS: “namespace” Objective-C test classes by prefixing with CPTest
Re: https://chromium-review.googlesource.com/c/2028183/4/test/ios/crash_type_xctest.mm#13 We previously discussed using the CP prefix for Objective-C class and protocol names, and CPTest for those restricted to tests. This is intended to parallel our C++ code’s use of the crashpad and crashpad::test namespaces, but with name prefixing because Objective-C doesn’t support any other form of namespacing. These class names are changed: ApplicationDelegate→CPTestApplicationDelegate CrashViewController→CPTestCrashViewController CrashpadUnitTestDelegate→CPTestUnitTestApplicationDelegate Filenames and #include guards are also adjusted to match. This also has include-what-you-use fixes and more modern pointer handling in CPTestSharedObject, which was already named correctly. Bug: crashpad:31 Change-Id: I3645ee830a30eccb594d679e0d52ba1a2dd1225d Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2144453 Commit-Queue: Mark Mentovai <mark@chromium.org> Reviewed-by: Justin Cohen <justincohen@chromium.org>
This commit is contained in:
parent
24b4105d00
commit
dc9176b063
@ -53,12 +53,13 @@ void RegisterTestEndListener() {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@interface CrashpadUnitTestDelegate : NSObject <CPTestGoogleTestRunnerDelegate>
|
@interface CPTestUnitTestApplicationDelegate
|
||||||
|
: NSObject <CPTestGoogleTestRunnerDelegate>
|
||||||
@property(nonatomic, readwrite, strong) UIWindow* window;
|
@property(nonatomic, readwrite, strong) UIWindow* window;
|
||||||
- (void)runTests;
|
- (void)runTests;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CrashpadUnitTestDelegate
|
@implementation CPTestUnitTestApplicationDelegate
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication*)application
|
- (BOOL)application:(UIApplication*)application
|
||||||
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
|
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
|
||||||
@ -123,8 +124,8 @@ namespace test {
|
|||||||
|
|
||||||
void IOSLaunchApplicationAndRunTests(int argc, char* argv[]) {
|
void IOSLaunchApplicationAndRunTests(int argc, char* argv[]) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
int exit_status =
|
int exit_status = UIApplicationMain(
|
||||||
UIApplicationMain(argc, argv, nil, @"CrashpadUnitTestDelegate");
|
argc, argv, nil, @"CPTestUnitTestApplicationDelegate");
|
||||||
exit(exit_status);
|
exit(exit_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@ source_set("app_shared_sources") {
|
|||||||
static_library("app_host_sources") {
|
static_library("app_host_sources") {
|
||||||
testonly = true
|
testonly = true
|
||||||
sources = [
|
sources = [
|
||||||
"application_delegate.h",
|
"cptest_application_delegate.h",
|
||||||
"application_delegate.mm",
|
"cptest_application_delegate.mm",
|
||||||
"crash_view_controller.h",
|
"cptest_crash_view_controller.h",
|
||||||
"crash_view_controller.mm",
|
"cptest_crash_view_controller.mm",
|
||||||
"main.mm",
|
"main.mm",
|
||||||
]
|
]
|
||||||
configs += [ "../../..:crashpad_config" ]
|
configs += [ "../../..:crashpad_config" ]
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef CRASHPAD_TEST_IOS_HOST_CRASH_VIEW_CONTROLLER_H_
|
#ifndef CRASHPAD_TEST_IOS_HOST_CPTEST_APPLICATION_DELEGATE_H_
|
||||||
#define CRASHPAD_TEST_IOS_HOST_CRASH_VIEW_CONTROLLER_H_
|
#define CRASHPAD_TEST_IOS_HOST_CPTEST_APPLICATION_DELEGATE_H_
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface CrashViewController : UIViewController
|
@interface CPTestApplicationDelegate : UIResponder <UIApplicationDelegate>
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // CRASHPAD_TEST_IOS_HOST_CRASH_VIEW_CONTROLLER_H_
|
#endif // CRASHPAD_TEST_IOS_HOST_CPTEST_APPLICATION_DELEGATE_H_
|
@ -12,23 +12,28 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#import "test/ios/host/application_delegate.h"
|
#import "test/ios/host/cptest_application_delegate.h"
|
||||||
|
|
||||||
#include <dispatch/dispatch.h>
|
#include <dispatch/dispatch.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#import "Service/Sources/EDOHostNamingService.h"
|
#import "Service/Sources/EDOHostNamingService.h"
|
||||||
#import "Service/Sources/EDOHostService.h"
|
#import "Service/Sources/EDOHostService.h"
|
||||||
#include "client/crashpad_client.h"
|
#include "client/crashpad_client.h"
|
||||||
|
#import "test/ios/host/cptest_crash_view_controller.h"
|
||||||
#import "test/ios/host/cptest_shared_object.h"
|
#import "test/ios/host/cptest_shared_object.h"
|
||||||
#import "test/ios/host/crash_view_controller.h"
|
|
||||||
|
|
||||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||||
#error "This file requires ARC support."
|
#error "This file requires ARC support."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@implementation ApplicationDelegate
|
@implementation CPTestApplicationDelegate
|
||||||
|
|
||||||
@synthesize window = _window;
|
@synthesize window = _window;
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication*)application
|
- (BOOL)application:(UIApplication*)application
|
||||||
@ -41,7 +46,8 @@
|
|||||||
[self.window makeKeyAndVisible];
|
[self.window makeKeyAndVisible];
|
||||||
self.window.backgroundColor = UIColor.greenColor;
|
self.window.backgroundColor = UIColor.greenColor;
|
||||||
|
|
||||||
CrashViewController* controller = [[CrashViewController alloc] init];
|
CPTestCrashViewController* controller =
|
||||||
|
[[CPTestCrashViewController alloc] init];
|
||||||
self.window.rootViewController = controller;
|
self.window.rootViewController = controller;
|
||||||
|
|
||||||
// Start up EDO.
|
// Start up EDO.
|
||||||
@ -54,12 +60,13 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CPTestSharedObject
|
@implementation CPTestSharedObject
|
||||||
|
|
||||||
- (NSString*)testEDO {
|
- (NSString*)testEDO {
|
||||||
return @"crashpad";
|
return @"crashpad";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)crashBadAccess {
|
- (void)crashBadAccess {
|
||||||
strcpy(0, "bla");
|
strcpy(nullptr, "bla");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)crashKillAbort {
|
- (void)crashKillAbort {
|
||||||
@ -67,8 +74,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)crashSegv {
|
- (void)crashSegv {
|
||||||
long zero = 0;
|
long* zero = nullptr;
|
||||||
*(long*)zero = 0xC045004d;
|
*zero = 0xc045004d;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)crashTrap {
|
- (void)crashTrap {
|
@ -12,12 +12,12 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#ifndef CRASHPAD_TEST_IOS_HOST_APPLICATION_DELEGATE_H_
|
#ifndef CRASHPAD_TEST_IOS_HOST_CPTEST_CRASH_VIEW_CONTROLLER_H_
|
||||||
#define CRASHPAD_TEST_IOS_HOST_APPLICATION_DELEGATE_H_
|
#define CRASHPAD_TEST_IOS_HOST_CPTEST_CRASH_VIEW_CONTROLLER_H_
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface ApplicationDelegate : UIResponder <UIApplicationDelegate>
|
@interface CPTestCrashViewController : UIViewController
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // CRASHPAD_TEST_IOS_HOST_APPLICATION_DELEGATE_H_
|
#endif // CRASHPAD_TEST_IOS_HOST_CPTEST_CRASH_VIEW_CONTROLLER_H_
|
@ -12,13 +12,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#import "test/ios/host/crash_view_controller.h"
|
#import "test/ios/host/cptest_crash_view_controller.h"
|
||||||
|
|
||||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||||
#error "This file requires ARC support."
|
#error "This file requires ARC support."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@implementation CrashViewController
|
@implementation CPTestCrashViewController
|
||||||
|
|
||||||
- (void)loadView {
|
- (void)loadView {
|
||||||
self.view = [[UIView alloc] init];
|
self.view = [[UIView alloc] init];
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import "test/ios/host/application_delegate.h"
|
#import "test/ios/host/cptest_application_delegate.h"
|
||||||
|
|
||||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||||
#error "This file requires ARC support."
|
#error "This file requires ARC support."
|
||||||
@ -24,7 +24,7 @@ int main(int argc, char* argv[]) {
|
|||||||
NSString* appDelegateClassName;
|
NSString* appDelegateClassName;
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
// Setup code that might create autoreleased objects goes here.
|
// Setup code that might create autoreleased objects goes here.
|
||||||
appDelegateClassName = NSStringFromClass([ApplicationDelegate class]);
|
appDelegateClassName = NSStringFromClass([CPTestApplicationDelegate class]);
|
||||||
}
|
}
|
||||||
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
|
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user