Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: testing/iossim/iossim.mm

Issue 113403002: Move iossim to DVTiPhoneSimulatorRemoteClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Require 64bit too Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « testing/iossim/iossim.gyp ('k') | testing/iossim/redirect-stdout.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/iossim/iossim.mm
diff --git a/testing/iossim/iossim.mm b/testing/iossim/iossim.mm
index 152f2bea4c74d43143aa805ceafa16d4059a899a..6187973183aa4fa7443222af3724c0a807d5c981 100644
--- a/testing/iossim/iossim.mm
+++ b/testing/iossim/iossim.mm
@@ -28,6 +28,19 @@
@class DTiPhoneSimulatorSession;
@class DTiPhoneSimulatorSessionConfig;
@class DTiPhoneSimulatorSystemRoot;
+@class DVTiPhoneSimulatorMessenger;
+
+@interface DVTPlatform : NSObject
++ (BOOL)loadAllPlatformsReturningError:(id*)arg1;
+@end
+
+@protocol OS_dispatch_source
+@end
+@protocol OS_dispatch_queue
+@end
+@class DVTDispatchLock;
+@class DVTConfinementServiceConnection;
+@class DVTTask;
@protocol DTiPhoneSimulatorSessionDelegate
- (void)session:(DTiPhoneSimulatorSession*)session
@@ -37,7 +50,7 @@
withError:(NSError*)error;
@end
-#import "iPhoneSimulatorRemoteClient.h"
+#import "DVTiPhoneSimulatorRemoteClient.h"
// An undocumented system log key included in messages from launchd. The value
// is the PID of the process the message is about (as opposed to launchd's PID).
@@ -73,7 +86,9 @@ const NSTimeInterval kOutputPollIntervalSeconds = 0.1;
// The path within the developer dir of the private Simulator frameworks.
NSString* const kSimulatorFrameworkRelativePath =
@"Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/"
- @"iPhoneSimulatorRemoteClient.framework";
+ @"DVTiPhoneSimulatorRemoteClient.framework";
+NSString* const kDVTFoundationRelativePath =
+ @"../SharedFrameworks/DVTFoundation.framework";
NSString* const kDevToolsFoundationRelativePath =
@"../OtherFrameworks/DevToolsFoundation.framework";
NSString* const kSimulatorRelativePath =
@@ -300,9 +315,12 @@ void LogWarning(NSString* format, ...) {
aslmsg query = asl_new(ASL_TYPE_QUERY);
asl_set_query(query, ASL_KEY_SENDER, "launchd",
ASL_QUERY_OP_EQUAL | ASL_QUERY_OP_SUBSTRING);
- asl_set_query(query, ASL_KEY_REF_PID,
- [[[session simulatedApplicationPID] stringValue] UTF8String],
- ASL_QUERY_OP_EQUAL);
+ char session_id[20];
+ if (snprintf(session_id, 20, "%d", [session simulatedApplicationPID]) < 0) {
+ LogError(@"Failed to get [session simulatedApplicationPID]");
+ exit(kExitFailure);
+ }
+ asl_set_query(query, ASL_KEY_REF_PID, session_id, ASL_QUERY_OP_EQUAL);
asl_set_query(query, ASL_KEY_TIME, "-1m", ASL_QUERY_OP_GREATER_EQUAL);
// Log any messages found, and take note of any messages that may indicate
@@ -393,16 +411,43 @@ NSString* FindDeveloperDir() {
return output;
}
+// Helper to find a class by name and die if it isn't found.
+Class FindClassByName(NSString* nameOfClass) {
+ Class theClass = NSClassFromString(nameOfClass);
+ if (!theClass) {
+ LogError(@"Failed to find class %@ at runtime.", nameOfClass);
+ exit(kExitInitializationFailure);
+ }
+ return theClass;
+}
+
// Loads the Simulator framework from the given developer dir.
NSBundle* LoadSimulatorFramework(NSString* developerDir) {
// The Simulator framework depends on some of the other Xcode private
// frameworks; manually load them first so everything can be linked up.
+ NSString* dvtFoundationPath = [developerDir
+ stringByAppendingPathComponent:kDVTFoundationRelativePath];
+ NSBundle* dvtFoundationBundle =
+ [NSBundle bundleWithPath:dvtFoundationPath];
+ if (![dvtFoundationBundle load])
+ return nil;
+
NSString* devToolsFoundationPath = [developerDir
stringByAppendingPathComponent:kDevToolsFoundationRelativePath];
NSBundle* devToolsFoundationBundle =
[NSBundle bundleWithPath:devToolsFoundationPath];
if (![devToolsFoundationBundle load])
return nil;
+
+ // Prime DVTPlatform.
+ NSError* error;
+ Class DVTPlatformClass = FindClassByName(@"DVTPlatform");
+ if (![DVTPlatformClass loadAllPlatformsReturningError:&error]) {
+ LogError(@"Unable to loadAllPlatformsReturningError. Error: %@",
+ [error localizedDescription]);
+ return nil;
+ }
+
NSString* simBundlePath = [developerDir
stringByAppendingPathComponent:kSimulatorFrameworkRelativePath];
NSBundle* simBundle = [NSBundle bundleWithPath:simBundlePath];
@@ -411,16 +456,6 @@ NSBundle* LoadSimulatorFramework(NSString* developerDir) {
return simBundle;
}
-// Helper to find a class by name and die if it isn't found.
-Class FindClassByName(NSString* nameOfClass) {
- Class theClass = NSClassFromString(nameOfClass);
- if (!theClass) {
- LogError(@"Failed to find class %@ at runtime.", nameOfClass);
- exit(kExitInitializationFailure);
- }
- return theClass;
-}
-
// Converts the given app path to an application spec, which requires an
// absolute path.
DTiPhoneSimulatorApplicationSpecifier* BuildAppSpec(NSString* appPath) {
@@ -454,7 +489,8 @@ DTiPhoneSimulatorSessionConfig* BuildSessionConfig(
NSString* stderrPath,
NSArray* appArgs,
NSDictionary* appEnv,
- NSNumber* deviceFamily) {
+ NSNumber* deviceFamily,
+ NSString* deviceName) {
Class sessionConfigClass = FindClassByName(@"DTiPhoneSimulatorSessionConfig");
DTiPhoneSimulatorSessionConfig* sessionConfig =
[[[sessionConfigClass alloc] init] autorelease];
@@ -465,6 +501,7 @@ DTiPhoneSimulatorSessionConfig* BuildSessionConfig(
sessionConfig.simulatedApplicationStdOutPath = stdoutPath;
sessionConfig.simulatedApplicationLaunchArgs = appArgs;
sessionConfig.simulatedApplicationLaunchEnvironment = appEnv;
+ sessionConfig.simulatedDeviceInfoName = deviceName;
sessionConfig.simulatedDeviceFamily = deviceFamily;
return sessionConfig;
}
@@ -529,18 +566,10 @@ BOOL CreateHomeDirSubDirs(NSString* userHomePath) {
// path, then sets the path in the appropriate environment variable.
// Returns YES if successful, NO if unable to create or initialize the given
// directory.
-BOOL InitializeSimulatorUserHome(NSString* userHomePath, NSString* deviceName) {
+BOOL InitializeSimulatorUserHome(NSString* userHomePath) {
if (!CreateHomeDirSubDirs(userHomePath))
return NO;
- // Set the device to simulate. Note that the iOS Simulator must not be running
- // for this setting to take effect.
- CFStringRef iPhoneSimulatorAppID = CFSTR("com.apple.iphonesimulator");
- CFPreferencesSetAppValue(CFSTR("SimulateDevice"),
- deviceName,
- iPhoneSimulatorAppID);
- CFPreferencesAppSynchronize(iPhoneSimulatorAppID);
-
// Update the environment to use the specified directory as the user home
// directory.
// Note: the third param of setenv specifies whether or not to overwrite the
@@ -728,7 +757,7 @@ int main(int argc, char* const argv[]) {
exit(kExitInitializationFailure);
}
}
- if (!InitializeSimulatorUserHome(simHomePath, deviceName)) {
+ if (!InitializeSimulatorUserHome(simHomePath)) {
LogError(@"Unable to initialize home directory for simulator: %@",
simHomePath);
exit(kExitInitializationFailure);
@@ -741,7 +770,8 @@ int main(int argc, char* const argv[]) {
stdioPath,
appArgs,
appEnv,
- deviceFamily);
+ deviceFamily,
+ deviceName);
SimulatorDelegate* delegate =
[[[SimulatorDelegate alloc] initWithStdioPath:stdioPath
developerDir:developerDir
« no previous file with comments | « testing/iossim/iossim.gyp ('k') | testing/iossim/redirect-stdout.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698