Commit 413493e0 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

SyncStandaloneTransport: Add integration test for "Reset Sync" from dashboard

Bug: 856179
Change-Id: I0fb499c5bb5c0de6df4fa7c2f46d3b0b35f5f0df
Reviewed-on: https://chromium-review.googlesource.com/c/1326901
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606848}
parent 3052bf26
...@@ -25,6 +25,21 @@ syncer::ModelTypeSet AllowedTypesInStandaloneTransportMode() { ...@@ -25,6 +25,21 @@ syncer::ModelTypeSet AllowedTypesInStandaloneTransportMode() {
return allowed_types; return allowed_types;
} }
class SyncDisabledByUserChecker : public SingleClientStatusChangeChecker {
public:
explicit SyncDisabledByUserChecker(browser_sync::ProfileSyncService* service)
: SingleClientStatusChangeChecker(service) {}
bool IsExitConditionSatisfied() override {
return service()->HasDisableReason(
syncer::SyncService::DISABLE_REASON_USER_CHOICE);
}
std::string GetDebugMessage() const override {
return "Sync Disabled by User";
}
};
class SingleClientStandaloneTransportSyncTest : public SyncTest { class SingleClientStandaloneTransportSyncTest : public SyncTest {
public: public:
SingleClientStandaloneTransportSyncTest() : SyncTest(SINGLE_CLIENT) { SingleClientStandaloneTransportSyncTest() : SyncTest(SINGLE_CLIENT) {
...@@ -160,4 +175,55 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportSyncTest, ...@@ -160,4 +175,55 @@ IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportSyncTest,
EXPECT_TRUE(GetSyncService(0)->GetActiveDataTypes().Has(syncer::BOOKMARKS)); EXPECT_TRUE(GetSyncService(0)->GetActiveDataTypes().Has(syncer::BOOKMARKS));
} }
// Tests the behavior of receiving a "Reset Sync" operation from the dashboard
// while Sync-the-feature is active: On non-ChromeOS, this signs the user out,
// so Sync will be fully disabled. On ChromeOS, there is no sign-out, so
// Sync-the-transport will start.
IN_PROC_BROWSER_TEST_F(SingleClientStandaloneTransportSyncTest,
HandlesResetFromDashboardWhenSyncActive) {
ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
// Set up Sync-the-feature.
ASSERT_TRUE(GetClient(0)->SetupSync());
ASSERT_EQ(syncer::SyncService::TransportState::ACTIVE,
GetSyncService(0)->GetTransportState());
ASSERT_TRUE(GetSyncService(0)->IsSyncFeatureEnabled());
ASSERT_TRUE(GetSyncService(0)->IsSyncFeatureActive());
// Trigger a "Reset Sync" from the dashboard and wait for it to apply.
ASSERT_TRUE(GetFakeServer()->TriggerActionableError(
sync_pb::SyncEnums::NOT_MY_BIRTHDAY, "Reset Sync from Dashboard",
"https://chrome.google.com/sync",
sync_pb::SyncEnums::DISABLE_SYNC_ON_CLIENT));
EXPECT_TRUE(SyncDisabledByUserChecker(GetSyncService(0)).Wait());
GetFakeServer()->ClearActionableError();
// On all platforms, Sync-the-feature should now be disabled.
EXPECT_FALSE(GetSyncService(0)->IsSyncFeatureEnabled());
EXPECT_TRUE(GetSyncService(0)->HasDisableReason(
syncer::SyncService::DISABLE_REASON_USER_CHOICE));
#if defined(OS_CHROMEOS)
// On ChromeOS, Sync should start up again in standalone transport mode.
EXPECT_FALSE(GetSyncService(0)->HasDisableReason(
syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
EXPECT_NE(syncer::SyncService::TransportState::DISABLED,
GetSyncService(0)->GetTransportState());
EXPECT_TRUE(GetClient(0)->AwaitSyncSetupCompletion(
/*skip_passphrase_verification=*/false));
EXPECT_EQ(syncer::SyncService::TransportState::ACTIVE,
GetSyncService(0)->GetTransportState());
EXPECT_FALSE(GetSyncService(0)->IsSyncFeatureEnabled());
#else
// On non-ChromeOS platforms, the "Reset Sync" operation also signs the user
// out, so Sync should now be fully disabled. Note that this behavior may
// change in the future, see crbug.com/246839.
EXPECT_TRUE(GetSyncService(0)->HasDisableReason(
syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
EXPECT_EQ(syncer::SyncService::TransportState::DISABLED,
GetSyncService(0)->GetTransportState());
#endif // defined(OS_CHROMEOS)
}
} // namespace } // namespace
...@@ -404,6 +404,10 @@ bool FakeServer::TriggerActionableError( ...@@ -404,6 +404,10 @@ bool FakeServer::TriggerActionableError(
return true; return true;
} }
void FakeServer::ClearActionableError() {
triggered_actionable_error_.reset();
}
bool FakeServer::EnableAlternatingTriggeredErrors() { bool FakeServer::EnableAlternatingTriggeredErrors() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
if (error_type_ == sync_pb::SyncEnums::SUCCESS && if (error_type_ == sync_pb::SyncEnums::SUCCESS &&
......
...@@ -152,6 +152,8 @@ class FakeServer : public syncer::LoopbackServer::ObserverForTests { ...@@ -152,6 +152,8 @@ class FakeServer : public syncer::LoopbackServer::ObserverForTests {
const std::string& url, const std::string& url,
const sync_pb::SyncEnums::Action& action); const sync_pb::SyncEnums::Action& action);
void ClearActionableError();
// Instructs the server to send triggered errors on every other request // Instructs the server to send triggered errors on every other request
// (starting with the first one after this call). This feature can be used to // (starting with the first one after this call). This feature can be used to
// test the resiliency of the client when communicating with a problematic // test the resiliency of the client when communicating with a problematic
......
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