OLD | NEW |
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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 const GURL kOriginB; | 35 const GURL kOriginB; |
36 const GURL kOriginOther; | 36 const GURL kOriginOther; |
37 | 37 |
38 IndexedDBQuotaClientTest() | 38 IndexedDBQuotaClientTest() |
39 : kOriginA("http://host"), | 39 : kOriginA("http://host"), |
40 kOriginB("http://host:8000"), | 40 kOriginB("http://host:8000"), |
41 kOriginOther("http://other"), | 41 kOriginOther("http://other"), |
42 usage_(0), | 42 usage_(0), |
43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
44 message_loop_(MessageLoop::TYPE_IO), | 44 message_loop_(MessageLoop::TYPE_IO), |
| 45 db_thread_(BrowserThread::DB, &message_loop_), |
45 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_), | 46 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_), |
46 file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_), | 47 file_thread_(BrowserThread::FILE, &message_loop_), |
| 48 file_user_blocking_thread_( |
| 49 BrowserThread::FILE_USER_BLOCKING, &message_loop_), |
47 io_thread_(BrowserThread::IO, &message_loop_) { | 50 io_thread_(BrowserThread::IO, &message_loop_) { |
48 TestBrowserContext browser_context; | 51 idb_context_ = BrowserContext::GetWebKitContext(&browser_context_)-> |
49 idb_context_ = BrowserContext::GetWebKitContext(&browser_context)-> | |
50 indexed_db_context(); | 52 indexed_db_context(); |
51 setup_temp_dir(); | 53 setup_temp_dir(); |
52 } | 54 } |
53 void setup_temp_dir() { | 55 void setup_temp_dir() { |
54 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 56 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
55 FilePath indexeddb_dir = temp_dir_.path().Append( | 57 FilePath indexeddb_dir = temp_dir_.path().Append( |
56 IndexedDBContext::kIndexedDBDirectory); | 58 IndexedDBContext::kIndexedDBDirectory); |
57 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); | 59 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); |
58 idb_context()->set_data_path_for_testing(indexeddb_dir); | 60 idb_context()->set_data_path_for_testing(indexeddb_dir); |
59 } | 61 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 delete_status_ = code; | 155 delete_status_ = code; |
154 } | 156 } |
155 | 157 |
156 ScopedTempDir temp_dir_; | 158 ScopedTempDir temp_dir_; |
157 int64 usage_; | 159 int64 usage_; |
158 std::set<GURL> origins_; | 160 std::set<GURL> origins_; |
159 quota::StorageType type_; | 161 quota::StorageType type_; |
160 scoped_refptr<IndexedDBContext> idb_context_; | 162 scoped_refptr<IndexedDBContext> idb_context_; |
161 base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_; | 163 base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_; |
162 MessageLoop message_loop_; | 164 MessageLoop message_loop_; |
| 165 BrowserThreadImpl db_thread_; |
163 BrowserThreadImpl webkit_thread_; | 166 BrowserThreadImpl webkit_thread_; |
164 BrowserThreadImpl file_thread_; | 167 BrowserThreadImpl file_thread_; |
| 168 BrowserThreadImpl file_user_blocking_thread_; |
165 BrowserThreadImpl io_thread_; | 169 BrowserThreadImpl io_thread_; |
| 170 TestBrowserContext browser_context_; |
166 quota::QuotaStatusCode delete_status_; | 171 quota::QuotaStatusCode delete_status_; |
167 }; | 172 }; |
168 | 173 |
169 | 174 |
170 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) { | 175 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) { |
171 IndexedDBQuotaClient client( | 176 IndexedDBQuotaClient client( |
172 base::MessageLoopProxy::current(), | 177 base::MessageLoopProxy::current(), |
173 idb_context()); | 178 idb_context()); |
174 | 179 |
175 AddFakeIndexedDB(kOriginA, 6); | 180 AddFakeIndexedDB(kOriginA, 6); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 AddFakeIndexedDB(kOriginA, 1000); | 241 AddFakeIndexedDB(kOriginA, 1000); |
237 AddFakeIndexedDB(kOriginB, 50); | 242 AddFakeIndexedDB(kOriginB, 50); |
238 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); | 243 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); |
239 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 244 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
240 | 245 |
241 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); | 246 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); |
242 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); | 247 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); |
243 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); | 248 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); |
244 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 249 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
245 } | 250 } |
OLD | NEW |