OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" |
7 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" |
8 #include "build/build_config.h" | 10 #include "build/build_config.h" |
9 #include "mojo/message_pump/message_pump_mojo.h" | 11 #include "mojo/message_pump/message_pump_mojo.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
11 #include "mojo/public/cpp/bindings/interface_ptr.h" | 13 #include "mojo/public/cpp/bindings/interface_ptr.h" |
12 #include "mojo/public/cpp/bindings/string.h" | 14 #include "mojo/public/cpp/bindings/string.h" |
13 #include "mojo/public/cpp/system/message_pipe.h" | 15 #include "mojo/public/cpp/system/message_pipe.h" |
14 #include "mojo/public/cpp/test_support/test_support.h" | 16 #include "mojo/public/cpp/test_support/test_support.h" |
15 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" | 17 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 | 19 |
18 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
19 // | 21 // |
20 // The tests in this file are designed to test the interaction between a | 22 // The tests in this file are designed to test the interaction between a |
21 // Callback and its associated Binding. If a Callback is deleted before | 23 // Callback and its associated Binding. If a Callback is deleted before |
22 // being used we DCHECK fail--unless the associated Binding has already | 24 // being used we DCHECK fail--unless the associated Binding has already |
23 // been closed or deleted. This contract must be explained to the Mojo | 25 // been closed or deleted. This contract must be explained to the Mojo |
24 // application developer. For example it is the developer's responsibility to | 26 // application developer. For example it is the developer's responsibility to |
25 // ensure that the Binding is destroyed before an unused Callback is destroyed. | 27 // ensure that the Binding is destroyed before an unused Callback is destroyed. |
26 // | 28 // |
27 /////////////////////////////////////////////////////////////////////////////// | 29 /////////////////////////////////////////////////////////////////////////////// |
28 | 30 |
29 namespace mojo { | 31 namespace mojo { |
30 namespace test { | 32 namespace test { |
31 namespace { | 33 namespace { |
32 | 34 |
33 // A Runnable object that saves the last value it sees via the | 35 // A Runnable object that saves the last value it sees via the |
34 // provided int32_t*. Used on the client side. | 36 // provided int32_t*. Used on the client side. |
35 class ValueSaver { | 37 class ValueSaver { |
36 public: | 38 public: |
37 explicit ValueSaver(int32_t* last_value_seen) | 39 ValueSaver(int32_t* last_value_seen, const base::Closure& closure) |
38 : last_value_seen_(last_value_seen) {} | 40 : last_value_seen_(last_value_seen), closure_(closure) {} |
39 void Run(int32_t x) const { *last_value_seen_ = x; } | 41 void Run(int32_t x) const { |
| 42 *last_value_seen_ = x; |
| 43 if (!closure_.is_null()) { |
| 44 closure_.Run(); |
| 45 closure_.Reset(); |
| 46 } |
| 47 } |
40 | 48 |
41 private: | 49 private: |
42 int32_t* const last_value_seen_; | 50 int32_t* const last_value_seen_; |
| 51 mutable base::Closure closure_; |
43 }; | 52 }; |
44 | 53 |
45 // An implementation of sample::Provider used on the server side. | 54 // An implementation of sample::Provider used on the server side. |
46 // It only implements one of the methods: EchoInt(). | 55 // It only implements one of the methods: EchoInt(). |
47 // All it does is save the values and Callbacks it sees. | 56 // All it does is save the values and Callbacks it sees. |
48 class InterfaceImpl : public sample::Provider { | 57 class InterfaceImpl : public sample::Provider { |
49 public: | 58 public: |
50 InterfaceImpl() | 59 InterfaceImpl() |
51 : last_server_value_seen_(0), | 60 : last_server_value_seen_(0), |
52 callback_saved_(new Callback<void(int32_t)>()) {} | 61 callback_saved_(new Callback<void(int32_t)>()) {} |
(...skipping 19 matching lines...) Expand all Loading... |
72 delete callback_saved_; | 81 delete callback_saved_; |
73 callback_saved_ = nullptr; | 82 callback_saved_ = nullptr; |
74 } | 83 } |
75 | 84 |
76 // sample::Provider implementation | 85 // sample::Provider implementation |
77 | 86 |
78 // Saves its two input values in member variables and does nothing else. | 87 // Saves its two input values in member variables and does nothing else. |
79 void EchoInt(int32_t x, const Callback<void(int32_t)>& callback) override { | 88 void EchoInt(int32_t x, const Callback<void(int32_t)>& callback) override { |
80 last_server_value_seen_ = x; | 89 last_server_value_seen_ = x; |
81 *callback_saved_ = callback; | 90 *callback_saved_ = callback; |
| 91 if (!closure_.is_null()) { |
| 92 closure_.Run(); |
| 93 closure_.Reset(); |
| 94 } |
82 } | 95 } |
83 | 96 |
84 void EchoString(const String& a, | 97 void EchoString(const String& a, |
85 const Callback<void(String)>& callback) override { | 98 const Callback<void(String)>& callback) override { |
86 MOJO_CHECK(false) << "Not implemented."; | 99 MOJO_CHECK(false) << "Not implemented."; |
87 } | 100 } |
88 | 101 |
89 void EchoStrings(const String& a, | 102 void EchoStrings(const String& a, |
90 const String& b, | 103 const String& b, |
91 const Callback<void(String, String)>& callback) override { | 104 const Callback<void(String, String)>& callback) override { |
92 MOJO_CHECK(false) << "Not implemented."; | 105 MOJO_CHECK(false) << "Not implemented."; |
93 } | 106 } |
94 | 107 |
95 void EchoMessagePipeHandle( | 108 void EchoMessagePipeHandle( |
96 ScopedMessagePipeHandle a, | 109 ScopedMessagePipeHandle a, |
97 const Callback<void(ScopedMessagePipeHandle)>& callback) override { | 110 const Callback<void(ScopedMessagePipeHandle)>& callback) override { |
98 MOJO_CHECK(false) << "Not implemented."; | 111 MOJO_CHECK(false) << "Not implemented."; |
99 } | 112 } |
100 | 113 |
101 void EchoEnum(sample::Enum a, | 114 void EchoEnum(sample::Enum a, |
102 const Callback<void(sample::Enum)>& callback) override { | 115 const Callback<void(sample::Enum)>& callback) override { |
103 MOJO_CHECK(false) << "Not implemented."; | 116 MOJO_CHECK(false) << "Not implemented."; |
104 } | 117 } |
105 | 118 |
106 void resetLastServerValueSeen() { last_server_value_seen_ = 0; } | 119 void resetLastServerValueSeen() { last_server_value_seen_ = 0; } |
107 | 120 |
108 int32_t last_server_value_seen() const { return last_server_value_seen_; } | 121 int32_t last_server_value_seen() const { return last_server_value_seen_; } |
109 | 122 |
| 123 void set_closure(const base::Closure& closure) { closure_ = closure; } |
| 124 |
110 private: | 125 private: |
111 int32_t last_server_value_seen_; | 126 int32_t last_server_value_seen_; |
112 Callback<void(int32_t)>* callback_saved_; | 127 Callback<void(int32_t)>* callback_saved_; |
| 128 base::Closure closure_; |
113 }; | 129 }; |
114 | 130 |
115 class BindingCallbackTest : public testing::Test { | 131 class BindingCallbackTest : public testing::Test { |
116 public: | 132 public: |
117 BindingCallbackTest() : loop_(common::MessagePumpMojo::Create()) {} | 133 BindingCallbackTest() : loop_(common::MessagePumpMojo::Create()) {} |
118 ~BindingCallbackTest() override {} | 134 ~BindingCallbackTest() override {} |
119 | 135 |
120 protected: | 136 protected: |
121 int32_t last_client_callback_value_seen_; | 137 int32_t last_client_callback_value_seen_; |
122 sample::ProviderPtr interface_ptr_; | 138 sample::ProviderPtr interface_ptr_; |
123 | 139 |
124 void PumpMessages() { loop_.RunUntilIdle(); } | 140 void PumpMessages() { loop_.RunUntilIdle(); } |
125 | 141 |
126 private: | 142 private: |
127 base::MessageLoop loop_; | 143 base::MessageLoop loop_; |
128 }; | 144 }; |
129 | 145 |
130 // Tests that the InterfacePtr and the Binding can communicate with each | 146 // Tests that the InterfacePtr and the Binding can communicate with each |
131 // other normally. | 147 // other normally. |
132 TEST_F(BindingCallbackTest, Basic) { | 148 TEST_F(BindingCallbackTest, Basic) { |
133 // Create the ServerImpl and the Binding. | 149 // Create the ServerImpl and the Binding. |
134 InterfaceImpl server_impl; | 150 InterfaceImpl server_impl; |
135 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); | 151 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); |
136 | 152 |
137 // Initialize the test values. | 153 // Initialize the test values. |
138 server_impl.resetLastServerValueSeen(); | 154 server_impl.resetLastServerValueSeen(); |
139 last_client_callback_value_seen_ = 0; | 155 last_client_callback_value_seen_ = 0; |
140 | 156 |
141 // Invoke the Echo method. | 157 // Invoke the Echo method. |
142 interface_ptr_->EchoInt(7, ValueSaver(&last_client_callback_value_seen_)); | 158 base::RunLoop run_loop, run_loop2; |
143 PumpMessages(); | 159 server_impl.set_closure(run_loop.QuitClosure()); |
| 160 interface_ptr_->EchoInt( |
| 161 7, |
| 162 ValueSaver(&last_client_callback_value_seen_, run_loop2.QuitClosure())); |
| 163 run_loop.Run(); |
144 | 164 |
145 // Check that server saw the correct value, but the client has not yet. | 165 // Check that server saw the correct value, but the client has not yet. |
146 EXPECT_EQ(7, server_impl.last_server_value_seen()); | 166 EXPECT_EQ(7, server_impl.last_server_value_seen()); |
147 EXPECT_EQ(0, last_client_callback_value_seen_); | 167 EXPECT_EQ(0, last_client_callback_value_seen_); |
148 | 168 |
149 // Now run the Callback. | 169 // Now run the Callback. |
150 server_impl.RunCallback(); | 170 server_impl.RunCallback(); |
151 PumpMessages(); | 171 run_loop2.Run(); |
152 | 172 |
153 // Check that the client has now seen the correct value. | 173 // Check that the client has now seen the correct value. |
154 EXPECT_EQ(7, last_client_callback_value_seen_); | 174 EXPECT_EQ(7, last_client_callback_value_seen_); |
155 | 175 |
156 // Initialize the test values again. | 176 // Initialize the test values again. |
157 server_impl.resetLastServerValueSeen(); | 177 server_impl.resetLastServerValueSeen(); |
158 last_client_callback_value_seen_ = 0; | 178 last_client_callback_value_seen_ = 0; |
159 | 179 |
160 // Invoke the Echo method again. | 180 // Invoke the Echo method again. |
161 interface_ptr_->EchoInt(13, ValueSaver(&last_client_callback_value_seen_)); | 181 base::RunLoop run_loop3, run_loop4; |
162 PumpMessages(); | 182 server_impl.set_closure(run_loop3.QuitClosure()); |
| 183 interface_ptr_->EchoInt( |
| 184 13, |
| 185 ValueSaver(&last_client_callback_value_seen_, run_loop4.QuitClosure())); |
| 186 run_loop3.Run(); |
163 | 187 |
164 // Check that server saw the correct value, but the client has not yet. | 188 // Check that server saw the correct value, but the client has not yet. |
165 EXPECT_EQ(13, server_impl.last_server_value_seen()); | 189 EXPECT_EQ(13, server_impl.last_server_value_seen()); |
166 EXPECT_EQ(0, last_client_callback_value_seen_); | 190 EXPECT_EQ(0, last_client_callback_value_seen_); |
167 | 191 |
168 // Now run the Callback again. | 192 // Now run the Callback again. |
169 server_impl.RunCallback(); | 193 server_impl.RunCallback(); |
170 PumpMessages(); | 194 run_loop4.Run(); |
171 | 195 |
172 // Check that the client has now seen the correct value again. | 196 // Check that the client has now seen the correct value again. |
173 EXPECT_EQ(13, last_client_callback_value_seen_); | 197 EXPECT_EQ(13, last_client_callback_value_seen_); |
174 } | 198 } |
175 | 199 |
176 // Tests that running the Callback after the Binding has been deleted | 200 // Tests that running the Callback after the Binding has been deleted |
177 // results in a clean failure. | 201 // results in a clean failure. |
178 TEST_F(BindingCallbackTest, DeleteBindingThenRunCallback) { | 202 TEST_F(BindingCallbackTest, DeleteBindingThenRunCallback) { |
179 // Create the ServerImpl. | 203 // Create the ServerImpl. |
180 InterfaceImpl server_impl; | 204 InterfaceImpl server_impl; |
| 205 base::RunLoop run_loop; |
181 { | 206 { |
182 // Create the binding in an inner scope so it can be deleted first. | 207 // Create the binding in an inner scope so it can be deleted first. |
183 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); | 208 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); |
| 209 interface_ptr_.set_connection_error_handler(run_loop.QuitClosure()); |
184 | 210 |
185 // Initialize the test values. | 211 // Initialize the test values. |
186 server_impl.resetLastServerValueSeen(); | 212 server_impl.resetLastServerValueSeen(); |
187 last_client_callback_value_seen_ = 0; | 213 last_client_callback_value_seen_ = 0; |
188 | 214 |
189 // Invoke the Echo method. | 215 // Invoke the Echo method. |
190 interface_ptr_->EchoInt(7, ValueSaver(&last_client_callback_value_seen_)); | 216 base::RunLoop run_loop2; |
191 PumpMessages(); | 217 server_impl.set_closure(run_loop2.QuitClosure()); |
| 218 interface_ptr_->EchoInt( |
| 219 7, |
| 220 ValueSaver(&last_client_callback_value_seen_, base::Closure())); |
| 221 run_loop2.Run(); |
192 } | 222 } |
193 // The binding has now been destroyed and the pipe is closed. | 223 // The binding has now been destroyed and the pipe is closed. |
194 | 224 |
195 // Check that server saw the correct value, but the client has not yet. | 225 // Check that server saw the correct value, but the client has not yet. |
196 EXPECT_EQ(7, server_impl.last_server_value_seen()); | 226 EXPECT_EQ(7, server_impl.last_server_value_seen()); |
197 EXPECT_EQ(0, last_client_callback_value_seen_); | 227 EXPECT_EQ(0, last_client_callback_value_seen_); |
198 | 228 |
199 // Now try to run the Callback. This should do nothing since the pipe | 229 // Now try to run the Callback. This should do nothing since the pipe |
200 // is closed. | 230 // is closed. |
201 EXPECT_TRUE(server_impl.RunCallback()); | 231 EXPECT_TRUE(server_impl.RunCallback()); |
202 PumpMessages(); | 232 PumpMessages(); |
203 | 233 |
204 // Check that the client has still not seen the correct value. | 234 // Check that the client has still not seen the correct value. |
205 EXPECT_EQ(0, last_client_callback_value_seen_); | 235 EXPECT_EQ(0, last_client_callback_value_seen_); |
206 | 236 |
207 // Attempt to invoke the method again and confirm that an error was | 237 // Attempt to invoke the method again and confirm that an error was |
208 // encountered. | 238 // encountered. |
209 interface_ptr_->EchoInt(13, ValueSaver(&last_client_callback_value_seen_)); | 239 interface_ptr_->EchoInt( |
210 PumpMessages(); | 240 13, |
| 241 ValueSaver(&last_client_callback_value_seen_, base::Closure())); |
| 242 run_loop.Run(); |
211 EXPECT_TRUE(interface_ptr_.encountered_error()); | 243 EXPECT_TRUE(interface_ptr_.encountered_error()); |
212 } | 244 } |
213 | 245 |
214 // Tests that deleting a Callback without running it after the corresponding | 246 // Tests that deleting a Callback without running it after the corresponding |
215 // binding has already been deleted does not result in a crash. | 247 // binding has already been deleted does not result in a crash. |
216 TEST_F(BindingCallbackTest, DeleteBindingThenDeleteCallback) { | 248 TEST_F(BindingCallbackTest, DeleteBindingThenDeleteCallback) { |
217 // Create the ServerImpl. | 249 // Create the ServerImpl. |
218 InterfaceImpl server_impl; | 250 InterfaceImpl server_impl; |
219 { | 251 { |
220 // Create the binding in an inner scope so it can be deleted first. | 252 // Create the binding in an inner scope so it can be deleted first. |
221 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); | 253 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); |
222 | 254 |
223 // Initialize the test values. | 255 // Initialize the test values. |
224 server_impl.resetLastServerValueSeen(); | 256 server_impl.resetLastServerValueSeen(); |
225 last_client_callback_value_seen_ = 0; | 257 last_client_callback_value_seen_ = 0; |
226 | 258 |
227 // Invoke the Echo method. | 259 // Invoke the Echo method. |
228 interface_ptr_->EchoInt(7, ValueSaver(&last_client_callback_value_seen_)); | 260 base::RunLoop run_loop; |
229 PumpMessages(); | 261 server_impl.set_closure(run_loop.QuitClosure()); |
| 262 interface_ptr_->EchoInt( |
| 263 7, |
| 264 ValueSaver(&last_client_callback_value_seen_, base::Closure())); |
| 265 run_loop.Run(); |
230 } | 266 } |
231 // The binding has now been destroyed and the pipe is closed. | 267 // The binding has now been destroyed and the pipe is closed. |
232 | 268 |
233 // Check that server saw the correct value, but the client has not yet. | 269 // Check that server saw the correct value, but the client has not yet. |
234 EXPECT_EQ(7, server_impl.last_server_value_seen()); | 270 EXPECT_EQ(7, server_impl.last_server_value_seen()); |
235 EXPECT_EQ(0, last_client_callback_value_seen_); | 271 EXPECT_EQ(0, last_client_callback_value_seen_); |
236 | 272 |
237 // Delete the callback without running it. This should not | 273 // Delete the callback without running it. This should not |
238 // cause a problem because the insfrastructure can detect that the | 274 // cause a problem because the insfrastructure can detect that the |
239 // binding has already been destroyed and the pipe is closed. | 275 // binding has already been destroyed and the pipe is closed. |
240 server_impl.DeleteCallback(); | 276 server_impl.DeleteCallback(); |
241 } | 277 } |
242 | 278 |
243 // Tests that closing a Binding allows us to delete a callback | 279 // Tests that closing a Binding allows us to delete a callback |
244 // without running it without encountering a crash. | 280 // without running it without encountering a crash. |
245 TEST_F(BindingCallbackTest, CloseBindingBeforeDeletingCallback) { | 281 TEST_F(BindingCallbackTest, CloseBindingBeforeDeletingCallback) { |
246 // Create the ServerImpl and the Binding. | 282 // Create the ServerImpl and the Binding. |
247 InterfaceImpl server_impl; | 283 InterfaceImpl server_impl; |
248 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); | 284 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); |
249 | 285 |
250 // Initialize the test values. | 286 // Initialize the test values. |
251 server_impl.resetLastServerValueSeen(); | 287 server_impl.resetLastServerValueSeen(); |
252 last_client_callback_value_seen_ = 0; | 288 last_client_callback_value_seen_ = 0; |
253 | 289 |
254 // Invoke the Echo method. | 290 // Invoke the Echo method. |
255 interface_ptr_->EchoInt(7, ValueSaver(&last_client_callback_value_seen_)); | 291 base::RunLoop run_loop; |
256 PumpMessages(); | 292 server_impl.set_closure(run_loop.QuitClosure()); |
| 293 interface_ptr_->EchoInt( |
| 294 7, |
| 295 ValueSaver(&last_client_callback_value_seen_, base::Closure())); |
| 296 run_loop.Run(); |
257 | 297 |
258 // Check that server saw the correct value, but the client has not yet. | 298 // Check that server saw the correct value, but the client has not yet. |
259 EXPECT_EQ(7, server_impl.last_server_value_seen()); | 299 EXPECT_EQ(7, server_impl.last_server_value_seen()); |
260 EXPECT_EQ(0, last_client_callback_value_seen_); | 300 EXPECT_EQ(0, last_client_callback_value_seen_); |
261 | 301 |
262 // Now close the Binding. | 302 // Now close the Binding. |
263 binding.Close(); | 303 binding.Close(); |
264 | 304 |
265 // Delete the callback without running it. This should not | 305 // Delete the callback without running it. This should not |
266 // cause a crash because the insfrastructure can detect that the | 306 // cause a crash because the insfrastructure can detect that the |
267 // binding has already been closed. | 307 // binding has already been closed. |
268 server_impl.DeleteCallback(); | 308 server_impl.DeleteCallback(); |
269 | 309 |
270 // Check that the client has still not seen the correct value. | 310 // Check that the client has still not seen the correct value. |
271 EXPECT_EQ(0, last_client_callback_value_seen_); | 311 EXPECT_EQ(0, last_client_callback_value_seen_); |
272 } | 312 } |
273 | 313 |
274 // Tests that deleting a Callback without using it before the | 314 // Tests that deleting a Callback without using it before the |
275 // Binding has been destroyed or closed results in a DCHECK. | 315 // Binding has been destroyed or closed results in a DCHECK. |
276 TEST_F(BindingCallbackTest, DeleteCallbackBeforeBindingDeathTest) { | 316 TEST_F(BindingCallbackTest, DeleteCallbackBeforeBindingDeathTest) { |
277 // Create the ServerImpl and the Binding. | 317 // Create the ServerImpl and the Binding. |
278 InterfaceImpl server_impl; | 318 InterfaceImpl server_impl; |
279 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); | 319 Binding<sample::Provider> binding(&server_impl, GetProxy(&interface_ptr_)); |
280 | 320 |
281 // Initialize the test values. | 321 // Initialize the test values. |
282 server_impl.resetLastServerValueSeen(); | 322 server_impl.resetLastServerValueSeen(); |
283 last_client_callback_value_seen_ = 0; | 323 last_client_callback_value_seen_ = 0; |
284 | 324 |
285 // Invoke the Echo method. | 325 // Invoke the Echo method. |
286 interface_ptr_->EchoInt(7, ValueSaver(&last_client_callback_value_seen_)); | 326 base::RunLoop run_loop; |
287 PumpMessages(); | 327 server_impl.set_closure(run_loop.QuitClosure()); |
| 328 interface_ptr_->EchoInt( |
| 329 7, |
| 330 ValueSaver(&last_client_callback_value_seen_, base::Closure())); |
| 331 run_loop.Run(); |
288 | 332 |
289 // Check that server saw the correct value, but the client has not yet. | 333 // Check that server saw the correct value, but the client has not yet. |
290 EXPECT_EQ(7, server_impl.last_server_value_seen()); | 334 EXPECT_EQ(7, server_impl.last_server_value_seen()); |
291 EXPECT_EQ(0, last_client_callback_value_seen_); | 335 EXPECT_EQ(0, last_client_callback_value_seen_); |
292 | 336 |
293 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 337 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
294 // Delete the callback without running it. This should cause a crash in debug | 338 // Delete the callback without running it. This should cause a crash in debug |
295 // builds due to a DCHECK. | 339 // builds due to a DCHECK. |
296 std::string regex("Check failed: !callback_was_dropped."); | 340 std::string regex("Check failed: !callback_was_dropped."); |
297 #if defined(OS_WIN) | 341 #if defined(OS_WIN) |
298 // TODO(msw): Fix MOJO_DCHECK logs and EXPECT_DEATH* on Win: crbug.com/535014 | 342 // TODO(msw): Fix MOJO_DCHECK logs and EXPECT_DEATH* on Win: crbug.com/535014 |
299 regex.clear(); | 343 regex.clear(); |
300 #endif // OS_WIN | 344 #endif // OS_WIN |
301 EXPECT_DEATH_IF_SUPPORTED(server_impl.DeleteCallback(), regex.c_str()); | 345 EXPECT_DEATH_IF_SUPPORTED(server_impl.DeleteCallback(), regex.c_str()); |
302 #endif // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 346 #endif // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
303 } | 347 } |
304 | 348 |
305 } // namespace | 349 } // namespace |
306 } // namespace test | 350 } // namespace test |
307 } // namespace mojo | 351 } // namespace mojo |
OLD | NEW |