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
3 // found in the LICENSE file.
5 #ifndef SQL_TEST_ERROR_CALLBACK_SUPPORT_H_
6 #define SQL_TEST_ERROR_CALLBACK_SUPPORT_H_
8 #include "sql/connection.h"
12 // Helper to capture any errors into a local variable for testing.
14 // int error = SQLITE_OK;
15 // ScopedErrorCallback sec(db, base::Bind(&CaptureErrorCallback, &error));
16 // // Provoke SQLITE_CONSTRAINT on db.
17 // EXPECT_EQ(SQLITE_CONSTRAINT, error);
18 void CaptureErrorCallback(int* error_pointer
, int error
, sql::Statement
* stmt
);
20 // Helper to set db's error callback and then reset it when it goes
22 class ScopedErrorCallback
{
24 ScopedErrorCallback(sql::Connection
* db
,
25 const sql::Connection::ErrorCallback
& cb
);
26 ~ScopedErrorCallback();
31 DISALLOW_COPY_AND_ASSIGN(ScopedErrorCallback
);
36 #endif // SQL_TEST_ERROR_CALLBACK_SUPPORT_H_