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(&IndexedDBContextImpl::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( |
| 430 FROM_HERE, base::Bind(&IndexedDBContextImpl::DeleteForOrigin, |
| 431 GetContext(), GURL("file:///"))); |
| 432 EXPECT_EQ(0, RequestBlobFileCount()); // Start with no blob files. |
| 433 const GURL test_url = GetTestUrl("indexeddb", "empty_blob.html"); |
| 434 // For some reason Android's futimes fails (EPERM) in this test. Do not assert |
| 435 // file times on Android, but do so on other platforms. crbug.com/467247 |
| 436 // TODO(cmumford): Figure out why this is the case and fix if possible. |
| 437 #if defined(OS_ANDROID) |
| 438 SimpleTest(GURL(test_url.spec() + "#ignoreTimes")); |
| 439 #else |
| 440 SimpleTest(GURL(test_url.spec())); |
| 441 #endif |
| 442 // Test stores one blob and one file to disk, so expect two files. |
| 443 EXPECT_EQ(2, RequestBlobFileCount()); |
| 444 } |
| 445 |
408 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, BlobDidAck) { | 446 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, BlobDidAck) { |
409 SimpleTest(GetTestUrl("indexeddb", "blob_did_ack.html")); | 447 SimpleTest(GetTestUrl("indexeddb", "blob_did_ack.html")); |
410 // Wait for idle so that the blob ack has time to be received/processed by | 448 // Wait for idle so that the blob ack has time to be received/processed by |
411 // the browser process. | 449 // the browser process. |
412 base::MessageLoop::current()->RunUntilIdle(); | 450 base::MessageLoop::current()->RunUntilIdle(); |
413 content::ChromeBlobStorageContext* blob_context = | 451 content::ChromeBlobStorageContext* blob_context = |
414 ChromeBlobStorageContext::GetFor( | 452 ChromeBlobStorageContext::GetFor( |
415 shell()->web_contents()->GetBrowserContext()); | 453 shell()->web_contents()->GetBrowserContext()); |
416 EXPECT_EQ(0UL, blob_context->context()->blob_count()); | 454 EXPECT_EQ(0UL, blob_context->context()->blob_count()); |
417 } | 455 } |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 command_line->AppendSwitch(switches::kSingleProcess); | 839 command_line->AppendSwitch(switches::kSingleProcess); |
802 } | 840 } |
803 }; | 841 }; |
804 | 842 |
805 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 843 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
806 RenderThreadShutdownTest) { | 844 RenderThreadShutdownTest) { |
807 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 845 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
808 } | 846 } |
809 | 847 |
810 } // namespace content | 848 } // namespace content |
OLD | NEW |