OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, this)); | 143 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, this)); |
144 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 144 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
145 BrowserMainLoop::GetInstance()->indexed_db_thread()-> | 145 BrowserMainLoop::GetInstance()->indexed_db_thread()-> |
146 message_loop_proxy())); | 146 message_loop_proxy())); |
147 EXPECT_TRUE(helper->Run()); | 147 EXPECT_TRUE(helper->Run()); |
148 // Wait for DidGetDiskUsage to be called. | 148 // Wait for DidGetDiskUsage to be called. |
149 base::MessageLoop::current()->RunUntilIdle(); | 149 base::MessageLoop::current()->RunUntilIdle(); |
150 return disk_usage_; | 150 return disk_usage_; |
151 } | 151 } |
152 | 152 |
153 virtual int RequestBlobFileCount() { | |
154 PostTaskAndReplyWithResult( | |
155 GetContext()->TaskRunner(), FROM_HERE, | |
156 base::Bind(&IndexedDBContext::GetOriginBlobFileCount, GetContext(), | |
157 GURL("file:///")), | |
158 base::Bind(&IndexedDBBrowserTest::DidGetBlobFileCount, this)); | |
159 scoped_refptr<base::ThreadTestHelper> helper( | |
160 new base::ThreadTestHelper(BrowserMainLoop::GetInstance() | |
161 ->indexed_db_thread() | |
162 ->message_loop_proxy())); | |
163 EXPECT_TRUE(helper->Run()); | |
164 // Wait for DidGetBlobFileCount to be called. | |
165 base::MessageLoop::current()->RunUntilIdle(); | |
166 return blob_file_count_; | |
167 } | |
168 | |
153 private: | 169 private: |
154 static MockBrowserTestIndexedDBClassFactory* GetTestClassFactory() { | 170 static MockBrowserTestIndexedDBClassFactory* GetTestClassFactory() { |
155 static ::base::LazyInstance<MockBrowserTestIndexedDBClassFactory>::Leaky | 171 static ::base::LazyInstance<MockBrowserTestIndexedDBClassFactory>::Leaky |
156 s_factory = LAZY_INSTANCE_INITIALIZER; | 172 s_factory = LAZY_INSTANCE_INITIALIZER; |
157 return s_factory.Pointer(); | 173 return s_factory.Pointer(); |
158 } | 174 } |
159 | 175 |
160 static IndexedDBClassFactory* GetIDBClassFactory() { | 176 static IndexedDBClassFactory* GetIDBClassFactory() { |
161 return GetTestClassFactory(); | 177 return GetTestClassFactory(); |
162 } | 178 } |
163 | 179 |
164 virtual void DidGetDiskUsage(int64 bytes) { | 180 virtual void DidGetDiskUsage(int64 bytes) { |
165 disk_usage_ = bytes; | 181 disk_usage_ = bytes; |
166 } | 182 } |
167 | 183 |
184 virtual void DidGetBlobFileCount(int count) { blob_file_count_ = count; } | |
185 | |
168 int64 disk_usage_; | 186 int64 disk_usage_; |
187 int blob_file_count_ = 0; | |
169 | 188 |
170 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTest); | 189 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTest); |
171 }; | 190 }; |
172 | 191 |
173 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { | 192 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { |
174 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); | 193 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); |
175 } | 194 } |
176 | 195 |
177 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { | 196 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { |
178 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), | 197 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 | 417 |
399 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CanDeleteWhenOverQuotaTest) { | 418 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CanDeleteWhenOverQuotaTest) { |
400 SimpleTest(GetTestUrl("indexeddb", "fill_up_5k.html")); | 419 SimpleTest(GetTestUrl("indexeddb", "fill_up_5k.html")); |
401 int64 size = RequestDiskUsage(); | 420 int64 size = RequestDiskUsage(); |
402 const int kQuotaKilobytes = 2; | 421 const int kQuotaKilobytes = 2; |
403 EXPECT_GT(size, kQuotaKilobytes * 1024); | 422 EXPECT_GT(size, kQuotaKilobytes * 1024); |
404 SetQuota(kQuotaKilobytes); | 423 SetQuota(kQuotaKilobytes); |
405 SimpleTest(GetTestUrl("indexeddb", "delete_over_quota.html")); | 424 SimpleTest(GetTestUrl("indexeddb", "delete_over_quota.html")); |
406 } | 425 } |
407 | 426 |
427 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, EmptyBlob) { | |
428 // First delete all IDB's for the test origin | |
429 GetContext()->TaskRunner()->PostTask( | |
jsbell
2015/03/03 22:38:07
Is this actually necessary? Is state persisted acr
cmumford
2015/03/03 23:01:35
Yes, it is necessary. Do you think this should be
jsbell
2015/03/03 23:37:56
SetUp would probably be better, but involve a new
| |
430 FROM_HERE, base::Bind(&IndexedDBContextImpl::DeleteForOrigin, | |
431 GetContext(), GURL("file:///"))); | |
432 int64 original_count = RequestBlobFileCount(); | |
433 EXPECT_EQ(0, original_count); // Start with no blob files. | |
434 SimpleTest(GetTestUrl("indexeddb", "empty_blob.html")); | |
435 int64 new_count = RequestBlobFileCount(); | |
436 // The test creates/writes an empty blob, and file. It then deletes the one | |
437 // file, so a single file should be left on disk. | |
438 EXPECT_EQ(1, new_count); | |
jsbell
2015/03/03 23:37:56
Is this still valid if the Blob is deleted too? (s
| |
439 } | |
440 | |
408 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, BlobDidAck) { | 441 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, BlobDidAck) { |
409 SimpleTest(GetTestUrl("indexeddb", "blob_did_ack.html")); | 442 SimpleTest(GetTestUrl("indexeddb", "blob_did_ack.html")); |
410 // Wait for idle so that the blob ack has time to be received/processed by | 443 // Wait for idle so that the blob ack has time to be received/processed by |
411 // the browser process. | 444 // the browser process. |
412 base::MessageLoop::current()->RunUntilIdle(); | 445 base::MessageLoop::current()->RunUntilIdle(); |
413 content::ChromeBlobStorageContext* blob_context = | 446 content::ChromeBlobStorageContext* blob_context = |
414 ChromeBlobStorageContext::GetFor( | 447 ChromeBlobStorageContext::GetFor( |
415 shell()->web_contents()->GetBrowserContext()); | 448 shell()->web_contents()->GetBrowserContext()); |
416 EXPECT_EQ(0UL, blob_context->context()->blob_count()); | 449 EXPECT_EQ(0UL, blob_context->context()->blob_count()); |
417 } | 450 } |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
801 command_line->AppendSwitch(switches::kSingleProcess); | 834 command_line->AppendSwitch(switches::kSingleProcess); |
802 } | 835 } |
803 }; | 836 }; |
804 | 837 |
805 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 838 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
806 RenderThreadShutdownTest) { | 839 RenderThreadShutdownTest) { |
807 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 840 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
808 } | 841 } |
809 | 842 |
810 } // namespace content | 843 } // namespace content |
OLD | NEW |