OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef SQL_TEST_ERROR_CALLBACK_SUPPORT_H_ |
| 6 #define SQL_TEST_ERROR_CALLBACK_SUPPORT_H_ |
| 7 |
| 8 #include "sql/connection.h" |
| 9 |
| 10 namespace sql { |
| 11 |
| 12 // Used in concert to test that the error callback is catching a |
| 13 // specific error. 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 |
| 19 |
| 20 void CaptureErrorCallback(int* error_pointer, int error, sql::Statement* stmt); |
| 21 |
| 22 class ScopedErrorCallback { |
| 23 public: |
| 24 ScopedErrorCallback(sql::Connection* db, |
| 25 const sql::Connection::ErrorCallback& cb); |
| 26 ~ScopedErrorCallback(); |
| 27 |
| 28 private: |
| 29 sql::Connection* db_; |
| 30 |
| 31 DISALLOW_COPY_AND_ASSIGN(ScopedErrorCallback); |
| 32 }; |
| 33 |
| 34 } // namespace sql |
| 35 |
| 36 #endif // SQL_TEST_ERROR_CALLBACK_SUPPORT_H_ |
OLD | NEW |