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

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

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class IDBRequestTest : public testing::Test { 52 class IDBRequestTest : public testing::Test {
53 public: 53 public:
54 IDBRequestTest() 54 IDBRequestTest()
55 : m_scope(v8::Isolate::GetCurrent()) 55 : m_scope(v8::Isolate::GetCurrent())
56 { 56 {
57 } 57 }
58 58
59 void SetUp() override 59 void SetUp() override
60 { 60 {
61 m_executionContext = adoptRefWillBeNoop(new NullExecutionContext()); 61 m_executionContext = adoptRefWillBeNoop(new NullExecutionContext());
62 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); 62 m_scope.getScriptState()->setExecutionContext(m_executionContext.get());
63 } 63 }
64 64
65 void TearDown() override 65 void TearDown() override
66 { 66 {
67 m_executionContext->notifyContextDestroyed(); 67 m_executionContext->notifyContextDestroyed();
68 m_scope.scriptState()->setExecutionContext(nullptr); 68 m_scope.getScriptState()->setExecutionContext(nullptr);
69 } 69 }
70 70
71 v8::Isolate* isolate() const { return m_scope.isolate(); } 71 v8::Isolate* isolate() const { return m_scope.isolate(); }
72 ScriptState* scriptState() const { return m_scope.scriptState(); } 72 ScriptState* getScriptState() const { return m_scope.getScriptState(); }
73 ExecutionContext* executionContext() const { return m_scope.scriptState()->e xecutionContext(); } 73 ExecutionContext* getExecutionContext() const { return m_scope.getScriptStat e()->getExecutionContext(); }
74 74
75 private: 75 private:
76 V8TestingScope m_scope; 76 V8TestingScope m_scope;
77 RefPtrWillBePersistent<ExecutionContext> m_executionContext; 77 RefPtrWillBePersistent<ExecutionContext> m_executionContext;
78 }; 78 };
79 79
80 TEST_F(IDBRequestTest, EventsAfterStopping) 80 TEST_F(IDBRequestTest, EventsAfterStopping)
81 { 81 {
82 IDBTransaction* transaction = nullptr; 82 IDBTransaction* transaction = nullptr;
83 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction); 83 IDBRequest* request = IDBRequest::create(getScriptState(), IDBAny::createUnd efined(), transaction);
84 EXPECT_EQ(request->readyState(), "pending"); 84 EXPECT_EQ(request->readyState(), "pending");
85 executionContext()->stopActiveDOMObjects(); 85 getExecutionContext()->stopActiveDOMObjects();
86 86
87 // Ensure none of the following raise assertions in stopped state: 87 // Ensure none of the following raise assertions in stopped state:
88 request->onError(DOMException::create(AbortError, "Description goes here.")) ; 88 request->onError(DOMException::create(AbortError, "Description goes here.")) ;
89 request->onSuccess(Vector<String>()); 89 request->onSuccess(Vector<String>());
90 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid() , IDBValue::create()); 90 request->onSuccess(nullptr, IDBKey::createInvalid(), IDBKey::createInvalid() , IDBValue::create());
91 request->onSuccess(IDBKey::createInvalid()); 91 request->onSuccess(IDBKey::createInvalid());
92 request->onSuccess(IDBValue::create()); 92 request->onSuccess(IDBValue::create());
93 request->onSuccess(static_cast<int64_t>(0)); 93 request->onSuccess(static_cast<int64_t>(0));
94 request->onSuccess(); 94 request->onSuccess();
95 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), IDBValu e::create()); 95 request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), IDBValu e::create());
96 } 96 }
97 97
98 TEST_F(IDBRequestTest, AbortErrorAfterAbort) 98 TEST_F(IDBRequestTest, AbortErrorAfterAbort)
99 { 99 {
100 IDBTransaction* transaction = nullptr; 100 IDBTransaction* transaction = nullptr;
101 IDBRequest* request = IDBRequest::create(scriptState(), IDBAny::createUndefi ned(), transaction); 101 IDBRequest* request = IDBRequest::create(getScriptState(), IDBAny::createUnd efined(), transaction);
102 EXPECT_EQ(request->readyState(), "pending"); 102 EXPECT_EQ(request->readyState(), "pending");
103 103
104 // Simulate the IDBTransaction having received onAbort from back end and abo rting the request: 104 // Simulate the IDBTransaction having received onAbort from back end and abo rting the request:
105 request->abort(); 105 request->abort();
106 106
107 // Now simulate the back end having fired an abort error at the request to c lear up any intermediaries. 107 // Now simulate the back end having fired an abort error at the request to c lear up any intermediaries.
108 // Ensure an assertion is not raised. 108 // Ensure an assertion is not raised.
109 request->onError(DOMException::create(AbortError, "Description goes here.")) ; 109 request->onError(DOMException::create(AbortError, "Description goes here.")) ;
110 110
111 // Stop the request lest it be GCed and its destructor 111 // Stop the request lest it be GCed and its destructor
112 // finds the object in a pending state (and asserts.) 112 // finds the object in a pending state (and asserts.)
113 executionContext()->stopActiveDOMObjects(); 113 getExecutionContext()->stopActiveDOMObjects();
114 } 114 }
115 115
116 TEST_F(IDBRequestTest, ConnectionsAfterStopping) 116 TEST_F(IDBRequestTest, ConnectionsAfterStopping)
117 { 117 {
118 const int64_t transactionId = 1234; 118 const int64_t transactionId = 1234;
119 const int64_t version = 1; 119 const int64_t version = 1;
120 const int64_t oldVersion = 0; 120 const int64_t oldVersion = 0;
121 const IDBDatabaseMetadata metadata; 121 const IDBDatabaseMetadata metadata;
122 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); 122 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create();
123 123
124 { 124 {
125 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 125 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
126 EXPECT_CALL(*backend, abort(transactionId)) 126 EXPECT_CALL(*backend, abort(transactionId))
127 .Times(1); 127 .Times(1);
128 EXPECT_CALL(*backend, close()) 128 EXPECT_CALL(*backend, close())
129 .Times(1); 129 .Times(1);
130 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version); 130 IDBOpenDBRequest* request = IDBOpenDBRequest::create(getScriptState(), c allbacks, transactionId, version);
131 EXPECT_EQ(request->readyState(), "pending"); 131 EXPECT_EQ(request->readyState(), "pending");
132 132
133 executionContext()->stopActiveDOMObjects(); 133 getExecutionContext()->stopActiveDOMObjects();
134 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, WebIDB DataLossNone, String()); 134 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, WebIDB DataLossNone, String());
135 } 135 }
136 136
137 { 137 {
138 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 138 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
139 EXPECT_CALL(*backend, close()) 139 EXPECT_CALL(*backend, close())
140 .Times(1); 140 .Times(1);
141 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version); 141 IDBOpenDBRequest* request = IDBOpenDBRequest::create(getScriptState(), c allbacks, transactionId, version);
142 EXPECT_EQ(request->readyState(), "pending"); 142 EXPECT_EQ(request->readyState(), "pending");
143 143
144 executionContext()->stopActiveDOMObjects(); 144 getExecutionContext()->stopActiveDOMObjects();
145 request->onSuccess(backend.release(), metadata); 145 request->onSuccess(backend.release(), metadata);
146 } 146 }
147 } 147 }
148 148
149 } // namespace 149 } // namespace
150 } // namespace blink 150 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698