OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/process_handle.h" | 7 #include "base/process/process_handle.h" |
8 #include "chrome/common/partial_circular_buffer.h" | 8 #include "chrome/common/partial_circular_buffer.h" |
9 #include "chrome/renderer/media/chrome_webrtc_log_message_delegate.h" | 9 #include "chrome/renderer/media/chrome_webrtc_log_message_delegate.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 TEST(ChromeWebRtcLogMessageDelegateTest, Basic) { | 12 TEST(ChromeWebRtcLogMessageDelegateTest, Basic) { |
13 const uint32 kTestLogSize = 1024; // 1 KB | 13 const uint32 kTestLogSize = 1024; // 1 KB |
14 const char kTestString[] = "abcdefghijklmnopqrstuvwxyz"; | 14 const char kTestString[] = "abcdefghijklmnopqrstuvwxyz"; |
15 | 15 |
16 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO); | 16 base::MessageLoopForIO message_loop; |
17 | 17 |
18 scoped_ptr<ChromeWebRtcLogMessageDelegate> log_message_delegate( | 18 scoped_ptr<ChromeWebRtcLogMessageDelegate> log_message_delegate( |
19 new ChromeWebRtcLogMessageDelegate(message_loop.message_loop_proxy(), | 19 new ChromeWebRtcLogMessageDelegate(message_loop.message_loop_proxy(), |
20 NULL)); | 20 NULL)); |
21 | 21 |
22 base::SharedMemory shared_memory; | 22 base::SharedMemory shared_memory; |
23 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(kTestLogSize)); | 23 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(kTestLogSize)); |
24 base::SharedMemoryHandle new_handle; | 24 base::SharedMemoryHandle new_handle; |
25 ASSERT_TRUE(shared_memory.ShareToProcess(base::GetCurrentProcessHandle(), | 25 ASSERT_TRUE(shared_memory.ShareToProcess(base::GetCurrentProcessHandle(), |
26 &new_handle)); | 26 &new_handle)); |
(...skipping 19 matching lines...) Expand all Loading... |
46 char read_buffer[kExpectedSize * 2] = {0}; | 46 char read_buffer[kExpectedSize * 2] = {0}; |
47 | 47 |
48 uint32 read = read_pcb.Read(read_buffer, kExpectedSize * 2); | 48 uint32 read = read_pcb.Read(read_buffer, kExpectedSize * 2); |
49 EXPECT_EQ(kExpectedSize, read); | 49 EXPECT_EQ(kExpectedSize, read); |
50 std::string ref_output = kTestString; | 50 std::string ref_output = kTestString; |
51 ref_output.append("\n"); | 51 ref_output.append("\n"); |
52 ref_output.append(kTestString); | 52 ref_output.append(kTestString); |
53 ref_output.append("\n"); | 53 ref_output.append("\n"); |
54 EXPECT_STREQ(ref_output.c_str(), read_buffer); | 54 EXPECT_STREQ(ref_output.c_str(), read_buffer); |
55 } | 55 } |
OLD | NEW |