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

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

Issue 16870007: Switch database/file_identifier to std::string, remove createFromDatabaseIdentifier calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/indexed_db/indexed_db_leveldb_coding.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_leveldb_coding.h" 5 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 std::vector<IndexedDBKeyPath> key_paths; 643 std::vector<IndexedDBKeyPath> key_paths;
644 std::vector<std::string> encoded_paths; 644 std::vector<std::string> encoded_paths;
645 645
646 { 646 {
647 key_paths.push_back(IndexedDBKeyPath(string16())); 647 key_paths.push_back(IndexedDBKeyPath(string16()));
648 encoded_paths.push_back(std::string()); 648 encoded_paths.push_back(std::string());
649 } 649 }
650 { 650 {
651 key_paths.push_back(IndexedDBKeyPath(ASCIIToUTF16("foo"))); 651 key_paths.push_back(IndexedDBKeyPath(ASCIIToUTF16("foo")));
652 char expected[] = {0, 'f', 0, 'o', 0, 'o'}; 652 char expected[] = {0, 'f', 0, 'o', 0, 'o'};
653 encoded_paths.push_back( 653 encoded_paths.push_back(std::string(expected, arraysize(expected)));
654 std::string(expected, arraysize(expected)));
655 } 654 }
656 { 655 {
657 key_paths.push_back(IndexedDBKeyPath(ASCIIToUTF16("foo.bar"))); 656 key_paths.push_back(IndexedDBKeyPath(ASCIIToUTF16("foo.bar")));
658 char expected[] = {0, 'f', 0, 'o', 0, 'o', 0, '.', 0, 'b', 0, 'a', 0, 'r'}; 657 char expected[] = {0, 'f', 0, 'o', 0, 'o', 0, '.', 0, 'b', 0, 'a', 0, 'r'};
659 encoded_paths.push_back( 658 encoded_paths.push_back(std::string(expected, arraysize(expected)));
660 std::string(expected, arraysize(expected)));
661 } 659 }
662 660
663 ASSERT_EQ(key_paths.size(), encoded_paths.size()); 661 ASSERT_EQ(key_paths.size(), encoded_paths.size());
664 for (size_t i = 0; i < key_paths.size(); ++i) { 662 for (size_t i = 0; i < key_paths.size(); ++i) {
665 IndexedDBKeyPath key_path = key_paths[i]; 663 IndexedDBKeyPath key_path = key_paths[i];
666 std::string encoded = encoded_paths[i]; 664 std::string encoded = encoded_paths[i];
667 665
668 StringPiece slice(encoded); 666 StringPiece slice(encoded);
669 IndexedDBKeyPath decoded; 667 IndexedDBKeyPath decoded;
670 EXPECT_TRUE(DecodeIDBKeyPath(&slice, &decoded)); 668 EXPECT_TRUE(DecodeIDBKeyPath(&slice, &decoded));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 EXPECT_FALSE(ExtractEncodedIDBKey(&slice, &extracted_a)); 741 EXPECT_FALSE(ExtractEncodedIDBKey(&slice, &extracted_a));
744 } 742 }
745 } 743 }
746 744
747 TEST(IndexedDBLevelDBCodingTest, ComparisonTest) { 745 TEST(IndexedDBLevelDBCodingTest, ComparisonTest) {
748 std::vector<std::vector<char> > keys; 746 std::vector<std::vector<char> > keys;
749 keys.push_back(SchemaVersionKey::Encode()); 747 keys.push_back(SchemaVersionKey::Encode());
750 keys.push_back(MaxDatabaseIdKey::Encode()); 748 keys.push_back(MaxDatabaseIdKey::Encode());
751 keys.push_back(DatabaseFreeListKey::Encode(0)); 749 keys.push_back(DatabaseFreeListKey::Encode(0));
752 keys.push_back(DatabaseFreeListKey::EncodeMaxKey()); 750 keys.push_back(DatabaseFreeListKey::EncodeMaxKey());
753 keys.push_back(DatabaseNameKey::Encode(ASCIIToUTF16(""), ASCIIToUTF16(""))); 751 keys.push_back(DatabaseNameKey::Encode("", ASCIIToUTF16("")));
754 keys.push_back(DatabaseNameKey::Encode(ASCIIToUTF16(""), ASCIIToUTF16("a"))); 752 keys.push_back(DatabaseNameKey::Encode("", ASCIIToUTF16("a")));
755 keys.push_back(DatabaseNameKey::Encode(ASCIIToUTF16("a"), ASCIIToUTF16("a"))); 753 keys.push_back(DatabaseNameKey::Encode("a", ASCIIToUTF16("a")));
756 keys.push_back( 754 keys.push_back(
757 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::ORIGIN_NAME)); 755 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::ORIGIN_NAME));
758 keys.push_back( 756 keys.push_back(
759 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::DATABASE_NAME)); 757 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::DATABASE_NAME));
760 keys.push_back( 758 keys.push_back(
761 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::USER_VERSION)); 759 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::USER_VERSION));
762 keys.push_back( 760 keys.push_back(
763 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::MAX_OBJECT_STORE_ID)); 761 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::MAX_OBJECT_STORE_ID));
764 keys.push_back( 762 keys.push_back(
765 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::USER_INT_VERSION)); 763 DatabaseMetaDataKey::Encode(1, DatabaseMetaDataKey::USER_INT_VERSION));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 std::vector<char> vB = WrappedEncodeVarInt(static_cast<int64>(n)); 845 std::vector<char> vB = WrappedEncodeVarInt(static_cast<int64>(n));
848 846
849 EXPECT_EQ(vA.size(), vB.size()); 847 EXPECT_EQ(vA.size(), vB.size());
850 EXPECT_EQ(*vA.begin(), *vB.begin()); 848 EXPECT_EQ(*vA.begin(), *vB.begin());
851 } 849 }
852 } 850 }
853 851
854 } // namespace 852 } // namespace
855 853
856 } // namespace content 854 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_leveldb_coding.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698