diff options
author | jackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-19 04:11:58 +0000 |
---|---|---|
committer | jackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-19 04:11:58 +0000 |
commit | c6e22aa32e9c4d23ebe874fc6cb3e28aedeeaaf4 (patch) | |
tree | 550b67f7f461a5008265fc7b8fc08cc08efe8dfe | |
parent | c30bda26c225a049e105db1c1164833032c0682f (diff) | |
download | chromium_src-c6e22aa32e9c4d23ebe874fc6cb3e28aedeeaaf4.zip chromium_src-c6e22aa32e9c4d23ebe874fc6cb3e28aedeeaaf4.tar.gz chromium_src-c6e22aa32e9c4d23ebe874fc6cb3e28aedeeaaf4.tar.bz2 |
[Mac] App shim error test.
Split out from http://crrev.com/265163006.
CQ has issues committing executables, so dcommitting this part.
TBR=tapted@chromium.org
BUG=353047
Review URL: https://codereview.chromium.org/345493004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278266 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | apps/app_shim/app_shim_interactive_uitest_mac.mm | 91 | ||||
-rw-r--r-- | chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Info.plist | 18 | ||||
-rw-r--r-- | chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Resources/DWARF/app_mode_loader | bin | 0 -> 865553 bytes | |||
-rw-r--r-- | chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Info.plist | 56 | ||||
-rwxr-xr-x | chrome/test/data/app_shim/app_shim_32_bit.app/Contents/MacOS/app_mode_loader | bin | 0 -> 49424 bytes | |||
-rw-r--r-- | chrome/test/data/app_shim/app_shim_32_bit.app/Contents/PkgInfo | 1 | ||||
-rw-r--r-- | chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/app.icns | bin | 0 -> 104634 bytes | |||
-rw-r--r-- | chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/en.lproj/InfoPlist.strings | 10 | ||||
-rwxr-xr-x | tools/checkperms/checkperms.py | 2 |
9 files changed, 178 insertions, 0 deletions
diff --git a/apps/app_shim/app_shim_interactive_uitest_mac.mm b/apps/app_shim/app_shim_interactive_uitest_mac.mm index 1cfdf79..a51cc9b 100644 --- a/apps/app_shim/app_shim_interactive_uitest_mac.mm +++ b/apps/app_shim/app_shim_interactive_uitest_mac.mm @@ -15,6 +15,7 @@ #include "base/files/file_path_watcher.h" #include "base/mac/foundation_util.h" #include "base/mac/launch_services_util.h" +#include "base/mac/mac_util.h" #include "base/mac/scoped_nsobject.h" #include "base/path_service.h" #include "base/process/launch.h" @@ -215,8 +216,10 @@ namespace apps { // Shims require static libraries http://crbug.com/386024. #if defined(COMPONENT_BUILD) #define MAYBE_Launch DISABLED_Launch +#define MAYBE_RebuildShim DISABLED_RebuildShim #else #define MAYBE_Launch Launch +#define MAYBE_RebuildShim RebuildShim #endif // Test that launching the shim for an app starts the app, and vice versa. @@ -304,4 +307,92 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_Launch) { } } +#if defined(ARCH_CPU_64_BITS) + +// Tests that a 32 bit shim attempting to launch 64 bit Chrome will eventually +// be rebuilt. +IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, MAYBE_RebuildShim) { + // Get the 32 bit shim. + base::FilePath test_data_dir; + PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); + base::FilePath shim_path_32 = + test_data_dir.Append("app_shim").Append("app_shim_32_bit.app"); + EXPECT_TRUE(base::PathExists(shim_path_32)); + + // Install test app. + const extensions::Extension* app = InstallPlatformApp("minimal"); + + // Use WebAppShortcutCreator to create a 64 bit shim. + web_app::WebAppShortcutCreator shortcut_creator( + web_app::GetWebAppDataDirectory(profile()->GetPath(), app->id(), GURL()), + web_app::ShortcutInfoForExtensionAndProfile(app, profile()), + extensions::FileHandlersInfo()); + shortcut_creator.UpdateShortcuts(); + base::FilePath shim_path = shortcut_creator.GetInternalShortcutPath(); + NSMutableDictionary* plist_64 = [NSMutableDictionary + dictionaryWithContentsOfFile:base::mac::FilePathToNSString( + shim_path.Append("Contents").Append("Info.plist"))]; + + // Copy 32 bit shim to where it's expected to be. + // CopyDirectory doesn't seem to work when copying and renaming in one go. + ASSERT_TRUE(base::DeleteFile(shim_path, true)); + ASSERT_TRUE(base::PathExists(shim_path.DirName())); + ASSERT_TRUE(base::CopyDirectory(shim_path_32, shim_path.DirName(), true)); + ASSERT_TRUE(base::Move(shim_path.DirName().Append(shim_path_32.BaseName()), + shim_path)); + ASSERT_TRUE(base::PathExists( + shim_path.Append("Contents").Append("MacOS").Append("app_mode_loader"))); + + // Fix up the plist so that it matches the installed test app. + NSString* plist_path = base::mac::FilePathToNSString( + shim_path.Append("Contents").Append("Info.plist")); + NSMutableDictionary* plist = + [NSMutableDictionary dictionaryWithContentsOfFile:plist_path]; + + NSArray* keys_to_copy = @[ + base::mac::CFToNSCast(kCFBundleIdentifierKey), + base::mac::CFToNSCast(kCFBundleNameKey), + app_mode::kCrAppModeShortcutIDKey, + app_mode::kCrAppModeUserDataDirKey, + app_mode::kBrowserBundleIDKey + ]; + for (NSString* key in keys_to_copy) { + [plist setObject:[plist_64 objectForKey:key] + forKey:key]; + } + [plist writeToFile:plist_path + atomically:YES]; + + base::mac::RemoveQuarantineAttribute(shim_path); + + // Launch the shim, it should start the app and ultimately connect over IPC. + // This actually happens in multiple launches of the shim: + // (1) The shim will fail and instead launch Chrome with --app-id so that the + // app starts. + // (2) Chrome launches the shim in response to an app starting, this time the + // shim launches Chrome with --app-shim-error, which causes Chrome to + // rebuild the shim. + // (3) After rebuilding, Chrome again launches the shim and expects it to + // behave normally. + ExtensionTestMessageListener launched_listener("Launched", false); + CommandLine shim_cmdline(CommandLine::NO_PROGRAM); + ASSERT_TRUE(base::mac::OpenApplicationWithPath( + shim_path, shim_cmdline, kLSLaunchDefaults, NULL)); + + // Wait for the app to start (1). At this point there is no shim host. + ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); + EXPECT_FALSE(HasAppShimHost(profile(), app->id())); + + // Wait for the rebuilt shim to connect (3). This does not race with the app + // starting (1) because Chrome only launches the shim (2) after the app + // starts. Then Chrome must handle --app-shim-error on the UI thread before + // the shim is rebuilt. + WindowedAppShimLaunchObserver(app->id()).Wait(); + + EXPECT_TRUE(GetFirstAppWindow()); + EXPECT_TRUE(HasAppShimHost(profile(), app->id())); +} + +#endif // defined(ARCH_CPU_64_BITS) + } // namespace apps diff --git a/chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Info.plist b/chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Info.plist new file mode 100644 index 0000000..69ea9fb --- /dev/null +++ b/chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Info.plist @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleIdentifier</key> + <string>com.apple.xcode.dsym.com.google.Chrome.app.@APP_MODE_SHORTCUT_ID@</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>dSYM</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1</string> + </dict> +</plist> diff --git a/chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Resources/DWARF/app_mode_loader b/chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Resources/DWARF/app_mode_loader Binary files differnew file mode 100644 index 0000000..92eb998c --- /dev/null +++ b/chrome/test/data/app_shim/app_shim_32_bit.app.dSYM/Contents/Resources/DWARF/app_mode_loader diff --git a/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Info.plist b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Info.plist new file mode 100644 index 0000000..4b91ff0 --- /dev/null +++ b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Info.plist @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>BuildMachineOSBuild</key> + <string>13D65</string> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>app_mode_loader</string> + <key>CFBundleIconFile</key> + <string>app.icns</string> + <key>CFBundleIdentifier</key> + <string>FILLED_IN_BY_TEST</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>FILLED_IN_BY_TEST</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>37.0.2043.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>2043.0</string> + <key>CrAppModeProfileDir</key> + <string>Default</string> + <key>CrAppModeProfileName</key> + <string>First user</string> + <key>CrAppModeShortcutID</key> + <string>FILLED_IN_BY_TEST</string> + <key>CrAppModeShortcutName</key> + <string>Platform App Test: minimal platform app</string> + <key>CrAppModeShortcutURL</key> + <string></string> + <key>CrAppModeUserDataDir</key> + <string>FILLED_IN_BY_TEST</string> + <key>CrBundleIdentifier</key> + <string>FILLED_IN_BY_TEST</string> + <key>DTSDKBuild</key> + <string>10M2518</string> + <key>DTSDKName</key> + <string>macosx10.6</string> + <key>DTXcode</key> + <string>0511</string> + <key>DTXcodeBuild</key> + <string>5B1008</string> + <key>LSHasLocalizedDisplayName</key> + <true/> + <key>LSMinimumSystemVersion</key> + <string>10.6.0</string> + <key>NSAppleScriptEnabled</key> + <true/> +</dict> +</plist> diff --git a/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/MacOS/app_mode_loader b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/MacOS/app_mode_loader Binary files differnew file mode 100755 index 0000000..e40c750 --- /dev/null +++ b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/MacOS/app_mode_loader diff --git a/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/PkgInfo b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/PkgInfo new file mode 100644 index 0000000..bd04210 --- /dev/null +++ b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/PkgInfo @@ -0,0 +1 @@ +APPL????
\ No newline at end of file diff --git a/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/app.icns b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/app.icns Binary files differnew file mode 100644 index 0000000..8a8b64b --- /dev/null +++ b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/app.icns diff --git a/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/en.lproj/InfoPlist.strings b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..a676415 --- /dev/null +++ b/chrome/test/data/app_shim/app_shim_32_bit.app/Contents/Resources/en.lproj/InfoPlist.strings @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDisplayName</key> + <string>Platform App Test: minimal platform app</string> + <key>CFBundleName</key> + <string>Platform App Test: minimal platform app</string> +</dict> +</plist> diff --git a/tools/checkperms/checkperms.py b/tools/checkperms/checkperms.py index ffb0804..c90f68d 100755 --- a/tools/checkperms/checkperms.py +++ b/tools/checkperms/checkperms.py @@ -50,6 +50,8 @@ EXECUTABLE_EXTENSIONS = ( # # Case-insensitive, lower-case only. EXECUTABLE_PATHS = ( + 'chrome/test/data/app_shim/app_shim_32_bit.app/contents/' + 'macos/app_mode_loader', 'chrome/test/data/extensions/uitest/plugins/plugin.plugin/contents/' 'macos/testnetscapeplugin', 'chrome/test/data/extensions/uitest/plugins_private/plugin.plugin/contents/' |