chromium/chrome/browser/sync/test/integration/two_client_extension_apps_sync_test.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>
#include <memory>
#include <utility>

#include "base/functional/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/extensions/extension_sync_data.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/apps_helper.h"
#include "chrome/browser/sync/test/integration/apps_sync_test_base.h"
#include "chrome/browser/sync/test/integration/sync_app_helper.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h"
#include "chrome/browser/web_applications/preinstalled_web_apps/preinstalled_web_apps.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_install_info.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "components/sync/base/features.h"
#include "components/sync/model/string_ordinal.h"
#include "components/sync/service/sync_service_impl.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/app_sorting.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/constants.h"

AllProfilesHaveSameApps;
DisableApp;
EnableApp;
GetAppLaunchOrdinalForApp;
IncognitoDisableApp;
IncognitoEnableApp;
InstallHostedApp;
InstallPlatformApp;
SetAppLaunchOrdinalForApp;
SetPageOrdinalForApp;
UninstallApp;

namespace {

extensions::ExtensionRegistry* GetExtensionRegistry(Profile* profile) {}

}  // namespace

class TwoClientExtensionAppsSyncTest : public AppsSyncTestBase {};

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(StartWithNoApps)) {}

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(StartWithSameApps)) {}

// Install some apps on both clients, some on only one client, some on only the
// other, and sync.  Both clients should end up with all apps, and the app and
// page ordinals should be identical.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest, StartWithDifferentApps) {}

// Install some apps on both clients, then sync.  Then install some apps on only
// one client, some on only the other, and then sync again.  Both clients should
// end up with all apps, and the app and page ordinals should be identical.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(InstallDifferentApps)) {}

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest, E2E_ENABLED(Add)) {}

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest, E2E_ENABLED(Uninstall)) {}

// Install an app on one client, then sync. Then uninstall the app on the first
// client and sync again. Now install a new app on the first client and sync.
// Both client should only have the second app, with identical app and page
// ordinals.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(UninstallThenInstall)) {}

// TODO(crbug.com/40203939): Change back to E2E_ENABLED when flakiness is
// fixed.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest, E2E_ONLY(Merge)) {}

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(UpdateEnableDisableApp)) {}

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(UpdateIncognitoEnableDisable)) {}

// Install the same app on both clients, then sync. Change the page ordinal on
// one client and sync. Both clients should have the updated page ordinal for
// the app.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(UpdatePageOrdinal)) {}

// Install the same app on both clients, then sync. Change the app launch
// ordinal on one client and sync. Both clients should have the updated app
// launch ordinal for the app.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(UpdateAppLaunchOrdinal)) {}

// Adjust the CWS location within a page on the first client and sync. Adjust
// which page the CWS appears on and sync. Both clients should have the same
// page and app launch ordinal values for the CWS.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(UpdateCWSOrdinals)) {}

// Adjust the launch type on the first client and sync. Both clients should
// have the same launch type values for the CWS.
IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       E2E_ENABLED(UpdateLaunchType)) {}

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest, UnexpectedLaunchType) {}

namespace {
constexpr char kHostedAppId0[] =;
constexpr char kHostedAppId1[] =;
}  // namespace

IN_PROC_BROWSER_TEST_F(TwoClientExtensionAppsSyncTest,
                       DefaultWebAppMigratedChromeAppSyncBlocked) {}

// TODO(akalin): Add tests exercising:
//   - Offline installation/uninstallation behavior
//   - App-specific properties