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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc

Issue 7583053: Add MessageLoopProxy::current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need for MessageLoopProxy destruction observer. Created 9 years, 4 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 | « content/browser/geolocation/mock_location_provider.cc ('k') | content/common/url_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_callback_factory.h" 9 #include "base/memory/scoped_callback_factory.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 base::ScopedCallbackFactory<IndexedDBQuotaClientTest> callback_factory_; 147 base::ScopedCallbackFactory<IndexedDBQuotaClientTest> callback_factory_;
148 MessageLoop message_loop_; 148 MessageLoop message_loop_;
149 BrowserThread webkit_thread_; 149 BrowserThread webkit_thread_;
150 BrowserThread io_thread_; 150 BrowserThread io_thread_;
151 quota::QuotaStatusCode delete_status_; 151 quota::QuotaStatusCode delete_status_;
152 }; 152 };
153 153
154 154
155 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) { 155 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) {
156 IndexedDBQuotaClient client( 156 IndexedDBQuotaClient client(
157 base::MessageLoopProxy::CreateForCurrentThread(), 157 base::MessageLoopProxy::current(),
158 idb_context()); 158 idb_context());
159 159
160 AddFakeIndexedDB(kOriginA, 6); 160 AddFakeIndexedDB(kOriginA, 6);
161 AddFakeIndexedDB(kOriginB, 3); 161 AddFakeIndexedDB(kOriginB, 3);
162 EXPECT_EQ(6, GetOriginUsage(&client, kOriginA, kTemp)); 162 EXPECT_EQ(6, GetOriginUsage(&client, kOriginA, kTemp));
163 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm)); 163 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm));
164 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp)); 164 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp));
165 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm)); 165 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm));
166 166
167 AddFakeIndexedDB(kOriginA, 1000); 167 AddFakeIndexedDB(kOriginA, 1000);
168 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 168 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
169 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm)); 169 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm));
170 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp)); 170 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp));
171 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm)); 171 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm));
172 } 172 }
173 173
174 TEST_F(IndexedDBQuotaClientTest, GetOriginsForHost) { 174 TEST_F(IndexedDBQuotaClientTest, GetOriginsForHost) {
175 IndexedDBQuotaClient client( 175 IndexedDBQuotaClient client(
176 base::MessageLoopProxy::CreateForCurrentThread(), 176 base::MessageLoopProxy::current(),
177 idb_context()); 177 idb_context());
178 178
179 EXPECT_EQ(kOriginA.host(), kOriginB.host()); 179 EXPECT_EQ(kOriginA.host(), kOriginB.host());
180 EXPECT_NE(kOriginA.host(), kOriginOther.host()); 180 EXPECT_NE(kOriginA.host(), kOriginOther.host());
181 181
182 std::set<GURL> origins = GetOriginsForHost(&client, kTemp, kOriginA.host()); 182 std::set<GURL> origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
183 EXPECT_TRUE(origins.empty()); 183 EXPECT_TRUE(origins.empty());
184 184
185 AddFakeIndexedDB(kOriginA, 1000); 185 AddFakeIndexedDB(kOriginA, 1000);
186 origins = GetOriginsForHost(&client, kTemp, kOriginA.host()); 186 origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
187 EXPECT_EQ(origins.size(), 1ul); 187 EXPECT_EQ(origins.size(), 1ul);
188 EXPECT_TRUE(origins.find(kOriginA) != origins.end()); 188 EXPECT_TRUE(origins.find(kOriginA) != origins.end());
189 189
190 AddFakeIndexedDB(kOriginB, 1000); 190 AddFakeIndexedDB(kOriginB, 1000);
191 origins = GetOriginsForHost(&client, kTemp, kOriginA.host()); 191 origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
192 EXPECT_EQ(origins.size(), 2ul); 192 EXPECT_EQ(origins.size(), 2ul);
193 EXPECT_TRUE(origins.find(kOriginA) != origins.end()); 193 EXPECT_TRUE(origins.find(kOriginA) != origins.end());
194 EXPECT_TRUE(origins.find(kOriginB) != origins.end()); 194 EXPECT_TRUE(origins.find(kOriginB) != origins.end());
195 195
196 EXPECT_TRUE(GetOriginsForHost(&client, kPerm, kOriginA.host()).empty()); 196 EXPECT_TRUE(GetOriginsForHost(&client, kPerm, kOriginA.host()).empty());
197 EXPECT_TRUE(GetOriginsForHost(&client, kTemp, kOriginOther.host()).empty()); 197 EXPECT_TRUE(GetOriginsForHost(&client, kTemp, kOriginOther.host()).empty());
198 } 198 }
199 199
200 TEST_F(IndexedDBQuotaClientTest, GetOriginsForType) { 200 TEST_F(IndexedDBQuotaClientTest, GetOriginsForType) {
201 IndexedDBQuotaClient client( 201 IndexedDBQuotaClient client(
202 base::MessageLoopProxy::CreateForCurrentThread(), 202 base::MessageLoopProxy::current(),
203 idb_context()); 203 idb_context());
204 204
205 EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty()); 205 EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty());
206 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty()); 206 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
207 207
208 AddFakeIndexedDB(kOriginA, 1000); 208 AddFakeIndexedDB(kOriginA, 1000);
209 std::set<GURL> origins = GetOriginsForType(&client, kTemp); 209 std::set<GURL> origins = GetOriginsForType(&client, kTemp);
210 EXPECT_EQ(origins.size(), 1ul); 210 EXPECT_EQ(origins.size(), 1ul);
211 EXPECT_TRUE(origins.find(kOriginA) != origins.end()); 211 EXPECT_TRUE(origins.find(kOriginA) != origins.end());
212 212
213 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty()); 213 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
214 } 214 }
215 215
216 TEST_F(IndexedDBQuotaClientTest, DeleteOrigin) { 216 TEST_F(IndexedDBQuotaClientTest, DeleteOrigin) {
217 IndexedDBQuotaClient client( 217 IndexedDBQuotaClient client(
218 base::MessageLoopProxy::CreateForCurrentThread(), 218 base::MessageLoopProxy::current(),
219 idb_context()); 219 idb_context());
220 220
221 AddFakeIndexedDB(kOriginA, 1000); 221 AddFakeIndexedDB(kOriginA, 1000);
222 AddFakeIndexedDB(kOriginB, 50); 222 AddFakeIndexedDB(kOriginB, 50);
223 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 223 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
224 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 224 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
225 225
226 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); 226 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA);
227 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); 227 EXPECT_EQ(quota::kQuotaStatusOk, delete_status);
228 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); 228 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
229 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 229 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
230 } 230 }
OLDNEW
« no previous file with comments | « content/browser/geolocation/mock_location_provider.cc ('k') | content/common/url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698