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

Side by Side Diff: components/leveldb/remote_iterator_unittest.cc

Issue 2625873004: Delete and try to recreate localstorage database on invalid schema version. (Closed)
Patch Set: 80 cols, and fix typo Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <map> 5 #include <map>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "components/leveldb/public/cpp/remote_iterator.h" 10 #include "components/leveldb/public/cpp/remote_iterator.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 ~RemoteIteratorTest() override {} 45 ~RemoteIteratorTest() override {}
46 46
47 protected: 47 protected:
48 // Overridden from mojo::test::ApplicationTestBase: 48 // Overridden from mojo::test::ApplicationTestBase:
49 void SetUp() override { 49 void SetUp() override {
50 ServiceTest::SetUp(); 50 ServiceTest::SetUp();
51 connector()->BindInterface("leveldb", &leveldb_); 51 connector()->BindInterface("leveldb", &leveldb_);
52 52
53 mojom::DatabaseError error; 53 mojom::DatabaseError error;
54 base::RunLoop run_loop; 54 base::RunLoop run_loop;
55 leveldb()->OpenInMemory(MakeRequest(&database_), 55 leveldb()->OpenInMemory(
56 Capture(&error, run_loop.QuitClosure())); 56 MakeRequest(&database_, leveldb().associated_group()),
57 Capture(&error, run_loop.QuitClosure()));
57 run_loop.Run(); 58 run_loop.Run();
58 EXPECT_EQ(mojom::DatabaseError::OK, error); 59 EXPECT_EQ(mojom::DatabaseError::OK, error);
59 60
60 std::map<std::string, std::string> data{ 61 std::map<std::string, std::string> data{
61 {"a", "first"}, {"b:suffix", "second"}, {"c", "third"}}; 62 {"a", "first"}, {"b:suffix", "second"}, {"c", "third"}};
62 63
63 for (auto p : data) { 64 for (auto p : data) {
64 // Write a key to the database. 65 // Write a key to the database.
65 error = mojom::DatabaseError::INVALID_ARGUMENT; 66 error = mojom::DatabaseError::INVALID_ARGUMENT;
66 base::RunLoop run_loop; 67 base::RunLoop run_loop;
67 database_->Put(StdStringToUint8Vector(p.first), 68 database_->Put(StdStringToUint8Vector(p.first),
68 StdStringToUint8Vector(p.second), 69 StdStringToUint8Vector(p.second),
69 Capture(&error, run_loop.QuitClosure())); 70 Capture(&error, run_loop.QuitClosure()));
70 run_loop.Run(); 71 run_loop.Run();
71 EXPECT_EQ(mojom::DatabaseError::OK, error); 72 EXPECT_EQ(mojom::DatabaseError::OK, error);
72 } 73 }
73 } 74 }
74 75
75 void TearDown() override { 76 void TearDown() override {
76 leveldb_.reset(); 77 leveldb_.reset();
77 ServiceTest::TearDown(); 78 ServiceTest::TearDown();
78 } 79 }
79 80
80 mojom::LevelDBServicePtr& leveldb() { return leveldb_; } 81 mojom::LevelDBServicePtr& leveldb() { return leveldb_; }
81 mojom::LevelDBDatabasePtr& database() { return database_; } 82 mojom::LevelDBDatabaseAssociatedPtr& database() { return database_; }
82 83
83 private: 84 private:
84 mojom::LevelDBServicePtr leveldb_; 85 mojom::LevelDBServicePtr leveldb_;
85 mojom::LevelDBDatabasePtr database_; 86 mojom::LevelDBDatabaseAssociatedPtr database_;
86 87
87 DISALLOW_COPY_AND_ASSIGN(RemoteIteratorTest); 88 DISALLOW_COPY_AND_ASSIGN(RemoteIteratorTest);
88 }; 89 };
89 90
90 TEST_F(RemoteIteratorTest, Seeking) { 91 TEST_F(RemoteIteratorTest, Seeking) {
91 base::UnguessableToken iterator; 92 base::UnguessableToken iterator;
92 base::RunLoop run_loop; 93 base::RunLoop run_loop;
93 database()->NewIterator(CaptureToken(&iterator, run_loop.QuitClosure())); 94 database()->NewIterator(CaptureToken(&iterator, run_loop.QuitClosure()));
94 run_loop.Run(); 95 run_loop.Run();
95 EXPECT_FALSE(iterator.is_empty()); 96 EXPECT_FALSE(iterator.is_empty());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_TRUE(it.Valid()); 167 EXPECT_TRUE(it.Valid());
167 EXPECT_EQ("a", it.key()); 168 EXPECT_EQ("a", it.key());
168 EXPECT_EQ("first", it.value()); 169 EXPECT_EQ("first", it.value());
169 170
170 it.Prev(); 171 it.Prev();
171 EXPECT_FALSE(it.Valid()); 172 EXPECT_FALSE(it.Valid());
172 } 173 }
173 174
174 } // namespace 175 } // namespace
175 } // namespace leveldb 176 } // namespace leveldb
OLDNEW
« no previous file with comments | « components/leveldb/public/interfaces/leveldb.mojom ('k') | content/browser/dom_storage/local_storage_context_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698