Commit aebfdc01 authored by Jeffrey Kardatzke's avatar Jeffrey Kardatzke Committed by Commit Bot

Add autotest API for launching an app from the launcher

BUG=chromium:849438
TEST=tast run vm.CrostiniStartEverything

Change-Id: I51963c9f4fe7b5aa9fd42e2c040410a974376f58
Reviewed-on: https://chromium-review.googlesource.com/1235199Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Cr-Commit-Position: refs/heads/master@{#592972}
parent 748a892c
......@@ -56,6 +56,7 @@
#include "net/base/filename_util.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/screen.h"
#include "ui/message_center/public/cpp/notification.h"
#endif
......@@ -715,6 +716,28 @@ ExtensionFunction::ResponseAction AutotestPrivateIsAppShownFunction::Run() {
#endif
}
AutotestPrivateLaunchAppFunction::~AutotestPrivateLaunchAppFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateLaunchAppFunction::Run() {
DVLOG(1) << "AutotestPrivateLaunchAppFunction";
#if defined(OS_CHROMEOS)
std::unique_ptr<api::autotest_private::LaunchApp::Params> params(
api::autotest_private::LaunchApp::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
ChromeLauncherController* const controller =
ChromeLauncherController::instance();
if (!controller)
return RespondNow(Error("Controller not available"));
controller->LaunchApp(ash::ShelfID(params->app_id),
ash::ShelfLaunchSource::LAUNCH_FROM_APP_LIST,
0, /* event_flags */
display::Screen::GetScreen()->GetPrimaryDisplay().id());
return RespondNow(NoArguments());
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
AutotestPrivateSetCrostiniEnabledFunction::
~AutotestPrivateSetCrostiniEnabledFunction() = default;
......
......@@ -251,6 +251,16 @@ class AutotestPrivateIsAppShownFunction : public UIThreadExtensionFunction {
ResponseAction Run() override;
};
class AutotestPrivateLaunchAppFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("autotestPrivate.launchApp",
AUTOTESTPRIVATE_LAUNCHAPP)
private:
~AutotestPrivateLaunchAppFunction() override;
ResponseAction Run() override;
};
class AutotestPrivateSetCrostiniEnabledFunction
: public UIThreadExtensionFunction {
public:
......
......@@ -171,6 +171,9 @@ namespace autotestPrivate {
// Returns true if requested app is shown in Chrome.
static void isAppShown(DOMString appId, IsAppShownCallback callback);
// Launches an application from the launcher with the given appId.
static void launchApp(DOMString appId, VoidCallback callback);
// Update printer. Printer with empty ID is considered new.
static void updatePrinter(Printer printer);
......
......@@ -169,6 +169,14 @@ chrome.test.runTests([
});
});
},
// This launches Chrome.
function launchApp() {
chrome.autotestPrivate.launchApp('mgndgikekgjfcpckkfioiadnlibdjbkf',
function() {
chrome.test.assertNoLastError();
chrome.test.succeed();
});
},
function setCrostiniEnabled() {
chrome.autotestPrivate.setCrostiniEnabled(true, chrome.test.callbackFail(
'Crostini is not available for the current user'));
......
......@@ -1340,6 +1340,7 @@ enum HistogramValue {
WEBVIEWINTERNAL_ISSPATIALNAVIGATIONENABLED = 1277,
FILEMANAGERPRIVATEINTERNAL_GETTHUMBNAIL = 1278,
FILEMANAGERPRIVATEINTERNAL_GETCROSTINISHAREDPATHS = 1279,
AUTOTESTPRIVATE_LAUNCHAPP = 1280,
// Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY
......
......@@ -16837,6 +16837,7 @@ Called by update_net_error_codes.py.-->
<int value="1277" label="WEBVIEWINTERNAL_ISSPATIALNAVIGATIONENABLED"/>
<int value="1278" label="FILEMANAGERPRIVATEINTERNAL_GETTHUMBNAIL"/>
<int value="1279" label="FILEMANAGERPRIVATEINTERNAL_GETCROSTINISHAREDPATHS"/>
<int value="1280" label="AUTOTESTPRIVATE_LAUNCHAPP"/>
</enum>
<enum name="ExtensionIconState">
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