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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBRequestTest.cpp

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Address last nits and fix leaks in unit tests. Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 #include "core/dom/DOMException.h" 31 #include "core/dom/DOMException.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/dom/ExecutionContext.h" 33 #include "core/dom/ExecutionContext.h"
34 #include "core/testing/NullExecutionContext.h" 34 #include "core/testing/NullExecutionContext.h"
35 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 35 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
36 #include "modules/indexeddb/IDBKey.h" 36 #include "modules/indexeddb/IDBKey.h"
37 #include "modules/indexeddb/IDBOpenDBRequest.h" 37 #include "modules/indexeddb/IDBOpenDBRequest.h"
38 #include "modules/indexeddb/IDBValue.h" 38 #include "modules/indexeddb/IDBValue.h"
39 #include "modules/indexeddb/MockWebIDBDatabase.h" 39 #include "modules/indexeddb/MockWebIDBDatabase.h"
40 #include "platform/SharedBuffer.h" 40 #include "platform/SharedBuffer.h"
41 #include "public/platform/modules/indexeddb/WebIDBCallbacks.h"
41 #include "testing/gtest/include/gtest/gtest.h" 42 #include "testing/gtest/include/gtest/gtest.h"
42 #include "wtf/PassRefPtr.h" 43 #include "wtf/PassRefPtr.h"
43 #include "wtf/Vector.h" 44 #include "wtf/Vector.h"
44 #include "wtf/dtoa/utils.h" 45 #include "wtf/dtoa/utils.h"
45 #include <memory> 46 #include <memory>
46 #include <v8.h> 47 #include <v8.h>
47 48
48 namespace blink { 49 namespace blink {
49 namespace { 50 namespace {
50 51
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Stop the request lest it be GCed and its destructor 88 // Stop the request lest it be GCed and its destructor
88 // finds the object in a pending state (and asserts.) 89 // finds the object in a pending state (and asserts.)
89 scope.getExecutionContext()->notifyContextDestroyed(); 90 scope.getExecutionContext()->notifyContextDestroyed();
90 } 91 }
91 92
92 TEST(IDBRequestTest, ConnectionsAfterStopping) { 93 TEST(IDBRequestTest, ConnectionsAfterStopping) {
93 V8TestingScope scope; 94 V8TestingScope scope;
94 const int64_t transactionId = 1234; 95 const int64_t transactionId = 1234;
95 const int64_t version = 1; 96 const int64_t version = 1;
96 const int64_t oldVersion = 0; 97 const int64_t oldVersion = 0;
97 const IDBDatabaseMetadata metadata; 98 const WebIDBMetadata metadata;
98 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); 99 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create();
99 100
100 { 101 {
101 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 102 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
102 EXPECT_CALL(*backend, abort(transactionId)).Times(1);
103 EXPECT_CALL(*backend, close()).Times(1); 103 EXPECT_CALL(*backend, close()).Times(1);
104 IDBOpenDBRequest* request = IDBOpenDBRequest::create( 104 IDBOpenDBRequest* request = IDBOpenDBRequest::create(
105 scope.getScriptState(), callbacks, transactionId, version); 105 scope.getScriptState(), callbacks, transactionId, version);
106 EXPECT_EQ(request->readyState(), "pending"); 106 EXPECT_EQ(request->readyState(), "pending");
107 std::unique_ptr<WebIDBCallbacks> callbacks = request->createWebCallbacks();
107 108
108 scope.getExecutionContext()->notifyContextDestroyed(); 109 scope.getExecutionContext()->notifyContextDestroyed();
109 request->onUpgradeNeeded(oldVersion, std::move(backend), metadata, 110 callbacks->onUpgradeNeeded(oldVersion, backend.release(), metadata,
110 WebIDBDataLossNone, String()); 111 WebIDBDataLossNone, String());
111 } 112 }
112 113
113 { 114 {
114 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 115 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
115 EXPECT_CALL(*backend, close()).Times(1); 116 EXPECT_CALL(*backend, close()).Times(1);
116 IDBOpenDBRequest* request = IDBOpenDBRequest::create( 117 IDBOpenDBRequest* request = IDBOpenDBRequest::create(
117 scope.getScriptState(), callbacks, transactionId, version); 118 scope.getScriptState(), callbacks, transactionId, version);
118 EXPECT_EQ(request->readyState(), "pending"); 119 EXPECT_EQ(request->readyState(), "pending");
120 std::unique_ptr<WebIDBCallbacks> callbacks = request->createWebCallbacks();
119 121
120 scope.getExecutionContext()->notifyContextDestroyed(); 122 scope.getExecutionContext()->notifyContextDestroyed();
121 request->onSuccess(std::move(backend), metadata); 123 callbacks->onSuccess(backend.release(), metadata);
122 } 124 }
123 } 125 }
124 126
125 } // namespace 127 } // namespace
126 } // namespace blink 128 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698