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

Side by Side Diff: sql/connection_unittest.cc

Issue 1306863006: [sqlite] Respect the gyp and gn component switch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 3 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 | « sql/BUILD.gn ('k') | sql/proxy.h » ('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/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_file.h" 7 #include "base/files/scoped_file.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/statistics_recorder.h" 10 #include "base/metrics/statistics_recorder.h"
11 #include "base/test/histogram_tester.h" 11 #include "base/test/histogram_tester.h"
12 #include "sql/connection.h" 12 #include "sql/connection.h"
13 #include "sql/correct_sql_test_base.h" 13 #include "sql/correct_sql_test_base.h"
14 #include "sql/meta_table.h" 14 #include "sql/meta_table.h"
15 #include "sql/proxy.h"
16 #include "sql/statement.h" 15 #include "sql/statement.h"
17 #include "sql/test/error_callback_support.h" 16 #include "sql/test/error_callback_support.h"
18 #include "sql/test/scoped_error_ignorer.h" 17 #include "sql/test/scoped_error_ignorer.h"
19 #include "sql/test/test_helpers.h" 18 #include "sql/test/test_helpers.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/sqlite/sqlite3.h" 20 #include "third_party/sqlite/sqlite3.h"
22 21
23 namespace sql { 22 namespace sql {
24 namespace test { 23 namespace test {
25 24
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 78
80 // Allow a test to add a SQLite function in a scoped context. 79 // Allow a test to add a SQLite function in a scoped context.
81 class ScopedScalarFunction { 80 class ScopedScalarFunction {
82 public: 81 public:
83 ScopedScalarFunction( 82 ScopedScalarFunction(
84 sql::Connection& db, 83 sql::Connection& db,
85 const char* function_name, 84 const char* function_name,
86 int args, 85 int args,
87 base::Callback<void(sqlite3_context*,int,sqlite3_value**)> cb) 86 base::Callback<void(sqlite3_context*,int,sqlite3_value**)> cb)
88 : db_(db.db_), function_name_(function_name), cb_(cb) { 87 : db_(db.db_), function_name_(function_name), cb_(cb) {
89 sql::sqlite3_create_function_v2(db_, function_name, args, SQLITE_UTF8, 88 ::sqlite3_create_function_v2(db_, function_name, args, SQLITE_UTF8,
90 this, &Run, NULL, NULL, NULL); 89 this, &Run, NULL, NULL, NULL);
91 } 90 }
92 ~ScopedScalarFunction() { 91 ~ScopedScalarFunction() {
93 sql::sqlite3_create_function_v2(db_, function_name_, 0, SQLITE_UTF8, 92 ::sqlite3_create_function_v2(db_, function_name_, 0, SQLITE_UTF8,
94 NULL, NULL, NULL, NULL, NULL); 93 NULL, NULL, NULL, NULL, NULL);
95 } 94 }
96 95
97 private: 96 private:
98 static void Run(sqlite3_context* context, int argc, sqlite3_value** argv) { 97 static void Run(sqlite3_context* context, int argc, sqlite3_value** argv) {
99 ScopedScalarFunction* t = static_cast<ScopedScalarFunction*>( 98 ScopedScalarFunction* t = static_cast<ScopedScalarFunction*>(
100 sqlite3_user_data(context)); 99 sqlite3_user_data(context));
101 t->cb_.Run(context, argc, argv); 100 t->cb_.Run(context, argc, argv);
102 } 101 }
103 102
104 sqlite3* db_; 103 sqlite3* db_;
105 const char* function_name_; 104 const char* function_name_;
106 base::Callback<void(sqlite3_context*,int,sqlite3_value**)> cb_; 105 base::Callback<void(sqlite3_context*,int,sqlite3_value**)> cb_;
107 106
108 DISALLOW_COPY_AND_ASSIGN(ScopedScalarFunction); 107 DISALLOW_COPY_AND_ASSIGN(ScopedScalarFunction);
109 }; 108 };
110 109
111 // Allow a test to add a SQLite commit hook in a scoped context. 110 // Allow a test to add a SQLite commit hook in a scoped context.
112 class ScopedCommitHook { 111 class ScopedCommitHook {
113 public: 112 public:
114 ScopedCommitHook(sql::Connection& db, 113 ScopedCommitHook(sql::Connection& db,
115 base::Callback<int(void)> cb) 114 base::Callback<int(void)> cb)
116 : db_(db.db_), 115 : db_(db.db_),
117 cb_(cb) { 116 cb_(cb) {
118 sql::sqlite3_commit_hook(db_, &Run, this); 117 ::sqlite3_commit_hook(db_, &Run, this);
119 } 118 }
120 ~ScopedCommitHook() { 119 ~ScopedCommitHook() {
121 sql::sqlite3_commit_hook(db_, NULL, NULL); 120 ::sqlite3_commit_hook(db_, NULL, NULL);
122 } 121 }
123 122
124 private: 123 private:
125 static int Run(void* p) { 124 static int Run(void* p) {
126 ScopedCommitHook* t = static_cast<ScopedCommitHook*>(p); 125 ScopedCommitHook* t = static_cast<ScopedCommitHook*>(p);
127 return t->cb_.Run(); 126 return t->cb_.Run();
128 } 127 }
129 128
130 sqlite3* db_; 129 sqlite3* db_;
131 base::Callback<int(void)> cb_; 130 base::Callback<int(void)> cb_;
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 samples = tester.GetHistogramSamplesSinceCreation(kCommitTime); 1292 samples = tester.GetHistogramSamplesSinceCreation(kCommitTime);
1294 ASSERT_TRUE(samples); 1293 ASSERT_TRUE(samples);
1295 // 100 for commit adjust, 1 for measuring COMMIT. 1294 // 100 for commit adjust, 1 for measuring COMMIT.
1296 EXPECT_EQ(101, samples->sum()); 1295 EXPECT_EQ(101, samples->sum());
1297 1296
1298 samples = tester.GetHistogramSamplesSinceCreation(kAutoCommitTime); 1297 samples = tester.GetHistogramSamplesSinceCreation(kAutoCommitTime);
1299 EXPECT_EQ(0, samples->sum()); 1298 EXPECT_EQ(0, samples->sum());
1300 } 1299 }
1301 1300
1302 } // namespace 1301 } // namespace
OLDNEW
« no previous file with comments | « sql/BUILD.gn ('k') | sql/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698