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

Unified Diff: components/sync/protocol/proto_size_estimations_unittest.cc

Issue 2382443006: Sync MDP: implement MemoryDumpProvider
Patch Set: Created 4 years, 3 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: components/sync/protocol/proto_size_estimations_unittest.cc
diff --git a/components/sync/protocol/proto_size_estimations_unittest.cc b/components/sync/protocol/proto_size_estimations_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2c3a2fe3b43826f8b9333acc1792a51dcc7a1b98
--- /dev/null
+++ b/components/sync/protocol/proto_size_estimations_unittest.cc
@@ -0,0 +1,147 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/debug/scoped_thread_heap_usage.h"
+#include "base/logging.h"
+#include "build/build_config.h"
+#include "components/sync/protocol/app_list_specifics.pb.h"
+#include "components/sync/protocol/app_notification_specifics.pb.h"
+#include "components/sync/protocol/app_setting_specifics.pb.h"
+#include "components/sync/protocol/app_specifics.pb.h"
+#include "components/sync/protocol/arc_package_specifics.pb.h"
+#include "components/sync/protocol/autofill_specifics.pb.h"
+#include "components/sync/protocol/bookmark_specifics.pb.h"
+#include "components/sync/protocol/dictionary_specifics.pb.h"
+#include "components/sync/protocol/encryption.pb.h"
+#include "components/sync/protocol/entity_metadata.pb.h"
+#include "components/sync/protocol/experiments_specifics.pb.h"
+#include "components/sync/protocol/extension_setting_specifics.pb.h"
+#include "components/sync/protocol/extension_specifics.pb.h"
+#include "components/sync/protocol/favicon_image_specifics.pb.h"
+#include "components/sync/protocol/favicon_tracking_specifics.pb.h"
+#include "components/sync/protocol/history_delete_directive_specifics.pb.h"
+#include "components/sync/protocol/nigori_specifics.pb.h"
+#include "components/sync/protocol/password_specifics.pb.h"
+#include "components/sync/protocol/preference_specifics.pb.h"
+#include "components/sync/protocol/printer_specifics.pb.h"
+#include "components/sync/protocol/priority_preference_specifics.pb.h"
+#include "components/sync/protocol/proto_enum_conversions.h"
+#include "components/sync/protocol/proto_size_estimations.h"
+#include "components/sync/protocol/proto_unittest_serialized_data.h"
+#include "components/sync/protocol/reading_list_specifics.pb.h"
+#include "components/sync/protocol/search_engine_specifics.pb.h"
+#include "components/sync/protocol/session_specifics.pb.h"
+#include "components/sync/protocol/sync.pb.h"
+#include "components/sync/protocol/theme_specifics.pb.h"
+#include "components/sync/protocol/typed_url_specifics.pb.h"
+#include "components/sync/protocol/unique_position.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
+
+namespace syncer {
+namespace {
+
+using base::debug::ScopedThreadHeapUsage;
+
+class TestingScopedThreadHeapUsage : public ScopedThreadHeapUsage {
+ public:
+ using ScopedThreadHeapUsage::DisableHeapTrackingForTesting;
+};
+
+class ProtoSizeEstimationsTest : public testing::Test {
+ public:
+ void SetUp() override {
+ TestingScopedThreadHeapUsage::Initialize();
+ TestingScopedThreadHeapUsage::EnableHeapTracking();
+ }
+ void TearDown() override {
+ TestingScopedThreadHeapUsage::DisableHeapTrackingForTesting();
+ }
+};
+
+#define IMPLEMENT_TEST(Proto) \
+ TEST_F(ProtoSizeEstimationsTest, Proto) { \
+ sync_pb::Proto proto; \
+ const auto& serialized_data = SerializedProto<sync_pb::Proto>::data; \
+ \
+ base::debug::ScopedThreadHeapUsage scoped_heap_usage; \
+ auto usage_before = ScopedThreadHeapUsage::CurrentUsage(); \
+ EXPECT_TRUE(proto.ParseFromArray(serialized_data, sizeof(serialized_data))); \
+ auto usage_after = ScopedThreadHeapUsage::CurrentUsage(); \
+ \
+ size_t memory_usage = \
+ (usage_after.alloc_bytes - usage_before.alloc_bytes) - \
+ (usage_after.free_bytes - usage_before.free_bytes); \
+ size_t estimated_memory_usage = sync_pb::EstimateMemoryUsage(proto); \
+ \
+ EXPECT_EQ(memory_usage, estimated_memory_usage); \
+ }
+
+IMPLEMENT_TEST(EncryptedData)
+IMPLEMENT_TEST(AppListSpecifics)
+IMPLEMENT_TEST(AppNotificationSettings)
+IMPLEMENT_TEST(LinkedAppIconInfo)
+IMPLEMENT_TEST(ArcPackageSpecifics)
+IMPLEMENT_TEST(SessionHeader)
+IMPLEMENT_TEST(SessionTab)
+IMPLEMENT_TEST(SessionWindow)
+IMPLEMENT_TEST(TabNavigation)
+IMPLEMENT_TEST(NavigationRedirect)
+IMPLEMENT_TEST(PasswordSpecificsData)
+IMPLEMENT_TEST(GlobalIdDirective)
+IMPLEMENT_TEST(TimeRangeDirective)
+IMPLEMENT_TEST(SessionSpecifics)
+IMPLEMENT_TEST(PrinterPPDData)
+IMPLEMENT_TEST(AppNotification)
+IMPLEMENT_TEST(AppSettingSpecifics)
+IMPLEMENT_TEST(AppSpecifics)
+IMPLEMENT_TEST(ArticleSpecifics)
+IMPLEMENT_TEST(AutofillSpecifics)
+IMPLEMENT_TEST(AutofillProfileSpecifics)
+IMPLEMENT_TEST(WalletMetadataSpecifics)
+IMPLEMENT_TEST(AutofillWalletSpecifics)
+IMPLEMENT_TEST(BookmarkSpecifics)
+IMPLEMENT_TEST(DeviceInfoSpecifics)
+IMPLEMENT_TEST(DictionarySpecifics)
+IMPLEMENT_TEST(ExperimentsSpecifics)
+IMPLEMENT_TEST(PriorityPreferenceSpecifics)
+IMPLEMENT_TEST(ExtensionSettingSpecifics)
+IMPLEMENT_TEST(ExtensionSpecifics)
+IMPLEMENT_TEST(FaviconImageSpecifics)
+IMPLEMENT_TEST(FaviconTrackingSpecifics)
+IMPLEMENT_TEST(HistoryDeleteDirectiveSpecifics)
+IMPLEMENT_TEST(ManagedUserSettingSpecifics)
+IMPLEMENT_TEST(ManagedUserSpecifics)
+IMPLEMENT_TEST(ManagedUserSharedSettingSpecifics)
+IMPLEMENT_TEST(ManagedUserWhitelistSpecifics)
+IMPLEMENT_TEST(NigoriSpecifics)
+IMPLEMENT_TEST(PasswordSpecifics)
+IMPLEMENT_TEST(PreferenceSpecifics)
+IMPLEMENT_TEST(PrinterSpecifics)
+IMPLEMENT_TEST(ReadingListSpecifics)
+IMPLEMENT_TEST(SyncedNotificationAppInfoSpecifics)
+IMPLEMENT_TEST(SyncedNotificationSpecifics)
+IMPLEMENT_TEST(SearchEngineSpecifics)
+IMPLEMENT_TEST(ThemeSpecifics)
+IMPLEMENT_TEST(TypedUrlSpecifics)
+IMPLEMENT_TEST(WalletMaskedCreditCard)
+IMPLEMENT_TEST(WalletPostalAddress)
+IMPLEMENT_TEST(WifiCredentialSpecifics)
+IMPLEMENT_TEST(EntitySpecifics)
+IMPLEMENT_TEST(SyncEntity)
+// IMPLEMENT_TEST(ClientToServerMessage)
+// IMPLEMENT_TEST(ClientToServerResponse)
+IMPLEMENT_TEST(DatatypeAssociationStats)
+IMPLEMENT_TEST(DebugEventInfo)
+IMPLEMENT_TEST(DebugInfo)
+IMPLEMENT_TEST(SyncCycleCompletedEventInfo)
+IMPLEMENT_TEST(ClientConfigParams)
+IMPLEMENT_TEST(AttachmentIdProto)
+IMPLEMENT_TEST(EntityMetadata)
+
+} // namespace
+} // namespace syncer
+
+#endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
« no previous file with comments | « components/sync/protocol/proto_size_estimations.cc ('k') | components/sync/protocol/proto_value_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698