summaryrefslogtreecommitdiffstats
path: root/sync/sessions
diff options
context:
space:
mode:
Diffstat (limited to 'sync/sessions')
-rw-r--r--sync/sessions/status_controller.h3
-rw-r--r--sync/sessions/sync_session_unittest.cc52
2 files changed, 6 insertions, 49 deletions
diff --git a/sync/sessions/status_controller.h b/sync/sessions/status_controller.h
index c2a3cfc..7e2f258 100644
--- a/sync/sessions/status_controller.h
+++ b/sync/sessions/status_controller.h
@@ -175,7 +175,8 @@ class StatusController {
// Returns true if the last download_updates_command received a valid
// server response.
bool download_updates_succeeded() const {
- return updates_response().has_get_updates();
+ return shared_.error.value().last_download_updates_result
+ == SYNCER_OK;
}
// Returns true if the last updates response indicated that we were fully
diff --git a/sync/sessions/sync_session_unittest.cc b/sync/sessions/sync_session_unittest.cc
index 48524a4..d5ce46a 100644
--- a/sync/sessions/sync_session_unittest.cc
+++ b/sync/sessions/sync_session_unittest.cc
@@ -215,6 +215,8 @@ TEST_F(SyncSessionTest, MoreToSyncIfUnsyncedGreaterThanCommitted) {
TEST_F(SyncSessionTest, MoreToDownloadIfDownloadFailed) {
status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
+ status()->set_last_download_updates_result(NETWORK_IO_ERROR);
+
// When DownloadUpdatesCommand fails, these should be false.
EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
EXPECT_FALSE(status()->download_updates_succeeded());
@@ -229,6 +231,7 @@ TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemaining) {
// When the server returns changes_remaining, that means there's
// more to download.
+ status()->set_last_download_updates_result(SYNCER_OK);
status()->mutable_updates_response()->mutable_get_updates()
->set_changes_remaining(1000L);
EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
@@ -242,54 +245,7 @@ TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemaining) {
TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemaining) {
status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
- // When the server returns a timestamp, that means we're up to date.
- status()->mutable_updates_response()->mutable_get_updates()
- ->set_changes_remaining(0);
- EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload());
- EXPECT_TRUE(status()->download_updates_succeeded());
-
- // Download updates has its own loop in the syncer; it shouldn't factor
- // into HasMoreToSync.
- EXPECT_FALSE(session_->HasMoreToSync());
-}
-
-TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemainingForSubset) {
- status()->set_updates_request_types(ParamsMeaningJustOneEnabledType());
-
- // When the server returns a timestamp, that means we're up to date for that
- // type. But there may still be more to download if there are other
- // datatypes that we didn't request on this go-round.
- status()->mutable_updates_response()->mutable_get_updates()
- ->set_changes_remaining(0);
-
- EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload());
- EXPECT_TRUE(status()->download_updates_succeeded());
-
- // Download updates has its own loop in the syncer; it shouldn't factor
- // into HasMoreToSync.
- EXPECT_FALSE(session_->HasMoreToSync());
-}
-
-TEST_F(SyncSessionTest, MoreToDownloadIfGotChangesRemainingAndEntries) {
- status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
- // The actual entry count should not factor into the HasMoreToSync
- // determination.
- status()->mutable_updates_response()->mutable_get_updates()->add_entries();
- status()->mutable_updates_response()->mutable_get_updates()
- ->set_changes_remaining(1000000L);;
- EXPECT_FALSE(status()->ServerSaysNothingMoreToDownload());
- EXPECT_TRUE(status()->download_updates_succeeded());
-
- // Download updates has its own loop in the syncer; it shouldn't factor
- // into HasMoreToSync.
- EXPECT_FALSE(session_->HasMoreToSync());
-}
-
-TEST_F(SyncSessionTest, MoreToDownloadIfGotNoChangesRemainingAndEntries) {
- status()->set_updates_request_types(ParamsMeaningAllEnabledTypes());
- // The actual entry count should not factor into the HasMoreToSync
- // determination.
- status()->mutable_updates_response()->mutable_get_updates()->add_entries();
+ status()->set_last_download_updates_result(SYNCER_OK);
status()->mutable_updates_response()->mutable_get_updates()
->set_changes_remaining(0);
EXPECT_TRUE(status()->ServerSaysNothingMoreToDownload());