Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / sql / test / error_callback_support.h
blob30268570f89bfc4f9c58c52884f9335170c8961d
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"
10 namespace sql {
12 // Helper to capture any errors into a local variable for testing.
13 // For instance:
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
21 // out of scope.
22 class ScopedErrorCallback {
23 public:
24 ScopedErrorCallback(sql::Connection* db,
25 const sql::Connection::ErrorCallback& cb);
26 ~ScopedErrorCallback();
28 private:
29 sql::Connection* db_;
31 DISALLOW_COPY_AND_ASSIGN(ScopedErrorCallback);
34 } // namespace sql
36 #endif // SQL_TEST_ERROR_CALLBACK_SUPPORT_H_