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

Side by Side Diff: sql/connection_unittest.cc

Issue 10809015: Fix the sqlite errors of content unittests on Android (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase Created 8 years, 4 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
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 "sql/meta_table.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/sqlite/sqlite3.h" 11 #include "third_party/sqlite/sqlite3.h"
11 12
12 class SQLConnectionTest : public testing::Test { 13 class SQLConnectionTest : public testing::Test {
13 public: 14 public:
14 SQLConnectionTest() {} 15 SQLConnectionTest() {}
15 16
16 void SetUp() { 17 void SetUp() {
17 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
18 ASSERT_TRUE(db_.Open(db_path())); 19 ASSERT_TRUE(db_.Open(db_path()));
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 const char *kQuery = "SELECT COUNT(*) FROM foo"; 253 const char *kQuery = "SELECT COUNT(*) FROM foo";
253 sql::Statement s(other_db.GetUniqueStatement(kQuery)); 254 sql::Statement s(other_db.GetUniqueStatement(kQuery));
254 ASSERT_TRUE(s.Step()); 255 ASSERT_TRUE(s.Step());
255 ASSERT_FALSE(db().Raze()); 256 ASSERT_FALSE(db().Raze());
256 257
257 // Complete the statement unlocks the database. 258 // Complete the statement unlocks the database.
258 ASSERT_FALSE(s.Step()); 259 ASSERT_FALSE(s.Step());
259 ASSERT_TRUE(db().Raze()); 260 ASSERT_TRUE(db().Raze());
260 } 261 }
261 262
263 #if defined(OS_ANDROID)
264 TEST_F(SQLConnectionTest, SetTempDirForSQL) {
265
266 sql::MetaTable meta_table;
267 // Below call needs a temporary directory in sqlite3
268 // On Android, it can pass only when the temporary directory is set.
269 // Otherwise, sqlite3 doesn't find the correct directory to store
270 // temporary files and will report the error 'unable to open
271 // database file'.
272 ASSERT_TRUE(meta_table.Init(&db(), 4, 4));
273 }
274 #endif
275
262 // TODO(shess): Spin up a background thread to hold other_db, to more 276 // TODO(shess): Spin up a background thread to hold other_db, to more
263 // closely match real life. That would also allow testing 277 // closely match real life. That would also allow testing
264 // RazeWithTimeout(). 278 // RazeWithTimeout().
OLDNEW
« no previous file with comments | « build/android/gtest_filter/content_unittests_disabled ('k') | third_party/sqlite/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698