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

Unified Diff: sql/test/error_callback_support.h

Issue 17726002: [sql] Callback and scoped-ignore tests for sql::Statement. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: prevent nesting, TODO. Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/statement_unittest.cc ('k') | sql/test/error_callback_support.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/test/error_callback_support.h
diff --git a/sql/test/error_callback_support.h b/sql/test/error_callback_support.h
new file mode 100644
index 0000000000000000000000000000000000000000..30268570f89bfc4f9c58c52884f9335170c8961d
--- /dev/null
+++ b/sql/test/error_callback_support.h
@@ -0,0 +1,36 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SQL_TEST_ERROR_CALLBACK_SUPPORT_H_
+#define SQL_TEST_ERROR_CALLBACK_SUPPORT_H_
+
+#include "sql/connection.h"
+
+namespace sql {
+
+// Helper to capture any errors into a local variable for testing.
+// For instance:
+// int error = SQLITE_OK;
+// ScopedErrorCallback sec(db, base::Bind(&CaptureErrorCallback, &error));
+// // Provoke SQLITE_CONSTRAINT on db.
+// EXPECT_EQ(SQLITE_CONSTRAINT, error);
+void CaptureErrorCallback(int* error_pointer, int error, sql::Statement* stmt);
+
+// Helper to set db's error callback and then reset it when it goes
+// out of scope.
+class ScopedErrorCallback {
+ public:
+ ScopedErrorCallback(sql::Connection* db,
+ const sql::Connection::ErrorCallback& cb);
+ ~ScopedErrorCallback();
+
+ private:
+ sql::Connection* db_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedErrorCallback);
+};
+
+} // namespace sql
+
+#endif // SQL_TEST_ERROR_CALLBACK_SUPPORT_H_
« no previous file with comments | « sql/statement_unittest.cc ('k') | sql/test/error_callback_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698