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

Side by Side Diff: mojo/public/cpp/system/tests/watcher_unittest.cc

Issue 1895083004: [Draft] See what tests are broken. Base URL: https://chromium.googlesource.com/chromium/src.git@27_watcher_no_abort
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | mojo/public/cpp/system/watcher.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mojo/public/cpp/system/watcher.h" 5 #include "mojo/public/cpp/system/watcher.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // |b_watcher| should be cancelled when it goes out of scope. 154 // |b_watcher| should be cancelled when it goes out of scope.
155 } 155 }
156 156
157 // This should never trigger the watcher above. 157 // This should never trigger the watcher above.
158 EXPECT_EQ(MOJO_RESULT_OK, WriteMessageRaw(a.get(), "hello", 5, nullptr, 0, 158 EXPECT_EQ(MOJO_RESULT_OK, WriteMessageRaw(a.get(), "hello", 5, nullptr, 0,
159 MOJO_WRITE_MESSAGE_FLAG_NONE)); 159 MOJO_WRITE_MESSAGE_FLAG_NONE));
160 base::ThreadTaskRunnerHandle::Get()->PostTask( 160 base::ThreadTaskRunnerHandle::Get()->PostTask(
161 FROM_HERE, run_loop.QuitClosure()); 161 FROM_HERE, run_loop.QuitClosure());
162 run_loop.Run(); 162 run_loop.Run();
163 } 163 }
164 164 /*
165 TEST_F(WatcherTest, NotifyOnMessageLoopDestruction) { 165 TEST_F(WatcherTest, NotifyOnMessageLoopDestruction) {
166 ScopedMessagePipeHandle a, b; 166 ScopedMessagePipeHandle a, b;
167 CreateMessagePipe(nullptr, &a, &b); 167 CreateMessagePipe(nullptr, &a, &b);
168 168
169 bool notified = false; 169 bool notified = false;
170 Watcher b_watcher; 170 Watcher b_watcher;
171 EXPECT_EQ(MOJO_RESULT_OK, 171 EXPECT_EQ(MOJO_RESULT_OK,
172 b_watcher.Start(b.get(), MOJO_HANDLE_SIGNAL_READABLE, 172 b_watcher.Start(b.get(), MOJO_HANDLE_SIGNAL_READABLE,
173 OnReady([&] (MojoResult result) { 173 OnReady([&] (MojoResult result) {
174 EXPECT_EQ(MOJO_RESULT_ABORTED, result); 174 EXPECT_EQ(MOJO_RESULT_ABORTED, result);
175 notified = true; 175 notified = true;
176 }))); 176 })));
177 EXPECT_TRUE(b_watcher.IsWatching()); 177 EXPECT_TRUE(b_watcher.IsWatching());
178 178
179 message_loop_.reset(); 179 message_loop_.reset();
180 180
181 EXPECT_TRUE(notified); 181 EXPECT_TRUE(notified);
182 182
183 EXPECT_TRUE(b_watcher.IsWatching()); 183 EXPECT_TRUE(b_watcher.IsWatching());
184 b_watcher.Cancel(); 184 b_watcher.Cancel();
185 } 185 }
186 186 */
187 TEST_F(WatcherTest, CloseAndCancel) { 187 TEST_F(WatcherTest, CloseAndCancel) {
188 ScopedMessagePipeHandle a, b; 188 ScopedMessagePipeHandle a, b;
189 CreateMessagePipe(nullptr, &a, &b); 189 CreateMessagePipe(nullptr, &a, &b);
190 190
191 Watcher b_watcher; 191 Watcher b_watcher;
192 EXPECT_EQ(MOJO_RESULT_OK, 192 EXPECT_EQ(MOJO_RESULT_OK,
193 b_watcher.Start(b.get(), MOJO_HANDLE_SIGNAL_READABLE, 193 b_watcher.Start(b.get(), MOJO_HANDLE_SIGNAL_READABLE,
194 OnReady([](MojoResult result) { FAIL(); }))); 194 OnReady([](MojoResult result) { FAIL(); })));
195 EXPECT_TRUE(b_watcher.IsWatching()); 195 EXPECT_TRUE(b_watcher.IsWatching());
196 196
197 // This should trigger the watcher above... 197 // This should trigger the watcher above...
198 b.reset(); 198 b.reset();
199 // ...but the watcher is cancelled first. 199 // ...but the watcher is cancelled first.
200 b_watcher.Cancel(); 200 b_watcher.Cancel();
201 201
202 EXPECT_FALSE(b_watcher.IsWatching()); 202 EXPECT_FALSE(b_watcher.IsWatching());
203 203
204 base::RunLoop().RunUntilIdle(); 204 base::RunLoop().RunUntilIdle();
205 } 205 }
206 206
207 } // namespace 207 } // namespace
208 } // namespace mojo 208 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/system/watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698