summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-14 16:29:47 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-14 16:29:47 +0200
commitd0424a769059c84ae20beb3c217812792ea6726b (patch)
tree6f94a5c3db8c52c6694ee56498542a6c35417350 /Source/WebKit/chromium/tests
parent88a04ac016f57c2d78e714682445dff2e7db4ade (diff)
downloadqtwebkit-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')
-rw-r--r--Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp1
-rw-r--r--Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp115
-rw-r--r--Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp15
-rw-r--r--Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp38
-rw-r--r--Source/WebKit/chromium/tests/IDBFakeBackingStore.h1
-rw-r--r--Source/WebKit/chromium/tests/LocaleMacTest.cpp30
-rw-r--r--Source/WebKit/chromium/tests/LocaleWinTest.cpp24
-rw-r--r--Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp4
-rw-r--r--Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp14
-rw-r--r--Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp47
-rw-r--r--Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp10
11 files changed, 208 insertions, 91 deletions
diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
index d7e955783..3c47864ee 100644
--- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
@@ -89,6 +89,7 @@ public:
virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = true; }
virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; }
virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE { }
+ virtual void releaseContentsTexturesOnImplThread() OVERRIDE { }
PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOwnPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr)
{
diff --git a/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp b/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp
index 9076d34d4..7925f5d74 100644
--- a/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp
+++ b/Source/WebKit/chromium/tests/CCPrioritizedTextureTest.cpp
@@ -38,7 +38,7 @@ using namespace WebCore;
using namespace WebKitTests;
using namespace WTF;
-namespace {
+namespace WebCore {
class CCPrioritizedTextureTest : public testing::Test {
public:
@@ -70,11 +70,10 @@ public:
bool validateTexture(OwnPtr<CCPrioritizedTexture>& texture, bool requestLate)
{
-#if !ASSERT_DISABLED
- texture->textureManager()->assertInvariants();
-#endif
+ textureManagerAssertInvariants(texture->textureManager());
if (requestLate)
texture->requestLate();
+ textureManagerAssertInvariants(texture->textureManager());
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
bool success = texture->canAcquireBackingTexture();
if (success)
@@ -82,11 +81,36 @@ public:
return success;
}
+ void prioritizeTexturesAndBackings(CCPrioritizedTextureManager* textureManager)
+ {
+ textureManager->prioritizeTextures();
+ textureManagerUpdateBackingsPriorities(textureManager);
+ }
+
+ void textureManagerUpdateBackingsPriorities(CCPrioritizedTextureManager* textureManager)
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ textureManager->updateBackingsPriorities();
+ }
+
CCResourceProvider* resourceProvider()
{
return m_resourceProvider.get();
}
+ void textureManagerAssertInvariants(CCPrioritizedTextureManager* textureManager)
+ {
+#if !ASSERT_DISABLED
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ textureManager->assertInvariants();
+#endif
+ }
+
+ bool textureBackingIsAbovePriorityCutoff(CCPrioritizedTexture* texture)
+ {
+ return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate();
+ }
+
protected:
const IntSize m_textureSize;
const GC3Denum m_textureFormat;
@@ -95,6 +119,10 @@ protected:
OwnPtr<CCResourceProvider> m_resourceProvider;
};
+}
+
+namespace {
+
TEST_F(CCPrioritizedTextureTest, requestTextureExceedingMaxLimit)
{
const size_t maxTextures = 8;
@@ -111,7 +139,7 @@ TEST_F(CCPrioritizedTextureTest, requestTextureExceedingMaxLimit)
textures[i]->setRequestPriority(100 + i);
// Only lower half should be available.
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
EXPECT_TRUE(validateTexture(textures[0], false));
EXPECT_TRUE(validateTexture(textures[7], false));
EXPECT_FALSE(validateTexture(textures[8], false));
@@ -122,7 +150,7 @@ TEST_F(CCPrioritizedTextureTest, requestTextureExceedingMaxLimit)
textures[i]->setRequestPriority(100 - i);
// Only upper half should be available.
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
EXPECT_FALSE(validateTexture(textures[0], false));
EXPECT_FALSE(validateTexture(textures[7], false));
EXPECT_TRUE(validateTexture(textures[8], false));
@@ -148,7 +176,7 @@ TEST_F(CCPrioritizedTextureTest, changeMemoryLimits)
// Set max limit to 8 textures
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
for (size_t i = 0; i < maxTextures; ++i)
validateTexture(textures[i], false);
{
@@ -161,7 +189,7 @@ TEST_F(CCPrioritizedTextureTest, changeMemoryLimits)
// Set max limit to 5 textures
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(5));
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
for (size_t i = 0; i < maxTextures; ++i)
EXPECT_EQ(validateTexture(textures[i], false), i < 5);
{
@@ -174,7 +202,7 @@ TEST_F(CCPrioritizedTextureTest, changeMemoryLimits)
// Set max limit to 4 textures
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(4));
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
for (size_t i = 0; i < maxTextures; ++i)
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
{
@@ -204,7 +232,7 @@ TEST_F(CCPrioritizedTextureTest, textureManagerPartialUpdateTextures)
for (size_t i = 0; i < numTextures; ++i)
textures[i]->setRequestPriority(200 + i);
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
// Allocate textures which are currently high priority.
EXPECT_TRUE(validateTexture(textures[0], false));
@@ -219,7 +247,7 @@ TEST_F(CCPrioritizedTextureTest, textureManagerPartialUpdateTextures)
for (size_t i = 0; i < numTextures; ++i)
moreTextures[i]->setRequestPriority(100 + i);
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
// Textures are now below cutoff.
EXPECT_FALSE(validateTexture(textures[0], false));
@@ -266,7 +294,7 @@ TEST_F(CCPrioritizedTextureTest, textureManagerPrioritiesAreEqual)
// Set max limit to 8 textures
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
// The two high priority textures should be available, others should not.
for (size_t i = 0; i < 2; ++i)
@@ -298,7 +326,7 @@ TEST_F(CCPrioritizedTextureTest, textureManagerDestroyedFirst)
EXPECT_FALSE(texture->haveBackingTexture());
texture->setRequestPriority(100);
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
EXPECT_TRUE(validateTexture(texture, false));
EXPECT_TRUE(texture->canAcquireBackingTexture());
@@ -324,7 +352,7 @@ TEST_F(CCPrioritizedTextureTest, textureMovedToNewManager)
EXPECT_FALSE(texture->haveBackingTexture());
texture->setRequestPriority(100);
- textureManagerOne->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManagerOne.get());
EXPECT_TRUE(validateTexture(texture, false));
EXPECT_TRUE(texture->canAcquireBackingTexture());
@@ -343,7 +371,7 @@ TEST_F(CCPrioritizedTextureTest, textureMovedToNewManager)
texture->setTextureManager(textureManagerTwo.get());
- textureManagerTwo->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManagerTwo.get());
EXPECT_TRUE(validateTexture(texture, false));
EXPECT_TRUE(texture->canAcquireBackingTexture());
@@ -374,7 +402,7 @@ TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootS
textures[i]->setRequestPriority(100 + i);
// Only lower half should be available.
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
EXPECT_TRUE(validateTexture(textures[0], false));
EXPECT_TRUE(validateTexture(textures[3], false));
EXPECT_FALSE(validateTexture(textures[4], false));
@@ -385,7 +413,7 @@ TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootS
textures[i]->setRequestPriority(100 - i);
// Only upper half should be available.
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
EXPECT_FALSE(validateTexture(textures[0], false));
EXPECT_FALSE(validateTexture(textures[3], false));
EXPECT_TRUE(validateTexture(textures[4], false));
@@ -420,7 +448,7 @@ TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLa
textures[i]->setRequestPriority(100);
// The first four to be requested late will be available.
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
for (unsigned i = 0; i < maxTextures; ++i)
EXPECT_FALSE(validateTexture(textures[i], false));
for (unsigned i = 0; i < maxTextures; i += 2)
@@ -458,7 +486,7 @@ TEST_F(CCPrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAva
for (size_t i = 6; i < 8; ++i)
textures[i]->setRequestPriority(CCPriorityCalculator::visiblePriority(false));
- textureManager->prioritizeTextures();
+ prioritizeTexturesAndBackings(textureManager.get());
// Unable to requestLate textures in the child surface.
EXPECT_FALSE(validateTexture(textures[6], true));
@@ -476,4 +504,53 @@ TEST_F(CCPrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAva
textureManager->clearAllMemory(resourceProvider());
}
+TEST_F(CCPrioritizedTextureTest, requestLateBackingsSorting)
+{
+ const size_t maxTextures = 8;
+ OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextures);
+ textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
+
+ // Create textures to fill our memory limit.
+ OwnPtr<CCPrioritizedTexture> textures[maxTextures];
+ for (size_t i = 0; i < maxTextures; ++i)
+ textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
+
+ // Set equal priorities, and allocate backings for all textures.
+ for (size_t i = 0; i < maxTextures; ++i)
+ textures[i]->setRequestPriority(100);
+ prioritizeTexturesAndBackings(textureManager.get());
+ for (unsigned i = 0; i < maxTextures; ++i)
+ EXPECT_TRUE(validateTexture(textures[i], false));
+
+ // Drop the memory limit and prioritize (none will be above the threshold,
+ // but they still have backings because reduceMemory hasn't been called).
+ textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures / 2));
+ prioritizeTexturesAndBackings(textureManager.get());
+
+ // Push half of them back over the limit.
+ for (size_t i = 0; i < maxTextures; i += 2)
+ EXPECT_TRUE(textures[i]->requestLate());
+
+ // Push the priorities to the backings array and sort the backings array
+ textureManagerUpdateBackingsPriorities(textureManager.get());
+
+ // Assert that the backings list be sorted with the below-limit backings
+ // before the above-limit backings.
+ textureManagerAssertInvariants(textureManager.get());
+
+ // Make sure that we have backings for all of the textures.
+ for (size_t i = 0; i < maxTextures; ++i)
+ EXPECT_TRUE(textures[i]->haveBackingTexture());
+
+ // Make sure that only the requestLate textures are above the priority cutoff
+ for (size_t i = 0; i < maxTextures; i += 2)
+ EXPECT_TRUE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
+ for (size_t i = 1; i < maxTextures; i += 2)
+ EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
+
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ textureManager->clearAllMemory(resourceProvider());
+}
+
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp b/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
index 1d395096a..b080bfc4d 100644
--- a/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
+++ b/Source/WebKit/chromium/tests/IDBAbortOnCorruptTest.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "IDBCursorBackendInterface.h"
#include "IDBDatabaseBackendInterface.h"
+#include "IDBDatabaseCallbacks.h"
#include "IDBFactoryBackendImpl.h"
#include "IDBFakeBackingStore.h"
#include "SecurityOrigin.h"
@@ -96,14 +97,26 @@ protected:
}
};
+class FakeIDBDatabaseCallbacks : public IDBDatabaseCallbacks {
+public:
+ static PassRefPtr<FakeIDBDatabaseCallbacks> create() { return adoptRef(new FakeIDBDatabaseCallbacks()); }
+ virtual ~FakeIDBDatabaseCallbacks() { }
+ virtual void onVersionChange(const String& version) OVERRIDE { }
+ virtual void onVersionChange(int64_t oldVersion, int64_t newVersion) OVERRIDE { }
+ virtual void onForcedClose() OVERRIDE { }
+private:
+ FakeIDBDatabaseCallbacks() { }
+};
+
TEST(IDBAbortTest, TheTest)
{
RefPtr<IDBFactoryBackendImpl> factory = FailingIDBFactoryBackendImpl::create();
const String& name = "db name";
MockIDBCallbacks callbacks;
+ RefPtr<FakeIDBDatabaseCallbacks> databaseCallbacks = FakeIDBDatabaseCallbacks::create();
RefPtr<SecurityOrigin> origin = SecurityOrigin::create("http", "localhost", 81);
const int64_t DummyVersion = 2;
- factory->open(name, DummyVersion, &callbacks, origin, 0 /*Frame*/, String() /*path*/);
+ factory->open(name, DummyVersion, &callbacks, databaseCallbacks, origin, 0 /*Frame*/, String() /*path*/);
}
} // namespace
diff --git a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
index 1fa2c262d..cb94243d0 100644
--- a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
+++ b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
@@ -27,6 +27,7 @@
#include "IDBBackingStore.h"
#include "IDBCursorBackendInterface.h"
#include "IDBDatabaseBackendImpl.h"
+#include "IDBDatabaseCallbacksProxy.h"
#include "IDBFactoryBackendImpl.h"
#include "IDBFakeBackingStore.h"
#include "IDBIndexBackendImpl.h"
@@ -40,9 +41,10 @@
#if ENABLE(INDEXED_DATABASE)
using namespace WebCore;
+using WebKit::IDBDatabaseCallbacksProxy;
using WebKit::WebIDBDatabase;
-using WebKit::WebIDBDatabaseCallbacksImpl;
using WebKit::WebIDBDatabaseImpl;
+using WebKit::WebIDBDatabaseCallbacksImpl;
namespace {
@@ -122,20 +124,16 @@ TEST(IDBDatabaseBackendTest, ConnectionLifecycle)
EXPECT_GT(backingStore->refCount(), 1);
RefPtr<MockIDBCallbacks> request1 = MockIDBCallbacks::create();
- db->openConnection(request1);
-
RefPtr<FakeIDBDatabaseCallbacks> connection1 = FakeIDBDatabaseCallbacks::create();
- db->registerFrontendCallbacks(connection1);
+ db->openConnection(request1, connection1);
RefPtr<MockIDBCallbacks> request2 = MockIDBCallbacks::create();
- db->openConnection(request2);
+ RefPtr<FakeIDBDatabaseCallbacks> connection2 = FakeIDBDatabaseCallbacks::create();
+ db->openConnection(request2, connection2);
db->close(connection1);
EXPECT_GT(backingStore->refCount(), 1);
- RefPtr<FakeIDBDatabaseCallbacks> connection2 = FakeIDBDatabaseCallbacks::create();
- db->registerFrontendCallbacks(connection2);
-
db->close(connection2);
EXPECT_TRUE(backingStore->hasOneRef());
}
@@ -149,7 +147,7 @@ public:
~MockIDBDatabaseBackendProxy()
{
- EXPECT_TRUE(m_wasRegisterFrontendCallbacksCalled);
+ EXPECT_TRUE(m_wasCloseCalled);
}
virtual IDBDatabaseMetadata metadata() const { return IDBDatabaseMetadata(); }
@@ -163,19 +161,12 @@ public:
m_wasCloseCalled = true;
m_webDatabase.close();
}
- virtual void registerFrontendCallbacks(PassRefPtr<IDBDatabaseCallbacks> connection)
- {
- m_wasRegisterFrontendCallbacksCalled = true;
- m_webDatabase.open(new WebIDBDatabaseCallbacksImpl(connection));
- }
private:
MockIDBDatabaseBackendProxy(WebIDBDatabaseImpl& webDatabase)
- : m_wasRegisterFrontendCallbacksCalled(false)
- , m_wasCloseCalled(false)
+ : m_wasCloseCalled(false)
, m_webDatabase(webDatabase) { }
- bool m_wasRegisterFrontendCallbacksCalled;
bool m_wasCloseCalled;
WebIDBDatabaseImpl& m_webDatabase;
@@ -191,18 +182,19 @@ TEST(IDBDatabaseBackendTest, ForcedClose)
RefPtr<IDBDatabaseBackendImpl> backend = IDBDatabaseBackendImpl::create("db", backingStore.get(), coordinator, factory, "uniqueid");
EXPECT_GT(backingStore->refCount(), 1);
- WebIDBDatabaseImpl webDatabase(backend);
-
- RefPtr<MockIDBCallbacks> request1 = MockIDBCallbacks::create();
- backend->openConnection(request1);
+ RefPtr<FakeIDBDatabaseCallbacks> connection = FakeIDBDatabaseCallbacks::create();
+ RefPtr<IDBDatabaseCallbacksProxy> connectionProxy = IDBDatabaseCallbacksProxy::create(adoptPtr(new WebIDBDatabaseCallbacksImpl(connection)));
+ WebIDBDatabaseImpl webDatabase(backend, connectionProxy);
RefPtr<MockIDBDatabaseBackendProxy> proxy = MockIDBDatabaseBackendProxy::create(webDatabase);
+ RefPtr<MockIDBCallbacks> request = MockIDBCallbacks::create();
+ backend->openConnection(request, connectionProxy);
ScriptExecutionContext* context = 0;
- RefPtr<IDBDatabase> idbDatabase = IDBDatabase::create(context, proxy);
- idbDatabase->registerFrontendCallbacks();
+ RefPtr<IDBDatabase> idbDatabase = IDBDatabase::create(context, proxy, connection);
webDatabase.forceClose();
+
EXPECT_TRUE(backingStore->hasOneRef());
}
diff --git a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
index 8862b58d4..e0a5a8fa5 100644
--- a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
+++ b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
@@ -63,6 +63,7 @@ public:
virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) OVERRIDE { return PassRefPtr<IDBKey>(); }
virtual bool keyExistsInIndex(int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey) OVERRIDE { return false; }
+ virtual PassRefPtr<Cursor> openObjectStoreKeyCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); }
virtual PassRefPtr<Cursor> openObjectStoreCursor(int64_t databaseId, int64_t objectStoreId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); }
virtual PassRefPtr<Cursor> openIndexKeyCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); }
virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction) OVERRIDE { return PassRefPtr<Cursor>(); }
diff --git a/Source/WebKit/chromium/tests/LocaleMacTest.cpp b/Source/WebKit/chromium/tests/LocaleMacTest.cpp
index eb86a2f68..afcd0b889 100644
--- a/Source/WebKit/chromium/tests/LocaleMacTest.cpp
+++ b/Source/WebKit/chromium/tests/LocaleMacTest.cpp
@@ -101,16 +101,16 @@ protected:
#endif
#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
- String timeFormatText(const String& localeString)
+ String timeFormat(const String& localeString)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
- return locale->timeFormatText();
+ return locale->timeFormat();
}
- String shortTimeFormatText(const String& localeString)
+ String shortTimeFormat(const String& localeString)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
- return locale->shortTimeFormatText();
+ return locale->shortTimeFormat();
}
String timeAMPMLabel(const String& localeString, unsigned index)
@@ -188,18 +188,18 @@ TEST_F(LocaleMacTest, weekDayShortLabels)
#endif
#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
-TEST_F(LocaleMacTest, timeFormatText)
+TEST_F(LocaleMacTest, timeFormat)
{
- EXPECT_STREQ("h:mm:ss a", timeFormatText("en_US").utf8().data());
- EXPECT_STREQ("HH:mm:ss", timeFormatText("fr_FR").utf8().data());
- EXPECT_STREQ("H:mm:ss", timeFormatText("ja_JP").utf8().data());
+ EXPECT_STREQ("h:mm:ss a", timeFormat("en_US").utf8().data());
+ EXPECT_STREQ("HH:mm:ss", timeFormat("fr_FR").utf8().data());
+ EXPECT_STREQ("H:mm:ss", timeFormat("ja_JP").utf8().data());
}
-TEST_F(LocaleMacTest, shortTimeFormatText)
+TEST_F(LocaleMacTest, shortTimeFormat)
{
- EXPECT_STREQ("h:mm a", shortTimeFormatText("en_US").utf8().data());
- EXPECT_STREQ("HH:mm", shortTimeFormatText("fr_FR").utf8().data());
- EXPECT_STREQ("H:mm", shortTimeFormatText("ja_JP").utf8().data());
+ EXPECT_STREQ("h:mm a", shortTimeFormat("en_US").utf8().data());
+ EXPECT_STREQ("HH:mm", shortTimeFormat("fr_FR").utf8().data());
+ EXPECT_STREQ("H:mm", shortTimeFormat("ja_JP").utf8().data());
}
TEST_F(LocaleMacTest, timeAMPMLabels)
@@ -221,6 +221,12 @@ TEST_F(LocaleMacTest, decimalSeparator)
}
#endif
+TEST_F(LocaleMacTest, invalidLocale)
+{
+ EXPECT_STREQ(monthLabel("en_US", January).utf8().data(), monthLabel("foo", January).utf8().data());
+ EXPECT_STREQ(decimalSeparator("en_US").utf8().data(), decimalSeparator("foo").utf8().data());
+}
+
static void testNumberIsReversible(const AtomicString& localeString, const char* original, const char* shouldHave = 0)
{
OwnPtr<Localizer> locale = Localizer::create(localeString);
diff --git a/Source/WebKit/chromium/tests/LocaleWinTest.cpp b/Source/WebKit/chromium/tests/LocaleWinTest.cpp
index 32aaa53d7..a3719f0d3 100644
--- a/Source/WebKit/chromium/tests/LocaleWinTest.cpp
+++ b/Source/WebKit/chromium/tests/LocaleWinTest.cpp
@@ -123,16 +123,16 @@ protected:
#endif
#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
- String timeFormatText(LCID lcid)
+ String timeFormat(LCID lcid)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
- return locale->timeFormatText();
+ return locale->timeFormat();
}
- String shortTimeFormatText(LCID lcid)
+ String shortTimeFormat(LCID lcid)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
- return locale->shortTimeFormatText();
+ return locale->shortTimeFormat();
}
String timeAMPMLabel(LCID lcid, unsigned index)
@@ -325,18 +325,18 @@ TEST_F(LocaleWinTest, weekDayShortLabels)
#endif
#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
-TEST_F(LocaleWinTest, timeFormatText)
+TEST_F(LocaleWinTest, timeFormat)
{
- EXPECT_STREQ("h:mm:ss a", timeFormatText(EnglishUS).utf8().data());
- EXPECT_STREQ("HH:mm:ss", timeFormatText(FrenchFR).utf8().data());
- EXPECT_STREQ("H:mm:ss", timeFormatText(JapaneseJP).utf8().data());
+ EXPECT_STREQ("h:mm:ss a", timeFormat(EnglishUS).utf8().data());
+ EXPECT_STREQ("HH:mm:ss", timeFormat(FrenchFR).utf8().data());
+ EXPECT_STREQ("H:mm:ss", timeFormat(JapaneseJP).utf8().data());
}
-TEST_F(LocaleWinTest, shortTimeFormatText)
+TEST_F(LocaleWinTest, shortTimeFormat)
{
- EXPECT_STREQ("h:mm:ss a", shortTimeFormatText(EnglishUS).utf8().data());
- EXPECT_STREQ("HH:mm:ss", shortTimeFormatText(FrenchFR).utf8().data());
- EXPECT_STREQ("H:mm:ss", shortTimeFormatText(JapaneseJP).utf8().data());
+ EXPECT_STREQ("h:mm:ss a", shortTimeFormat(EnglishUS).utf8().data());
+ EXPECT_STREQ("HH:mm:ss", shortTimeFormat(FrenchFR).utf8().data());
+ EXPECT_STREQ("H:mm:ss", shortTimeFormat(JapaneseJP).utf8().data());
}
TEST_F(LocaleWinTest, timeAMPMLabels)
diff --git a/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp b/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp
index ea725a9f7..749f91038 100644
--- a/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp
+++ b/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp
@@ -91,13 +91,13 @@ protected:
String localizedDateFormatText(const char* localeString)
{
OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
- return locale->localizedTimeFormatText();
+ return locale->timeFormat();
}
String localizedShortDateFormatText(const char* localeString)
{
OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
- return locale->localizedShortTimeFormatText();
+ return locale->shortTimeFormat();
}
Labels timeAMPMLabels(const char* localeString)
diff --git a/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp b/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp
index 9f89ce7a1..ec7de4e9e 100644
--- a/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp
+++ b/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp
@@ -36,13 +36,13 @@
using namespace WebCore;
-void testNumberIsReversible(const char* localeString, const char* original, const char* shouldHave = 0)
+void testNumberIsReversible(const AtomicString& locale, const char* original, const char* shouldHave = 0)
{
- OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
- String localized = locale->convertToLocalizedNumber(original);
+ OwnPtr<Localizer> localizer = Localizer::create(locale);
+ String localized = localizer->convertToLocalizedNumber(original);
if (shouldHave)
EXPECT_TRUE(localized.contains(shouldHave));
- String converted = locale->convertFromLocalizedNumber(localized);
+ String converted = localizer->convertFromLocalizedNumber(localized);
EXPECT_EQ(original, converted);
}
@@ -82,10 +82,10 @@ TEST(LocalizedNumberICUTest, Reversible)
#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
-static String testDecimalSeparator(const char* localeString)
+static String testDecimalSeparator(const AtomicString& locale)
{
- OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
- return locale->localizedDecimalSeparator();
+ OwnPtr<Localizer> localizer = Localizer::create(locale);
+ return localizer->localizedDecimalSeparator();
}
TEST(LocalizedNumberICUTest, localizedDecimalSeparator)
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
diff --git a/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp b/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp
index 9bda21764..0e83a84e1 100644
--- a/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp
+++ b/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp
@@ -99,13 +99,15 @@ TEST(PlatformGestureCurve, flingCurveTouch)
{
double initialVelocity = 5000;
MockPlatformGestureCurveTarget target;
- OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(TouchFlingPlatformGestureCurve::createForTouchPad(FloatPoint(initialVelocity, 0)), &target);
+ // Explicitly parametrized to make test non-brittle in face of
+ // parameter changes.
+ OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(TouchFlingPlatformGestureCurve::create(FloatPoint(initialVelocity, 0), -5.70762e+03f, 1.72e+02f, 3.7e+00f, 1.3f), &target);
- // Note: the expectations below are dependent on the value of sigma hard-coded in the curve parameters.
- // If the parameters change, then the tests values/expectations will need to be updated.
+ // Note: the expectations below are dependent on the curve parameters hard
+ // coded into the create call above.
EXPECT_TRUE(animation->animate(0));
EXPECT_TRUE(animation->animate(0.25));
- EXPECT_TRUE(animation->animate(0.45)); // Use non-uniform tick spacing.
+ EXPECT_TRUE(animation->animate(0.45f)); // Use non-uniform tick spacing.
EXPECT_TRUE(animation->animate(1));
EXPECT_FALSE(animation->animate(1.5));
EXPECT_NEAR(target.cumulativeDelta().x(), 1193, 1);