Commit 434df0a3 authored by jackhou@chromium.org's avatar jackhou@chromium.org

[Mac] Add interactive App Shim test.

This test creates shims in the user data dir and actually starts them up and
expects them to connect to the IPC socket.

BUG=168080, 386024
NOTRY=true

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=276368

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=277743

Review URL: https://codereview.chromium.org/316493002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277955 0039d316-1c4b-4281-b951-d872f2087c98
parent b42a6050
This diff is collapsed.
...@@ -611,7 +611,11 @@ int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) { ...@@ -611,7 +611,11 @@ int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) {
main_message_loop.set_thread_name("MainThread"); main_message_loop.set_thread_name("MainThread");
base::PlatformThread::SetName("CrAppShimMain"); base::PlatformThread::SetName("CrAppShimMain");
if (pid == -1) { // In tests, launching Chrome does nothing, and we won't get a ping response,
// so just assume the socket exists.
if (pid == -1 &&
!CommandLine::ForCurrentProcess()->HasSwitch(
app_mode::kLaunchedForTest)) {
// Launch Chrome if it isn't already running. // Launch Chrome if it isn't already running.
ProcessSerialNumber psn; ProcessSerialNumber psn;
CommandLine command_line(CommandLine::NO_PROGRAM); CommandLine command_line(CommandLine::NO_PROGRAM);
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
<string>@APP_MODE_SHORTCUT_URL@</string> <string>@APP_MODE_SHORTCUT_URL@</string>
<key>CrBundleIdentifier</key> <key>CrBundleIdentifier</key>
<string>@APP_MODE_BROWSER_BUNDLE_ID@</string> <string>@APP_MODE_BROWSER_BUNDLE_ID@</string>
<key>LSFileQuarantineEnabled</key>
<true/>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}.0</string> <string>${MACOSX_DEPLOYMENT_TARGET}.0</string>
<key>NSAppleScriptEnabled</key> <key>NSAppleScriptEnabled</key>
......
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app.h"
#include "extensions/common/manifest_handlers/file_handler_info.h" #include "extensions/common/manifest_handlers/file_handler_info.h"
// Whether to enable update and launch of app shims in tests. (Normally shims
// are never created or launched in tests). Note that update only creates
// internal shim bundles, i.e. it does not create new shims in ~/Applications.
extern bool g_app_shims_allow_update_and_launch_in_tests;
namespace web_app { namespace web_app {
// Returns the full path of the .app shim that would be created by // Returns the full path of the .app shim that would be created by
......
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_family.h" #include "ui/gfx/image/image_family.h"
bool g_app_shims_allow_update_and_launch_in_tests = false;
namespace { namespace {
// Launch Services Key to run as an agent app, which doesn't launch in the dock. // Launch Services Key to run as an agent app, which doesn't launch in the dock.
...@@ -564,7 +566,11 @@ size_t WebAppShortcutCreator::CreateShortcutsIn( ...@@ -564,7 +566,11 @@ size_t WebAppShortcutCreator::CreateShortcutsIn(
return succeeded; return succeeded;
} }
// Remove the quarantine attribute from both the bundle and the executable.
base::mac::RemoveQuarantineAttribute(dst_path.Append(app_name)); base::mac::RemoveQuarantineAttribute(dst_path.Append(app_name));
base::mac::RemoveQuarantineAttribute(
dst_path.Append(app_name)
.Append("Contents").Append("MacOS").Append("app_mode_loader"));
++succeeded; ++succeeded;
} }
...@@ -863,8 +869,10 @@ base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { ...@@ -863,8 +869,10 @@ base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) {
} }
void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) { void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) {
if (AppShimsDisabledForTest()) if (AppShimsDisabledForTest() &&
!g_app_shims_allow_update_and_launch_in_tests) {
return; return;
}
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE, content::BrowserThread::FILE, FROM_HERE,
...@@ -976,8 +984,10 @@ void UpdatePlatformShortcuts( ...@@ -976,8 +984,10 @@ void UpdatePlatformShortcuts(
const ShortcutInfo& shortcut_info, const ShortcutInfo& shortcut_info,
const extensions::FileHandlersInfo& file_handlers_info) { const extensions::FileHandlersInfo& file_handlers_info) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
if (AppShimsDisabledForTest()) if (AppShimsDisabledForTest() &&
!g_app_shims_allow_update_and_launch_in_tests) {
return; return;
}
WebAppShortcutCreator shortcut_creator( WebAppShortcutCreator shortcut_creator(
app_data_path, shortcut_info, file_handlers_info); app_data_path, shortcut_info, file_handlers_info);
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
'HAS_OUT_OF_PROC_TEST_RUNNER', 'HAS_OUT_OF_PROC_TEST_RUNNER',
], ],
'sources': [ 'sources': [
'../apps/app_shim/app_shim_interactive_uitest_mac.mm',
'../apps/app_shim/app_shim_quit_interactive_uitest_mac.mm', '../apps/app_shim/app_shim_quit_interactive_uitest_mac.mm',
'../apps/app_window_interactive_uitest.cc', '../apps/app_window_interactive_uitest.cc',
'../ui/base/clipboard/clipboard_unittest.cc', '../ui/base/clipboard/clipboard_unittest.cc',
......
...@@ -37,6 +37,10 @@ extern const char kAppListModeId[]; ...@@ -37,6 +37,10 @@ extern const char kAppListModeId[];
// launch_now = false. This associates the shim without launching the app. // launch_now = false. This associates the shim without launching the app.
extern const char kLaunchedByChromeProcessId[]; extern const char kLaunchedByChromeProcessId[];
// Indicates to the shim that it was launched for a test, so don't attempt to
// launch Chrome.
extern const char kLaunchedForTest[];
// Path to an app shim bundle. Indicates to Chrome that this shim attempted to // Path to an app shim bundle. Indicates to Chrome that this shim attempted to
// launch but failed. // launch but failed.
extern const char kAppShimError[]; extern const char kAppShimError[];
......
...@@ -14,6 +14,7 @@ const char kAppShimSocketSymlinkName[] = "App Shim Socket"; ...@@ -14,6 +14,7 @@ const char kAppShimSocketSymlinkName[] = "App Shim Socket";
const char kAppListModeId[] = "app_list"; const char kAppListModeId[] = "app_list";
const char kLaunchedByChromeProcessId[] = "launched-by-chrome-process-id"; const char kLaunchedByChromeProcessId[] = "launched-by-chrome-process-id";
const char kLaunchedForTest[] = "launched-for-test";
const char kAppShimError[] = "app-shim-error"; const char kAppShimError[] = "app-shim-error";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment