Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Unified Diff: sync/engine/syncer_unittest.cc

Issue 1273303002: Measuring data use of different ModelTypes in Sync Service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewServices
Patch Set: Updating some of the comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/engine/syncer_unittest.cc
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index dcd326e8c887888ddab0eb867fafb20be8a07bcb..6e3e09d4dc702de8a7fb0810f948daff49adce89 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 has three steps. In the first steps BOOKMARKS are sync and they are
Nicolas Zea 2015/08/18 21:55:18 nit: "BOOKMARKS are sync and they are downloaded"
amohammadkhan 2015/08/19 17:33:35 Done.
+// downloaded. In the next step, syncing BOOKMARKS is disabled, so no BOOKMARK
+// is uploaded or downloaded. In the last step, BOOKMARKS are uploaded and
+// committed to server.
+TEST_F(SyncerTest, DataUseHistogramsTest) {
+ base::HistogramTester histogram_tester;
+ const ModelTypeSet throttled_types(BOOKMARKS);
Nicolas Zea 2015/08/18 21:55:18 throttled_types appears to be unused?
amohammadkhan 2015/08/19 17:33:36 Done.
+ 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);
Nicolas Zea 2015/08/18 21:55:18 Where are these byte values from? It would be good
amohammadkhan 2015/08/19 17:33:35 I got those values by test and you are right, they
+ 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) \

Powered by Google App Engine
This is Rietveld 408576698