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_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 virtual void SetUpCommandLine(CommandLine* command_line) { | 170 virtual void SetUpCommandLine(CommandLine* command_line) { |
171 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 171 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
172 } | 172 } |
173 }; | 173 }; |
174 | 174 |
175 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, | 175 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, |
176 DatabaseCallbacksTest) { | 176 DatabaseCallbacksTest) { |
177 SimpleTest(GetTestUrl("indexeddb", "database_callbacks_first.html")); | 177 SimpleTest(GetTestUrl("indexeddb", "database_callbacks_first.html")); |
178 } | 178 } |
179 | 179 |
| 180 class IndexedDBBrowserTestWithVersion0Schema : public IndexedDBBrowserTest { |
| 181 public: |
| 182 virtual void SetUpOnMainThread() { |
| 183 BrowserThread::PostTask( |
| 184 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 185 base::Bind( |
| 186 &IndexedDBBrowserTestWithVersion0Schema::CopyLevelDBToProfile, |
| 187 shell())); |
| 188 scoped_refptr<base::ThreadTestHelper> helper( |
| 189 new base::ThreadTestHelper(BrowserThread::GetMessageLoopProxyForThread( |
| 190 BrowserThread::WEBKIT_DEPRECATED))); |
| 191 ASSERT_TRUE(helper->Run()); |
| 192 } |
| 193 static void CopyLevelDBToProfile(Shell* shell) { |
| 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 195 FilePath leveldb_dir(FILE_PATH_LITERAL("file__0.indexeddb.leveldb")); |
| 196 FilePath test_data_dir = |
| 197 GetTestFilePath("indexeddb", "migration_from_0").Append(leveldb_dir); |
| 198 IndexedDBContext* context = BrowserContext::GetIndexedDBContext( |
| 199 shell->web_contents()->GetBrowserContext()); |
| 200 IndexedDBContextImpl* context_impl = |
| 201 static_cast<IndexedDBContextImpl*>(context); |
| 202 FilePath dest = context_impl->data_path().Append(leveldb_dir); |
| 203 // If we don't create the destination directory first, the contents of the |
| 204 // leveldb directory are copied directly into profile/IndexedDB instead of |
| 205 // profile/IndexedDB/file__0.xxx/ |
| 206 ASSERT_TRUE(file_util::CreateDirectory(dest)); |
| 207 const bool kRecursive = true; |
| 208 ASSERT_TRUE(file_util::CopyDirectory(test_data_dir, |
| 209 context_impl->data_path(), |
| 210 kRecursive)); |
| 211 } |
| 212 }; |
| 213 |
| 214 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithVersion0Schema, MigrationTest) { |
| 215 SimpleTest(GetTestUrl("indexeddb", "migration_test.html")); |
| 216 } |
| 217 |
180 } // namespace content | 218 } // namespace content |
OLD | NEW |