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

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

Issue 2572603002: ABANDONED CL: Rename readyState() to getReadyState(). (Closed)
Patch Set: Created 4 years 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include <v8.h> 47 #include <v8.h>
48 48
49 namespace blink { 49 namespace blink {
50 namespace { 50 namespace {
51 51
52 TEST(IDBRequestTest, EventsAfterStopping) { 52 TEST(IDBRequestTest, EventsAfterStopping) {
53 V8TestingScope scope; 53 V8TestingScope scope;
54 IDBTransaction* transaction = nullptr; 54 IDBTransaction* transaction = nullptr;
55 IDBRequest* request = IDBRequest::create( 55 IDBRequest* request = IDBRequest::create(
56 scope.getScriptState(), IDBAny::createUndefined(), transaction); 56 scope.getScriptState(), IDBAny::createUndefined(), transaction);
57 EXPECT_EQ(request->readyState(), "pending"); 57 EXPECT_EQ(request->getReadyState(), "pending");
58 scope.getExecutionContext()->notifyContextDestroyed(); 58 scope.getExecutionContext()->notifyContextDestroyed();
59 59
60 // Ensure none of the following raise assertions in stopped state: 60 // Ensure none of the following raise assertions in stopped state:
61 request->onError(DOMException::create(AbortError, "Description goes here.")); 61 request->onError(DOMException::create(AbortError, "Description goes here."));
62 request->onSuccess(Vector<String>()); 62 request->onSuccess(Vector<String>());
63 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid(), 63 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid(),
64 IDBValue::create()); 64 IDBValue::create());
65 request->onSuccess(IDBKey::createInvalid()); 65 request->onSuccess(IDBKey::createInvalid());
66 request->onSuccess(IDBValue::create()); 66 request->onSuccess(IDBValue::create());
67 request->onSuccess(static_cast<int64_t>(0)); 67 request->onSuccess(static_cast<int64_t>(0));
68 request->onSuccess(); 68 request->onSuccess();
69 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), 69 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(),
70 IDBValue::create()); 70 IDBValue::create());
71 } 71 }
72 72
73 TEST(IDBRequestTest, AbortErrorAfterAbort) { 73 TEST(IDBRequestTest, AbortErrorAfterAbort) {
74 V8TestingScope scope; 74 V8TestingScope scope;
75 IDBTransaction* transaction = nullptr; 75 IDBTransaction* transaction = nullptr;
76 IDBRequest* request = IDBRequest::create( 76 IDBRequest* request = IDBRequest::create(
77 scope.getScriptState(), IDBAny::createUndefined(), transaction); 77 scope.getScriptState(), IDBAny::createUndefined(), transaction);
78 EXPECT_EQ(request->readyState(), "pending"); 78 EXPECT_EQ(request->getReadyState(), "pending");
79 79
80 // Simulate the IDBTransaction having received onAbort from back end and 80 // Simulate the IDBTransaction having received onAbort from back end and
81 // aborting the request: 81 // aborting the request:
82 request->abort(); 82 request->abort();
83 83
84 // Now simulate the back end having fired an abort error at the request to 84 // Now simulate the back end having fired an abort error at the request to
85 // clear up any intermediaries. Ensure an assertion is not raised. 85 // clear up any intermediaries. Ensure an assertion is not raised.
86 request->onError(DOMException::create(AbortError, "Description goes here.")); 86 request->onError(DOMException::create(AbortError, "Description goes here."));
87 87
88 // Stop the request lest it be GCed and its destructor 88 // Stop the request lest it be GCed and its destructor
89 // finds the object in a pending state (and asserts.) 89 // finds the object in a pending state (and asserts.)
90 scope.getExecutionContext()->notifyContextDestroyed(); 90 scope.getExecutionContext()->notifyContextDestroyed();
91 } 91 }
92 92
93 TEST(IDBRequestTest, ConnectionsAfterStopping) { 93 TEST(IDBRequestTest, ConnectionsAfterStopping) {
94 V8TestingScope scope; 94 V8TestingScope scope;
95 const int64_t transactionId = 1234; 95 const int64_t transactionId = 1234;
96 const int64_t version = 1; 96 const int64_t version = 1;
97 const int64_t oldVersion = 0; 97 const int64_t oldVersion = 0;
98 const WebIDBMetadata metadata; 98 const WebIDBMetadata metadata;
99 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); 99 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create();
100 100
101 { 101 {
102 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 102 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
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->getReadyState(), "pending");
107 std::unique_ptr<WebIDBCallbacks> callbacks = request->createWebCallbacks(); 107 std::unique_ptr<WebIDBCallbacks> callbacks = request->createWebCallbacks();
108 108
109 scope.getExecutionContext()->notifyContextDestroyed(); 109 scope.getExecutionContext()->notifyContextDestroyed();
110 callbacks->onUpgradeNeeded(oldVersion, backend.release(), metadata, 110 callbacks->onUpgradeNeeded(oldVersion, backend.release(), metadata,
111 WebIDBDataLossNone, String()); 111 WebIDBDataLossNone, String());
112 } 112 }
113 113
114 { 114 {
115 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 115 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
116 EXPECT_CALL(*backend, close()).Times(1); 116 EXPECT_CALL(*backend, close()).Times(1);
117 IDBOpenDBRequest* request = IDBOpenDBRequest::create( 117 IDBOpenDBRequest* request = IDBOpenDBRequest::create(
118 scope.getScriptState(), callbacks, transactionId, version); 118 scope.getScriptState(), callbacks, transactionId, version);
119 EXPECT_EQ(request->readyState(), "pending"); 119 EXPECT_EQ(request->getReadyState(), "pending");
120 std::unique_ptr<WebIDBCallbacks> callbacks = request->createWebCallbacks(); 120 std::unique_ptr<WebIDBCallbacks> callbacks = request->createWebCallbacks();
121 121
122 scope.getExecutionContext()->notifyContextDestroyed(); 122 scope.getExecutionContext()->notifyContextDestroyed();
123 callbacks->onSuccess(backend.release(), metadata); 123 callbacks->onSuccess(backend.release(), metadata);
124 } 124 }
125 } 125 }
126 126
127 } // namespace 127 } // namespace
128 } // namespace blink 128 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698