OLD | NEW |
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 28 matching lines...) Expand all Loading... |
39 #include "public/platform/WebBlobInfo.h" | 39 #include "public/platform/WebBlobInfo.h" |
40 #include "public/platform/WebIDBDatabase.h" | 40 #include "public/platform/WebIDBDatabase.h" |
41 #include "wtf/OwnPtr.h" | 41 #include "wtf/OwnPtr.h" |
42 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
43 #include "wtf/PassRefPtr.h" | 43 #include "wtf/PassRefPtr.h" |
44 #include "wtf/Vector.h" | 44 #include "wtf/Vector.h" |
45 #include "wtf/dtoa/utils.h" | 45 #include "wtf/dtoa/utils.h" |
46 #include <gtest/gtest.h> | 46 #include <gtest/gtest.h> |
47 #include <v8.h> | 47 #include <v8.h> |
48 | 48 |
49 using blink::WebBlobInfo; | 49 namespace blink { |
50 using namespace blink; | |
51 | |
52 namespace { | 50 namespace { |
53 | 51 |
54 class IDBRequestTest : public testing::Test { | 52 class IDBRequestTest : public testing::Test { |
55 public: | 53 public: |
56 IDBRequestTest() | 54 IDBRequestTest() |
57 : m_scope(v8::Isolate::GetCurrent()) | 55 : m_scope(v8::Isolate::GetCurrent()) |
58 , m_executionContext(adoptRefWillBeNoop(new NullExecutionContext())) | 56 , m_executionContext(adoptRefWillBeNoop(new NullExecutionContext())) |
59 { | 57 { |
60 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); | 58 m_scope.scriptState()->setExecutionContext(m_executionContext.get()); |
61 } | 59 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 EXPECT_EQ(request->readyState(), "pending"); | 98 EXPECT_EQ(request->readyState(), "pending"); |
101 | 99 |
102 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: | 100 // Simulate the IDBTransaction having received onAbort from back end and abo
rting the request: |
103 request->abort(); | 101 request->abort(); |
104 | 102 |
105 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. | 103 // Now simulate the back end having fired an abort error at the request to c
lear up any intermediaries. |
106 // Ensure an assertion is not raised. | 104 // Ensure an assertion is not raised. |
107 request->onError(DOMError::create(AbortError, "Description goes here.")); | 105 request->onError(DOMError::create(AbortError, "Description goes here.")); |
108 } | 106 } |
109 | 107 |
110 class MockWebIDBDatabase : public blink::WebIDBDatabase { | 108 class MockWebIDBDatabase : public WebIDBDatabase { |
111 public: | 109 public: |
112 static PassOwnPtr<MockWebIDBDatabase> create() | 110 static PassOwnPtr<MockWebIDBDatabase> create() |
113 { | 111 { |
114 return adoptPtr(new MockWebIDBDatabase()); | 112 return adoptPtr(new MockWebIDBDatabase()); |
115 } | 113 } |
116 virtual ~MockWebIDBDatabase() | 114 virtual ~MockWebIDBDatabase() |
117 { | 115 { |
118 EXPECT_TRUE(m_closeCalled); | 116 EXPECT_TRUE(m_closeCalled); |
119 } | 117 } |
120 | 118 |
(...skipping 19 matching lines...) Expand all Loading... |
140 const int64_t oldVersion = 0; | 138 const int64_t oldVersion = 0; |
141 const IDBDatabaseMetadata metadata; | 139 const IDBDatabaseMetadata metadata; |
142 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); | 140 Persistent<IDBDatabaseCallbacks> callbacks = IDBDatabaseCallbacks::create(); |
143 | 141 |
144 { | 142 { |
145 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 143 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
146 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); | 144 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); |
147 EXPECT_EQ(request->readyState(), "pending"); | 145 EXPECT_EQ(request->readyState(), "pending"); |
148 | 146 |
149 executionContext()->stopActiveDOMObjects(); | 147 executionContext()->stopActiveDOMObjects(); |
150 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, blink:
:WebIDBDataLossNone, String()); | 148 request->onUpgradeNeeded(oldVersion, backend.release(), metadata, WebIDB
DataLossNone, String()); |
151 } | 149 } |
152 | 150 |
153 { | 151 { |
154 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 152 OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); |
155 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); | 153 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState(), call
backs, transactionId, version); |
156 EXPECT_EQ(request->readyState(), "pending"); | 154 EXPECT_EQ(request->readyState(), "pending"); |
157 | 155 |
158 executionContext()->stopActiveDOMObjects(); | 156 executionContext()->stopActiveDOMObjects(); |
159 request->onSuccess(backend.release(), metadata); | 157 request->onSuccess(backend.release(), metadata); |
160 } | 158 } |
161 } | 159 } |
162 | 160 |
163 } // namespace | 161 } // namespace |
| 162 } // namespace blink |
OLD | NEW |