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

Unified Diff: base/supports_user_data_unittest.cc

Issue 298023008: Make sure that when a SupportsUserData is destroyed, objects destroyed transitively see it as empty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« base/supports_user_data.cc ('K') | « base/supports_user_data.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/supports_user_data_unittest.cc
diff --git a/base/supports_user_data_unittest.cc b/base/supports_user_data_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6fb1102427556da5b24b68603972c1e1d30572c2
--- /dev/null
+++ b/base/supports_user_data_unittest.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 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/supports_user_data.h"
+
+#include <vector>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+
+namespace {
+
+struct TestSupportsUserData : public SupportsUserData {};
+
+struct UsesItself : public SupportsUserData::Data {
+ UsesItself(SupportsUserData* supports_user_data, const void* key)
+ : supports_user_data_(supports_user_data), key_(key) {}
Peter Kasting 2014/05/28 03:44:13 Nit: One initializer per line if they don't all fi
Jeffrey Yasskin 2014/05/28 05:45:26 Done, and filed b/15292387.
+ virtual ~UsesItself() {
+ EXPECT_EQ(NULL, supports_user_data_->GetUserData(key_));
+ }
+
+ SupportsUserData* supports_user_data_;
+ const void* key_;
+};
+
+TEST(SupportsUserDataTest, ClearWorksRecursively) {
+ TestSupportsUserData supports_user_data;
+ char key = 0;
+ supports_user_data.SetUserData(&key,
+ new UsesItself(&supports_user_data, &key));
+ // Destruction of supports_user_data runs the actual test.
+}
+
+} // namespace
+} // namespace base
Peter Kasting 2014/05/28 03:44:13 Nit: Either add a blank line here or take it out a
Jeffrey Yasskin 2014/05/28 05:45:26 Thanks; I've taken it out above.
« base/supports_user_data.cc ('K') | « base/supports_user_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698