| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/indexed_db/indexed_db_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 virtual void OnSuccess(int64) OVERRIDE { success_called_ = true; } | 163 virtual void OnSuccess(int64) OVERRIDE { success_called_ = true; } |
| 164 | 164 |
| 165 bool blocked_called() const { return blocked_called_; } | 165 bool blocked_called() const { return blocked_called_; } |
| 166 bool success_called() const { return success_called_; } | 166 bool success_called() const { return success_called_; } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 virtual ~MockDeleteCallbacks() {} | 169 virtual ~MockDeleteCallbacks() {} |
| 170 | 170 |
| 171 bool blocked_called_; | 171 bool blocked_called_; |
| 172 bool success_called_; | 172 bool success_called_; |
| 173 |
| 174 DISALLOW_COPY_AND_ASSIGN(MockDeleteCallbacks); |
| 173 }; | 175 }; |
| 174 | 176 |
| 175 TEST(IndexedDBDatabaseTest, PendingDelete) { | 177 TEST(IndexedDBDatabaseTest, PendingDelete) { |
| 176 scoped_refptr<IndexedDBFakeBackingStore> backing_store = | 178 scoped_refptr<IndexedDBFakeBackingStore> backing_store = |
| 177 new IndexedDBFakeBackingStore(); | 179 new IndexedDBFakeBackingStore(); |
| 178 EXPECT_TRUE(backing_store->HasOneRef()); // local | 180 EXPECT_TRUE(backing_store->HasOneRef()); // local |
| 179 | 181 |
| 180 IndexedDBFactory* factory = 0; | 182 IndexedDBFactory* factory = 0; |
| 181 leveldb::Status s; | 183 leveldb::Status s; |
| 182 scoped_refptr<IndexedDBDatabase> db = | 184 scoped_refptr<IndexedDBDatabase> db = |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 1ULL, | 319 1ULL, |
| 318 db_->metadata().object_stores.find(store_id)->second.indexes.size()); | 320 db_->metadata().object_stores.find(store_id)->second.indexes.size()); |
| 319 } | 321 } |
| 320 | 322 |
| 321 class IndexedDBDatabaseOperationAbortTest | 323 class IndexedDBDatabaseOperationAbortTest |
| 322 : public IndexedDBDatabaseOperationTest { | 324 : public IndexedDBDatabaseOperationTest { |
| 323 public: | 325 public: |
| 324 IndexedDBDatabaseOperationAbortTest() { | 326 IndexedDBDatabaseOperationAbortTest() { |
| 325 commit_success_ = leveldb::Status::NotFound("Bummer."); | 327 commit_success_ = leveldb::Status::NotFound("Bummer."); |
| 326 } | 328 } |
| 329 |
| 330 private: |
| 331 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseOperationAbortTest); |
| 327 }; | 332 }; |
| 328 | 333 |
| 329 TEST_F(IndexedDBDatabaseOperationAbortTest, CreateObjectStore) { | 334 TEST_F(IndexedDBDatabaseOperationAbortTest, CreateObjectStore) { |
| 330 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); | 335 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); |
| 331 const int64 store_id = 1001; | 336 const int64 store_id = 1001; |
| 332 db_->CreateObjectStore(transaction_->id(), | 337 db_->CreateObjectStore(transaction_->id(), |
| 333 store_id, | 338 store_id, |
| 334 ASCIIToUTF16("store"), | 339 ASCIIToUTF16("store"), |
| 335 IndexedDBKeyPath(), | 340 IndexedDBKeyPath(), |
| 336 false /*auto_increment*/); | 341 false /*auto_increment*/); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); | 405 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); |
| 401 | 406 |
| 402 // This will execute the Put then Delete. | 407 // This will execute the Put then Delete. |
| 403 RunPostedTasks(); | 408 RunPostedTasks(); |
| 404 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); | 409 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); |
| 405 | 410 |
| 406 transaction_->Commit(); // Cleans up the object hierarchy. | 411 transaction_->Commit(); // Cleans up the object hierarchy. |
| 407 } | 412 } |
| 408 | 413 |
| 409 } // namespace content | 414 } // namespace content |
| OLD | NEW |