#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/test/test_future.h"
#include "chrome/browser/apps/app_service/app_registry_cache_waiter.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/app_service_test.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/test/fake_web_app_provider.h"
#include "chrome/browser/web_applications/test/fake_web_app_ui_manager.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/browser/web_applications/web_app_ui_manager.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/services/app_service/public/cpp/types_util.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/web_applications/web_app_id_constants.h"
#include "chromeos/ash/components/system/fake_statistics_provider.h"
#include "chromeos/ash/components/system/statistics_provider.h"
#include "chromeos/constants/url_constants.h"
#include "net/base/url_util.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/web_applications/app_service/lacros_web_apps_controller.h"
#include "chrome/browser/web_applications/app_service/test/loopback_crosapi_app_service_proxy.h"
#endif
namespace web_app {
class WebAppPublisherTest : public testing::Test { … };
#if BUILDFLAG(IS_CHROMEOS_ASH)
class WebAppPublisherTest_Mall : public WebAppPublisherTest {
private:
base::test::ScopedFeatureList scoped_feature_list_{
chromeos::features::kCrosMall};
ash::system::ScopedFakeStatisticsProvider fake_statistics_provider_;
};
TEST_F(WebAppPublisherTest_Mall, LaunchMallAppWithContext) {
CreateWebApp(GURL(chromeos::kAppMallBaseUrl), "Mall");
auto* provider = WebAppProvider::GetForTest(profile());
base::test::TestFuture<apps::AppLaunchParams,
web_app::LaunchWebAppWindowSetting>
app_launch_future;
static_cast<web_app::FakeWebAppUiManager*>(&provider->ui_manager())
->SetOnLaunchWebAppCallback(app_launch_future.GetRepeatingCallback());
proxy()->Launch(kMallAppId, 0, apps::LaunchSource::kFromTest);
auto [params, setting] = app_launch_future.Take();
ASSERT_TRUE(params.intent->url.has_value());
std::string context_value;
ASSERT_TRUE(net::GetValueForKeyInQuery(*params.intent->url, "context",
&context_value));
ASSERT_FALSE(context_value.empty());
}
#endif
}