#include "chrome/browser/web_applications/commands/fetch_manifest_and_install_command.h"
#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include "base/containers/contains.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "chrome/browser/ui/web_applications/web_app_dialog_utils.h"
#include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.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/fake_web_contents_manager.h"
#include "chrome/browser/web_applications/test/test_file_utils.h"
#include "chrome/browser/web_applications/test/web_app_icon_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test.h"
#include "chrome/browser/web_applications/web_app_command_manager.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_icon_generator.h"
#include "chrome/browser/web_applications/web_app_icon_manager.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "chrome/browser/web_applications/web_app_install_params.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "chrome/browser/web_applications/web_contents/web_app_data_retriever.h"
#include "chrome/common/chrome_features.h"
#include "components/webapps/browser/install_result_code.h"
#include "components/webapps/browser/installable/installable_logging.h"
#include "components/webapps/browser/installable/installable_metrics.h"
#include "components/webapps/browser/web_contents/web_app_url_loader.h"
#include "components/webapps/common/web_app_id.h"
#include "components/webapps/common/web_page_metadata.mojom.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
#include "net/http/http_status_code.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/manifest/manifest_util.h"
#include "third_party/blink/public/mojom/manifest/display_mode.mojom-shared.h"
#include "third_party/blink/public/mojom/manifest/display_mode.mojom.h"
#include "third_party/blink/public/mojom/manifest/manifest.mojom-forward.h"
#include "third_party/blink/public/mojom/manifest/manifest.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/color/color_provider_utils.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/test/sk_gmock_support.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/arc/mojom/intent_helper.mojom.h"
#include "ash/components/arc/session/arc_bridge_service.h"
#include "ash/components/arc/session/arc_service_manager.h"
#include "ash/components/arc/test/connection_holder_util.h"
#include "ash/components/arc/test/fake_app_instance.h"
#include "chrome/browser/ash/app_list/arc/arc_app_test.h"
#include "components/arc/test/fake_intent_helper_host.h"
#include "components/arc/test/fake_intent_helper_instance.h"
#endif
namespace web_app {
namespace {
class FetchManifestAndInstallCommandTest : public WebAppTest { … };
TEST_F(FetchManifestAndInstallCommandTest, SuccessWithManifest) { … }
TEST_F(FetchManifestAndInstallCommandTest,
SuccessWithFallbackInstallWithManifest) { … }
TEST_F(FetchManifestAndInstallCommandTest,
SuccessWithFallbackInstallNoManifest) { … }
TEST_F(FetchManifestAndInstallCommandTest,
FallbackInstallWithFailToGetInstallInfo) { … }
TEST_F(FetchManifestAndInstallCommandTest, SuccessWithoutReparent) { … }
TEST_F(FetchManifestAndInstallCommandTest, UserInstallDeclined) { … }
TEST_F(FetchManifestAndInstallCommandTest, Shutdown) { … }
TEST_F(FetchManifestAndInstallCommandTest, WebContentsDestroyed) { … }
TEST_F(FetchManifestAndInstallCommandTest,
MainFrameNavigationDifferentOriginDestroysCommand) { … }
TEST_F(FetchManifestAndInstallCommandTest,
MainFrameNavigationSameOriginAllowsSuccessfulCompletion) { … }
TEST_F(FetchManifestAndInstallCommandTest, WriteDataToDisk) { … }
TEST_F(FetchManifestAndInstallCommandTest, GetIcons_PrimaryPageChanged) { … }
TEST_F(FetchManifestAndInstallCommandTest, GetIcons_IconNotFound) { … }
TEST_F(FetchManifestAndInstallCommandTest, WriteDataToDiskFailed) { … }
TEST_F(FetchManifestAndInstallCommandTest, WebContentsNavigates) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(FetchManifestAndInstallCommandTest, IntentToPlayStore) {
arc_test().app_instance()->set_is_installable(true);
auto manifest = CreateValidManifest();
blink::Manifest::RelatedApplication related_app;
related_app.platform = u"chromeos_play";
related_app.id = u"com.app.id";
manifest->related_applications.push_back(std::move(related_app));
SetupPageState(std::move(manifest));
EXPECT_EQ(InstallAndWait(webapps::WebappInstallSource::OMNIBOX_INSTALL_ICON,
CreateDialogCallback(true)),
webapps::InstallResultCode::kIntentToPlayStore);
}
#endif
class FetchManifestAndInstallCommandUniversalInstallTest
: public FetchManifestAndInstallCommandTest { … };
TEST_F(FetchManifestAndInstallCommandUniversalInstallTest, CraftedApp) { … }
TEST_F(FetchManifestAndInstallCommandUniversalInstallTest, NoManifest) { … }
ManifestConfig;
class UniversalInstallComboTest
: public FetchManifestAndInstallCommandUniversalInstallTest,
public testing::WithParamInterface<ManifestConfig> { … };
TEST_P(UniversalInstallComboTest, InstallStateValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}