Commit a60a79f4 authored by Paula Vidas's avatar Paula Vidas Committed by Commit Bot

[SyncInvalidations] Improve SyncEngineImpl tests.

This CL adds to DoNotUseOldInvalidationsAtAll test a check that
interested topics (for old invalidations) are cleared upon construction
of SyncEngineImpl.
To allow that, the construction of SyncEngineImpl is moved from SetUp()
to a helper method.

Bug: 1082115
Change-Id: I94be0c2c781b62ab2f5464c43b4efe86c277d9fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437395
Commit-Queue: Paula Vidas <paulavidas@google.com>
Reviewed-by: default avatarRushan Suleymanov <rushans@google.com>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811746}
parent dcfb1625
......@@ -56,6 +56,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
using testing::_;
using testing::NiceMock;
using testing::NotNull;
......@@ -196,12 +197,8 @@ class SyncEngineImplTest : public testing::Test {
sync_prefs_ = std::make_unique<SyncPrefs>(&pref_service_);
sync_thread_.StartAndWaitForTesting();
ON_CALL(invalidator_, UpdateInterestedTopics(testing::_, testing::_))
ON_CALL(invalidator_, UpdateInterestedTopics(_, _))
.WillByDefault(testing::Return(true));
backend_ = std::make_unique<SyncEngineImpl>(
"dummyDebugName", &invalidator_, GetSyncInvalidationsService(),
sync_prefs_->AsWeakPtr(),
temp_dir_.GetPath().Append(base::FilePath(kTestSyncDir)));
fake_manager_factory_ = std::make_unique<FakeSyncManagerFactory>(
&fake_manager_, network::TestNetworkConnectionTracker::GetInstance());
......@@ -229,8 +226,19 @@ class SyncEngineImplTest : public testing::Test {
base::RunLoop().RunUntilIdle();
}
void CreateBackend() {
backend_ = std::make_unique<SyncEngineImpl>(
"dummyDebugName", &invalidator_, GetSyncInvalidationsService(),
sync_prefs_->AsWeakPtr(),
temp_dir_.GetPath().Append(base::FilePath(kTestSyncDir)));
}
// Synchronously initializes the backend.
void InitializeBackend(bool expect_success) {
if (!backend_) {
CreateBackend();
}
host_.SetExpectSuccess(expect_success);
SyncEngine::InitParams params;
......@@ -675,6 +683,7 @@ TEST_F(SyncEngineImplTest, ShouldDestroyAfterInitFailure) {
TEST_F(SyncEngineImplWithSyncInvalidationsTest,
ShouldInvalidateDataTypesOnIncomingInvalidation) {
CreateBackend();
EXPECT_CALL(mock_instance_id_driver_, AddListener(backend_.get()));
InitializeBackend(/*expect_success=*/true);
......@@ -713,9 +722,14 @@ TEST_F(SyncEngineImplWithSyncInvalidationsForWalletAndOfferTest,
DoNotUseOldInvalidationsAtAll) {
enabled_types_.PutAll({AUTOFILL_WALLET_DATA, AUTOFILL_WALLET_OFFER});
// Since the old invalidations system is not being used anymore (based on the
// enabled feature flags), SyncEngine should call the (old) invalidator with
// an empty TopicSet upon construction.
EXPECT_CALL(invalidator_, UpdateInterestedTopics(_, TopicSet()));
CreateBackend();
EXPECT_CALL(invalidator_, UpdateInterestedTopics(_, _)).Times(0);
InitializeBackend(/*expect_success=*/true);
EXPECT_CALL(invalidator_, UpdateInterestedTopics(testing::_, testing::_))
.Times(0);
ConfigureDataTypes();
}
......
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