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

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

Issue 338833002: Factor out NullExecutionContext from unittest files. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed #2 Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/testing/NullExecutionContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "modules/indexeddb/IDBRequest.h" 27 #include "modules/indexeddb/IDBRequest.h"
28 28
29 #include "bindings/v8/ScriptState.h"
30 #include "bindings/v8/V8Binding.h"
29 #include "core/dom/DOMError.h" 31 #include "core/dom/DOMError.h"
30 #include "core/dom/Document.h" 32 #include "core/dom/ExecutionContext.h"
31 #include "core/dom/SecurityContext.h" 33 #include "core/testing/NullExecutionContext.h"
32 #include "core/events/EventQueue.h"
33 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 34 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
35 #include "modules/indexeddb/IDBKey.h"
34 #include "modules/indexeddb/IDBKeyRange.h" 36 #include "modules/indexeddb/IDBKeyRange.h"
35 #include "modules/indexeddb/IDBOpenDBRequest.h" 37 #include "modules/indexeddb/IDBOpenDBRequest.h"
36 #include "platform/SharedBuffer.h" 38 #include "platform/SharedBuffer.h"
37 #include "public/platform/WebBlobInfo.h" 39 #include "public/platform/WebBlobInfo.h"
38 #include "public/platform/WebIDBDatabase.h" 40 #include "public/platform/WebIDBDatabase.h"
41 #include "wtf/OwnPtr.h"
39 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
43 #include "wtf/PassRefPtr.h"
44 #include "wtf/Vector.h"
45 #include "wtf/dtoa/utils.h"
40 #include <gtest/gtest.h> 46 #include <gtest/gtest.h>
41 #include <v8.h> 47 #include <v8.h>
42 48
43 using blink::WebBlobInfo; 49 using blink::WebBlobInfo;
44 using namespace WebCore; 50 using namespace WebCore;
45 51
46 namespace { 52 namespace {
47 53
48 class NullEventQueue FINAL : public EventQueue {
49 public:
50 NullEventQueue() { }
51 virtual ~NullEventQueue() { }
52 virtual bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE { return t rue; }
53 virtual bool cancelEvent(Event*) OVERRIDE { return true; }
54 virtual void close() OVERRIDE { }
55 };
56
57 class NullExecutionContext FINAL : public RefCountedWillBeGarbageCollectedFinali zed<NullExecutionContext>, public SecurityContext, public ExecutionContext {
58 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NullExecutionContext);
59 public:
60 NullExecutionContext();
61
62 virtual EventQueue* eventQueue() const OVERRIDE { return m_queue.get(); }
63
64 void trace(Visitor* visitor)
65 {
66 visitor->trace(m_queue);
67 ExecutionContext::trace(visitor);
68 }
69
70 virtual void reportBlockedScriptExecutionToInspector(const String& directive Text) OVERRIDE { }
71 virtual SecurityContext& securityContext() { return *this; }
72
73 #if !ENABLE(OILPAN)
74 using RefCounted<NullExecutionContext>::ref;
75 using RefCounted<NullExecutionContext>::deref;
76
77 virtual void refExecutionContext() OVERRIDE { ref(); }
78 virtual void derefExecutionContext() OVERRIDE { deref(); }
79 #endif
80
81 protected:
82 virtual const KURL& virtualURL() const OVERRIDE { return m_dummyURL; }
83 virtual KURL virtualCompleteURL(const String&) const OVERRIDE { return m_dum myURL; }
84
85 private:
86 OwnPtrWillBeMember<EventQueue> m_queue;
87
88 KURL m_dummyURL;
89 };
90
91 NullExecutionContext::NullExecutionContext()
92 : m_queue(adoptPtrWillBeNoop(new NullEventQueue()))
93 {
94 }
95
96 class IDBRequestTest : public testing::Test { 54 class IDBRequestTest : public testing::Test {
97 public: 55 public:
98 IDBRequestTest() 56 IDBRequestTest()
99 : m_scope(v8::Isolate::GetCurrent()) 57 : m_scope(v8::Isolate::GetCurrent())
100 , m_executionContext(adoptRefWillBeNoop(new NullExecutionContext())) 58 , m_executionContext(adoptRefWillBeNoop(new NullExecutionContext()))
101 { 59 {
102 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); 60 m_scope.scriptState()->setExecutionContext(m_executionContext.get());
103 } 61 }
104 62
105 ~IDBRequestTest() 63 ~IDBRequestTest()
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 154 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
197 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version); 155 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call backs, transactionId, version);
198 EXPECT_EQ(request->readyState(), "pending"); 156 EXPECT_EQ(request->readyState(), "pending");
199 157
200 executionContext()->stopActiveDOMObjects(); 158 executionContext()->stopActiveDOMObjects();
201 request->onSuccess(backend.release(), metadata); 159 request->onSuccess(backend.release(), metadata);
202 } 160 }
203 } 161 }
204 162
205 } // namespace 163 } // namespace
OLDNEW
« no previous file with comments | « Source/core/testing/NullExecutionContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698