1 // Copyright 2014 The Chromium Authors 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 NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ 6 #define NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ 7 8 #include "base/logging.h" 9 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gtest/include/gtest/gtest.h" 11 12 namespace net::test { 13 14 // The ScopedDisableExitOnDFatal class is used to disable exiting the 15 // program when we encounter a LOG(DFATAL) within the current block. 16 // After we leave the current block, the default behavior is 17 // restored. 18 class ScopedDisableExitOnDFatal { 19 public: 20 ScopedDisableExitOnDFatal(); 21 22 ScopedDisableExitOnDFatal(const ScopedDisableExitOnDFatal&) = delete; 23 ScopedDisableExitOnDFatal& operator=(const ScopedDisableExitOnDFatal&) = 24 delete; 25 26 ~ScopedDisableExitOnDFatal(); 27 28 private: 29 // Static function which is set as the logging assert handler. 30 // Called when there is a check failure. 31 static void LogAssertHandler(const char* file, 32 int line, 33 const base::StringPiece message, 34 const base::StringPiece stack_trace); 35 36 logging::ScopedLogAssertHandler assert_handler_; 37 }; 38 39 } // namespace net::test 40 41 #endif // NET_TEST_SCOPED_DISABLE_EXIT_ON_DFATAL_H_ 42