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

Side by Side Diff: content/browser/dom_storage/dom_storage_database_unittest.cc

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 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/BUILD.gn » ('j') | third_party/sqlite/src/src/os_unix.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/dom_storage/dom_storage_database.h" 5 #include "content/browser/dom_storage/dom_storage_database.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/public/common/content_paths.h" 12 #include "content/public/common/content_paths.h"
13 #include "sql/statement.h" 13 #include "sql/statement.h"
14 #include "sql/test/scoped_error_ignorer.h" 14 #include "sql/test/scoped_error_ignorer.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/sqlite/sqlite3.h"
17 16
18 using base::ASCIIToUTF16; 17 using base::ASCIIToUTF16;
19 18
20 namespace content { 19 namespace content {
21 20
22 void CreateV1Table(sql::Connection* db) { 21 void CreateV1Table(sql::Connection* db) {
23 ASSERT_TRUE(db->is_open()); 22 ASSERT_TRUE(db->is_open());
24 ASSERT_TRUE(db->Execute("DROP TABLE IF EXISTS ItemTable")); 23 ASSERT_TRUE(db->Execute("DROP TABLE IF EXISTS ItemTable"));
25 ASSERT_TRUE(db->Execute( 24 ASSERT_TRUE(db->Execute(
26 "CREATE TABLE ItemTable (" 25 "CREATE TABLE ItemTable ("
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 base::ScopedTempDir temp_dir; 341 base::ScopedTempDir temp_dir;
343 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 342 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
344 base::FilePath file_name = 343 base::FilePath file_name =
345 temp_dir.path().AppendASCII("TestDOMStorageDatabase.db"); 344 temp_dir.path().AppendASCII("TestDOMStorageDatabase.db");
346 345
347 const char kData[] = "I am not a database."; 346 const char kData[] = "I am not a database.";
348 base::WriteFile(file_name, kData, strlen(kData)); 347 base::WriteFile(file_name, kData, strlen(kData));
349 348
350 { 349 {
351 sql::ScopedErrorIgnorer ignore_errors; 350 sql::ScopedErrorIgnorer ignore_errors;
352 ignore_errors.IgnoreError(SQLITE_IOERR_SHORT_READ); 351
352 // Earlier versions of Chromium compiled against SQLite 3.6.7.3, which
353 // returned SQLITE_IOERR_SHORT_READ in this case. Some platforms may still
354 // compile against an earlier SQLite via USE_SYSTEM_SQLITE.
355 if (ignore_errors.SQLiteLibVersionNumber() < 3008007) {
356 ignore_errors.IgnoreError(SQLITE_IOERR_SHORT_READ);
357 } else {
358 ignore_errors.IgnoreError(SQLITE_NOTADB);
359 }
353 360
354 // Try and open the file. As it's not a database, we should end up deleting 361 // Try and open the file. As it's not a database, we should end up deleting
355 // it and creating a new, valid file, so everything should actually 362 // it and creating a new, valid file, so everything should actually
356 // succeed. 363 // succeed.
357 DOMStorageDatabase db(file_name); 364 DOMStorageDatabase db(file_name);
358 DOMStorageValuesMap values; 365 DOMStorageValuesMap values;
359 CreateMapWithValues(&values); 366 CreateMapWithValues(&values);
360 EXPECT_TRUE(db.CommitChanges(true, values)); 367 EXPECT_TRUE(db.CommitChanges(true, values));
361 EXPECT_TRUE(db.CommitChanges(false, values)); 368 EXPECT_TRUE(db.CommitChanges(false, values));
362 EXPECT_TRUE(db.IsOpen()); 369 EXPECT_TRUE(db.IsOpen());
(...skipping 22 matching lines...) Expand all
385 EXPECT_EQ(0u, values.size()); 392 EXPECT_EQ(0u, values.size());
386 EXPECT_FALSE(db.IsOpen()); 393 EXPECT_FALSE(db.IsOpen());
387 394
388 EXPECT_TRUE(base::PathExists(temp_dir.path())); 395 EXPECT_TRUE(base::PathExists(temp_dir.path()));
389 396
390 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); 397 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
391 } 398 }
392 } 399 }
393 400
394 } // namespace content 401 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | sql/BUILD.gn » ('j') | third_party/sqlite/src/src/os_unix.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698