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

Side by Side Diff: content/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: Fixed handler unit test. 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/process_util.h"
8 #include "content/common/partial_circular_buffer.h"
9 #include "content/renderer/media/webrtc_logging_handler_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace content {
13
14 TEST(WebRtcLoggingHandlerImplTest, Basic) {
15 const uint32 kTestLogSize = 1024; // 1 KB
16 const char kTestString[] = "abcdefghijklmnopqrstuvwxyz";
17
18 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO);
19
20 scoped_ptr<WebRtcLoggingHandlerImpl> logging_handler(
21 new WebRtcLoggingHandlerImpl(message_loop.message_loop_proxy()));
22
23 base::SharedMemory shared_memory;
24 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(kTestLogSize));
25 base::SharedMemoryHandle new_handle;
26 ASSERT_TRUE(shared_memory.ShareToProcess(base::GetCurrentProcessHandle(),
27 &new_handle));
28 logging_handler->OnLogOpened(new_handle, kTestLogSize);
29
30 logging_handler->LogMessage(kTestString);
31 logging_handler->LogMessage(kTestString);
32
33 content::PartialCircularBuffer read_pcb(
34 reinterpret_cast<uint8*>(shared_memory.memory()), kTestLogSize);
35
36 // Size is calculated as (sizeof(kTestString) - 1 for terminating null
37 // + 1 for eol added for each log message in LogMessage) * 2 + 1 for
38 // terminating null.
39 char read_buffer[sizeof(kTestString) * 2 + 1] = {0};
40
41 uint32 read = read_pcb.Read(read_buffer, sizeof(read_buffer));
42 EXPECT_EQ(sizeof(read_buffer) - 1, read);
43 std::string ref_output = kTestString;
44 ref_output.append("\n");
45 ref_output.append(kTestString);
46 ref_output.append("\n");
47 EXPECT_STREQ(ref_output.c_str(), read_buffer);
48 }
49
50 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698