Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: content/browser/indexed_db/indexed_db_factory_unittest.cc

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h>
6
5 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
9 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_simple_task_runner.h" 13 #include "base/test/test_simple_task_runner.h"
11 #include "content/browser/indexed_db/indexed_db_connection.h" 14 #include "content/browser/indexed_db/indexed_db_connection.h"
12 #include "content/browser/indexed_db/indexed_db_context_impl.h" 15 #include "content/browser/indexed_db/indexed_db_context_impl.h"
13 #include "content/browser/indexed_db/indexed_db_factory_impl.h" 16 #include "content/browser/indexed_db/indexed_db_factory_impl.h"
14 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" 17 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h"
15 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" 18 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h"
16 #include "storage/common/database/database_identifier.h" 19 #include "storage/common/database/database_identifier.h"
17 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 269
267 TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) { 270 TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
268 GURL origin("http://localhost:81"); 271 GURL origin("http://localhost:81");
269 272
270 base::ScopedTempDir temp_directory; 273 base::ScopedTempDir temp_directory;
271 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 274 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
272 275
273 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 276 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
274 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 277 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
275 new MockIndexedDBDatabaseCallbacks()); 278 new MockIndexedDBDatabaseCallbacks());
276 const int64 transaction_id = 1; 279 const int64_t transaction_id = 1;
277 IndexedDBPendingConnection connection( 280 IndexedDBPendingConnection connection(
278 callbacks, 281 callbacks,
279 db_callbacks, 282 db_callbacks,
280 0, /* child_process_id */ 283 0, /* child_process_id */
281 transaction_id, 284 transaction_id,
282 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); 285 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
283 factory()->Open(ASCIIToUTF16("db"), 286 factory()->Open(ASCIIToUTF16("db"),
284 connection, 287 connection,
285 NULL /* request_context */, 288 NULL /* request_context */,
286 origin, 289 origin,
(...skipping 12 matching lines...) Expand all
299 302
300 TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) { 303 TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) {
301 GURL origin("http://localhost:81"); 304 GURL origin("http://localhost:81");
302 305
303 base::ScopedTempDir temp_directory; 306 base::ScopedTempDir temp_directory;
304 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 307 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
305 308
306 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 309 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
307 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 310 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
308 new MockIndexedDBDatabaseCallbacks()); 311 new MockIndexedDBDatabaseCallbacks());
309 const int64 transaction_id = 1; 312 const int64_t transaction_id = 1;
310 IndexedDBPendingConnection connection( 313 IndexedDBPendingConnection connection(
311 callbacks, 314 callbacks,
312 db_callbacks, 315 db_callbacks,
313 0, /* child_process_id */ 316 0, /* child_process_id */
314 transaction_id, 317 transaction_id,
315 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); 318 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
316 factory()->Open(ASCIIToUTF16("db"), 319 factory()->Open(ASCIIToUTF16("db"),
317 connection, 320 connection,
318 NULL /* request_context */, 321 NULL /* request_context */,
319 origin, 322 origin,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 397
395 TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) { 398 TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) {
396 GURL origin("http://localhost:81"); 399 GURL origin("http://localhost:81");
397 400
398 base::ScopedTempDir temp_directory; 401 base::ScopedTempDir temp_directory;
399 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 402 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
400 403
401 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 404 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
402 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 405 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
403 new MockIndexedDBDatabaseCallbacks()); 406 new MockIndexedDBDatabaseCallbacks());
404 const int64 transaction_id = 1; 407 const int64_t transaction_id = 1;
405 IndexedDBPendingConnection connection( 408 IndexedDBPendingConnection connection(
406 callbacks, 409 callbacks,
407 db_callbacks, 410 db_callbacks,
408 0, /* child_process_id */ 411 0, /* child_process_id */
409 transaction_id, 412 transaction_id,
410 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); 413 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
411 factory()->Open(ASCIIToUTF16("db"), 414 factory()->Open(ASCIIToUTF16("db"),
412 connection, 415 connection,
413 NULL /* request_context */, 416 NULL /* request_context */,
414 origin, 417 origin,
(...skipping 21 matching lines...) Expand all
436 public: 439 public:
437 UpgradeNeededCallbacks() {} 440 UpgradeNeededCallbacks() {}
438 441
439 void OnSuccess(scoped_ptr<IndexedDBConnection> connection, 442 void OnSuccess(scoped_ptr<IndexedDBConnection> connection,
440 const IndexedDBDatabaseMetadata& metadata) override { 443 const IndexedDBDatabaseMetadata& metadata) override {
441 EXPECT_TRUE(connection_.get()); 444 EXPECT_TRUE(connection_.get());
442 EXPECT_FALSE(connection.get()); 445 EXPECT_FALSE(connection.get());
443 } 446 }
444 447
445 void OnUpgradeNeeded( 448 void OnUpgradeNeeded(
446 int64 old_version, 449 int64_t old_version,
447 scoped_ptr<IndexedDBConnection> connection, 450 scoped_ptr<IndexedDBConnection> connection,
448 const content::IndexedDBDatabaseMetadata& metadata) override { 451 const content::IndexedDBDatabaseMetadata& metadata) override {
449 connection_ = connection.Pass(); 452 connection_ = connection.Pass();
450 } 453 }
451 454
452 protected: 455 protected:
453 ~UpgradeNeededCallbacks() override {} 456 ~UpgradeNeededCallbacks() override {}
454 457
455 private: 458 private:
456 DISALLOW_COPY_AND_ASSIGN(UpgradeNeededCallbacks); 459 DISALLOW_COPY_AND_ASSIGN(UpgradeNeededCallbacks);
(...skipping 15 matching lines...) Expand all
472 DISALLOW_COPY_AND_ASSIGN(ErrorCallbacks); 475 DISALLOW_COPY_AND_ASSIGN(ErrorCallbacks);
473 }; 476 };
474 477
475 TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) { 478 TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
476 GURL origin("http://localhost:81"); 479 GURL origin("http://localhost:81");
477 480
478 base::ScopedTempDir temp_directory; 481 base::ScopedTempDir temp_directory;
479 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 482 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
480 483
481 const base::string16 db_name(ASCIIToUTF16("db")); 484 const base::string16 db_name(ASCIIToUTF16("db"));
482 const int64 db_version = 2; 485 const int64_t db_version = 2;
483 const int64 transaction_id = 1; 486 const int64_t transaction_id = 1;
484 scoped_refptr<IndexedDBDatabaseCallbacks> db_callbacks( 487 scoped_refptr<IndexedDBDatabaseCallbacks> db_callbacks(
485 new MockIndexedDBDatabaseCallbacks()); 488 new MockIndexedDBDatabaseCallbacks());
486 489
487 // Open at version 2, then close. 490 // Open at version 2, then close.
488 { 491 {
489 scoped_refptr<MockIndexedDBCallbacks> callbacks( 492 scoped_refptr<MockIndexedDBCallbacks> callbacks(
490 new UpgradeNeededCallbacks()); 493 new UpgradeNeededCallbacks());
491 IndexedDBPendingConnection connection(callbacks, 494 IndexedDBPendingConnection connection(callbacks,
492 db_callbacks, 495 db_callbacks,
493 0, /* child_process_id */ 496 0, /* child_process_id */
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 temp_directory.path()); 528 temp_directory.path());
526 EXPECT_TRUE(callbacks->saw_error()); 529 EXPECT_TRUE(callbacks->saw_error());
527 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); 530 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
528 } 531 }
529 532
530 // Terminate all pending-close timers. 533 // Terminate all pending-close timers.
531 factory()->ForceClose(origin); 534 factory()->ForceClose(origin);
532 } 535 }
533 536
534 } // namespace content 537 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory_impl.cc ('k') | content/browser/indexed_db/indexed_db_fake_backing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698