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_transaction.h" | 5 #include "content/browser/indexed_db/indexed_db_transaction.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 new MockIndexedDBDatabaseCallbacks(), | 55 new MockIndexedDBDatabaseCallbacks(), |
56 scope, | 56 scope, |
57 indexed_db::TRANSACTION_READ_WRITE, | 57 indexed_db::TRANSACTION_READ_WRITE, |
58 db_, | 58 db_, |
59 new IndexedDBFakeBackingStore::FakeTransaction(commit_success)); | 59 new IndexedDBFakeBackingStore::FakeTransaction(commit_success)); |
60 db_->TransactionCreated(transaction); | 60 db_->TransactionCreated(transaction); |
61 | 61 |
62 // No conflicting transactions, so coordinator will start it immediately: | 62 // No conflicting transactions, so coordinator will start it immediately: |
63 EXPECT_EQ(IndexedDBTransaction::STARTED, transaction->state()); | 63 EXPECT_EQ(IndexedDBTransaction::STARTED, transaction->state()); |
64 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); | 64 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
65 EXPECT_EQ(0, transaction->diagnostics().tasks_scheduled); | |
66 EXPECT_EQ(0, transaction->diagnostics().tasks_completed); | |
65 | 67 |
66 // Schedule a task - timer won't be started until it's processed. | 68 // Schedule a task - timer won't be started until it's processed. |
67 transaction->ScheduleTask(base::Bind( | 69 transaction->ScheduleTask(base::Bind( |
68 &IndexedDBTransactionTest::DummyOperation, base::Unretained(this))); | 70 &IndexedDBTransactionTest::DummyOperation, base::Unretained(this))); |
69 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); | 71 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
72 EXPECT_EQ(1, transaction->diagnostics().tasks_scheduled); | |
73 EXPECT_EQ(0, transaction->diagnostics().tasks_completed); | |
70 | 74 |
71 RunPostedTasks(); | 75 RunPostedTasks(); |
72 EXPECT_TRUE(transaction->IsTimeoutTimerRunning()); | 76 EXPECT_TRUE(transaction->IsTimeoutTimerRunning()); |
73 | 77 |
74 // Abort should cancel the timer. | 78 // Abort should cancel the timer. |
dgrogan
2014/04/09 00:59:58
Fix or remove this comment.
| |
75 transaction->Abort(); | 79 transaction->Timeout(); |
76 EXPECT_EQ(IndexedDBTransaction::FINISHED, transaction->state()); | 80 EXPECT_EQ(IndexedDBTransaction::FINISHED, transaction->state()); |
77 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); | 81 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
82 EXPECT_EQ(1, transaction->diagnostics().tasks_scheduled); | |
83 EXPECT_EQ(1, transaction->diagnostics().tasks_completed); | |
78 | 84 |
79 // This task will be ignored. | 85 // This task will be ignored. |
80 transaction->ScheduleTask(base::Bind( | 86 transaction->ScheduleTask(base::Bind( |
81 &IndexedDBTransactionTest::DummyOperation, base::Unretained(this))); | 87 &IndexedDBTransactionTest::DummyOperation, base::Unretained(this))); |
82 EXPECT_EQ(IndexedDBTransaction::FINISHED, transaction->state()); | 88 EXPECT_EQ(IndexedDBTransaction::FINISHED, transaction->state()); |
83 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); | 89 EXPECT_FALSE(transaction->IsTimeoutTimerRunning()); |
90 EXPECT_EQ(1, transaction->diagnostics().tasks_scheduled); | |
91 EXPECT_EQ(1, transaction->diagnostics().tasks_completed); | |
84 } | 92 } |
85 | 93 |
86 TEST_F(IndexedDBTransactionTest, NoTimeoutReadOnly) { | 94 TEST_F(IndexedDBTransactionTest, NoTimeoutReadOnly) { |
87 const int64 id = 0; | 95 const int64 id = 0; |
88 const std::set<int64> scope; | 96 const std::set<int64> scope; |
89 const bool commit_success = true; | 97 const bool commit_success = true; |
90 scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction( | 98 scoped_refptr<IndexedDBTransaction> transaction = new IndexedDBTransaction( |
91 id, | 99 id, |
92 new MockIndexedDBDatabaseCallbacks(), | 100 new MockIndexedDBDatabaseCallbacks(), |
93 scope, | 101 scope, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 indexed_db::TRANSACTION_READ_ONLY, | 223 indexed_db::TRANSACTION_READ_ONLY, |
216 indexed_db::TRANSACTION_READ_WRITE, | 224 indexed_db::TRANSACTION_READ_WRITE, |
217 indexed_db::TRANSACTION_VERSION_CHANGE | 225 indexed_db::TRANSACTION_VERSION_CHANGE |
218 }; | 226 }; |
219 | 227 |
220 INSTANTIATE_TEST_CASE_P(IndexedDBTransactions, | 228 INSTANTIATE_TEST_CASE_P(IndexedDBTransactions, |
221 IndexedDBTransactionTestMode, | 229 IndexedDBTransactionTestMode, |
222 ::testing::ValuesIn(kTestModes)); | 230 ::testing::ValuesIn(kTestModes)); |
223 | 231 |
224 } // namespace content | 232 } // namespace content |
OLD | NEW |