Commit 62224a2b authored by khmel@google.com's avatar khmel@google.com Committed by Commit Bot

autotest: Add functionality to check if app is shown.

This is required for cheets_AuthPerf test that waits until Play Store
window is shown. Before we used implicit check that some property file
was created. That was bit flaky due background nature of creating this
file and did not work on all platforms. This CL introduces explicit way
by checking if app is actually shown on Chrome.

BUG=b:110060284
TEST=cheets_AuthPerf passes for Scarlet (where was failing before) + few
other boards.

Change-Id: Ia372b4939853a1c99fdd70a68079e080e14111c3
Reviewed-on: https://chromium-review.googlesource.com/1194735
Commit-Queue: Yury Khmel <khmel@google.com>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587850}
parent d6ea8c1c
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "chrome/browser/chromeos/printing/cups_printers_manager.h" #include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/chromeos/system/input_device_settings.h" #include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/login_screen_client.h" #include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/views/crostini/crostini_installer_view.h" #include "chrome/browser/ui/views/crostini/crostini_installer_view.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
...@@ -118,10 +119,17 @@ std::unique_ptr<base::DictionaryValue> MakeDictionaryFromNotification( ...@@ -118,10 +119,17 @@ std::unique_ptr<base::DictionaryValue> MakeDictionaryFromNotification(
result->SetInteger("progress", notification.progress()); result->SetInteger("progress", notification.progress());
return result; return result;
} }
#else
constexpr char kOnlyAvailableOnChromeOSError[] = "Only available on ChromeOS";
#endif #endif
} // namespace } // namespace
AutotestPrivateLogoutFunction::~AutotestPrivateLogoutFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateLogoutFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateLogoutFunction::Run() {
DVLOG(1) << "AutotestPrivateLogoutFunction"; DVLOG(1) << "AutotestPrivateLogoutFunction";
if (!IsTestMode(browser_context())) if (!IsTestMode(browser_context()))
...@@ -129,6 +137,8 @@ ExtensionFunction::ResponseAction AutotestPrivateLogoutFunction::Run() { ...@@ -129,6 +137,8 @@ ExtensionFunction::ResponseAction AutotestPrivateLogoutFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateRestartFunction::~AutotestPrivateRestartFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateRestartFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateRestartFunction::Run() {
DVLOG(1) << "AutotestPrivateRestartFunction"; DVLOG(1) << "AutotestPrivateRestartFunction";
if (!IsTestMode(browser_context())) if (!IsTestMode(browser_context()))
...@@ -136,6 +146,8 @@ ExtensionFunction::ResponseAction AutotestPrivateRestartFunction::Run() { ...@@ -136,6 +146,8 @@ ExtensionFunction::ResponseAction AutotestPrivateRestartFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateShutdownFunction::~AutotestPrivateShutdownFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() {
std::unique_ptr<api::autotest_private::Shutdown::Params> params( std::unique_ptr<api::autotest_private::Shutdown::Params> params(
api::autotest_private::Shutdown::Params::Create(*args_)); api::autotest_private::Shutdown::Params::Create(*args_));
...@@ -148,6 +160,9 @@ ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() { ...@@ -148,6 +160,9 @@ ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateLoginStatusFunction::~AutotestPrivateLoginStatusFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
DVLOG(1) << "AutotestPrivateLoginStatusFunction"; DVLOG(1) << "AutotestPrivateLoginStatusFunction";
...@@ -208,6 +223,9 @@ void AutotestPrivateLoginStatusFunction::OnIsReadyForPassword(bool is_ready) { ...@@ -208,6 +223,9 @@ void AutotestPrivateLoginStatusFunction::OnIsReadyForPassword(bool is_ready) {
} }
#endif #endif
AutotestPrivateLockScreenFunction::~AutotestPrivateLockScreenFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() {
DVLOG(1) << "AutotestPrivateLockScreenFunction"; DVLOG(1) << "AutotestPrivateLockScreenFunction";
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
...@@ -217,6 +235,9 @@ ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() { ...@@ -217,6 +235,9 @@ ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateGetExtensionsInfoFunction::
~AutotestPrivateGetExtensionsInfoFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateGetExtensionsInfoFunction::Run() { AutotestPrivateGetExtensionsInfoFunction::Run() {
DVLOG(1) << "AutotestPrivateGetExtensionsInfoFunction"; DVLOG(1) << "AutotestPrivateGetExtensionsInfoFunction";
...@@ -283,6 +304,9 @@ static int AccessArray(const volatile int arr[], const volatile int *index) { ...@@ -283,6 +304,9 @@ static int AccessArray(const volatile int arr[], const volatile int *index) {
return arr[*index]; return arr[*index];
} }
AutotestPrivateSimulateAsanMemoryBugFunction::
~AutotestPrivateSimulateAsanMemoryBugFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSimulateAsanMemoryBugFunction::Run() { AutotestPrivateSimulateAsanMemoryBugFunction::Run() {
DVLOG(1) << "AutotestPrivateSimulateAsanMemoryBugFunction"; DVLOG(1) << "AutotestPrivateSimulateAsanMemoryBugFunction";
...@@ -297,6 +321,9 @@ AutotestPrivateSimulateAsanMemoryBugFunction::Run() { ...@@ -297,6 +321,9 @@ AutotestPrivateSimulateAsanMemoryBugFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetTouchpadSensitivityFunction::
~AutotestPrivateSetTouchpadSensitivityFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSetTouchpadSensitivityFunction::Run() { AutotestPrivateSetTouchpadSensitivityFunction::Run() {
std::unique_ptr<api::autotest_private::SetTouchpadSensitivity::Params> params( std::unique_ptr<api::autotest_private::SetTouchpadSensitivity::Params> params(
...@@ -312,6 +339,9 @@ AutotestPrivateSetTouchpadSensitivityFunction::Run() { ...@@ -312,6 +339,9 @@ AutotestPrivateSetTouchpadSensitivityFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetTapToClickFunction::~AutotestPrivateSetTapToClickFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateSetTapToClickFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateSetTapToClickFunction::Run() {
std::unique_ptr<api::autotest_private::SetTapToClick::Params> params( std::unique_ptr<api::autotest_private::SetTapToClick::Params> params(
api::autotest_private::SetTapToClick::Params::Create(*args_)); api::autotest_private::SetTapToClick::Params::Create(*args_));
...@@ -325,6 +355,9 @@ ExtensionFunction::ResponseAction AutotestPrivateSetTapToClickFunction::Run() { ...@@ -325,6 +355,9 @@ ExtensionFunction::ResponseAction AutotestPrivateSetTapToClickFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetThreeFingerClickFunction::
~AutotestPrivateSetThreeFingerClickFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSetThreeFingerClickFunction::Run() { AutotestPrivateSetThreeFingerClickFunction::Run() {
std::unique_ptr<api::autotest_private::SetThreeFingerClick::Params> params( std::unique_ptr<api::autotest_private::SetThreeFingerClick::Params> params(
...@@ -340,6 +373,9 @@ AutotestPrivateSetThreeFingerClickFunction::Run() { ...@@ -340,6 +373,9 @@ AutotestPrivateSetThreeFingerClickFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetTapDraggingFunction::
~AutotestPrivateSetTapDraggingFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateSetTapDraggingFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateSetTapDraggingFunction::Run() {
std::unique_ptr<api::autotest_private::SetTapDragging::Params> params( std::unique_ptr<api::autotest_private::SetTapDragging::Params> params(
api::autotest_private::SetTapDragging::Params::Create(*args_)); api::autotest_private::SetTapDragging::Params::Create(*args_));
...@@ -353,6 +389,9 @@ ExtensionFunction::ResponseAction AutotestPrivateSetTapDraggingFunction::Run() { ...@@ -353,6 +389,9 @@ ExtensionFunction::ResponseAction AutotestPrivateSetTapDraggingFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetNaturalScrollFunction::
~AutotestPrivateSetNaturalScrollFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSetNaturalScrollFunction::Run() { AutotestPrivateSetNaturalScrollFunction::Run() {
std::unique_ptr<api::autotest_private::SetNaturalScroll::Params> params( std::unique_ptr<api::autotest_private::SetNaturalScroll::Params> params(
...@@ -368,6 +407,9 @@ AutotestPrivateSetNaturalScrollFunction::Run() { ...@@ -368,6 +407,9 @@ AutotestPrivateSetNaturalScrollFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetMouseSensitivityFunction::
~AutotestPrivateSetMouseSensitivityFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSetMouseSensitivityFunction::Run() { AutotestPrivateSetMouseSensitivityFunction::Run() {
std::unique_ptr<api::autotest_private::SetMouseSensitivity::Params> params( std::unique_ptr<api::autotest_private::SetMouseSensitivity::Params> params(
...@@ -383,6 +425,9 @@ AutotestPrivateSetMouseSensitivityFunction::Run() { ...@@ -383,6 +425,9 @@ AutotestPrivateSetMouseSensitivityFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetPrimaryButtonRightFunction::
~AutotestPrivateSetPrimaryButtonRightFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSetPrimaryButtonRightFunction::Run() { AutotestPrivateSetPrimaryButtonRightFunction::Run() {
std::unique_ptr<api::autotest_private::SetPrimaryButtonRight::Params> params( std::unique_ptr<api::autotest_private::SetPrimaryButtonRight::Params> params(
...@@ -398,6 +443,9 @@ AutotestPrivateSetPrimaryButtonRightFunction::Run() { ...@@ -398,6 +443,9 @@ AutotestPrivateSetPrimaryButtonRightFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateSetMouseReverseScrollFunction::
~AutotestPrivateSetMouseReverseScrollFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSetMouseReverseScrollFunction::Run() { AutotestPrivateSetMouseReverseScrollFunction::Run() {
std::unique_ptr<api::autotest_private::SetMouseReverseScroll::Params> params( std::unique_ptr<api::autotest_private::SetMouseReverseScroll::Params> params(
...@@ -463,6 +511,9 @@ std::string AutotestPrivateGetPrinterListFunction::GetPrinterType( ...@@ -463,6 +511,9 @@ std::string AutotestPrivateGetPrinterListFunction::GetPrinterType(
} }
#endif #endif
AutotestPrivateGetPrinterListFunction::
~AutotestPrivateGetPrinterListFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateGetPrinterListFunction::Run() { ExtensionFunction::ResponseAction AutotestPrivateGetPrinterListFunction::Run() {
DVLOG(1) << "AutotestPrivateGetPrinterListFunction"; DVLOG(1) << "AutotestPrivateGetPrinterListFunction";
auto values = std::make_unique<base::ListValue>(); auto values = std::make_unique<base::ListValue>();
...@@ -546,6 +597,9 @@ ExtensionFunction::ResponseAction AutotestPrivateRemovePrinterFunction::Run() { ...@@ -546,6 +597,9 @@ ExtensionFunction::ResponseAction AutotestPrivateRemovePrinterFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
AutotestPrivateGetPlayStoreStateFunction::
~AutotestPrivateGetPlayStoreStateFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateGetPlayStoreStateFunction::Run() { AutotestPrivateGetPlayStoreStateFunction::Run() {
DVLOG(1) << "AutotestPrivateGetPlayStoreStateFunction"; DVLOG(1) << "AutotestPrivateGetPlayStoreStateFunction";
...@@ -564,13 +618,16 @@ AutotestPrivateGetPlayStoreStateFunction::Run() { ...@@ -564,13 +618,16 @@ AutotestPrivateGetPlayStoreStateFunction::Run() {
return RespondNow(OneArgument(play_store_state.ToValue())); return RespondNow(OneArgument(play_store_state.ToValue()));
} }
AutotestPrivateSetPlayStoreEnabledFunction::
~AutotestPrivateSetPlayStoreEnabledFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateSetPlayStoreEnabledFunction::Run() { AutotestPrivateSetPlayStoreEnabledFunction::Run() {
DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction"; DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction";
#if defined(OS_CHROMEOS)
std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params( std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params(
api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_)); api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
#if defined(OS_CHROMEOS)
Profile* profile = ProfileManager::GetActiveUserProfile(); Profile* profile = ProfileManager::GetActiveUserProfile();
if (arc::IsArcAllowedForProfile(profile)) { if (arc::IsArcAllowedForProfile(profile)) {
if (!arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled)) { if (!arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled)) {
...@@ -583,10 +640,39 @@ AutotestPrivateSetPlayStoreEnabledFunction::Run() { ...@@ -583,10 +640,39 @@ AutotestPrivateSetPlayStoreEnabledFunction::Run() {
} else { } else {
return RespondNow(Error("ARC is not available for the current user")); return RespondNow(Error("ARC is not available for the current user"));
} }
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif #endif
return RespondNow(Error("ARC is not available for the current platform"));
} }
AutotestPrivateIsAppShownFunction::~AutotestPrivateIsAppShownFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateIsAppShownFunction::Run() {
DVLOG(1) << "AutotestPrivateIsAppShownFunction";
#if defined(OS_CHROMEOS)
std::unique_ptr<api::autotest_private::IsAppShown::Params> params(
api::autotest_private::IsAppShown::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
ChromeLauncherController* const controller =
ChromeLauncherController::instance();
if (!controller)
return RespondNow(Error("Controller not available"));
const ash::ShelfItem* item =
controller->GetItem(ash::ShelfID(params->app_id));
const bool window_attached =
item && item->status == ash::ShelfItemStatus::STATUS_RUNNING;
return RespondNow(
OneArgument(std::make_unique<base::Value>(window_attached)));
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
AutotestPrivateRunCrostiniInstallerFunction::
~AutotestPrivateRunCrostiniInstallerFunction() = default;
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
AutotestPrivateRunCrostiniInstallerFunction::Run() { AutotestPrivateRunCrostiniInstallerFunction::Run() {
DVLOG(1) << "AutotestPrivateInstallCrostiniFunction"; DVLOG(1) << "AutotestPrivateInstallCrostiniFunction";
...@@ -609,8 +695,7 @@ AutotestPrivateRunCrostiniInstallerFunction::Run() { ...@@ -609,8 +695,7 @@ AutotestPrivateRunCrostiniInstallerFunction::Run() {
return RespondLater(); return RespondLater();
#else #else
return RespondNow( return RespondNow(Error(kOnlyAvailableOnChromeOSError));
Error("Crostini is not available for the current platform"));
#endif #endif
} }
......
...@@ -34,7 +34,7 @@ class AutotestPrivateLogoutFunction : public UIThreadExtensionFunction { ...@@ -34,7 +34,7 @@ class AutotestPrivateLogoutFunction : public UIThreadExtensionFunction {
DECLARE_EXTENSION_FUNCTION("autotestPrivate.logout", AUTOTESTPRIVATE_LOGOUT) DECLARE_EXTENSION_FUNCTION("autotestPrivate.logout", AUTOTESTPRIVATE_LOGOUT)
private: private:
~AutotestPrivateLogoutFunction() override {} ~AutotestPrivateLogoutFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -43,7 +43,7 @@ class AutotestPrivateRestartFunction : public UIThreadExtensionFunction { ...@@ -43,7 +43,7 @@ class AutotestPrivateRestartFunction : public UIThreadExtensionFunction {
DECLARE_EXTENSION_FUNCTION("autotestPrivate.restart", AUTOTESTPRIVATE_RESTART) DECLARE_EXTENSION_FUNCTION("autotestPrivate.restart", AUTOTESTPRIVATE_RESTART)
private: private:
~AutotestPrivateRestartFunction() override {} ~AutotestPrivateRestartFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -53,7 +53,7 @@ class AutotestPrivateShutdownFunction : public UIThreadExtensionFunction { ...@@ -53,7 +53,7 @@ class AutotestPrivateShutdownFunction : public UIThreadExtensionFunction {
AUTOTESTPRIVATE_SHUTDOWN) AUTOTESTPRIVATE_SHUTDOWN)
private: private:
~AutotestPrivateShutdownFunction() override {} ~AutotestPrivateShutdownFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -63,7 +63,7 @@ class AutotestPrivateLoginStatusFunction : public UIThreadExtensionFunction { ...@@ -63,7 +63,7 @@ class AutotestPrivateLoginStatusFunction : public UIThreadExtensionFunction {
AUTOTESTPRIVATE_LOGINSTATUS) AUTOTESTPRIVATE_LOGINSTATUS)
private: private:
~AutotestPrivateLoginStatusFunction() override {} ~AutotestPrivateLoginStatusFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
...@@ -77,7 +77,7 @@ class AutotestPrivateLockScreenFunction : public UIThreadExtensionFunction { ...@@ -77,7 +77,7 @@ class AutotestPrivateLockScreenFunction : public UIThreadExtensionFunction {
AUTOTESTPRIVATE_LOCKSCREEN) AUTOTESTPRIVATE_LOCKSCREEN)
private: private:
~AutotestPrivateLockScreenFunction() override {} ~AutotestPrivateLockScreenFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -88,7 +88,7 @@ class AutotestPrivateGetExtensionsInfoFunction ...@@ -88,7 +88,7 @@ class AutotestPrivateGetExtensionsInfoFunction
AUTOTESTPRIVATE_GETEXTENSIONSINFO) AUTOTESTPRIVATE_GETEXTENSIONSINFO)
private: private:
~AutotestPrivateGetExtensionsInfoFunction() override {} ~AutotestPrivateGetExtensionsInfoFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -99,7 +99,7 @@ class AutotestPrivateSimulateAsanMemoryBugFunction ...@@ -99,7 +99,7 @@ class AutotestPrivateSimulateAsanMemoryBugFunction
AUTOTESTPRIVATE_SIMULATEASANMEMORYBUG) AUTOTESTPRIVATE_SIMULATEASANMEMORYBUG)
private: private:
~AutotestPrivateSimulateAsanMemoryBugFunction() override {} ~AutotestPrivateSimulateAsanMemoryBugFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -110,7 +110,7 @@ class AutotestPrivateSetTouchpadSensitivityFunction ...@@ -110,7 +110,7 @@ class AutotestPrivateSetTouchpadSensitivityFunction
AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY) AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY)
private: private:
~AutotestPrivateSetTouchpadSensitivityFunction() override {} ~AutotestPrivateSetTouchpadSensitivityFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -120,7 +120,7 @@ class AutotestPrivateSetTapToClickFunction : public UIThreadExtensionFunction { ...@@ -120,7 +120,7 @@ class AutotestPrivateSetTapToClickFunction : public UIThreadExtensionFunction {
AUTOTESTPRIVATE_SETTAPTOCLICK) AUTOTESTPRIVATE_SETTAPTOCLICK)
private: private:
~AutotestPrivateSetTapToClickFunction() override {} ~AutotestPrivateSetTapToClickFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -131,7 +131,7 @@ class AutotestPrivateSetThreeFingerClickFunction ...@@ -131,7 +131,7 @@ class AutotestPrivateSetThreeFingerClickFunction
AUTOTESTPRIVATE_SETTHREEFINGERCLICK) AUTOTESTPRIVATE_SETTHREEFINGERCLICK)
private: private:
~AutotestPrivateSetThreeFingerClickFunction() override {} ~AutotestPrivateSetThreeFingerClickFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -141,7 +141,7 @@ class AutotestPrivateSetTapDraggingFunction : public UIThreadExtensionFunction { ...@@ -141,7 +141,7 @@ class AutotestPrivateSetTapDraggingFunction : public UIThreadExtensionFunction {
AUTOTESTPRIVATE_SETTAPDRAGGING) AUTOTESTPRIVATE_SETTAPDRAGGING)
private: private:
~AutotestPrivateSetTapDraggingFunction() override {} ~AutotestPrivateSetTapDraggingFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -152,7 +152,7 @@ class AutotestPrivateSetNaturalScrollFunction ...@@ -152,7 +152,7 @@ class AutotestPrivateSetNaturalScrollFunction
AUTOTESTPRIVATE_SETNATURALSCROLL) AUTOTESTPRIVATE_SETNATURALSCROLL)
private: private:
~AutotestPrivateSetNaturalScrollFunction() override {} ~AutotestPrivateSetNaturalScrollFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -163,7 +163,7 @@ class AutotestPrivateSetMouseSensitivityFunction ...@@ -163,7 +163,7 @@ class AutotestPrivateSetMouseSensitivityFunction
AUTOTESTPRIVATE_SETMOUSESENSITIVITY) AUTOTESTPRIVATE_SETMOUSESENSITIVITY)
private: private:
~AutotestPrivateSetMouseSensitivityFunction() override {} ~AutotestPrivateSetMouseSensitivityFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -174,7 +174,7 @@ class AutotestPrivateSetPrimaryButtonRightFunction ...@@ -174,7 +174,7 @@ class AutotestPrivateSetPrimaryButtonRightFunction
AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT) AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT)
private: private:
~AutotestPrivateSetPrimaryButtonRightFunction() override {} ~AutotestPrivateSetPrimaryButtonRightFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -185,7 +185,7 @@ class AutotestPrivateSetMouseReverseScrollFunction ...@@ -185,7 +185,7 @@ class AutotestPrivateSetMouseReverseScrollFunction
AUTOTESTPRIVATE_SETMOUSEREVERSESCROLL) AUTOTESTPRIVATE_SETMOUSEREVERSESCROLL)
private: private:
~AutotestPrivateSetMouseReverseScrollFunction() override {} ~AutotestPrivateSetMouseReverseScrollFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -216,7 +216,7 @@ class AutotestPrivateGetPlayStoreStateFunction ...@@ -216,7 +216,7 @@ class AutotestPrivateGetPlayStoreStateFunction
AUTOTESTPRIVATE_GETPLAYSTORESTATE) AUTOTESTPRIVATE_GETPLAYSTORESTATE)
private: private:
~AutotestPrivateGetPlayStoreStateFunction() override {} ~AutotestPrivateGetPlayStoreStateFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -227,7 +227,17 @@ class AutotestPrivateSetPlayStoreEnabledFunction ...@@ -227,7 +227,17 @@ class AutotestPrivateSetPlayStoreEnabledFunction
AUTOTESTPRIVATE_SETPLAYSTOREENABLED) AUTOTESTPRIVATE_SETPLAYSTOREENABLED)
private: private:
~AutotestPrivateSetPlayStoreEnabledFunction() override {} ~AutotestPrivateSetPlayStoreEnabledFunction() override;
ResponseAction Run() override;
};
class AutotestPrivateIsAppShownFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("autotestPrivate.isAppShown",
AUTOTESTPRIVATE_ISAPPSHOWN)
private:
~AutotestPrivateIsAppShownFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
}; };
...@@ -239,7 +249,7 @@ class AutotestPrivateRunCrostiniInstallerFunction ...@@ -239,7 +249,7 @@ class AutotestPrivateRunCrostiniInstallerFunction
AUTOTESTPRIVATE_RUNCROSTINIINSTALLER) AUTOTESTPRIVATE_RUNCROSTINIINSTALLER)
private: private:
~AutotestPrivateRunCrostiniInstallerFunction() override = default; ~AutotestPrivateRunCrostiniInstallerFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
void CrostiniRestarted(crostini::ConciergeClientResult); void CrostiniRestarted(crostini::ConciergeClientResult);
...@@ -259,7 +269,7 @@ class AutotestPrivateGetPrinterListFunction : public UIThreadExtensionFunction { ...@@ -259,7 +269,7 @@ class AutotestPrivateGetPrinterListFunction : public UIThreadExtensionFunction {
static std::string GetPrinterType( static std::string GetPrinterType(
chromeos::CupsPrintersManager::PrinterClass type); chromeos::CupsPrintersManager::PrinterClass type);
#endif #endif
~AutotestPrivateGetPrinterListFunction() override = default; ~AutotestPrivateGetPrinterListFunction() override;
ResponseAction Run() override; ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateGetPrinterListFunction); DISALLOW_COPY_AND_ASSIGN(AutotestPrivateGetPrinterListFunction);
......
...@@ -2,20 +2,42 @@ ...@@ -2,20 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/macros.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/chromeos/arc/arc_session_manager.h"
#include "chrome/browser/extensions/api/autotest_private/autotest_private_api.h" #include "chrome/browser/extensions/api/autotest_private/autotest_private_api.h"
#include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_apitest.h"
#include "components/arc/arc_util.h"
namespace extensions { namespace extensions {
#if defined(OS_CHROMEOS) class AutotestPrivateApiTest : public ExtensionApiTest {
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AutotestPrivate) { public:
AutotestPrivateApiTest() = default;
~AutotestPrivateApiTest() override = default;
void SetUpCommandLine(base::CommandLine* command_line) override {
ExtensionApiTest::SetUpCommandLine(command_line);
// Make ARC enabled for tests.
arc::SetArcAvailableCommandLineForTesting(command_line);
}
void SetUpInProcessBrowserTestFixture() override {
ExtensionApiTest::SetUpInProcessBrowserTestFixture();
arc::ArcSessionManager::SetUiEnabledForTesting(false);
}
private:
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateApiTest);
};
IN_PROC_BROWSER_TEST_F(AutotestPrivateApiTest, AutotestPrivate) {
// Turn on testing mode so we don't kill the browser. // Turn on testing mode so we don't kill the browser.
AutotestPrivateAPI::GetFactoryInstance() AutotestPrivateAPI::GetFactoryInstance()
->Get(browser()->profile()) ->Get(browser()->profile())
->set_test_mode(true); ->set_test_mode(true);
ASSERT_TRUE(RunComponentExtensionTest("autotest_private")) << message_; ASSERT_TRUE(RunComponentExtensionTest("autotest_private")) << message_;
} }
#endif
} // namespace extensions } // namespace extensions
...@@ -86,6 +86,8 @@ namespace autotestPrivate { ...@@ -86,6 +86,8 @@ namespace autotestPrivate {
}; };
callback PlayStoreStateCallback = void (PlayStoreState result); callback PlayStoreStateCallback = void (PlayStoreState result);
callback IsAppShownCallback = void (boolean appShown);
callback VoidCallback = void (); callback VoidCallback = void ();
interface Functions { interface Functions {
...@@ -152,6 +154,9 @@ namespace autotestPrivate { ...@@ -152,6 +154,9 @@ namespace autotestPrivate {
// Get list of available printers // Get list of available printers
static void getPrinterList(PrinterArrayCallback callback); static void getPrinterList(PrinterArrayCallback callback);
// Returns true if requested app is shown in Chrome.
static void isAppShown(DOMString appId, IsAppShownCallback callback);
// Update printer. Printer with empty ID is considered new. // Update printer. Printer with empty ID is considered new.
static void updatePrinter(Printer printer); static void updatePrinter(Printer printer);
......
...@@ -1207,7 +1207,6 @@ test("browser_tests") { ...@@ -1207,7 +1207,6 @@ test("browser_tests") {
"../browser/extensions/api/activity_log_private/activity_log_private_apitest.cc", "../browser/extensions/api/activity_log_private/activity_log_private_apitest.cc",
"../browser/extensions/api/autofill_private/autofill_private_apitest.cc", "../browser/extensions/api/autofill_private/autofill_private_apitest.cc",
"../browser/extensions/api/automation/automation_apitest.cc", "../browser/extensions/api/automation/automation_apitest.cc",
"../browser/extensions/api/autotest_private/autotest_private_apitest.cc",
"../browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc", "../browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc",
"../browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc", "../browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc",
"../browser/extensions/api/bookmarks/bookmark_apitest.cc", "../browser/extensions/api/bookmarks/bookmark_apitest.cc",
...@@ -1760,6 +1759,7 @@ test("browser_tests") { ...@@ -1760,6 +1759,7 @@ test("browser_tests") {
"../browser/chromeos/system/device_disabling_browsertest.cc", "../browser/chromeos/system/device_disabling_browsertest.cc",
"../browser/chromeos/system/tray_accessibility_browsertest.cc", "../browser/chromeos/system/tray_accessibility_browsertest.cc",
"../browser/drive/drive_notification_manager_factory_browsertest.cc", "../browser/drive/drive_notification_manager_factory_browsertest.cc",
"../browser/extensions/api/autotest_private/autotest_private_apitest.cc",
"../browser/extensions/api/certificate_provider/certificate_provider_apitest.cc", "../browser/extensions/api/certificate_provider/certificate_provider_apitest.cc",
"../browser/extensions/api/networking_private/networking_private_apitest.cc", "../browser/extensions/api/networking_private/networking_private_apitest.cc",
"../browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc", "../browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc",
......
...@@ -113,22 +113,43 @@ chrome.test.runTests([ ...@@ -113,22 +113,43 @@ chrome.test.runTests([
chrome.autotestPrivate.getVisibleNotifications(function(){}); chrome.autotestPrivate.getVisibleNotifications(function(){});
chrome.test.succeed(); chrome.test.succeed();
}, },
// In this test, ARC is available but not managed and not enabled by default.
function getPlayStoreState() { function getPlayStoreState() {
chrome.autotestPrivate.getPlayStoreState(function(state) { chrome.autotestPrivate.getPlayStoreState(function(state) {
// By default ARC is not available. Field allowed must be set to false; chrome.test.assertTrue(state.allowed);
// managed and enabled should be underfined. chrome.test.assertFalse(state.enabled);
chrome.test.assertFalse(state.allowed); chrome.test.assertFalse(state.managed);
chrome.test.assertEq(undefined, state.enabled);
chrome.test.assertEq(undefined, state.managed);
chrome.test.succeed(); chrome.test.succeed();
}); });
}, },
// This test turns ARC enabled state to ON.
function setPlayStoreEnabled() { function setPlayStoreEnabled() {
chrome.autotestPrivate.setPlayStoreEnabled(false, function() { chrome.autotestPrivate.setPlayStoreEnabled(true, function() {
// By default ARC is not available. chrome.test.assertNoLastError();
chrome.test.assertTrue(chrome.runtime.lastError != undefined); chrome.autotestPrivate.getPlayStoreState(function(state) {
chrome.test.assertTrue(state.allowed);
chrome.test.assertTrue(state.enabled);
chrome.test.assertFalse(state.managed);
chrome.test.succeed(); chrome.test.succeed();
}); });
});
},
// This test verifies that Play Store window is not shown by default but
// Chrome is shown.
function isAppShown() {
chrome.autotestPrivate.isAppShown('cnbgggchhmkkdmeppjobngjoejnihlei',
function(appShown) {
chrome.test.assertFalse(appShown);
chrome.test.assertNoLastError();
// Chrome is running.
chrome.autotestPrivate.isAppShown('mgndgikekgjfcpckkfioiadnlibdjbkf',
function(appShown) {
chrome.test.assertTrue(appShown);
chrome.test.assertNoLastError();
chrome.test.succeed();
});
});
}, },
function runCrostiniInstaller() { function runCrostiniInstaller() {
chrome.autotestPrivate.runCrostiniInstaller(chrome.test.callbackFail( chrome.autotestPrivate.runCrostiniInstaller(chrome.test.callbackFail(
......
...@@ -1329,6 +1329,7 @@ enum HistogramValue { ...@@ -1329,6 +1329,7 @@ enum HistogramValue {
ARCAPPSPRIVATE_LAUNCHAPP = 1266, ARCAPPSPRIVATE_LAUNCHAPP = 1266,
AUTOTESTPRIVATE_RUNCROSTINIINSTALLER = 1267, AUTOTESTPRIVATE_RUNCROSTINIINSTALLER = 1267,
AUTOFILLPRIVATE_MIGRATECREDITCARDS = 1268, AUTOFILLPRIVATE_MIGRATECREDITCARDS = 1268,
AUTOTESTPRIVATE_ISAPPSHOWN = 1269,
// Last entry: Add new entries above, then run: // Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py // python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -16555,6 +16555,7 @@ Called by update_net_error_codes.py.--> ...@@ -16555,6 +16555,7 @@ Called by update_net_error_codes.py.-->
<int value="1266" label="ARCAPPSPRIVATE_LAUNCHAPP"/> <int value="1266" label="ARCAPPSPRIVATE_LAUNCHAPP"/>
<int value="1267" label="AUTOTESTPRIVATE_RUNCROSTINIINSTALLER"/> <int value="1267" label="AUTOTESTPRIVATE_RUNCROSTINIINSTALLER"/>
<int value="1268" label="AUTOFILLPRIVATE_MIGRATECREDITCARDS"/> <int value="1268" label="AUTOFILLPRIVATE_MIGRATECREDITCARDS"/>
<int value="1269" label="AUTOTESTPRIVATE_ISAPPSHOWN"/>
</enum> </enum>
<enum name="ExtensionIconState"> <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