diff --git a/webrtc/common_types.h b/webrtc/common_types.h index f5d55d78f..fc1979c10 100644 --- a/webrtc/common_types.h +++ b/webrtc/common_types.h @@ -103,17 +103,14 @@ enum TraceLevel }; // External Trace API -class TraceCallback -{ -public: - virtual void Print(const TraceLevel level, - const char *traceString, - const int length) = 0; -protected: - virtual ~TraceCallback() {} - TraceCallback() {} -}; +class TraceCallback { + public: + virtual void Print(TraceLevel level, const char* message, int length) = 0; + protected: + virtual ~TraceCallback() {} + TraceCallback() {} +}; enum FileFormats { diff --git a/webrtc/modules/udp_transport/source/udp_socket_wrapper_unittest.cc b/webrtc/modules/udp_transport/source/udp_socket_wrapper_unittest.cc index 32d9a6484..2489604d5 100644 --- a/webrtc/modules/udp_transport/source/udp_socket_wrapper_unittest.cc +++ b/webrtc/modules/udp_transport/source/udp_socket_wrapper_unittest.cc @@ -24,31 +24,12 @@ #include "gmock/gmock.h" #include "modules/udp_transport/source/udp_socket_wrapper.h" #include "modules/udp_transport/source/udp_socket_manager_wrapper.h" -#include "system_wrappers/interface/trace.h" using ::testing::_; using ::testing::Return; namespace webrtc { -const int kLogTrace = 0; - -class TestTraceCallback: public TraceCallback { - public: - void Print(const TraceLevel level, - const char *traceString, - const int length) { - if (traceString) { - char* tmp = new char[length+1]; - memcpy(tmp, traceString, length); - tmp[length] = '\0'; - printf("%s\n", tmp); - fflush(stdout); - delete[] tmp; - } - } -}; - class MockSocketManager : public UdpSocketManager { public: MockSocketManager() {} @@ -67,20 +48,10 @@ class MockSocketManager : public UdpSocketManager { // Creates a socket using the static constructor method and verifies that // it's added to the socket manager. TEST(UdpSocketWrapper, CreateSocket) { - TestTraceCallback trace; - if (kLogTrace) { - Trace::CreateTrace(); - Trace::SetLevelFilter(webrtc::kTraceAll); - Trace::SetTraceCallback(&trace); - } - WebRtc_Word32 id = 42; // We can't test deletion of sockets without a socket manager. WebRtc_UWord8 threads = 1; UdpSocketManager* mgr = UdpSocketManager::Create(id, threads); - WEBRTC_TRACE(kTraceMemory, kTraceTransport, 42, - "Test trace call"); - UdpSocketWrapper* socket = UdpSocketWrapper::CreateSocket(id, mgr, @@ -90,9 +61,6 @@ TEST(UdpSocketWrapper, CreateSocket) { false); // disableGQOS socket->CloseBlocking(); UdpSocketManager::Return(); - if (kLogTrace) { - Trace::ReturnTrace(); - } } } // namespace webrtc diff --git a/webrtc/system_wrappers/source/logging_unittest.cc b/webrtc/system_wrappers/source/logging_unittest.cc index 45acbfd30..95102b009 100644 --- a/webrtc/system_wrappers/source/logging_unittest.cc +++ b/webrtc/system_wrappers/source/logging_unittest.cc @@ -24,9 +24,7 @@ const size_t kBoilerplateLength = 71; class LoggingTest : public ::testing::Test, public TraceCallback { public: - virtual void Print(const TraceLevel level, - const char* msg, - const int length) { + virtual void Print(TraceLevel level, const char* msg, int length) { CriticalSectionScoped cs(crit_.get()); // We test the length here to ensure (with high likelihood) that only our // traces will be tested. diff --git a/webrtc/system_wrappers/source/thread_unittest.cc b/webrtc/system_wrappers/source/thread_unittest.cc index 6bbe13693..d188c7af5 100644 --- a/webrtc/system_wrappers/source/thread_unittest.cc +++ b/webrtc/system_wrappers/source/thread_unittest.cc @@ -12,56 +12,10 @@ #include "gtest/gtest.h" #include "system_wrappers/interface/scoped_ptr.h" -#include "system_wrappers/interface/trace.h" namespace webrtc { -const int kLogTrace = 0; - -class TestTraceCallback : public TraceCallback { - public: - virtual void Print(const TraceLevel level, - const char* traceString, - const int length) { - if (traceString) { - char* cmd_print = new char[length+1]; - memcpy(cmd_print, traceString, length); - cmd_print[length] = '\0'; - printf("%s\n", cmd_print); - fflush(stdout); - delete[] cmd_print; - } - } -}; - -class ThreadTest : public ::testing::Test { - public: - ThreadTest() { - StartTrace(); - } - ~ThreadTest() { - StopTrace(); - } - - private: - void StartTrace() { - if (kLogTrace) { - Trace::CreateTrace(); - Trace::SetLevelFilter(webrtc::kTraceAll); - Trace::SetTraceCallback(&trace_); - } - } - - void StopTrace() { - if (kLogTrace) { - Trace::ReturnTrace(); - } - } - - TestTraceCallback trace_; -}; - -TEST_F(ThreadTest, NullFunctionPointer) { +TEST(ThreadTest, NullFunctionPointer) { webrtc::scoped_ptr thread( webrtc::ThreadWrapper::CreateThread()); unsigned int id = 42; @@ -73,7 +27,7 @@ bool NullRunFunction(void* /* obj */) { return true; } -TEST_F(ThreadTest, StartStop) { +TEST(ThreadTest, StartStop) { ThreadWrapper* thread = ThreadWrapper::CreateThread(&NullRunFunction); unsigned int id = 42; ASSERT_TRUE(thread->Start(id)); @@ -88,7 +42,7 @@ bool SetFlagRunFunction(void* obj) { return true; } -TEST_F(ThreadTest, RunFunctionIsCalled) { +TEST(ThreadTest, RunFunctionIsCalled) { bool flag = false; ThreadWrapper* thread = ThreadWrapper::CreateThread(&SetFlagRunFunction, &flag); diff --git a/webrtc/system_wrappers/source/unittest_utilities.h b/webrtc/system_wrappers/source/unittest_utilities.h index 771d798f5..cfc5392a6 100644 --- a/webrtc/system_wrappers/source/unittest_utilities.h +++ b/webrtc/system_wrappers/source/unittest_utilities.h @@ -23,12 +23,10 @@ namespace webrtc { class TestTraceCallback : public TraceCallback { public: - virtual void Print(const TraceLevel level, - const char* traceString, - const int length) { - if (traceString) { + virtual void Print(TraceLevel level, const char* msg, int length) { + if (msg) { char* cmd_print = new char[length+1]; - memcpy(cmd_print, traceString, length); + memcpy(cmd_print, msg, length); cmd_print[length] = '\0'; printf("%s\n", cmd_print); fflush(stdout);