diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-14 16:29:47 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-14 16:29:47 +0200 |
commit | d0424a769059c84ae20beb3c217812792ea6726b (patch) | |
tree | 6f94a5c3db8c52c6694ee56498542a6c35417350 /Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp | |
parent | 88a04ac016f57c2d78e714682445dff2e7db4ade (diff) | |
download | qtwebkit-d0424a769059c84ae20beb3c217812792ea6726b.tar.gz |
Imported WebKit commit 37c5e5041d39a14ea0d429a77ebd352e4bd26516 (http://svn.webkit.org/repository/webkit/trunk@128608)
New snapshot that enables WebKit2 build on Windows (still some bugs) and allows for WebKit to be built with qmake && make
Diffstat (limited to 'Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp index 51b200ade..4a0a3cf81 100644 --- a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp +++ b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp @@ -40,6 +40,7 @@ #include <wtf/RefCounted.h> #include <wtf/Vector.h> #include <wtf/text/AtomicString.h> +#include <wtf/text/CString.h> #include <wtf/text/StringImpl.h> #include <wtf/text/WTFString.h> @@ -179,7 +180,7 @@ public: void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Undefined); + MemoryClassInfo info(memoryObjectInfo, this); } int m_data; }; @@ -228,26 +229,50 @@ TEST(MemoryInstrumentationTest, visitFirstMemberInNonVirtualClass) EXPECT_EQ(2, visitedObjects.size()); } -class StringOwnerInstrumented { +template<typename T> +class InstrumentedOwner { public: - StringOwnerInstrumented() : m_name("string") { } + template<typename V> + InstrumentedOwner(const V& value) : m_value(value) { } void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); - info.addInstrumentedMember(m_name); + info.addInstrumentedMember(m_value); } - String m_name; + T m_value; }; 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()); + { + VisitedObjects visitedObjects; + MemoryInstrumentationImpl impl(visitedObjects); + InstrumentedOwner<String> stringInstrumentedOwner("String"); + stringInstrumentedOwner.m_value.characters(); // Force 16bit shadow creation. + impl.addRootObject(stringInstrumentedOwner); + EXPECT_EQ(sizeof(StringImpl) + stringInstrumentedOwner.m_value.length() * 2, impl.reportedSizeForAllTypes()); + EXPECT_EQ(2, visitedObjects.size()); + } + + { + VisitedObjects visitedObjects; + MemoryInstrumentationImpl impl(visitedObjects); + InstrumentedOwner<AtomicString> atomicStringInstrumentedOwner("AtomicString"); + atomicStringInstrumentedOwner.m_value.string().characters(); // Force 16bit shadow creation. + impl.addRootObject(atomicStringInstrumentedOwner); + EXPECT_EQ(sizeof(StringImpl) + atomicStringInstrumentedOwner.m_value.length() * 2, impl.reportedSizeForAllTypes()); + EXPECT_EQ(2, visitedObjects.size()); + } + + { + VisitedObjects visitedObjects; + MemoryInstrumentationImpl impl(visitedObjects); + InstrumentedOwner<CString> cStringInstrumentedOwner("CString"); + impl.addRootObject(cStringInstrumentedOwner); + EXPECT_EQ(sizeof(WTF::CStringBuffer) + cStringInstrumentedOwner.m_value.length(), impl.reportedSizeForAllTypes()); + EXPECT_EQ(1, visitedObjects.size()); + } } } // namespace |