| Index: net/base/sdch_manager_unittest.cc
|
| diff --git a/net/base/sdch_manager_unittest.cc b/net/base/sdch_manager_unittest.cc
|
| index bfdb78fc7ca8c9002879fbfc11082781fa12f3bf..53c0617b6efbf73a373e7561e0624fd49eee4be3 100644
|
| --- a/net/base/sdch_manager_unittest.cc
|
| +++ b/net/base/sdch_manager_unittest.cc
|
| @@ -13,6 +13,9 @@
|
| #include "base/macros.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/test/simple_test_clock.h"
|
| +#include "base/trace_event/memory_allocator_dump.h"
|
| +#include "base/trace_event/process_memory_dump.h"
|
| +#include "base/trace_event/trace_event_argument.h"
|
| #include "net/base/sdch_observer.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "url/gurl.h"
|
| @@ -636,4 +639,49 @@ TEST_F(SdchManagerTest, AddRemoveNotifications) {
|
| sdch_manager()->RemoveObserver(&observer);
|
| }
|
|
|
| +TEST_F(SdchManagerTest, DumpMemoryStats) {
|
| + MockSdchObserver observer;
|
| + sdch_manager()->AddObserver(&observer);
|
| +
|
| + std::string dictionary_domain("x.y.z.google.com");
|
| + GURL target_gurl("http://" + dictionary_domain);
|
| + std::string dictionary_text(NewSdchDictionary(dictionary_domain));
|
| + std::string client_hash;
|
| + std::string server_hash;
|
| + SdchManager::GenerateHash(dictionary_text, &client_hash, &server_hash);
|
| + EXPECT_TRUE(AddSdchDictionary(dictionary_text, target_gurl));
|
| + EXPECT_EQ(1, observer.dictionary_added_notifications());
|
| + EXPECT_EQ(target_gurl, observer.last_dictionary_url());
|
| + EXPECT_EQ(server_hash, observer.last_server_hash());
|
| +
|
| + base::trace_event::MemoryDumpArgs dump_args = {
|
| + base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
|
| + std::unique_ptr<base::trace_event::ProcessMemoryDump> pmd(
|
| + new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
|
| +
|
| + base::trace_event::MemoryAllocatorDump* parent =
|
| + pmd->CreateAllocatorDump("parent");
|
| + sdch_manager()->DumpMemoryStats(pmd.get(), parent->absolute_name());
|
| +
|
| + const base::trace_event::MemoryAllocatorDump* sub_dump =
|
| + pmd->GetAllocatorDump("parent/sdch_manager");
|
| + ASSERT_NE(nullptr, sub_dump);
|
| + const base::trace_event::MemoryAllocatorDump* dump = pmd->GetAllocatorDump(
|
| + base::StringPrintf("net/sdch_manager_%p", sdch_manager()));
|
| + std::unique_ptr<base::Value> raw_attrs =
|
| + dump->attributes_for_testing()->ToBaseValue();
|
| + base::DictionaryValue* attrs;
|
| + ASSERT_TRUE(raw_attrs->GetAsDictionary(&attrs));
|
| + ASSERT_TRUE(attrs->HasKey(base::trace_event::MemoryAllocatorDump::kNameSize));
|
| + base::DictionaryValue* count_attrs;
|
| + ASSERT_TRUE(attrs->GetDictionary(
|
| + base::trace_event::MemoryAllocatorDump::kNameObjectCount, &count_attrs));
|
| + std::string count;
|
| + ASSERT_TRUE(count_attrs->GetString("value", &count));
|
| + // One dictionary.
|
| + ASSERT_EQ("1", count);
|
| +
|
| + sdch_manager()->RemoveObserver(&observer);
|
| +}
|
| +
|
| } // namespace net
|
|
|