summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
commit284837daa07b29d6a63a748544a90b1f5842ac5c (patch)
treeecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
parent2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff)
downloadqtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp69
1 files changed, 32 insertions, 37 deletions
diff --git a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
index b5b50bf7d..51b200ade 100644
--- a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
+++ b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
@@ -32,6 +32,7 @@
#include "DataRef.h"
#include "MemoryInstrumentationImpl.h"
+#include "WebCoreMemoryInstrumentation.h"
#include <gtest/gtest.h>
@@ -58,7 +59,7 @@ public:
virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
info.addMember(m_notInstrumented);
}
NotInstrumented* m_notInstrumented;
@@ -122,7 +123,7 @@ public:
virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
info.addMember(m_notInstrumented);
}
NotInstrumented* m_notInstrumented;
@@ -155,7 +156,7 @@ public:
virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
Instrumented::reportMemoryUsage(memoryObjectInfo);
info.addMember(m_notInstrumentedOwnPtr);
}
@@ -172,27 +173,27 @@ TEST(MemoryInstrumentationTest, ownPtrNotInstrumented)
EXPECT_EQ(2, visitedObjects.size());
}
-class InstrumentedOther {
+class InstrumentedUndefined {
public:
- InstrumentedOther() : m_data(0) { }
+ InstrumentedUndefined() : m_data(0) { }
void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::Other);
+ MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Undefined);
}
int m_data;
};
class InstrumentedDOM {
public:
- InstrumentedDOM() : m_instrumentedOther(adoptPtr(new InstrumentedOther)) { }
+ InstrumentedDOM() : m_instrumentedUndefined(adoptPtr(new InstrumentedUndefined)) { }
void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
- info.addInstrumentedMember(m_instrumentedOther);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+ info.addInstrumentedMember(m_instrumentedUndefined);
}
- OwnPtr<InstrumentedOther> m_instrumentedOther;
+ OwnPtr<InstrumentedUndefined> m_instrumentedUndefined;
};
TEST(MemoryInstrumentationTest, ownerTypePropagation)
@@ -201,8 +202,8 @@ TEST(MemoryInstrumentationTest, ownerTypePropagation)
MemoryInstrumentationImpl impl(visitedObjects);
OwnPtr<InstrumentedDOM> instrumentedDOM(adoptPtr(new InstrumentedDOM));
impl.addRootObject(instrumentedDOM);
- EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedOther), impl.reportedSizeForAllTypes());
- EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedOther), impl.totalSize(MemoryInstrumentation::DOM));
+ EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedUndefined), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedUndefined), impl.totalSize(WebCoreMemoryTypes::DOM));
EXPECT_EQ(2, visitedObjects.size());
}
@@ -210,7 +211,7 @@ class NonVirtualInstrumented {
public:
void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
info.addInstrumentedMember(m_instrumented);
}
@@ -227,32 +228,26 @@ TEST(MemoryInstrumentationTest, visitFirstMemberInNonVirtualClass)
EXPECT_EQ(2, visitedObjects.size());
}
-TEST(MemoryInstrumentationTest, visitStrings)
-{
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- String string("string");
- impl.addRootObject(string);
- EXPECT_EQ(string.impl()->sizeInBytes(), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
- }
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- String string("string");
- impl.addRootObject(&string);
- EXPECT_EQ(string.impl()->sizeInBytes() + sizeof(String), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
- }
+class StringOwnerInstrumented {
+public:
+ StringOwnerInstrumented() : m_name("string") { }
+ void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- AtomicString string("string");
- impl.addRootObject(&string);
- EXPECT_EQ(string.impl()->sizeInBytes() + sizeof(AtomicString), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
+ MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+ info.addInstrumentedMember(m_name);
}
+
+ String m_name;
+};
+
+TEST(MemoryInstrumentationTest, visitStrings)
+{
+ VisitedObjects visitedObjects;
+ MemoryInstrumentationImpl impl(visitedObjects);
+ StringOwnerInstrumented stringOwnerInstrumented;
+ impl.addRootObject(stringOwnerInstrumented);
+ EXPECT_EQ(stringOwnerInstrumented.m_name.impl()->sizeInBytes(), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(2, visitedObjects.size());
}
} // namespace