Commit 6f03093b authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

Revert "[Sync] Support FCM Invalidations in Sync browser tests"

This reverts commit 5f47f6e7.

Reason for revert: Reverting some CLs that are suspect for causing
flakiness in the tests

Original change's description:
> [Sync] Support FCM Invalidations in Sync browser tests
> 
> Change-Id: I43de31210a0e52a39f2b0017e08994ccf1207714
> Bug: 985287
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1745997
> Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
> Reviewed-by: Marc Treib <treib@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#689571}

TBR=treib@chromium.org,mamir@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 985287
Change-Id: Idacca73b390e5fe88fa5a658991c5e3f9c611cab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774924Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691572}
parent dd6b3c84
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/test/integration/fake_server_invalidation_sender.h"
#include "chrome/browser/profiles/profile.h"
#include "components/invalidation/impl/fcm_network_handler.h"
namespace fake_server {
namespace {
const char kInvalidationsFCMAppId[] = "com.google.chrome.fcm.invalidations";
} // namespace
FakeServerInvalidationSender::FakeServerInvalidationSender(
const std::string& client_id,
bool self_notify,
base::RepeatingCallback<syncer::FCMNetworkHandler*()>
fcm_network_handler_getter)
: client_id_(client_id),
self_notify_(self_notify),
fcm_network_handler_getter_(fcm_network_handler_getter) {}
FakeServerInvalidationSender::~FakeServerInvalidationSender() {}
void FakeServerInvalidationSender::OnCommit(
const std::string& committer_id,
syncer::ModelTypeSet committed_model_types) {
if (!self_notify_ && client_id_ == committer_id) {
return;
}
syncer::FCMNetworkHandler* fcm_network_handler =
fcm_network_handler_getter_.Run();
// If there is no FCM network handler registered for this profile, there is
// nothing to do. This could be the case during test Setup phase because the
// FCM network handlers get assigned in SetupInvalidations() which happens
// after SetupSync().
if (fcm_network_handler == nullptr) {
return;
}
// For each of the committed model types, pass a message to the FCM Network
// Handler to simulate a message from the GCMDriver.
for (syncer::ModelType type : committed_model_types) {
std::string notification_type;
bool result = RealModelTypeToNotificationType(type, &notification_type);
// We shouldn't ever get commits for non-protocol types.
DCHECK(result);
gcm::IncomingMessage message;
// Client doesn't parse the payload.
message.data["payload"] = "any_payload";
// version doesn't matter, it's not used in the client.
message.data["version"] = "1234567890";
// The public topic name should be stored in the external name field.
message.data["external_name"] = notification_type;
// The private topic name is stored in the sender_id field.
message.sender_id =
"/topics/private/" + notification_type + "-topic_server_user_id";
fcm_network_handler->OnMessage(kInvalidationsFCMAppId, message);
}
}
} // namespace fake_server
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SENDER_H_
#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SENDER_H_
#include "base/macros.h"
#include "components/sync/base/model_type.h"
#include "components/sync/test/fake_server/fake_server.h"
namespace syncer {
class FCMNetworkHandler;
}
namespace fake_server {
// This class is observing changes to the fake server, and sends invalidations
// to different clients upon commits. Sent invalidation follows the same format
// expected by the FCM invalidations framework.
class FakeServerInvalidationSender : public FakeServer::Observer {
public:
FakeServerInvalidationSender(
const std::string& client_id,
bool self_notify,
base::RepeatingCallback<syncer::FCMNetworkHandler*()>
fcm_network_handler_getter);
~FakeServerInvalidationSender() override;
// FakeServer::Observer implementation.
void OnCommit(const std::string& committer_id,
syncer::ModelTypeSet committed_model_types) override;
private:
const std::string client_id_;
const bool self_notify_;
const base::RepeatingCallback<syncer::FCMNetworkHandler*()>
fcm_network_handler_getter_;
DISALLOW_COPY_AND_ASSIGN(FakeServerInvalidationSender);
};
} // namespace fake_server
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SENDER_H_
...@@ -16,11 +16,8 @@ ...@@ -16,11 +16,8 @@
#include "chrome/browser/extensions/install_verifier.h" #include "chrome/browser/extensions/install_verifier.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/configuration_refresher.h" #include "chrome/browser/sync/test/integration/configuration_refresher.h"
#include "chrome/browser/sync/test/integration/fake_server_invalidation_sender.h"
#include "chrome/common/buildflags.h" #include "chrome/common/buildflags.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync/base/user_selectable_type.h" #include "components/sync/base/user_selectable_type.h"
#include "components/sync/test/fake_server/fake_server.h" #include "components/sync/test/fake_server/fake_server.h"
...@@ -62,6 +59,7 @@ class ScopedTempDir; ...@@ -62,6 +59,7 @@ class ScopedTempDir;
namespace fake_server { namespace fake_server {
class FakeServer; class FakeServer;
class FakeServerInvalidationService;
} // namespace fake_server } // namespace fake_server
namespace syncer { namespace syncer {
...@@ -94,55 +92,6 @@ class SyncTest : public InProcessBrowserTest { ...@@ -94,55 +92,6 @@ class SyncTest : public InProcessBrowserTest {
// in-process (bypassing HTTP calls). // in-process (bypassing HTTP calls).
}; };
class FakeInstanceID : public instance_id::InstanceID {
public:
FakeInstanceID()
: instance_id::InstanceID("FakeAppId", /*gcm_driver = */ nullptr) {}
~FakeInstanceID() override = default;
void GetID(const GetIDCallback& callback) override {}
void GetCreationTime(const GetCreationTimeCallback& callback) override {}
void GetToken(const std::string& authorized_entity,
const std::string& scope,
const std::map<std::string, std::string>& options,
std::set<Flags> flags,
GetTokenCallback callback) override {}
void ValidateToken(const std::string& authorized_entity,
const std::string& scope,
const std::string& token,
const ValidateTokenCallback& callback) override {}
void DeleteToken(const std::string& authorized_entity,
const std::string& scope,
DeleteTokenCallback callback) override {}
protected:
void DeleteTokenImpl(const std::string& authorized_entity,
const std::string& scope,
DeleteTokenCallback callback) override {}
void DeleteIDImpl(DeleteIDCallback callback) override {}
private:
DISALLOW_COPY_AND_ASSIGN(FakeInstanceID);
};
class FakeInstanceIDDriver : public instance_id::InstanceIDDriver {
public:
FakeInstanceIDDriver()
: instance_id::InstanceIDDriver(/*gcm_driver=*/nullptr) {}
~FakeInstanceIDDriver() override = default;
instance_id::InstanceID* GetInstanceID(const std::string& app_id) override;
void RemoveInstanceID(const std::string& app_id) override {}
bool ExistsInstanceID(const std::string& app_id) const override;
private:
FakeInstanceID fake_instance_id_;
DISALLOW_COPY_AND_ASSIGN(FakeInstanceIDDriver);
};
// A SyncTest must be associated with a particular test type. // A SyncTest must be associated with a particular test type.
explicit SyncTest(TestType test_type); explicit SyncTest(TestType test_type);
...@@ -279,9 +228,6 @@ class SyncTest : public InProcessBrowserTest { ...@@ -279,9 +228,6 @@ class SyncTest : public InProcessBrowserTest {
// BrowserTestBase implementation: // BrowserTestBase implementation:
void SetUpOnMainThread() override; void SetUpOnMainThread() override;
void TearDownOnMainThread() override; void TearDownOnMainThread() override;
void SetUpInProcessBrowserTestFixture() override;
void OnWillCreateBrowserContextServices(content::BrowserContext* context);
virtual void BeforeSetupClient(int index); virtual void BeforeSetupClient(int index);
...@@ -348,12 +294,6 @@ class SyncTest : public InProcessBrowserTest { ...@@ -348,12 +294,6 @@ class SyncTest : public InProcessBrowserTest {
Profile* profile, Profile* profile,
Profile::CreateStatus status); Profile::CreateStatus status);
static std::unique_ptr<KeyedService> CreateProfileInvalidationProvider(
std::map<const Profile*, syncer::FCMNetworkHandler*>*
profile_to_fcm_network_handler_map,
instance_id::InstanceIDDriver* instance_id_driver,
content::BrowserContext* context);
// Helper to Profile::CreateProfile that handles path creation, setting up // Helper to Profile::CreateProfile that handles path creation, setting up
// preexisting pref files, and registering the created profile as a testing // preexisting pref files, and registering the created profile as a testing
// profile. // profile.
...@@ -469,25 +409,14 @@ class SyncTest : public InProcessBrowserTest { ...@@ -469,25 +409,14 @@ class SyncTest : public InProcessBrowserTest {
// notifications of this activity to its peer sync clients. // notifications of this activity to its peer sync clients.
std::vector<std::unique_ptr<P2PSyncRefresher>> sync_refreshers_; std::vector<std::unique_ptr<P2PSyncRefresher>> sync_refreshers_;
// Owns the FakeServerInvalidationSender for each profile. // Collection of pointers to FakeServerInvalidation objects for each
std::vector<std::unique_ptr<fake_server::FakeServerInvalidationSender>> // profile.
fake_server_invalidation_observers_; std::vector<fake_server::FakeServerInvalidationService*>
fake_server_invalidation_services_;
// Maps a profile to the corresponding FCMNetworkHandler. Contains one entry
// per profile. It is used to simulate an incoming FCM messages to different
// profiles within the FakeServerInvalidationSender.
std::map<const Profile*, syncer::FCMNetworkHandler*>
profile_to_fcm_network_handler_map_;
FakeInstanceIDDriver fake_instance_id_driver_;
// Triggers a GetUpdates via refresh after a configuration. // Triggers a GetUpdates via refresh after a configuration.
std::unique_ptr<ConfigurationRefresher> configuration_refresher_; std::unique_ptr<ConfigurationRefresher> configuration_refresher_;
std::unique_ptr<
base::CallbackList<void(content::BrowserContext*)>::Subscription>
will_create_browser_context_services_subscription_;
// Sync profile against which changes to individual profiles are verified. // Sync profile against which changes to individual profiles are verified.
// We don't need a corresponding verifier sync client because the contents // We don't need a corresponding verifier sync client because the contents
// of the verifier profile are strictly local, and are not meant to be // of the verifier profile are strictly local, and are not meant to be
......
...@@ -5814,8 +5814,6 @@ if (!is_android && !is_fuchsia) { ...@@ -5814,8 +5814,6 @@ if (!is_android && !is_fuchsia) {
"../browser/sync/test/integration/extension_settings_helper.h", "../browser/sync/test/integration/extension_settings_helper.h",
"../browser/sync/test/integration/extensions_helper.cc", "../browser/sync/test/integration/extensions_helper.cc",
"../browser/sync/test/integration/extensions_helper.h", "../browser/sync/test/integration/extensions_helper.h",
"../browser/sync/test/integration/fake_server_invalidation_sender.cc",
"../browser/sync/test/integration/fake_server_invalidation_sender.h",
"../browser/sync/test/integration/fake_server_invalidation_service.cc", "../browser/sync/test/integration/fake_server_invalidation_service.cc",
"../browser/sync/test/integration/fake_server_invalidation_service.h", "../browser/sync/test/integration/fake_server_invalidation_service.h",
"../browser/sync/test/integration/fake_server_match_status_checker.cc", "../browser/sync/test/integration/fake_server_match_status_checker.cc",
......
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