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

Side by Side Diff: sql/connection_unittest.cc

Issue 10702203: Modify sql unittests to pass on iOS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: I'm burning through patchsets like nobody's business. Created 8 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
« no previous file with comments | « no previous file | sql/run_all_unittests.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/scoped_temp_dir.h" 6 #include "base/scoped_temp_dir.h"
7 #include "sql/connection.h" 7 #include "sql/connection.h"
8 #include "sql/statement.h" 8 #include "sql/statement.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/sqlite/sqlite3.h" 10 #include "third_party/sqlite/sqlite3.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 { 168 {
169 sql::Statement s(db().GetUniqueStatement("SELECT * FROM sqlite_master")); 169 sql::Statement s(db().GetUniqueStatement("SELECT * FROM sqlite_master"));
170 ASSERT_FALSE(s.Step()); 170 ASSERT_FALSE(s.Step());
171 } 171 }
172 } 172 }
173 173
174 // Test that Raze() maintains page_size. 174 // Test that Raze() maintains page_size.
175 TEST_F(SQLConnectionTest, RazePageSize) { 175 TEST_F(SQLConnectionTest, RazePageSize) {
176 const int kPageSize = 4096; 176 // Fetch the default page size and double it for use in this test.
177
178 // Make sure that the default size isn't already |kPageSize|.
179 // Scoped to release statement before Close(). 177 // Scoped to release statement before Close().
178 int default_page_size = 0;
180 { 179 {
181 sql::Statement s(db().GetUniqueStatement("PRAGMA page_size")); 180 sql::Statement s(db().GetUniqueStatement("PRAGMA page_size"));
182 ASSERT_TRUE(s.Step()); 181 ASSERT_TRUE(s.Step());
183 ASSERT_NE(kPageSize, s.ColumnInt(0)); 182 default_page_size = s.ColumnInt(0);
184 } 183 }
184 ASSERT_GT(default_page_size, 0);
185 const int kPageSize = 2 * default_page_size;
185 186
186 // Re-open the database to allow setting the page size. 187 // Re-open the database to allow setting the page size.
187 db().Close(); 188 db().Close();
188 db().set_page_size(kPageSize); 189 db().set_page_size(kPageSize);
189 ASSERT_TRUE(db().Open(db_path())); 190 ASSERT_TRUE(db().Open(db_path()));
190 191
191 // page_size should match the indicated value. 192 // page_size should match the indicated value.
192 sql::Statement s(db().GetUniqueStatement("PRAGMA page_size")); 193 sql::Statement s(db().GetUniqueStatement("PRAGMA page_size"));
193 ASSERT_TRUE(s.Step()); 194 ASSERT_TRUE(s.Step());
194 ASSERT_EQ(kPageSize, s.ColumnInt(0)); 195 ASSERT_EQ(kPageSize, s.ColumnInt(0));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 ASSERT_FALSE(db().Raze()); 255 ASSERT_FALSE(db().Raze());
255 256
256 // Complete the statement unlocks the database. 257 // Complete the statement unlocks the database.
257 ASSERT_FALSE(s.Step()); 258 ASSERT_FALSE(s.Step());
258 ASSERT_TRUE(db().Raze()); 259 ASSERT_TRUE(db().Raze());
259 } 260 }
260 261
261 // TODO(shess): Spin up a background thread to hold other_db, to more 262 // TODO(shess): Spin up a background thread to hold other_db, to more
262 // closely match real life. That would also allow testing 263 // closely match real life. That would also allow testing
263 // RazeWithTimeout(). 264 // RazeWithTimeout().
OLDNEW
« no previous file with comments | « no previous file | sql/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698