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

Unified Diff: testing/iossim/iossim.mm

Issue 10978027: Add support in iossim for simulating retina devices (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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 | « no previous file | no next file » | 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 2cef4f36badf8c500ca3c0c5b9c6c86736832ba7..c85861c5eaeb888ce2080e87c508a52326aaa0e8 100644
--- a/testing/iossim/iossim.mm
+++ b/testing/iossim/iossim.mm
@@ -451,6 +451,7 @@ BOOL CreateHomeDirSubDirs(NSString* userHomePath) {
NSArray* subDirsToCreate = [NSArray arrayWithObjects:
@"Documents",
@"Library/Caches",
+ @"Library/Preferences",
nil];
for (NSString* subDir in subDirsToCreate) {
NSString* path = [userHomePath stringByAppendingPathComponent:subDir];
@@ -472,10 +473,17 @@ 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) {
+BOOL InitializeSimulatorUserHome(NSString* userHomePath, NSString* deviceName) {
if (!CreateHomeDirSubDirs(userHomePath))
return NO;
+ NSMutableDictionary* plistDict =
TVL 2012/09/25 19:13:23 might be worth a comment here that the simulator h
lliabraa 2012/10/04 15:51:39 Done.
+ [NSMutableDictionary dictionaryWithObject:deviceName
+ forKey:@"SimulateDevice"];
+ NSString* plistPath = @"Library/Preferences/com.apple.iphonesimulator.plist";
+ [plistDict writeToFile:[userHomePath stringByAppendingPathComponent:plistPath]
+ atomically:YES];
+
// 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
@@ -497,8 +505,8 @@ void PrintUsage() {
" arguments to send the simulated app.\n"
"\n"
"Options:\n"
- " -d Specifies the device (either 'iPhone' or 'iPad')."
- " Defaults to 'iPhone'.\n"
+ " -d Specifies the device (must be one of the values from the iOS"
+ " Simulator's Hardware -> Device menu. Defaults to 'iPhone'.\n"
" -s Specifies the SDK version to use (e.g '4.3')."
" Will use system default if not specified.\n"
" -u Specifies a user home directory for the simulator."
@@ -527,6 +535,7 @@ int main(int argc, char* const argv[]) {
if (worker != NULL)
free(worker);
+
NSString* appPath = nil;
NSString* appName = nil;
NSString* sdkVersion = nil;
@@ -630,15 +639,15 @@ int main(int argc, char* const argv[]) {
NSString* outputDir = CreateTempDirectory(@"iossim-XXXXXX");
NSString* stdioPath = [outputDir stringByAppendingPathComponent:@"stdio.txt"];
- // Make sure the device name is legit.
+ // Determine the deviceFamily based on the deviceName
NSNumber* deviceFamily = nil;
- if (!deviceName ||
- [@"iPhone" caseInsensitiveCompare:deviceName] == NSOrderedSame) {
+ if (!deviceName || [deviceName hasPrefix:@"iPhone"]) {
deviceFamily = [NSNumber numberWithInt:kIPhoneFamily];
- } else if ([@"iPad" caseInsensitiveCompare:deviceName] == NSOrderedSame) {
+ } else if ([deviceName hasPrefix:@"iPad"]) {
deviceFamily = [NSNumber numberWithInt:kIPadFamily];
} else {
- LogError(@"Invalid device name: %@", deviceName);
+ LogError(@"Invalid device name: %@. Must begin with 'iPhone' or 'iPad'",
+ deviceName);
exit(EXIT_FAILURE);
}
@@ -653,7 +662,7 @@ int main(int argc, char* const argv[]) {
exit(EXIT_FAILURE);
}
}
- if (!InitializeSimulatorUserHome(simHomePath)) {
+ if (!InitializeSimulatorUserHome(simHomePath, deviceName)) {
LogError(@"Unable to initialize home directory for simulator: %@",
simHomePath);
exit(EXIT_FAILURE);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698