Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp

Issue 10630009: Merge 120828 - [Chromium] IndexedDB: Don't close database if pending connections are in flight (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/inspector/InspectorIndexedDBAgent.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
===================================================================
--- Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp (revision 120957)
+++ Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp (working copy)
@@ -67,6 +67,70 @@
EXPECT_TRUE(backingStore->hasOneRef());
}
+class MockIDBCallbacks : public IDBCallbacks {
+public:
+ static PassRefPtr<MockIDBCallbacks> create() { return adoptRef(new MockIDBCallbacks()); }
+ virtual ~MockIDBCallbacks() OVERRIDE
+ {
+ EXPECT_TRUE(m_wasSuccessDBCalled);
+ }
+ virtual void onError(PassRefPtr<IDBDatabaseError>) OVERRIDE { }
+ virtual void onSuccess(PassRefPtr<DOMStringList>) OVERRIDE { }
+ virtual void onSuccess(PassRefPtr<IDBCursorBackendInterface>) OVERRIDE { }
+ virtual void onSuccess(PassRefPtr<IDBDatabaseBackendInterface>) OVERRIDE
+ {
+ m_wasSuccessDBCalled = true;
+ }
+ virtual void onSuccess(PassRefPtr<IDBKey>) OVERRIDE { }
+ virtual void onSuccess(PassRefPtr<IDBTransactionBackendInterface>) OVERRIDE { }
+ virtual void onSuccess(PassRefPtr<SerializedScriptValue>) OVERRIDE { }
+ virtual void onSuccessWithContinuation() OVERRIDE { }
+ virtual void onSuccessWithPrefetch(const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<IDBKey> >&, const Vector<RefPtr<SerializedScriptValue> >&) OVERRIDE { }
+ virtual void onBlocked() OVERRIDE { }
+private:
+ MockIDBCallbacks()
+ : m_wasSuccessDBCalled(false) { }
+ bool m_wasSuccessDBCalled;
+};
+
+class FakeIDBDatabaseCallbacks : public IDBDatabaseCallbacks {
+public:
+ static PassRefPtr<FakeIDBDatabaseCallbacks> create() { return adoptRef(new FakeIDBDatabaseCallbacks()); }
+ virtual ~FakeIDBDatabaseCallbacks() OVERRIDE { }
+ virtual void onVersionChange(const String& version) OVERRIDE { }
+private:
+ FakeIDBDatabaseCallbacks() { }
+};
+
+TEST(IDBDatabaseBackendTest, ConnectionLifecycle)
+{
+ RefPtr<IDBFakeBackingStore> backingStore = adoptRef(new IDBFakeBackingStore());
+ EXPECT_TRUE(backingStore->hasOneRef());
+
+ IDBTransactionCoordinator* coordinator = 0;
+ IDBFactoryBackendImpl* factory = 0;
+ RefPtr<IDBDatabaseBackendImpl> db = IDBDatabaseBackendImpl::create("db", backingStore.get(), coordinator, factory, "uniqueid");
+ EXPECT_GT(backingStore->refCount(), 1);
+
+ RefPtr<MockIDBCallbacks> request1 = MockIDBCallbacks::create();
+ db->openConnection(request1);
+
+ RefPtr<FakeIDBDatabaseCallbacks> connection1 = FakeIDBDatabaseCallbacks::create();
+ db->registerFrontendCallbacks(connection1);
+
+ RefPtr<MockIDBCallbacks> request2 = MockIDBCallbacks::create();
+ db->openConnection(request2);
+
+ db->close(connection1);
+ EXPECT_GT(backingStore->refCount(), 1);
+
+ RefPtr<FakeIDBDatabaseCallbacks> connection2 = FakeIDBDatabaseCallbacks::create();
+ db->registerFrontendCallbacks(connection2);
+
+ db->close(connection2);
+ EXPECT_TRUE(backingStore->hasOneRef());
+}
+
} // namespace
#endif // ENABLE(INDEXED_DATABASE)
« no previous file with comments | « Source/WebCore/inspector/InspectorIndexedDBAgent.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698