Chromium Code Reviews| Index: apps/app_shim/app_shim_interactive_uitest_mac.mm |
| diff --git a/apps/app_shim/app_shim_interactive_uitest_mac.mm b/apps/app_shim/app_shim_interactive_uitest_mac.mm |
| index 1c4cc114ae83c5737464c4d9bd2d2eee8a32ff76..0c01434af38e9d5c50d41b5e8c0b2335122ce25e 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" |
| @@ -297,4 +298,80 @@ IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, Launch) { |
| } |
| } |
| +// Tests that a 32 bit shim attempting to launch 64 bit Chrome will eventually |
| +// be rebuilt. |
| +IN_PROC_BROWSER_TEST_F(AppShimInteractiveTest, 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 = |
|
tapted
2014/06/11 03:32:43
Should this actually try to pick a shim that is th
jackhou1
2014/06/13 09:47:48
Oh yeah, I forgot to ifdef this out. I don't think
|
| + test_data_dir.Append("app_shim").Append("app_shim_32_bit"); |
| + 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 |
| + ]; |
| + 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. The first time the |
| + // shim will fail and instead launch Chrome with --app-id so that the app |
| + // starts. The second time is when 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. Finally, after rebuilding, Chrome |
| + // again launches the shim and expects it to behave normally. |
| + ExtensionTestMessageListener launched_listener("Launched", false); |
| + WindowedAppShimLaunchObserver observer(app->id()); |
| + |
| + CommandLine shim_cmdline(CommandLine::NO_PROGRAM); |
| + ASSERT_TRUE(base::mac::OpenApplicationWithPath( |
| + shim_path, shim_cmdline, kLSLaunchDefaults, NULL)); |
| + |
| + ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| + observer.Wait(); |
| + |
| + EXPECT_TRUE(GetFirstAppWindow()); |
| + EXPECT_TRUE(HasAppShimHost(profile(), app->id())); |
|
tapted
2014/06/11 03:32:43
Is there a non-flaky way to do an EXPECT_FALSE ver
jackhou1
2014/06/13 09:47:49
It should be non-flaky to do those waits sequentia
|
| +} |
| + |
| } // namespace apps |