Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: chrome/renderer/media/webrtc_logging_handler_impl_unittest.cc

Issue 15741003: Moving WebRTC logging related files from content to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 #include "content/common/partial_circular_buffer.h" 8 #include "chrome/common/partial_circular_buffer.h"
9 #include "content/renderer/media/webrtc_logging_handler_impl.h" 9 #include "chrome/renderer/media/webrtc_logging_handler_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace content {
13
14 TEST(WebRtcLoggingHandlerImplTest, Basic) { 12 TEST(WebRtcLoggingHandlerImplTest, Basic) {
15 const uint32 kTestLogSize = 1024; // 1 KB 13 const uint32 kTestLogSize = 1024; // 1 KB
16 const char kTestString[] = "abcdefghijklmnopqrstuvwxyz"; 14 const char kTestString[] = "abcdefghijklmnopqrstuvwxyz";
17 15
18 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO); 16 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
19 17
20 scoped_ptr<WebRtcLoggingHandlerImpl> logging_handler( 18 scoped_ptr<WebRtcLoggingHandlerImpl> logging_handler(
21 new WebRtcLoggingHandlerImpl(message_loop.message_loop_proxy())); 19 new WebRtcLoggingHandlerImpl(message_loop.message_loop_proxy(), NULL));
22 20
23 base::SharedMemory shared_memory; 21 base::SharedMemory shared_memory;
24 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(kTestLogSize)); 22 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(kTestLogSize));
25 base::SharedMemoryHandle new_handle; 23 base::SharedMemoryHandle new_handle;
26 ASSERT_TRUE(shared_memory.ShareToProcess(base::GetCurrentProcessHandle(), 24 ASSERT_TRUE(shared_memory.ShareToProcess(base::GetCurrentProcessHandle(),
27 &new_handle)); 25 &new_handle));
28 logging_handler->OnLogOpened(new_handle, kTestLogSize); 26 logging_handler->OnLogOpened(new_handle, kTestLogSize);
29 27
30 logging_handler->LogMessage(kTestString); 28 logging_handler->LogMessage(kTestString);
31 logging_handler->LogMessage(kTestString); 29 logging_handler->LogMessage(kTestString);
32 30
33 content::PartialCircularBuffer read_pcb( 31 PartialCircularBuffer read_pcb(
34 reinterpret_cast<uint8*>(shared_memory.memory()), kTestLogSize); 32 reinterpret_cast<uint8*>(shared_memory.memory()), kTestLogSize);
35 33
36 // Size is calculated as (sizeof(kTestString) - 1 for terminating null 34 // Size is calculated as (sizeof(kTestString) - 1 for terminating null
37 // + 1 for eol added for each log message in LogMessage) * 2 + 1 for 35 // + 1 for eol added for each log message in LogMessage) * 2 + 1 for
38 // terminating null. 36 // terminating null.
39 char read_buffer[sizeof(kTestString) * 2 + 1] = {0}; 37 char read_buffer[sizeof(kTestString) * 2 + 1] = {0};
40 38
41 uint32 read = read_pcb.Read(read_buffer, sizeof(read_buffer)); 39 uint32 read = read_pcb.Read(read_buffer, sizeof(read_buffer));
42 EXPECT_EQ(sizeof(read_buffer) - 1, read); 40 EXPECT_EQ(sizeof(read_buffer) - 1, read);
43 std::string ref_output = kTestString; 41 std::string ref_output = kTestString;
44 ref_output.append("\n"); 42 ref_output.append("\n");
45 ref_output.append(kTestString); 43 ref_output.append(kTestString);
46 ref_output.append("\n"); 44 ref_output.append("\n");
47 EXPECT_STREQ(ref_output.c_str(), read_buffer); 45 EXPECT_STREQ(ref_output.c_str(), read_buffer);
48 } 46 }
49
50 } // namespace content
OLDNEW
« no previous file with comments | « chrome/renderer/media/webrtc_logging_handler_impl.cc ('k') | chrome/renderer/media/webrtc_logging_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698