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

Side by Side Diff: media/audio/async_socket_io_handler_unittest.cc

Issue 11359193: media: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix rebase error Created 8 years, 1 month 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
« no previous file with comments | « no previous file | media/audio/audio_low_latency_input_output_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/audio/async_socket_io_handler.h" 5 #include "media/audio/async_socket_io_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 pair[1].Send(kAsyncSocketIoTestString, kAsyncSocketIoTestStringLength); 99 pair[1].Send(kAsyncSocketIoTestString, kAsyncSocketIoTestStringLength);
100 MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 100 MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),
101 base::TimeDelta::FromMilliseconds(100)); 101 base::TimeDelta::FromMilliseconds(100));
102 MessageLoop::current()->Run(); 102 MessageLoop::current()->Run();
103 103
104 EXPECT_TRUE(reader.IssueRead()); 104 EXPECT_TRUE(reader.IssueRead());
105 EXPECT_EQ(strcmp(reader.buffer(), kAsyncSocketIoTestString), 0); 105 EXPECT_EQ(strcmp(reader.buffer(), kAsyncSocketIoTestString), 0);
106 // We've now verified that the read happened synchronously, but it's not 106 // We've now verified that the read happened synchronously, but it's not
107 // guaranteed that the callback has been issued since the callback will be 107 // guaranteed that the callback has been issued since the callback will be
108 // called asynchronously even though the read may have been done. 108 // called asynchronously even though the read may have been done.
109 // So we call RunAllPending() to allow any event notifications or APC's on 109 // So we call RunUntilIdle() to allow any event notifications or APC's on
110 // Windows, to execute before checking the count of how many callbacks we've 110 // Windows, to execute before checking the count of how many callbacks we've
111 // received. 111 // received.
112 MessageLoop::current()->RunAllPending(); 112 MessageLoop::current()->RunUntilIdle();
113 EXPECT_EQ(1, reader.callbacks_received()); 113 EXPECT_EQ(1, reader.callbacks_received());
114 } 114 }
115 115
116 // Calls Read() from within a callback to test that simple read "loops" work. 116 // Calls Read() from within a callback to test that simple read "loops" work.
117 TEST(AsyncSocketIoHandlerTest, ReadFromCallback) { 117 TEST(AsyncSocketIoHandlerTest, ReadFromCallback) {
118 MessageLoopForIO loop; 118 MessageLoopForIO loop;
119 119
120 base::CancelableSyncSocket pair[2]; 120 base::CancelableSyncSocket pair[2];
121 ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&pair[0], &pair[1])); 121 ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&pair[0], &pair[1]));
122 122
(...skipping 10 matching lines...) Expand all
133 base::TimeDelta::FromMilliseconds(milliseconds)); 133 base::TimeDelta::FromMilliseconds(milliseconds));
134 milliseconds += 10; 134 milliseconds += 10;
135 } 135 }
136 136
137 MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), 137 MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),
138 base::TimeDelta::FromMilliseconds(100 + milliseconds)); 138 base::TimeDelta::FromMilliseconds(100 + milliseconds));
139 139
140 MessageLoop::current()->Run(); 140 MessageLoop::current()->Run();
141 EXPECT_EQ(kReadOperationCount, reader.callbacks_received()); 141 EXPECT_EQ(kReadOperationCount, reader.callbacks_received());
142 } 142 }
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_low_latency_input_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698