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

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

Issue 2315443004: Remove calls to deprecated MessageLoop methods in chrome. (Closed)
Patch Set: remove unused include Created 4 years, 3 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
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "chrome/renderer/media/chrome_webrtc_log_message_delegate.h" 14 #include "chrome/renderer/media/chrome_webrtc_log_message_delegate.h"
14 #include "chrome/renderer/media/mock_webrtc_logging_message_filter.h" 15 #include "chrome/renderer/media/mock_webrtc_logging_message_filter.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 TEST(ChromeWebRtcLogMessageDelegateTest, Basic) { 18 TEST(ChromeWebRtcLogMessageDelegateTest, Basic) {
18 const char kTestString[] = "abcdefghijklmnopqrstuvwxyz"; 19 const char kTestString[] = "abcdefghijklmnopqrstuvwxyz";
19 base::MessageLoopForIO message_loop; 20 base::MessageLoopForIO message_loop;
20 scoped_refptr<MockWebRtcLoggingMessageFilter> log_message_filter( 21 scoped_refptr<MockWebRtcLoggingMessageFilter> log_message_filter(
21 new MockWebRtcLoggingMessageFilter(message_loop.task_runner())); 22 new MockWebRtcLoggingMessageFilter(message_loop.task_runner()));
22 // Run message loop to initialize delegate. 23 // Run message loop to initialize delegate.
23 // TODO(vrk): Fix this so that we can construct a delegate without needing to 24 // TODO(vrk): Fix this so that we can construct a delegate without needing to
24 // construct a message filter. 25 // construct a message filter.
25 message_loop.RunUntilIdle(); 26 base::RunLoop().RunUntilIdle();
26 27
27 ChromeWebRtcLogMessageDelegate* log_message_delegate = 28 ChromeWebRtcLogMessageDelegate* log_message_delegate =
28 log_message_filter->log_message_delegate(); 29 log_message_filter->log_message_delegate();
29 30
30 // Start logging on the IO loop. 31 // Start logging on the IO loop.
31 message_loop.task_runner()->PostTask( 32 message_loop.task_runner()->PostTask(
32 FROM_HERE, base::Bind(&ChromeWebRtcLogMessageDelegate::OnStartLogging, 33 FROM_HERE, base::Bind(&ChromeWebRtcLogMessageDelegate::OnStartLogging,
33 base::Unretained(log_message_delegate))); 34 base::Unretained(log_message_delegate)));
34 35
35 // These log messages should be added to the log buffer outside of the IO 36 // These log messages should be added to the log buffer outside of the IO
36 // loop. 37 // loop.
37 log_message_delegate->LogMessage(kTestString); 38 log_message_delegate->LogMessage(kTestString);
38 log_message_delegate->LogMessage(kTestString); 39 log_message_delegate->LogMessage(kTestString);
39 40
40 // Stop logging on IO loop. 41 // Stop logging on IO loop.
41 message_loop.task_runner()->PostTask( 42 message_loop.task_runner()->PostTask(
42 FROM_HERE, base::Bind(&ChromeWebRtcLogMessageDelegate::OnStopLogging, 43 FROM_HERE, base::Bind(&ChromeWebRtcLogMessageDelegate::OnStopLogging,
43 base::Unretained(log_message_delegate))); 44 base::Unretained(log_message_delegate)));
44 45
45 // This log message should not be added to the log buffer. 46 // This log message should not be added to the log buffer.
46 log_message_delegate->LogMessage(kTestString); 47 log_message_delegate->LogMessage(kTestString);
47 48
48 message_loop.RunUntilIdle(); 49 base::RunLoop().RunUntilIdle();
49 50
50 // Size is calculated as (sizeof(kTestString) - 1 for terminating null 51 // Size is calculated as (sizeof(kTestString) - 1 for terminating null
51 // + 1 for eol added for each log message in LogMessage) * 2. 52 // + 1 for eol added for each log message in LogMessage) * 2.
52 const uint32_t kExpectedSize = sizeof(kTestString) * 2; 53 const uint32_t kExpectedSize = sizeof(kTestString) * 2;
53 EXPECT_EQ(kExpectedSize, log_message_filter->log_buffer_.size()); 54 EXPECT_EQ(kExpectedSize, log_message_filter->log_buffer_.size());
54 55
55 std::string ref_output = kTestString; 56 std::string ref_output = kTestString;
56 ref_output.append("\n"); 57 ref_output.append("\n");
57 ref_output.append(kTestString); 58 ref_output.append(kTestString);
58 ref_output.append("\n"); 59 ref_output.append("\n");
59 EXPECT_STREQ(ref_output.c_str(), log_message_filter->log_buffer_.c_str()); 60 EXPECT_STREQ(ref_output.c_str(), log_message_filter->log_buffer_.c_str());
60 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698