Index: sync/engine/syncer_unittest.cc |
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc |
index dcd326e8c887888ddab0eb867fafb20be8a07bcb..8559731a9dded8c4fb1e021eefbd1efbd94b211f 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,61 @@ 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); |
sclittle
2015/08/14 19:10:59
Instead of ExpectTotalCount, could you use ExpectU
amohammadkhan
2015/08/17 17:56:16
Done.
|
+ histogram_tester.ExpectTotalCount("DataUse.Sync.Upload.Bytes", 0); |
+ histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Count", 1); |
+ histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Bytes", 63); |
+ 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.ExpectTotalCount("DataUse.Sync.Download.Bytes", 63); |
+ 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.ExpectTotalCount("DataUse.Sync.Upload.Bytes", 91); |
+ histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Count", 1); |
+ histogram_tester.ExpectTotalCount("DataUse.Sync.Download.Bytes", 63); |
+ 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) \ |