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

Unified Diff: base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc

Issue 1846333002: Revert of [tracing] Adding task information to heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « base/trace_event/heap_profiler_type_name_deduplicator.cc ('k') | base/trace_event/trace_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc
diff --git a/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc b/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc
index 8ab3f3719aaa82245c95b2fa87a5d60b461e4223..92ffcf83599ca9e579a0a61170ea890fbb069712 100644
--- a/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc
+++ b/base/trace_event/heap_profiler_type_name_deduplicator_unittest.cc
@@ -13,8 +13,6 @@
namespace base {
namespace trace_event {
-namespace {
-
// Define all strings once, because the deduplicator requires pointer equality,
// and string interning is unreliable.
const char kInt[] = "int";
@@ -22,42 +20,11 @@
const char kString[] = "string";
const char kNeedsEscape[] = "\"quotes\"";
-#if defined(OS_POSIX)
-const char kTaskFileName[] = "../../base/trace_event/trace_log.cc";
-const char kTaskPath[] = "base/trace_event";
-#else
-const char kTaskFileName[] = "..\\..\\base\\memory\\memory_win.cc";
-const char kTaskPath[] = "base\\memory";
-#endif
-
scoped_ptr<Value> DumpAndReadBack(const TypeNameDeduplicator& deduplicator) {
std::string json;
deduplicator.AppendAsTraceFormat(&json);
return JSONReader::Read(json);
}
-
-// Inserts a single type name into a new TypeNameDeduplicator instance and
-// checks if the value gets inserted and the exported value for |type_name| is
-// the same as |expected_value|.
-void TestInsertTypeAndReadback(const char* type_name,
- const char* expected_value) {
- scoped_ptr<TypeNameDeduplicator> dedup(new TypeNameDeduplicator);
- ASSERT_EQ(1, dedup->Insert(type_name));
-
- scoped_ptr<Value> type_names = DumpAndReadBack(*dedup);
- ASSERT_NE(nullptr, type_names);
-
- const DictionaryValue* dictionary;
- ASSERT_TRUE(type_names->GetAsDictionary(&dictionary));
-
- // When the type name was inserted, it got ID 1. The exported key "1"
- // should be equal to |expected_value|.
- std::string value;
- ASSERT_TRUE(dictionary->GetString("1", &value));
- ASSERT_EQ(expected_value, value);
-}
-
-} // namespace
TEST(TypeNameDeduplicatorTest, Deduplication) {
// The type IDs should be like this:
@@ -81,14 +48,22 @@
}
TEST(TypeNameDeduplicatorTest, EscapeTypeName) {
+ scoped_ptr<TypeNameDeduplicator> dedup(new TypeNameDeduplicator);
+ ASSERT_EQ(1, dedup->Insert(kNeedsEscape));
+
// Reading json should not fail, because the type name should have been
- // escaped properly and exported value should contain quotes.
- TestInsertTypeAndReadback(kNeedsEscape, kNeedsEscape);
-}
+ // escaped properly.
+ scoped_ptr<Value> type_names = DumpAndReadBack(*dedup);
+ ASSERT_NE(nullptr, type_names);
-TEST(TypeNameDeduplicatorTest, TestExtractFileName) {
- // The exported value for passed file name should be the folders in the path.
- TestInsertTypeAndReadback(kTaskFileName, kTaskPath);
+ const DictionaryValue* dictionary;
+ ASSERT_TRUE(type_names->GetAsDictionary(&dictionary));
+
+ // When the type name was inserted, it got ID 1. The exported key "1"
+ // should contain the name, with quotes.
+ std::string type_name;
+ ASSERT_TRUE(dictionary->GetString("1", &type_name));
+ ASSERT_EQ("\"quotes\"", type_name);
}
} // namespace trace_event
« no previous file with comments | « base/trace_event/heap_profiler_type_name_deduplicator.cc ('k') | base/trace_event/trace_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698