diff options
| author | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-07 11:22:47 +0100 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-07 11:22:47 +0100 |
| commit | cfd86b747d32ac22246a1aa908eaa720c63a88c1 (patch) | |
| tree | 24d68c6f61c464ecba1e05670b80390ea3b0e50c /Source/WebKit/chromium/tests | |
| parent | 69d7c744c9de19d152dbe2d8e46eb7dfd4511d1a (diff) | |
| download | qtwebkit-cfd86b747d32ac22246a1aa908eaa720c63a88c1.tar.gz | |
Imported WebKit commit 20271caf2e2c016d5cef40184cddeefeac4f1876 (http://svn.webkit.org/repository/webkit/trunk@133733)
New snapshot that contains all previous fixes as well as build fix for latest QtMultimedia API changes.
Diffstat (limited to 'Source/WebKit/chromium/tests')
16 files changed, 323 insertions, 254 deletions
diff --git a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp index 0ce84257b..b04b3a945 100644 --- a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp @@ -52,8 +52,6 @@ class MockGraphicsLayerClient : public GraphicsLayerClient { virtual void notifyAnimationStarted(const GraphicsLayer*, double time) OVERRIDE { } virtual void notifyFlushRequired(const GraphicsLayer*) OVERRIDE { } virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) OVERRIDE { } - virtual bool showDebugBorders(const GraphicsLayer*) const OVERRIDE { return false; } - virtual bool showRepaintCounter(const GraphicsLayer*) const OVERRIDE { return false; } virtual float deviceScaleFactor() const OVERRIDE { return 2; } }; diff --git a/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp b/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp index 46710e745..a2a4f442d 100644 --- a/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp +++ b/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp @@ -24,11 +24,19 @@ */ #include "config.h" +#include "Document.h" +#include "Frame.h" +#include "FrameTestHelpers.h" #include "IDBBindingUtilities.h" #include "IDBKey.h" #include "IDBKeyPath.h" +#include "V8Binding.h" #include "V8PerIsolateData.h" #include "V8Utilities.h" +#include "WebFrame.h" +#include "WebFrameImpl.h" +#include "WebView.h" +#include "WorldContextHandle.h" #include <gtest/gtest.h> #include <wtf/Vector.h> @@ -36,6 +44,7 @@ #if ENABLE(INDEXED_DATABASE) using namespace WebCore; +using namespace WebKit; namespace { @@ -90,10 +99,21 @@ void checkKeyPathNumberValue(const ScriptValue& value, const String& keyPath, in ASSERT_TRUE(expected == idbKey->number()); } +static v8::Handle<v8::Context> context() +{ + static WebView* webView; + if (!webView) { + webView = FrameTestHelpers::createWebViewAndLoad("about:blank"); + webView->setFocus(true); + } + ScriptExecutionContext* context = static_cast<WebFrameImpl*>(webView->mainFrame())->frame()->document(); + return toV8Context(context, WorldContextHandle(UseCurrentWorld)); +} + TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) { v8::HandleScope handleScope; - v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); + v8::Context::Scope scope(context()); v8::Local<v8::Object> object = v8::Object::New(); object->Set(v8::String::New("foo"), v8::String::New("zoo")); @@ -107,7 +127,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue) TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) { v8::HandleScope handleScope; - v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); + v8::Context::Scope scope(context()); v8::Local<v8::Object> object = v8::Object::New(); object->Set(v8::String::New("foo"), v8::Number::New(456)); @@ -121,7 +141,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue) TEST(IDBKeyFromValueAndKeyPathTest, SubProperty) { v8::HandleScope handleScope; - v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); + v8::Context::Scope scope(context()); v8::Local<v8::Object> object = v8::Object::New(); v8::Local<v8::Object> subProperty = v8::Object::New(); @@ -137,7 +157,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, SubProperty) TEST(InjectIDBKeyTest, TopLevelPropertyStringValue) { v8::HandleScope handleScope; - v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); + v8::Context::Scope scope(context()); v8::Local<v8::Object> object = v8::Object::New(); object->Set(v8::String::New("foo"), v8::String::New("zoo")); @@ -152,7 +172,7 @@ TEST(InjectIDBKeyTest, TopLevelPropertyStringValue) TEST(InjectIDBKeyTest, SubProperty) { v8::HandleScope handleScope; - v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext()); + v8::Context::Scope scope(context()); v8::Local<v8::Object> object = v8::Object::New(); v8::Local<v8::Object> subProperty = v8::Object::New(); diff --git a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp index cee089c85..e97bc7f6d 100644 --- a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp +++ b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp @@ -57,12 +57,12 @@ TEST(IDBDatabaseBackendTest, BackingStoreRetention) EXPECT_GT(backingStore->refCount(), 1); const bool autoIncrement = false; - RefPtr<IDBObjectStoreBackendImpl> store = IDBObjectStoreBackendImpl::create(db.get(), 1, "store", IDBKeyPath("keyPath"), autoIncrement, 0); + RefPtr<IDBObjectStoreBackendImpl> store = IDBObjectStoreBackendImpl::create(db.get(), IDBObjectStoreMetadata("store", 1, IDBKeyPath("keyPath"), autoIncrement, 0)); EXPECT_GT(backingStore->refCount(), 1); const bool unique = false; const bool multiEntry = false; - RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(db.get(), store.get(), -1, "index", IDBKeyPath("keyPath"), unique, multiEntry); + RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(db.get(), store.get(), IDBIndexMetadata("index", -1, IDBKeyPath("keyPath"), unique, multiEntry)); EXPECT_GT(backingStore->refCount(), 1); db.clear(); @@ -152,8 +152,10 @@ public: virtual IDBDatabaseMetadata metadata() const { return IDBDatabaseMetadata(); } virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(int64_t, const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) { return 0; } virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&) { } + virtual void deleteObjectStore(int64_t, IDBTransactionBackendInterface*, ExceptionCode&) { } virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, ExceptionCode&) { } virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, ExceptionCode&) { return 0; } + virtual PassRefPtr<IDBTransactionBackendInterface> transaction(const Vector<int64_t>&, unsigned short mode) { return 0; } virtual void close(PassRefPtr<IDBDatabaseCallbacks>) { diff --git a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h index 45cdd1cb2..1f1640841 100644 --- a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h +++ b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h @@ -32,14 +32,14 @@ namespace WebCore { class IDBFakeBackingStore : public IDBBackingStore { public: - virtual void getDatabaseNames(Vector<String>& foundNames) OVERRIDE { } + virtual Vector<String> getDatabaseNames() OVERRIDE { return Vector<String>(); } virtual bool getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata*) OVERRIDE { return false; } virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) OVERRIDE { return true; } virtual bool updateIDBDatabaseMetaData(Transaction*, int64_t rowId, const String& version) OVERRIDE { return false; } virtual bool updateIDBDatabaseIntVersion(Transaction*, int64_t rowId, int64_t version) OVERRIDE { return false; } virtual bool deleteDatabase(const String& name) OVERRIDE { return false; } - virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags, Vector<int64_t>& foundMaxIndexIds) OVERRIDE { } + virtual Vector<IDBObjectStoreMetadata> getObjectStores(int64_t databaseId) OVERRIDE { return Vector<IDBObjectStoreMetadata>(); } virtual bool createObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { return false; }; virtual void deleteObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { } @@ -55,7 +55,7 @@ public: virtual bool forEachObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) OVERRIDE { return false; } - virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) OVERRIDE { } + virtual Vector<IDBIndexMetadata> getIndexes(int64_t databaseId, int64_t objectStoreId) OVERRIDE { return Vector<IDBIndexMetadata>(); } virtual bool createIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry) OVERRIDE { return false; }; virtual void deleteIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE { } virtual bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; } diff --git a/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp index bfb03ed30..74c2f1669 100644 --- a/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp @@ -40,8 +40,6 @@ class MockGraphicsLayerClient : public GraphicsLayerClient { virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { } virtual void notifyFlushRequired(const GraphicsLayer*) { } virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) { } - virtual bool showDebugBorders(const GraphicsLayer*) const { return false; } - virtual bool showRepaintCounter(const GraphicsLayer*) const { return false; } }; class TestImage : public Image { diff --git a/Source/WebKit/chromium/tests/LinkHighlightTest.cpp b/Source/WebKit/chromium/tests/LinkHighlightTest.cpp index eafe2307f..2fdb384ef 100644 --- a/Source/WebKit/chromium/tests/LinkHighlightTest.cpp +++ b/Source/WebKit/chromium/tests/LinkHighlightTest.cpp @@ -32,6 +32,7 @@ #include "URLTestHelpers.h" #include "WebCompositorInitializer.h" #include "WebFrame.h" +#include "WebInputEvent.h" #include "WebViewImpl.h" #include <gtest/gtest.h> #include <public/WebContentLayer.h> @@ -59,28 +60,40 @@ TEST(LinkHighlightTest, verifyWebViewImplIntegration) webViewImpl->resize(WebSize(pageWidth, pageHeight)); webViewImpl->layout(); + WebGestureEvent touchEvent; + // The coordinates below are linked to absolute positions in the referenced .html file. - IntPoint touchEventLocation(20, 20); - Node* touchNode = webViewImpl->bestTouchLinkNode(touchEventLocation); + touchEvent.x = 20; + touchEvent.y = 20; + Node* touchNode = webViewImpl->bestTouchLinkNode(touchEvent); ASSERT_TRUE(touchNode); - touchEventLocation = IntPoint(20, 40); - EXPECT_FALSE(webViewImpl->bestTouchLinkNode(touchEventLocation)); + touchEvent.y = 40; + EXPECT_FALSE(webViewImpl->bestTouchLinkNode(touchEvent)); - touchEventLocation = IntPoint(20, 20); + touchEvent.y = 20; // Shouldn't crash. - webViewImpl->enableTouchHighlight(touchEventLocation); + webViewImpl->enableTouchHighlight(touchEvent); EXPECT_TRUE(webViewImpl->linkHighlight()); EXPECT_TRUE(webViewImpl->linkHighlight()->contentLayer()); EXPECT_TRUE(webViewImpl->linkHighlight()->clipLayer()); // Find a target inside a scrollable div - touchEventLocation = IntPoint(20, 100); - webViewImpl->enableTouchHighlight(touchEventLocation); + touchEvent.y = 100; + webViewImpl->enableTouchHighlight(touchEvent); ASSERT_TRUE(webViewImpl->linkHighlight()); + // Don't highlight if no "hand cursor" + touchEvent.y = 220; // An A-link with cross-hair cursor. + webViewImpl->enableTouchHighlight(touchEvent); + ASSERT_FALSE(webViewImpl->linkHighlight()); + + touchEvent.y = 260; // A text input box. + webViewImpl->enableTouchHighlight(touchEvent); + ASSERT_FALSE(webViewImpl->linkHighlight()); + webViewImpl->close(); } #endif diff --git a/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp b/Source/WebKit/chromium/tests/LocaleICUTest.cpp index 03d0e1340..09e477225 100644 --- a/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp +++ b/Source/WebKit/chromium/tests/LocaleICUTest.cpp @@ -29,17 +29,15 @@ */ #include "config.h" - -#if ENABLE(INPUT_MULTIPLE_FIELDS_UI) - #include "LocaleICU.h" + #include <gtest/gtest.h> #include <wtf/PassOwnPtr.h> #include <wtf/text/StringBuilder.h> using namespace WebCore; -class LocalizedDateICUTest : public ::testing::Test { +class LocaleICUTest : public ::testing::Test { public: // Labels class is used for printing results in EXPECT_EQ macro. class Labels { @@ -88,6 +86,7 @@ protected: return Labels(labels); } +#if ENABLE(INPUT_MULTIPLE_FIELDS_UI) String monthFormat(const char* localeString) { OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); @@ -135,14 +134,16 @@ protected: OwnPtr<LocaleICU> locale = LocaleICU::create(localeString); return locale->isRTL(); } +#endif }; -std::ostream& operator<<(std::ostream& os, const LocalizedDateICUTest::Labels& labels) +std::ostream& operator<<(std::ostream& os, const LocaleICUTest::Labels& labels) { return os << labels.toString().utf8().data(); } -TEST_F(LocalizedDateICUTest, isRTL) +#if ENABLE(INPUT_MULTIPLE_FIELDS_UI) +TEST_F(LocaleICUTest, isRTL) { EXPECT_TRUE(isRTL("ar-EG")); EXPECT_FALSE(isRTL("en-us")); @@ -150,14 +151,14 @@ TEST_F(LocalizedDateICUTest, isRTL) EXPECT_FALSE(isRTL("**invalid**")); } -TEST_F(LocalizedDateICUTest, monthFormat) +TEST_F(LocaleICUTest, monthFormat) { EXPECT_STREQ("MMMM yyyy", monthFormat("en_US").utf8().data()); EXPECT_STREQ("MMMM yyyy", monthFormat("fr").utf8().data()); EXPECT_STREQ("yyyy\xE5\xB9\xB4M\xE6\x9C\x88", monthFormat("ja").utf8().data()); } -TEST_F(LocalizedDateICUTest, localizedDateFormatText) +TEST_F(LocaleICUTest, localizedDateFormatText) { // Note: EXPECT_EQ(String, String) doesn't print result as string. EXPECT_STREQ("h:mm:ss a", localizedDateFormatText("en_US").utf8().data()); @@ -165,14 +166,14 @@ TEST_F(LocalizedDateICUTest, localizedDateFormatText) EXPECT_STREQ("H:mm:ss", localizedDateFormatText("ja").utf8().data()); } -TEST_F(LocalizedDateICUTest, localizedShortDateFormatText) +TEST_F(LocaleICUTest, localizedShortDateFormatText) { EXPECT_STREQ("h:mm a", localizedShortDateFormatText("en_US").utf8().data()); EXPECT_STREQ("HH:mm", localizedShortDateFormatText("fr").utf8().data()); EXPECT_STREQ("H:mm", localizedShortDateFormatText("ja").utf8().data()); } -TEST_F(LocalizedDateICUTest, standAloneMonthLabels) +TEST_F(LocaleICUTest, standAloneMonthLabels) { EXPECT_STREQ("January", standAloneMonthLabel("en_US", 0).utf8().data()); EXPECT_STREQ("June", standAloneMonthLabel("en_US", 5).utf8().data()); @@ -190,7 +191,7 @@ TEST_F(LocalizedDateICUTest, standAloneMonthLabels) EXPECT_STREQ("\xD0\x9C\xD0\xB0\xD0\xB9", standAloneMonthLabel("ru_RU", 4).utf8().data()); } -TEST_F(LocalizedDateICUTest, shortMonthLabels) +TEST_F(LocaleICUTest, shortMonthLabels) { EXPECT_STREQ("Jan", shortMonthLabel("en_US", 0).utf8().data()); EXPECT_STREQ("Jan", shortStandAloneMonthLabel("en_US", 0).utf8().data()); @@ -213,7 +214,7 @@ TEST_F(LocalizedDateICUTest, shortMonthLabels) EXPECT_STREQ("\xD0\xBC\xD0\xB0\xD0\xB9", shortStandAloneMonthLabel("ru_RU", 4).utf8().data()); } -TEST_F(LocalizedDateICUTest, timeAMPMLabels) +TEST_F(LocaleICUTest, timeAMPMLabels) { EXPECT_EQ(labels("AM", "PM"), timeAMPMLabels("en_US")); EXPECT_EQ(labels("AM", "PM"), timeAMPMLabels("fr")); @@ -223,4 +224,59 @@ TEST_F(LocalizedDateICUTest, timeAMPMLabels) EXPECT_EQ(labels(String(jaAM), String(jaPM)), timeAMPMLabels("ja")); } +static String testDecimalSeparator(const AtomicString& localeIdentifier) +{ + OwnPtr<Locale> locale = Locale::create(localeIdentifier); + return locale->localizedDecimalSeparator(); +} + +TEST_F(LocaleICUTest, localizedDecimalSeparator) +{ + EXPECT_EQ(String("."), testDecimalSeparator("en_US")); + EXPECT_EQ(String(","), testDecimalSeparator("fr")); +} #endif + +void testNumberIsReversible(const AtomicString& localeIdentifier, const char* original, const char* shouldHave = 0) +{ + OwnPtr<Locale> locale = Locale::create(localeIdentifier); + String localized = locale->convertToLocalizedNumber(original); + if (shouldHave) + EXPECT_TRUE(localized.contains(shouldHave)); + String converted = locale->convertFromLocalizedNumber(localized); + EXPECT_EQ(original, converted); +} + +void testNumbers(const char* localeString) +{ + testNumberIsReversible(localeString, "123456789012345678901234567890"); + testNumberIsReversible(localeString, "-123.456"); + testNumberIsReversible(localeString, ".456"); + testNumberIsReversible(localeString, "-0.456"); +} + +TEST_F(LocaleICUTest, reversible) +{ + testNumberIsReversible("en_US", "123456789012345678901234567890"); + testNumberIsReversible("en_US", "-123.456", "."); + testNumberIsReversible("en_US", ".456", "."); + testNumberIsReversible("en_US", "-0.456", "."); + + testNumberIsReversible("fr", "123456789012345678901234567890"); + testNumberIsReversible("fr", "-123.456", ","); + testNumberIsReversible("fr", ".456", ","); + testNumberIsReversible("fr", "-0.456", ","); + + // Persian locale has a negative prefix and a negative suffix. + testNumbers("fa"); + + // Test some of major locales. + testNumbers("ar"); + testNumbers("de_DE"); + testNumbers("es_ES"); + testNumbers("ja_JP"); + testNumbers("ko_KR"); + testNumbers("zh_CN"); + testNumbers("zh_HK"); + testNumbers("zh_TW"); +} diff --git a/Source/WebKit/chromium/tests/LocaleMacTest.cpp b/Source/WebKit/chromium/tests/LocaleMacTest.cpp index e9e55d81c..0d2fed154 100644 --- a/Source/WebKit/chromium/tests/LocaleMacTest.cpp +++ b/Source/WebKit/chromium/tests/LocaleMacTest.cpp @@ -78,22 +78,10 @@ protected: String formatTime(const String& localeString, int hour, int minute, int second, int millisecond, bool useShortFormat) { OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); - return locale->formatDateTime(timeComponents(hour, minute, second, millisecond), (useShortFormat ? Localizer::FormatTypeShort : Localizer::FormatTypeMedium)); - } - - double parseDate(const String& localeString, const String& dateString) - { - OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); - return locale->parseDateTime(dateString, DateComponents::Date); + return locale->formatDateTime(timeComponents(hour, minute, second, millisecond), (useShortFormat ? Locale::FormatTypeShort : Locale::FormatTypeMedium)); } #if ENABLE(CALENDAR_PICKER) - String dateFormatText(const String& localeString) - { - OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); - return locale->dateFormatText(); - } - unsigned firstDayOfWeek(const String& localeString) { OwnPtr<LocaleMac> locale = LocaleMac::create(localeString); @@ -198,21 +186,7 @@ TEST_F(LocaleMacTest, formatTime) EXPECT_STREQ("\xDB\xB7:\xDB\xB0\xDB\xB7:\xDB\xB0\xDB\xB7\xD9\xAB\xDB\xB0\xDB\xB0\xDB\xB7", formatTime("fa", 07, 07, 07, 007, false).utf8().data()); } -TEST_F(LocaleMacTest, parseDate) -{ - EXPECT_EQ(msForDate(2005, April, 27), parseDate("en_US", "April 27, 2005")); - EXPECT_EQ(msForDate(2005, April, 27), parseDate("fr_FR", "27 avril 2005")); - EXPECT_EQ(msForDate(2005, April, 27), parseDate("ja_JP", "2005/04/27")); -} - #if ENABLE(CALENDAR_PICKER) -TEST_F(LocaleMacTest, dateFormatText) -{ - EXPECT_STREQ("Month/Day/Year", dateFormatText("en_US").utf8().data()); - EXPECT_STREQ("Day/Month/Year", dateFormatText("fr_FR").utf8().data()); - EXPECT_STREQ("Year/Month/Day", dateFormatText("ja_JP").utf8().data()); -} - TEST_F(LocaleMacTest, firstDayOfWeek) { EXPECT_EQ(Sunday, firstDayOfWeek("en_US")); @@ -350,7 +324,7 @@ TEST_F(LocaleMacTest, invalidLocale) static void testNumberIsReversible(const AtomicString& localeString, const char* original, const char* shouldHave = 0) { - OwnPtr<Localizer> locale = Localizer::create(localeString); + OwnPtr<Locale> locale = Locale::create(localeString); String localized = locale->convertToLocalizedNumber(original); if (shouldHave) EXPECT_TRUE(localized.contains(shouldHave)); diff --git a/Source/WebKit/chromium/tests/LocaleWinTest.cpp b/Source/WebKit/chromium/tests/LocaleWinTest.cpp index 35f064aac..bc98881db 100644 --- a/Source/WebKit/chromium/tests/LocaleWinTest.cpp +++ b/Source/WebKit/chromium/tests/LocaleWinTest.cpp @@ -90,19 +90,7 @@ protected: return locale->formatDateTime(dateComponents(year, month, day)); } - double parseDate(LCID lcid, const String& dateString) - { - OwnPtr<LocaleWin> locale = LocaleWin::create(lcid); - return locale->parseDateTime(dateString, DateComponents::Date); - } - #if ENABLE(CALENDAR_PICKER) - String dateFormatText(LCID lcid) - { - OwnPtr<LocaleWin> locale = LocaleWin::create(lcid); - return locale->dateFormatText(); - } - unsigned firstDayOfWeek(LCID lcid) { OwnPtr<LocaleWin> locale = LocaleWin::create(lcid); @@ -167,59 +155,6 @@ protected: #endif }; -TEST_F(LocaleWinTest, TestLocalizedDateFormatText) -{ - EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("y/M/d", "year", "month", "day").utf8().data()); - EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("yy/MM/dd", "year", "month", "day").utf8().data()); - EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("yyy/MMM/ddd", "year", "month", "day").utf8().data()); - EXPECT_STREQ("year/month/day", LocaleWin::dateFormatText("yyyy/MMMM/dddd", "year", "month", "day").utf8().data()); - EXPECT_STREQ("/month/day, year", LocaleWin::dateFormatText("/MM/dd, yyyy", "year", "month", "day").utf8().data()); - EXPECT_STREQ("month/day, year=year.", LocaleWin::dateFormatText("MM/dd, 'year='yyyy.", "year", "month", "day").utf8().data()); - EXPECT_STREQ("month-day 'year", LocaleWin::dateFormatText("MM-dd ''yyy", "year", "month", "day").utf8().data()); - EXPECT_STREQ("month-day aaa'bbb year", LocaleWin::dateFormatText("MM-dd 'aaa''bbb' yyy", "year", "month", "day").utf8().data()); - EXPECT_STREQ("year/month/day/year/month/day", LocaleWin::dateFormatText("yyyy/MMMM/dddd/yyyy/MMMM/dddd", "year", "month", "day").utf8().data()); - EXPECT_STREQ("YY/mm/DD", LocaleWin::dateFormatText("YY/mm/DD", "year", "month", "day").utf8().data()); -} - -TEST_F(LocaleWinTest, TestParse) -{ - OwnPtr<LocaleWin> locale = LocaleWin::create(EnglishUS); - - EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MM/dd/yy", 2012, "04/27/12")); - EXPECT_EQ(msForDate(2062, April, 27), locale->parseDate("MM/dd/yy", 2012, "04/27/62")); - EXPECT_EQ(msForDate(1963, April, 27), locale->parseDate("MM/dd/yy", 2012, "04/27/63")); - EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MM/dd/yy", 2012, "4/27/2012")); - EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MM/dd/yy", 2012, "Apr/27/2012")); - EXPECT_EQ(msForDate(2, April, 27), locale->parseDate("MM/d/yy", 2012, "April/27/2")); - EXPECT_EQ(msForDate(2, April, 27), locale->parseDate("MM/d/yy", 2012, "april/27/2")); - EXPECT_TRUE(isnan(locale->parseDate("MM/d/yy", 2012, "april/27"))); - EXPECT_TRUE(isnan(locale->parseDate("MM/d/yy", 2012, "april/27/"))); - EXPECT_TRUE(isnan(locale->parseDate("MM/d/yy", 2012, " april/27/"))); - - EXPECT_EQ(msForDate(12, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "04/7/12")); - EXPECT_EQ(msForDate(62, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "04/07/62")); - EXPECT_EQ(msForDate(63, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "04/07/63")); - EXPECT_EQ(msForDate(2012, April, 7), locale->parseDate("MMM/d/yyyy", 2012, "4/7/2012")); - EXPECT_EQ(msForDate(2012, May, 7), locale->parseDate("MMM/d/yyyy", 2012, "May/007/2012")); - EXPECT_EQ(msForDate(2, May, 27), locale->parseDate("MM/d/yyyy", 2012, "May/0027/2")); - EXPECT_TRUE(isnan(locale->parseDate("MM/d/yyyy", 2012, "May///0027///2"))); - EXPECT_TRUE(isnan(locale->parseDate("MM/d/yyyy", 2012, "Mayyyyyy/0027/2"))); - - EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MMMM/dd/y", 2012, "04/27/2")); - EXPECT_EQ(msForDate(2017, April, 27), locale->parseDate("MMMM/dd/y", 2012, "04/27/7")); - EXPECT_EQ(msForDate(2008, April, 27), locale->parseDate("MMMM/dd/y", 2012, "04/27/8")); - EXPECT_EQ(msForDate(2012, April, 27), locale->parseDate("MMMM/dd/y", 2012, "4/27/2012")); - EXPECT_EQ(msForDate(2012, December, 27), locale->parseDate("MMMM/dd/y", 2012, "December/27/2012")); - EXPECT_EQ(msForDate(2012, November, 27), locale->parseDate("MMMM/d/y", 2012, "November/27/2")); - EXPECT_TRUE(isnan(locale->parseDate("MMMM/d/y", 2012, "November 27 2"))); - EXPECT_TRUE(isnan(locale->parseDate("MMMM/d/y", 2012, "November 32 2"))); - EXPECT_TRUE(isnan(locale->parseDate("MMMM/d/y", 2012, "-1/-1/-1"))); - - OwnPtr<LocaleWin> persian = LocaleWin::create(Persian); - // U+06F1 U+06F6 / U+06F0 U+06F8 / 2012 - EXPECT_EQ(msForDate(2012, August, 16), persian->parseDate("dd/MM/yyyy", 2012, String::fromUTF8("\xDB\xB1\xDB\xB6/\xDB\xB0\xDB\xB8/2012"))); -} - TEST_F(LocaleWinTest, formatDate) { EXPECT_STREQ("04/27/2005", formatDate(EnglishUS, 2005, April, 27).utf8().data()); @@ -227,21 +162,7 @@ TEST_F(LocaleWinTest, formatDate) EXPECT_STREQ("2005/04/27", formatDate(JapaneseJP, 2005, April, 27).utf8().data()); } -TEST_F(LocaleWinTest, parseDate) -{ - EXPECT_EQ(msForDate(2005, April, 27), parseDate(EnglishUS, "April/27/2005")); - EXPECT_EQ(msForDate(2005, April, 27), parseDate(FrenchFR, "27/avril/2005")); - EXPECT_EQ(msForDate(2005, April, 27), parseDate(JapaneseJP, "2005/04/27")); -} - #if ENABLE(CALENDAR_PICKER) -TEST_F(LocaleWinTest, dateFormatText) -{ - EXPECT_STREQ("Month/Day/Year", dateFormatText(EnglishUS).utf8().data()); - EXPECT_STREQ("Day/Month/Year", dateFormatText(FrenchFR).utf8().data()); - EXPECT_STREQ("Year/Month/Day", dateFormatText(JapaneseJP).utf8().data()); -} - TEST_F(LocaleWinTest, firstDayOfWeek) { EXPECT_EQ(Sunday, firstDayOfWeek(EnglishUS)); @@ -290,17 +211,17 @@ TEST_F(LocaleWinTest, isRTL) #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) TEST_F(LocaleWinTest, dateFormat) { - EXPECT_STREQ("y'-'M'-'d", LocaleWin::dateFormat("y-M-d").utf8().data()); + EXPECT_STREQ("y-M-d", LocaleWin::dateFormat("y-M-d").utf8().data()); EXPECT_STREQ("''yy'-'''MM'''-'dd", LocaleWin::dateFormat("''yy-''MM''-dd").utf8().data()); EXPECT_STREQ("yyyy'-''''-'MMM'''''-'dd", LocaleWin::dateFormat("yyyy-''''-MMM''''-dd").utf8().data()); - EXPECT_STREQ("yyyy'-'''''MMMM'-'dd", LocaleWin::dateFormat("yyyy-''''MMMM-dd").utf8().data()); + EXPECT_STREQ("yyyy'-'''''MMMM-dd", LocaleWin::dateFormat("yyyy-''''MMMM-dd").utf8().data()); } TEST_F(LocaleWinTest, monthFormat) { - EXPECT_STREQ("MMMM', 'yyyy", monthFormat(EnglishUS).utf8().data()); - EXPECT_STREQ("MMMM' 'yyyy", monthFormat(FrenchFR).utf8().data()); - EXPECT_STREQ("yyyy'\xE5\xB9\xB4'M'\xE6\x9C\x88'", monthFormat(JapaneseJP).utf8().data()); + EXPECT_STREQ("MMMM, yyyy", monthFormat(EnglishUS).utf8().data()); + EXPECT_STREQ("MMMM yyyy", monthFormat(FrenchFR).utf8().data()); + EXPECT_STREQ("yyyy\xE5\xB9\xB4M\xE6\x9C\x88", monthFormat(JapaneseJP).utf8().data()); } TEST_F(LocaleWinTest, timeFormat) @@ -312,9 +233,9 @@ TEST_F(LocaleWinTest, timeFormat) TEST_F(LocaleWinTest, shortTimeFormat) { - 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()); + EXPECT_STREQ("h:mm a", shortTimeFormat(EnglishUS).utf8().data()); + EXPECT_STREQ("HH:mm", shortTimeFormat(FrenchFR).utf8().data()); + EXPECT_STREQ("H:mm", shortTimeFormat(JapaneseJP).utf8().data()); } TEST_F(LocaleWinTest, shortMonthLabels) diff --git a/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp b/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp deleted file mode 100644 index 6facdc1a1..000000000 --- a/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#include "LocaleICU.h" -#include <gtest/gtest.h> -#include <wtf/PassOwnPtr.h> - -using namespace WebCore; - -void testNumberIsReversible(const AtomicString& locale, const char* original, const char* shouldHave = 0) -{ - OwnPtr<Localizer> localizer = Localizer::create(locale); - String localized = localizer->convertToLocalizedNumber(original); - if (shouldHave) - EXPECT_TRUE(localized.contains(shouldHave)); - String converted = localizer->convertFromLocalizedNumber(localized); - EXPECT_EQ(original, converted); -} - -void testNumbers(const char* localeString) -{ - testNumberIsReversible(localeString, "123456789012345678901234567890"); - testNumberIsReversible(localeString, "-123.456"); - testNumberIsReversible(localeString, ".456"); - testNumberIsReversible(localeString, "-0.456"); -} - -TEST(LocalizedNumberICUTest, Reversible) -{ - testNumberIsReversible("en_US", "123456789012345678901234567890"); - testNumberIsReversible("en_US", "-123.456", "."); - testNumberIsReversible("en_US", ".456", "."); - testNumberIsReversible("en_US", "-0.456", "."); - - testNumberIsReversible("fr", "123456789012345678901234567890"); - testNumberIsReversible("fr", "-123.456", ","); - testNumberIsReversible("fr", ".456", ","); - testNumberIsReversible("fr", "-0.456", ","); - - // Persian locale has a negative prefix and a negative suffix. - testNumbers("fa"); - - // Test some of major locales. - testNumbers("ar"); - testNumbers("de_DE"); - testNumbers("es_ES"); - testNumbers("ja_JP"); - testNumbers("ko_KR"); - testNumbers("zh_CN"); - testNumbers("zh_HK"); - testNumbers("zh_TW"); -} - -#if ENABLE(INPUT_MULTIPLE_FIELDS_UI) - -static String testDecimalSeparator(const AtomicString& locale) -{ - OwnPtr<Localizer> localizer = Localizer::create(locale); - return localizer->localizedDecimalSeparator(); -} - -TEST(LocalizedNumberICUTest, localizedDecimalSeparator) -{ - EXPECT_EQ(String("."), testDecimalSeparator("en_US")); - EXPECT_EQ(String(","), testDecimalSeparator("fr")); -} - -#endif diff --git a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp new file mode 100644 index 000000000..72aa15a30 --- /dev/null +++ b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "CachedImage.h" +#include "MemoryInstrumentationImpl.h" +#include <gtest/gtest.h> +#include <wtf/MemoryInstrumentation.h> +#include <wtf/OwnPtr.h> + +using namespace WebCore; + +using WTF::MemoryObjectInfo; +using WTF::MemoryClassInfo; +using WTF::MemoryObjectType; + +namespace { + +MemoryObjectType TestType = "TestType"; + +class ImageObserverTestHelper { +public: + ImageObserverTestHelper() + : m_cachedImage(adoptPtr(new CachedImage(0))) + , m_imageOberver(m_cachedImage.get()) + { + } + void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const + { + MemoryClassInfo info(memoryObjectInfo, this, TestType); + info.addMember(m_cachedImage); + info.addMember(m_imageOberver); + } + + OwnPtr<CachedImage> m_cachedImage; + ImageObserver* m_imageOberver; +}; + +TEST(MemoryInstrumentationTest, ImageObserver) +{ + ImageObserverTestHelper helper; + + class TestClient : public MemoryInstrumentationClientImpl { + public: + TestClient(const void* expectedPointer, const void* unexpectedPointer) + : m_expectedPointer(expectedPointer) + , m_unexpectedPointer(unexpectedPointer) + , m_expectedPointerFound(false) + { + EXPECT_NE(expectedPointer, unexpectedPointer); + } + virtual void countObjectSize(const void* pointer, MemoryObjectType type, size_t size) OVERRIDE + { + EXPECT_NE(m_unexpectedPointer, pointer); + if (m_expectedPointer == pointer) + m_expectedPointerFound = true; + MemoryInstrumentationClientImpl::countObjectSize(pointer, type, size); + } + + bool expectedPointerFound() { return m_expectedPointerFound; } + + private: + const void* m_expectedPointer; + const void* m_unexpectedPointer; + bool m_expectedPointerFound; + } client(helper.m_cachedImage.get(), helper.m_imageOberver); + MemoryInstrumentationImpl instrumentation(&client); + instrumentation.addRootObject(helper); + EXPECT_TRUE(client.expectedPointerFound()); + EXPECT_LE(sizeof(CachedImage), client.reportedSizeForAllTypes()); + EXPECT_LE(1u, client.totalCountedObjects()); +} + + +} // namespace + diff --git a/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp b/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp index 0cf82494b..39e36a9fb 100644 --- a/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp +++ b/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp @@ -145,7 +145,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectPresentAfterOpa OpaqueRectTrackingContentLayerDelegate delegate(&painter); WebFloatRect opaqueRect; - delegate.paintContents(skCanvas(), canvasRect(), opaqueRect); + delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect); EXPECT_EQ_RECT(WebFloatRect(0, 0, 400, 400), opaqueRect); } @@ -156,7 +156,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentAfter OpaqueRectTrackingContentLayerDelegate delegate(&painter); WebFloatRect opaqueRect; - delegate.paintContents(skCanvas(), canvasRect(), opaqueRect); + delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect); EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect); } @@ -169,7 +169,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentForOp delegate.setOpaque(true); WebFloatRect opaqueRect; - delegate.paintContents(skCanvas(), canvasRect(), opaqueRect); + delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect); EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect); } @@ -182,7 +182,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentForOp delegate.setOpaque(true); WebFloatRect opaqueRect; - delegate.paintContents(skCanvas(), canvasRect(), opaqueRect); + delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect); EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect); } @@ -194,7 +194,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testPartialOpaqueRectNoTransf OpaqueRectTrackingContentLayerDelegate delegate(&painter); WebFloatRect opaqueRect; - delegate.paintContents(skCanvas(), canvasRect(), opaqueRect); + delegate.paintContents(skCanvas(), canvasRect(), false, opaqueRect); EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect); } @@ -207,7 +207,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testPartialOpaqueRectTranslat WebFloatRect opaqueRect; WebRect contentRect(11, 12, 389, 388); - delegate.paintContents(skCanvas(), contentRect, opaqueRect); + delegate.paintContents(skCanvas(), contentRect, false, opaqueRect); EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect); } @@ -225,7 +225,7 @@ TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testHintingScaleFactorSet) IntRect rectA; WebFloatRect rectB; - delegate.paintContents(&canvas, rectA, rectB); + delegate.paintContents(&canvas, rectA, false, rectB); EXPECT_EQ(callback.hintingScale, hintingScale); } #endif diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp index d4bc4819e..ffed3c203 100644 --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp @@ -1045,19 +1045,23 @@ class FindUpdateWebFrameClient : public WebFrameClient { public: FindUpdateWebFrameClient() : m_findResultsAreReady(false) + , m_count(-1) { } - virtual void reportFindInPageMatchCount(int, int, bool finalUpdate) OVERRIDE + virtual void reportFindInPageMatchCount(int, int count, bool finalUpdate) OVERRIDE { + m_count = count; if (finalUpdate) m_findResultsAreReady = true; } bool findResultsAreReady() const { return m_findResultsAreReady; } + int count() const { return m_count; } private: bool m_findResultsAreReady; + int m_count; }; TEST_F(WebFrameTest, FindInPageMatchRects) @@ -1172,6 +1176,37 @@ TEST_F(WebFrameTest, FindInPageMatchRects) webView->close(); } +TEST_F(WebFrameTest, FindInPageSkipsHiddenFrames) +{ + registerMockedHttpURLLoad("find_in_hidden_frame.html"); + + FindUpdateWebFrameClient client; + WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_hidden_frame.html", true, &client); + webView->resize(WebSize(640, 480)); + webView->layout(); + webkit_support::RunAllPendingMessages(); + + static const char* kFindString = "hello"; + static const int kFindIdentifier = 12345; + static const int kNumResults = 1; + + WebFindOptions options; + WebString searchText = WebString::fromUTF8(kFindString); + WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame()); + EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0)); + + mainFrame->resetMatchCount(); + + for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) + frame->scopeStringMatches(kFindIdentifier, searchText, options, true); + + webkit_support::RunAllPendingMessages(); + EXPECT_TRUE(client.findResultsAreReady()); + EXPECT_EQ(kNumResults, client.count()); + + webView->close(); +} + TEST_F(WebFrameTest, FindOnDetachedFrame) { registerMockedHttpURLLoad("find_in_page.html"); diff --git a/Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm b/Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm index 73a29bcd1..aabaa1076 100644 --- a/Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm +++ b/Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm @@ -36,12 +36,19 @@ #include "KeyboardEvent.h" #include "WebInputEvent.h" #include "WebInputEventFactory.h" +#include "WindowsKeyboardCodes.h" using WebKit::WebInputEventFactory; using WebKit::WebKeyboardEvent; namespace { +struct KeyMappingEntry { + int macKeyCode; + unichar character; + int windowsKeyCode; +}; + NSEvent* BuildFakeKeyEvent(NSUInteger keyCode, unichar character, NSUInteger modifierFlags) { NSString* string = [NSString stringWithCharacters:&character length:1]; @@ -82,3 +89,35 @@ TEST(WebInputEventFactoryTestMac, ArrowKeyNumPad) webEvent = WebInputEventFactory::keyboardEvent(macEvent); EXPECT_EQ(0, webEvent.modifiers); } + +// Test that numpad keys get mapped correctly. +TEST(WebInputEventFactoryTestMac, NumPadMapping) +{ + KeyMappingEntry table[] = + { + {65, '.', VK_DECIMAL}, + {67, '*', VK_MULTIPLY}, + {69, '+', VK_ADD}, + {71, NSClearLineFunctionKey, VK_CLEAR}, + {75, '/', VK_DIVIDE}, + {76, 3, VK_RETURN}, + {78, '-', VK_SUBTRACT}, + {81, '=', VK_OEM_PLUS}, + {82, '0', VK_NUMPAD0}, + {83, '1', VK_NUMPAD1}, + {84, '2', VK_NUMPAD2}, + {85, '3', VK_NUMPAD3}, + {86, '4', VK_NUMPAD4}, + {87, '5', VK_NUMPAD5}, + {88, '6', VK_NUMPAD6}, + {89, '7', VK_NUMPAD7}, + {91, '8', VK_NUMPAD8}, + {92, '9', VK_NUMPAD9}, + }; + + for (size_t i = 0; i < arraysize(table); ++i) { + NSEvent* macEvent = BuildFakeKeyEvent(table[i].macKeyCode, table[i].character, 0); + WebKeyboardEvent webEvent = WebInputEventFactory::keyboardEvent(macEvent); + EXPECT_EQ(table[i].windowsKeyCode, webEvent.windowsKeyCode); + } +} diff --git a/Source/WebKit/chromium/tests/data/find_in_hidden_frame.html b/Source/WebKit/chromium/tests/data/find_in_hidden_frame.html new file mode 100644 index 000000000..261f7afad --- /dev/null +++ b/Source/WebKit/chromium/tests/data/find_in_hidden_frame.html @@ -0,0 +1 @@ +<div>hello</div><iframe style="display:inline;width:0;height:0;border:none" src="data:text/html,hello"></iframe> diff --git a/Source/WebKit/chromium/tests/data/test_touch_link_highlight.html b/Source/WebKit/chromium/tests/data/test_touch_link_highlight.html index 2394b2624..e3e29a62b 100644 --- a/Source/WebKit/chromium/tests/data/test_touch_link_highlight.html +++ b/Source/WebKit/chromium/tests/data/test_touch_link_highlight.html @@ -24,6 +24,11 @@ Some stuff.<br> Some stuff.<br> </div> + <!-- Don't highlight if no hand cursor. --> + <a href="http://www.test.com" style="position: absolute; left: 20px; top: 220px; width: 200px; cursor: crosshair;">A link to *not* highlight</a> + <div style="position: absolute; left: 20px; top: 260px; width: 200px;"> + <input type="text"> <!-- This will have an I-beam cursor. --> + </div> <!-- The following is the text for the iframe tag below: <html> <body> |
