| Index: sync/engine/syncer_unittest.cc
|
| diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
|
| index dcd326e8c887888ddab0eb867fafb20be8a07bcb..51d854685867fbc0a9d3df60f4edb7bc9bb64c8d 100644
|
| --- a/sync/engine/syncer_unittest.cc
|
| +++ b/sync/engine/syncer_unittest.cc
|
| @@ -20,6 +20,7 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/test/histogram_tester.h"
|
| #include "base/time/time.h"
|
| #include "build/build_config.h"
|
| #include "sync/engine/backoff_delay_provider.h"
|
| @@ -666,6 +667,86 @@ TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) {
|
| }
|
| }
|
|
|
| +// This test is based on SyncerTest.GetCommitIdsFiltersThrottledEntries. After
|
| +// different steps in that test, the progress is verified against expected
|
| +// progress.
|
| +TEST_F(SyncerTest, DataUseHistogramsTest) {
|
| + base::HistogramTester histogram_tester;
|
| + const ModelTypeSet throttled_types(BOOKMARKS);
|
| + sync_pb::EntitySpecifics bookmark_data;
|
| + AddDefaultFieldValue(BOOKMARKS, &bookmark_data);
|
| +
|
| + mock_server_->AddUpdateDirectory(1, 0, "A", 10, 10,
|
| + foreign_cache_guid(), "-1");
|
| + EXPECT_TRUE(SyncShareNudge());
|
| + {
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Upload.Count", 0);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Upload.Bytes", 0);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Count", 1);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Download.Count",
|
| + BOOKMARKS, 1);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Bytes", 63);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Download.Bytes",
|
| + BOOKMARKS, 63);
|
| + histogram_tester.ExpectBucketCount("DataUse.Sync.ProgressMarker.Bytes",
|
| + BOOKMARKS, 28);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.ProgressMarker.Bytes", 84);
|
| +
|
| + WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
|
| + MutableEntry A(&wtrans, GET_BY_ID, ids_.FromNumber(1));
|
| + A.PutIsUnsynced(true);
|
| + A.PutSpecifics(bookmark_data);
|
| + A.PutNonUniqueName("bookmark");
|
| + }
|
| +
|
| + // Now sync without enabling bookmarks.
|
| + mock_server_->ExpectGetUpdatesRequestTypes(
|
| + Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS)));
|
| + ResetSession();
|
| + syncer_->NormalSyncShare(
|
| + Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS)),
|
| + &nudge_tracker_, session_.get());
|
| +
|
| + {
|
| + // Nothing should have been committed as bookmarks is throttled.
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Upload.Count", 0);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Upload.Bytes", 0);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Count", 1);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Download.Count",
|
| + BOOKMARKS, 1);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Bytes", 63);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Download.Bytes",
|
| + BOOKMARKS, 63);
|
| + histogram_tester.ExpectBucketCount("DataUse.Sync.ProgressMarker.Bytes",
|
| + BOOKMARKS, 28);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.ProgressMarker.Bytes", 140);
|
| +
|
| + }
|
| +
|
| + // Sync again with bookmarks enabled.
|
| + mock_server_->ExpectGetUpdatesRequestTypes(context_->GetEnabledTypes());
|
| + EXPECT_TRUE(SyncShareNudge());
|
| + {
|
| + // It should have been committed.
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Upload.Count", 1);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Upload.Count",
|
| + BOOKMARKS, 1);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Upload.Bytes", 91);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Upload.Bytes",
|
| + BOOKMARKS, 91);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Count", 1);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Download.Count",
|
| + BOOKMARKS, 1);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Bytes", 63);
|
| + histogram_tester.ExpectUniqueSample("DataUse.Sync.Download.Bytes",
|
| + BOOKMARKS, 63);
|
| + histogram_tester.ExpectBucketCount("DataUse.Sync.ProgressMarker.Bytes",
|
| + BOOKMARKS, 56);
|
| + histogram_tester.ExpectTotalCount("DataUse.Sync.ProgressMarker.Bytes", 224);
|
| +
|
| + }
|
| +}
|
| +
|
| // We use a macro so we can preserve the error location.
|
| #define VERIFY_ENTRY(id, is_unapplied, is_unsynced, prev_initialized, \
|
| parent_id, version, server_version, id_fac, rtrans) \
|
|
|