#include <string>
#include "base/functional/bind.h"
#include "base/scoped_observation.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/sync/test/integration/apps_helper.h"
#include "chrome/browser/sync/test/integration/web_apps_sync_test_base.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/browser/ui/web_applications/web_app_dialogs.h"
#include "chrome/browser/web_applications/mojom/user_display_mode.mojom.h"
#include "chrome/browser/web_applications/os_integration/os_integration_manager.h"
#include "chrome/browser/web_applications/proto/web_app_install_state.pb.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test_observers.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_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/sync/base/features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "third_party/blink/public/mojom/manifest/manifest.mojom.h"
#include "third_party/skia/include/core/SkColor.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/common/chrome_constants.h"
#include "components/sync/service/sync_service_impl.h"
#endif
namespace web_app {
namespace {
class DisplayModeChangeWaiter : public WebAppRegistrarObserver { … };
}
class TwoClientWebAppsSyncTest : public WebAppsSyncTestBase { … };
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, Basic) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, Minimal) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, ThemeColor) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, IsLocallyInstalled) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, AppFieldsChangeDoesNotSync) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, SyncFaviconOnly) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, SyncUsingStartUrlFallback) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, SyncUsingNameFallback) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, SyncWithoutUsingNameFallback) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, SyncUsingIconUrlFallback) { … }
IN_PROC_BROWSER_TEST_F(TwoClientWebAppsSyncTest, SyncUserDisplayModeChange) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
class TwoClientLacrosWebAppsSyncTest : public SyncTest {
public:
TwoClientLacrosWebAppsSyncTest() : SyncTest(TWO_CLIENT) {}
~TwoClientLacrosWebAppsSyncTest() override = default;
base::FilePath GetProfileBaseName(int index) override {
if (index == 0)
return base::FilePath(chrome::kInitialProfile);
return SyncTest::GetProfileBaseName(index);
}
};
IN_PROC_BROWSER_TEST_F(TwoClientLacrosWebAppsSyncTest,
SyncDisabledUnlessPrimary) {
ASSERT_TRUE(SetupClients());
#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (base::FeatureList::IsEnabled(syncer::kSyncChromeOSAppsToggleSharing)) {
GetSyncService(0)->GetUserSettings()->SetAppsSyncEnabledByOs(true);
GetSyncService(1)->GetUserSettings()->SetAppsSyncEnabledByOs(true);
}
#endif
ASSERT_TRUE(SetupSync());
{
EXPECT_TRUE(GetProfile(0)->IsMainProfile());
syncer::SyncServiceImpl* service = GetSyncService(0);
syncer::DataTypeSet types = service->GetActiveDataTypes();
EXPECT_TRUE(types.Has(syncer::APPS));
EXPECT_TRUE(types.Has(syncer::APP_SETTINGS));
EXPECT_TRUE(types.Has(syncer::WEB_APPS));
}
{
EXPECT_FALSE(GetProfile(1)->IsMainProfile());
syncer::SyncServiceImpl* service = GetSyncService(1);
syncer::DataTypeSet types = service->GetActiveDataTypes();
EXPECT_FALSE(types.Has(syncer::APPS));
EXPECT_FALSE(types.Has(syncer::APP_SETTINGS));
EXPECT_FALSE(types.Has(syncer::WEB_APPS));
}
}
#endif
}