| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 base::MessageLoop::current()->RunUntilIdle(); | 125 base::MessageLoop::current()->RunUntilIdle(); |
| 126 return disk_usage_; | 126 return disk_usage_; |
| 127 } | 127 } |
| 128 private: | 128 private: |
| 129 virtual void DidGetDiskUsage(int64 bytes) { | 129 virtual void DidGetDiskUsage(int64 bytes) { |
| 130 EXPECT_GT(bytes, 0); | 130 EXPECT_GT(bytes, 0); |
| 131 disk_usage_ = bytes; | 131 disk_usage_ = bytes; |
| 132 } | 132 } |
| 133 | 133 |
| 134 int64 disk_usage_; | 134 int64 disk_usage_; |
| 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTest); |
| 135 }; | 137 }; |
| 136 | 138 |
| 137 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { | 139 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { |
| 138 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); | 140 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); |
| 139 } | 141 } |
| 140 | 142 |
| 141 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { | 143 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { |
| 142 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), | 144 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), |
| 143 true /* incognito */); | 145 true /* incognito */); |
| 144 } | 146 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 203 |
| 202 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, Bug109187Test) { | 204 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, Bug109187Test) { |
| 203 const GURL url = GetTestUrl("indexeddb", "bug_109187.html"); | 205 const GURL url = GetTestUrl("indexeddb", "bug_109187.html"); |
| 204 | 206 |
| 205 // Just navigate to the URL. Test will crash if it fails. | 207 // Just navigate to the URL. Test will crash if it fails. |
| 206 NavigateToURLBlockUntilNavigationsComplete(shell(), url, 1); | 208 NavigateToURLBlockUntilNavigationsComplete(shell(), url, 1); |
| 207 } | 209 } |
| 208 | 210 |
| 209 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest { | 211 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest { |
| 210 public: | 212 public: |
| 213 IndexedDBBrowserTestWithLowQuota() {} |
| 214 |
| 211 virtual void SetUpOnMainThread() OVERRIDE { | 215 virtual void SetUpOnMainThread() OVERRIDE { |
| 212 const int kInitialQuotaKilobytes = 5000; | 216 const int kInitialQuotaKilobytes = 5000; |
| 213 SetQuota(kInitialQuotaKilobytes); | 217 SetQuota(kInitialQuotaKilobytes); |
| 214 } | 218 } |
| 219 |
| 220 private: |
| 221 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTestWithLowQuota); |
| 215 }; | 222 }; |
| 216 | 223 |
| 217 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithLowQuota, QuotaTest) { | 224 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithLowQuota, QuotaTest) { |
| 218 SimpleTest(GetTestUrl("indexeddb", "quota_test.html")); | 225 SimpleTest(GetTestUrl("indexeddb", "quota_test.html")); |
| 219 } | 226 } |
| 220 | 227 |
| 221 class IndexedDBBrowserTestWithGCExposed : public IndexedDBBrowserTest { | 228 class IndexedDBBrowserTestWithGCExposed : public IndexedDBBrowserTest { |
| 222 public: | 229 public: |
| 230 IndexedDBBrowserTestWithGCExposed() {} |
| 231 |
| 223 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 232 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 224 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 233 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
| 225 } | 234 } |
| 235 |
| 236 private: |
| 237 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTestWithGCExposed); |
| 226 }; | 238 }; |
| 227 | 239 |
| 228 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, | 240 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, |
| 229 DatabaseCallbacksTest) { | 241 DatabaseCallbacksTest) { |
| 230 SimpleTest(GetTestUrl("indexeddb", "database_callbacks_first.html")); | 242 SimpleTest(GetTestUrl("indexeddb", "database_callbacks_first.html")); |
| 231 } | 243 } |
| 232 | 244 |
| 233 static void CopyLevelDBToProfile(Shell* shell, | 245 static void CopyLevelDBToProfile(Shell* shell, |
| 234 scoped_refptr<IndexedDBContextImpl> context, | 246 scoped_refptr<IndexedDBContextImpl> context, |
| 235 const std::string& test_directory) { | 247 const std::string& test_directory) { |
| 236 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread()); | 248 DCHECK(context->TaskRunner()->RunsTasksOnCurrentThread()); |
| 237 base::FilePath leveldb_dir(FILE_PATH_LITERAL("file__0.indexeddb.leveldb")); | 249 base::FilePath leveldb_dir(FILE_PATH_LITERAL("file__0.indexeddb.leveldb")); |
| 238 base::FilePath test_data_dir = | 250 base::FilePath test_data_dir = |
| 239 GetTestFilePath("indexeddb", test_directory.c_str()).Append(leveldb_dir); | 251 GetTestFilePath("indexeddb", test_directory.c_str()).Append(leveldb_dir); |
| 240 base::FilePath dest = context->data_path().Append(leveldb_dir); | 252 base::FilePath dest = context->data_path().Append(leveldb_dir); |
| 241 // If we don't create the destination directory first, the contents of the | 253 // If we don't create the destination directory first, the contents of the |
| 242 // leveldb directory are copied directly into profile/IndexedDB instead of | 254 // leveldb directory are copied directly into profile/IndexedDB instead of |
| 243 // profile/IndexedDB/file__0.xxx/ | 255 // profile/IndexedDB/file__0.xxx/ |
| 244 ASSERT_TRUE(base::CreateDirectory(dest)); | 256 ASSERT_TRUE(base::CreateDirectory(dest)); |
| 245 const bool kRecursive = true; | 257 const bool kRecursive = true; |
| 246 ASSERT_TRUE(base::CopyDirectory(test_data_dir, | 258 ASSERT_TRUE(base::CopyDirectory(test_data_dir, |
| 247 context->data_path(), | 259 context->data_path(), |
| 248 kRecursive)); | 260 kRecursive)); |
| 249 } | 261 } |
| 250 | 262 |
| 251 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { | 263 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { |
| 252 public: | 264 public: |
| 265 IndexedDBBrowserTestWithPreexistingLevelDB() {} |
| 253 virtual void SetUpOnMainThread() OVERRIDE { | 266 virtual void SetUpOnMainThread() OVERRIDE { |
| 254 scoped_refptr<IndexedDBContextImpl> context = GetContext(); | 267 scoped_refptr<IndexedDBContextImpl> context = GetContext(); |
| 255 context->TaskRunner()->PostTask( | 268 context->TaskRunner()->PostTask( |
| 256 FROM_HERE, | 269 FROM_HERE, |
| 257 base::Bind( | 270 base::Bind( |
| 258 &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); | 271 &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); |
| 259 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 272 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
| 260 BrowserMainLoop::GetInstance()->indexed_db_thread()-> | 273 BrowserMainLoop::GetInstance()->indexed_db_thread()-> |
| 261 message_loop_proxy())); | 274 message_loop_proxy())); |
| 262 ASSERT_TRUE(helper->Run()); | 275 ASSERT_TRUE(helper->Run()); |
| 263 } | 276 } |
| 264 | 277 |
| 265 virtual std::string EnclosingLevelDBDir() = 0; | 278 virtual std::string EnclosingLevelDBDir() = 0; |
| 266 | 279 |
| 280 private: |
| 281 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTestWithPreexistingLevelDB); |
| 267 }; | 282 }; |
| 268 | 283 |
| 269 class IndexedDBBrowserTestWithVersion0Schema : public | 284 class IndexedDBBrowserTestWithVersion0Schema : public |
| 270 IndexedDBBrowserTestWithPreexistingLevelDB { | 285 IndexedDBBrowserTestWithPreexistingLevelDB { |
| 271 virtual std::string EnclosingLevelDBDir() OVERRIDE { | 286 virtual std::string EnclosingLevelDBDir() OVERRIDE { |
| 272 return "migration_from_0"; | 287 return "migration_from_0"; |
| 273 } | 288 } |
| 274 }; | 289 }; |
| 275 | 290 |
| 276 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithVersion0Schema, MigrationTest) { | 291 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithVersion0Schema, MigrationTest) { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 #define MAYBE_RenderThreadShutdownTest DISABLED_RenderThreadShutdownTest | 628 #define MAYBE_RenderThreadShutdownTest DISABLED_RenderThreadShutdownTest |
| 614 #else | 629 #else |
| 615 #define MAYBE_RenderThreadShutdownTest RenderThreadShutdownTest | 630 #define MAYBE_RenderThreadShutdownTest RenderThreadShutdownTest |
| 616 #endif | 631 #endif |
| 617 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 632 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
| 618 MAYBE_RenderThreadShutdownTest) { | 633 MAYBE_RenderThreadShutdownTest) { |
| 619 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 634 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
| 620 } | 635 } |
| 621 | 636 |
| 622 } // namespace content | 637 } // namespace content |
| OLD | NEW |