Apache Mesos
gmock.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License
12 
13 #ifndef __PROCESS_GMOCK_HPP__
14 #define __PROCESS_GMOCK_HPP__
15 
16 #include <gmock/gmock.h>
17 
18 #include <process/dispatch.hpp>
19 #include <process/event.hpp>
20 #include <process/filter.hpp>
21 #include <process/pid.hpp>
22 
23 #include <stout/exit.hpp>
24 #include <stout/nothing.hpp>
25 #include <stout/synchronized.hpp>
26 
27 
28 #define FUTURE_MESSAGE(name, from, to) \
29  process::FutureMessage(name, from, to)
30 
31 #define DROP_MESSAGE(name, from, to) \
32  process::FutureMessage(name, from, to, true)
33 
34 
35 // The mechanism of how we match method dispatches is done by
36 // comparing std::type_info of the member function pointers. Because
37 // of this, the method function pointer passed to either
38 // FUTURE_DISPATCH or DROP_DISPATCH must match exactly the member
39 // function that is passed to the dispatch method.
40 // TODO(tnachen): In a situation where a base class has a virtual
41 // function and that a derived class overrides, and if in unit tests
42 // we want to verify it calls the exact derived member function, we
43 // need to change how dispatch matching works. One possible way is to
44 // move the dispatch matching logic at event dequeue time, as we then
45 // have the actual Process the dispatch event is calling to.
46 #define FUTURE_DISPATCH(pid, method) \
47  process::FutureDispatch(pid, method)
48 
49 #define DROP_DISPATCH(pid, method) \
50  process::FutureDispatch(pid, method, true)
51 
52 #define DROP_MESSAGES(name, from, to) \
53  process::DropMessages(name, from, to)
54 
55 #define EXPECT_NO_FUTURE_MESSAGES(name, from, to) \
56  process::ExpectNoFutureMessages(name, from, to)
57 
58 #define DROP_DISPATCHES(pid, method) \
59  process::DropDispatches(pid, method)
60 
61 #define EXPECT_NO_FUTURE_DISPATCHES(pid, method) \
62  process::ExpectNoFutureDispatches(pid, method)
63 
64 
65 #define FUTURE_EXITED(from, to) \
66  process::FutureExited(from, to)
67 
68 #define DROP_EXITED(from, to) \
69  process::FutureExited(from, to, true)
70 
71 
72 ACTION_TEMPLATE(PromiseArg,
73  HAS_1_TEMPLATE_PARAMS(int, k),
74  AND_1_VALUE_PARAMS(promise))
75 {
76  // TODO(benh): Use a shared_ptr for promise to defend against this
77  // action getting invoked more than once (e.g., used via
78  // WillRepeatedly). We won't be able to set it a second time but at
79  // least we won't get a segmentation fault. We could also consider
80  // warning users if they attempted to set it more than once.
81  promise->set(std::get<k>(args));
82  delete promise;
83 }
84 
85 
86 template <int index, typename T>
87 PromiseArgActionP<index, process::Promise<T>*> FutureArg(
88  process::Future<T>* future)
89 {
91  *future = promise->future();
92  return PromiseArg<index>(promise);
93 }
94 
95 
96 ACTION_TEMPLATE(PromiseArgField,
97  HAS_1_TEMPLATE_PARAMS(int, k),
98  AND_2_VALUE_PARAMS(field, promise))
99 {
100  // TODO(benh): Use a shared_ptr for promise to defend against this
101  // action getting invoked more than once (e.g., used via
102  // WillRepeatedly). We won't be able to set it a second time but at
103  // least we won't get a segmentation fault. We could also consider
104  // warning users if they attempted to set it more than once.
105  promise->set(*(std::get<k>(args).*field));
106  delete promise;
107 }
108 
109 
110 template <int index, typename Field, typename T>
111 PromiseArgFieldActionP2<index, Field, process::Promise<T>*> FutureArgField(
112  Field field,
113  process::Future<T>* future)
114 {
116  *future = promise->future();
117  return PromiseArgField<index>(field, promise);
118 }
119 
120 
121 ACTION_TEMPLATE(PromiseArgNotPointerField,
122  HAS_1_TEMPLATE_PARAMS(int, k),
123  AND_2_VALUE_PARAMS(field, promise))
124 {
125  // TODO(benh): Use a shared_ptr for promise to defend against this
126  // action getting invoked more than once (e.g., used via
127  // WillRepeatedly). We won't be able to set it a second time but at
128  // least we won't get a segmentation fault. We could also consider
129  // warning users if they attempted to set it more than once.
130  promise->set(std::get<k>(args).*field);
131  delete promise;
132 }
133 
134 
135 template <int index, typename Field, typename T>
136 PromiseArgNotPointerFieldActionP2<index, Field, process::Promise<T>*>
138  Field field,
139  process::Future<T>* future)
140 {
142  *future = promise->future();
143  return PromiseArgNotPointerField<index>(field, promise);
144 }
145 
146 
147 ACTION_P2(PromiseSatisfy, promise, value)
148 {
149  promise->set(value);
150  delete promise;
151 }
152 
153 
154 template <typename T>
155 PromiseSatisfyActionP2<process::Promise<T>*, T> FutureSatisfy(
156  process::Future<T>* future,
157  T t)
158 {
160  *future = promise->future();
161  return PromiseSatisfy(promise, t);
162 }
163 
164 
165 inline PromiseSatisfyActionP2<process::Promise<Nothing>*, Nothing>
167 {
169  *future = promise->future();
170  return PromiseSatisfy(promise, Nothing());
171 }
172 
173 
174 // This action invokes an "inner" action but captures the result and
175 // stores a copy of it in a future. Note that this is implemented
176 // similarly to the IgnoreResult action, which relies on the cast
177 // operator to Action<F> which must occur (implicitly) before the
178 // expression has completed, hence we can pass the Future<R>* all the
179 // way through to our action "implementation".
180 template <typename R, typename A>
182 {
183 public:
184  explicit FutureResultAction(process::Future<R>* future, const A& action)
185  : future(future),
186  action(action) {}
187 
188  template <typename F>
189  operator ::testing::Action<F>() const
190  {
191  return ::testing::Action<F>(new Implementation<F>(future, action));
192  }
193 
194 private:
195  template <typename F>
196  class Implementation : public ::testing::ActionInterface<F>
197  {
198  public:
199  explicit Implementation(process::Future<R>* future, const A& action)
200  : action(action)
201  {
202  *future = promise.future();
203  }
204 
205  typename ::testing::ActionInterface<F>::Result Perform(
206  const typename ::testing::ActionInterface<F>::ArgumentTuple& args)
207  override
208  {
209  const typename ::testing::ActionInterface<F>::Result result =
210  action.Perform(args);
211  promise.set(result);
212  return result;
213  }
214 
215  private:
216  // Not copyable, not assignable.
217  Implementation(const Implementation&);
218  Implementation& operator=(const Implementation&);
219 
221  const ::testing::Action<F> action;
222  };
223 
224  process::Future<R>* future;
225  const A action;
226 };
227 
228 
229 template <typename R, typename A>
231  process::Future<R>* future,
232  const A& action)
233 {
234  return FutureResultAction<R, A>(future, action);
235 }
236 
237 
238 namespace process {
239 
240 class MockFilter : public Filter
241 {
242 public:
244  {
245  EXPECT_CALL(*this, filter(
246  testing::A<const UPID&>(),
247  testing::A<const MessageEvent&>()))
248  .WillRepeatedly(testing::Return(false));
249  EXPECT_CALL(*this, filter(
250  testing::A<const UPID&>(),
251  testing::A<const DispatchEvent&>()))
252  .WillRepeatedly(testing::Return(false));
253  EXPECT_CALL(*this, filter(
254  testing::A<const UPID&>(),
255  testing::A<const HttpEvent&>()))
256  .WillRepeatedly(testing::Return(false));
257  EXPECT_CALL(*this, filter(
258  testing::A<const UPID&>(),
259  testing::A<const ExitedEvent&>()))
260  .WillRepeatedly(testing::Return(false));
261  }
262 
263  MOCK_METHOD2(filter, bool(const UPID& process, const MessageEvent&));
264  MOCK_METHOD2(filter, bool(const UPID& process, const DispatchEvent&));
265  MOCK_METHOD2(filter, bool(const UPID& process, const HttpEvent&));
266  MOCK_METHOD2(filter, bool(const UPID& process, const ExitedEvent&));
267 };
268 
269 
270 // A definition of a libprocess filter to enable waiting for events
271 // (such as messages or dispatches) via in tests. This is not meant to
272 // be used directly by tests; tests should use macros like
273 // FUTURE_MESSAGE and FUTURE_DISPATCH instead.
274 class TestsFilter : public Filter
275 {
276 public:
277  TestsFilter() = default;
278 
279  bool filter(const UPID& process, const MessageEvent& event) override
280  {
281  return handle(process, event);
282  }
283  bool filter(const UPID& process, const DispatchEvent& event) override
284  {
285  return handle(process, event);
286  }
287  bool filter(const UPID& process, const HttpEvent& event) override
288  {
289  return handle(process, event);
290  }
291  bool filter(const UPID& process, const ExitedEvent& event) override
292  {
293  return handle(process, event);
294  }
295 
296  template <typename T>
297  bool handle(const UPID& process, const T& t)
298  {
299  synchronized (mutex) {
300  return mock.filter(process, t);
301  }
302  }
303 
305 
306  // We use a recursive mutex here in the event that satisfying the
307  // future created in FutureMessage or FutureDispatch via the
308  // FutureArgField or FutureSatisfy actions invokes callbacks (from
309  // Future::then or Future::onAny, etc) that themselves invoke
310  // FutureDispatch or FutureMessage.
311  std::recursive_mutex mutex;
312 };
313 
314 
315 class FilterTestEventListener : public ::testing::EmptyTestEventListener
316 {
317 public:
318  // Returns the singleton instance of the listener.
320  {
321  static FilterTestEventListener* listener = new FilterTestEventListener();
322  return listener;
323  }
324 
325  // Installs and returns the filter, creating it if necessary.
327  {
328  if (!started) {
329  EXIT(EXIT_FAILURE)
330  << "To use FUTURE/DROP_MESSAGE/DISPATCH, etc. you need to do the "
331  << "following before you invoke RUN_ALL_TESTS():\n\n"
332  << "\t::testing::TestEventListeners& listeners =\n"
333  << "\t ::testing::UnitTest::GetInstance()->listeners();\n"
334  << "\tlisteners.Append(process::FilterTestEventListener::instance());";
335  }
336 
337  if (filter != nullptr) {
338  return filter;
339  }
340 
341  filter = new TestsFilter();
342 
343  // Set the filter in libprocess.
345 
346  return filter;
347  }
348 
349  void OnTestProgramStart(const ::testing::UnitTest&) override
350  {
351  started = true;
352  }
353 
354  void OnTestEnd(const ::testing::TestInfo&) override
355  {
356  if (filter != nullptr) {
357  // Remove the filter in libprocess _before_ deleting.
358  process::filter(nullptr);
359  delete filter;
360  filter = nullptr;
361  }
362  }
363 
364 private:
365  FilterTestEventListener() : filter(nullptr), started(false) {}
366 
368 
369  // Indicates if we got the OnTestProgramStart callback in order to
370  // detect if we have been properly added as a listener.
371  bool started;
372 };
373 
374 
375 MATCHER_P2(MessageMatcher, name, from, "")
376 {
377  const MessageEvent& event = ::std::get<1>(arg);
378  return (testing::Matcher<std::string>(name).Matches(event.message.name) &&
379  testing::Matcher<UPID>(from).Matches(event.message.from));
380 }
381 
382 
383 // This matches protobuf messages that are described using the
384 // standard protocol buffer "union" trick, see:
385 // https://developers.google.com/protocol-buffers/docs/techniques#union.
386 MATCHER_P3(UnionMessageMatcher, message, unionType, from, "")
387 {
388  const process::MessageEvent& event = ::std::get<1>(arg);
389  message_type message;
390 
391  return (testing::Matcher<std::string>(message.GetTypeName()).Matches(
392  event.message.name) &&
393  message.ParseFromString(event.message.body) &&
394  testing::Matcher<unionType_type>(unionType).Matches(message.type()) &&
395  testing::Matcher<process::UPID>(from).Matches(event.message.from));
396 }
397 
398 
399 MATCHER_P(DispatchMatcher, method, "")
400 {
401  const DispatchEvent& event = ::std::get<1>(arg);
402  return (event.functionType.isSome() &&
403  *event.functionType.get() == typeid(method));
404 }
405 
406 
407 MATCHER_P(ExitedMatcher, from, "")
408 {
409  const ExitedEvent& event = ::std::get<1>(arg);
410  return testing::Matcher<process::UPID>(from).Matches(event.pid);
411 }
412 
413 
414 MATCHER_P3(HttpMatcher, message, path, deserializer, "")
415 {
416  const HttpEvent& event = ::std::get<1>(arg);
417 
418  Try<message_type> message_ = deserializer(event.request->body);
419  if (message_.isError()) {
420  return false;
421  }
422 
423  return (testing::Matcher<std::string>(path).Matches(event.request->url.path));
424 }
425 
426 
427 // See `UnionMessageMatcher` for more details on protobuf messages using the
428 // "union" trick.
429 MATCHER_P4(UnionHttpMatcher, message, unionType, path, deserializer, "")
430 {
431  const HttpEvent& event = ::std::get<1>(arg);
432 
433  Try<message_type> message_ = deserializer(event.request->body);
434  if (message_.isError()) {
435  return false;
436  }
437 
438  return (
439  testing::Matcher<unionType_type>(unionType).Matches(message_->type()) &&
440  testing::Matcher<std::string>(path).Matches(event.request->url.path));
441 }
442 
443 
444 template <typename Message, typename Path, typename Deserializer>
446  Message message,
447  Path path,
448  Deserializer deserializer,
449  bool drop = false)
450 {
451  TestsFilter* filter = FilterTestEventListener::instance()->install();
452  Future<http::Request> future;
453  synchronized (filter->mutex) {
454  EXPECT_CALL(filter->mock, filter(
455  testing::A<const UPID&>(),
456  testing::A<const HttpEvent&>()))
457  .With(HttpMatcher(message, path, deserializer))
458  .WillOnce(testing::DoAll(FutureArgField<1>(
460  &future),
461  testing::Return(drop)))
462  .RetiresOnSaturation(); // Don't impose any subsequent expectations.
463  }
464 
465  return future;
466 }
467 
468 
469 template <typename Message,
470  typename UnionType,
471  typename Path,
472  typename Deserializer>
474  Message message,
475  UnionType unionType,
476  Path path,
477  Deserializer deserializer,
478  bool drop = false)
479 {
480  TestsFilter* filter = FilterTestEventListener::instance()->install();
481  Future<http::Request> future;
482  synchronized (filter->mutex) {
483  EXPECT_CALL(filter->mock, filter(
484  testing::A<const UPID&>(),
485  testing::A<const HttpEvent&>()))
486  .With(UnionHttpMatcher(message, unionType, path, deserializer))
487  .WillOnce(testing::DoAll(FutureArgField<1>(
489  &future),
490  testing::Return(drop)))
491  .RetiresOnSaturation(); // Don't impose any subsequent expectations.
492  }
493 
494  return future;
495 }
496 
497 
498 template <typename Name, typename From, typename To>
499 Future<Message> FutureMessage(Name name, From from, To to, bool drop = false)
500 {
501  TestsFilter* filter = FilterTestEventListener::instance()->install();
502  Future<Message> future;
503  synchronized (filter->mutex) {
504  EXPECT_CALL(filter->mock, filter(to, testing::A<const MessageEvent&>()))
505  .With(MessageMatcher(name, from))
506  .WillOnce(testing::DoAll(FutureArgNotPointerField<1>(
507  &MessageEvent::message,
508  &future),
509  testing::Return(drop)))
510  .RetiresOnSaturation(); // Don't impose any subsequent expectations.
511  }
512 
513  return future;
514 }
515 
516 
517 template <typename Message, typename UnionType, typename From, typename To>
519  Message message, UnionType unionType, From from, To to, bool drop = false)
520 {
522  FilterTestEventListener::instance()->install();
523 
525  synchronized (filter->mutex) {
526  EXPECT_CALL(filter->mock, filter(to, testing::A<const MessageEvent&>()))
527  .With(UnionMessageMatcher(message, unionType, from))
528  .WillOnce(testing::DoAll(FutureArgNotPointerField<1>(
529  &MessageEvent::message,
530  &future),
531  testing::Return(drop)))
532  .RetiresOnSaturation(); // Don't impose any subsequent expectations.
533  }
534 
535  return future;
536 }
537 
538 
539 template <typename PID, typename Method>
540 Future<Nothing> FutureDispatch(PID pid, Method method, bool drop = false)
541 {
542  TestsFilter* filter = FilterTestEventListener::instance()->install();
543  Future<Nothing> future;
544  synchronized (filter->mutex) {
545  EXPECT_CALL(filter->mock, filter(pid, testing::A<const DispatchEvent&>()))
546  .With(DispatchMatcher(method))
547  .WillOnce(testing::DoAll(FutureSatisfy(&future),
548  testing::Return(drop)))
549  .RetiresOnSaturation(); // Don't impose any subsequent expectations.
550  }
551 
552  return future;
553 }
554 
555 
556 template <typename Name, typename From, typename To>
557 void DropMessages(Name name, From from, To to)
558 {
559  TestsFilter* filter = FilterTestEventListener::instance()->install();
560  synchronized (filter->mutex) {
561  EXPECT_CALL(filter->mock, filter(to, testing::A<const MessageEvent&>()))
562  .With(MessageMatcher(name, from))
563  .WillRepeatedly(testing::Return(true));
564  }
565 }
566 
567 
568 template <typename Message, typename UnionType, typename From, typename To>
569 void DropUnionMessages(Message message, UnionType unionType, From from, To to)
570 {
571  TestsFilter* filter = FilterTestEventListener::instance()->install();
572  synchronized (filter->mutex) {
573  EXPECT_CALL(filter->mock, filter(to, testing::A<const MessageEvent&>()))
574  .With(UnionMessageMatcher(message, unionType, from))
575  .WillRepeatedly(testing::Return(true));
576  }
577 }
578 
579 
580 template <typename Message, typename Path, typename Deserializer>
582  Message message,
583  Path path,
584  Deserializer deserializer,
585  bool drop = false)
586 {
587  TestsFilter* filter = FilterTestEventListener::instance()->install();
588  synchronized (filter->mutex) {
589  EXPECT_CALL(filter->mock, filter(
590  testing::A<const UPID&>(),
591  testing::A<const HttpEvent&>()))
592  .With(HttpMatcher(message, path, deserializer))
593  .WillRepeatedly(testing::Return(true));
594  }
595 }
596 
597 
598 template <typename Message,
599  typename UnionType,
600  typename Path,
601  typename Deserializer>
603  Message message,
604  UnionType unionType,
605  Path path,
606  Deserializer deserializer,
607  bool drop = false)
608 {
609  TestsFilter* filter = FilterTestEventListener::instance()->install();
610  Future<http::Request> future;
611  synchronized (filter->mutex) {
612  EXPECT_CALL(filter->mock, filter(
613  testing::A<const UPID&>(),
614  testing::A<const HttpEvent&>()))
615  .With(UnionHttpMatcher(message, unionType, path, deserializer))
616  .WillRepeatedly(testing::Return(true));
617  }
618 }
619 
620 
621 template <typename Message, typename Path, typename Deserializer>
623  Message message,
624  Path path,
625  Deserializer deserializer,
626  bool drop = false)
627 {
628  TestsFilter* filter = FilterTestEventListener::instance()->install();
629  synchronized (filter->mutex) {
630  EXPECT_CALL(filter->mock, filter(
631  testing::A<const UPID&>(),
632  testing::A<const HttpEvent&>()))
633  .With(HttpMatcher(message, path, deserializer))
634  .Times(0);
635  }
636 }
637 
638 
639 template <typename Message,
640  typename UnionType,
641  typename Path,
642  typename Deserializer>
644  Message message,
645  UnionType unionType,
646  Path path,
647  Deserializer deserializer,
648  bool drop = false)
649 {
650  TestsFilter* filter = FilterTestEventListener::instance()->install();
651  Future<http::Request> future;
652  synchronized (filter->mutex) {
653  EXPECT_CALL(filter->mock, filter(
654  testing::A<const UPID&>(),
655  testing::A<const HttpEvent&>()))
656  .With(UnionHttpMatcher(message, unionType, path, deserializer))
657  .Times(0);
658  }
659 }
660 
661 
662 template <typename Name, typename From, typename To>
663 void ExpectNoFutureMessages(Name name, From from, To to)
664 {
665  TestsFilter* filter = FilterTestEventListener::instance()->install();
666  synchronized (filter->mutex) {
667  EXPECT_CALL(filter->mock, filter(to, testing::A<const MessageEvent&>()))
668  .With(MessageMatcher(name, from))
669  .Times(0);
670  }
671 }
672 
673 
674 template <typename Message, typename UnionType, typename From, typename To>
676  Message message, UnionType unionType, From from, To to)
677 {
678  TestsFilter* filter = FilterTestEventListener::instance()->install();
679  synchronized (filter->mutex) {
680  EXPECT_CALL(filter->mock, filter(to, testing::A<const MessageEvent&>()))
681  .With(UnionMessageMatcher(message, unionType, from))
682  .Times(0);
683  }
684 }
685 
686 
687 template <typename PID, typename Method>
688 void DropDispatches(PID pid, Method method)
689 {
690  TestsFilter* filter = FilterTestEventListener::instance()->install();
691  synchronized (filter->mutex) {
692  EXPECT_CALL(filter->mock, filter(pid, testing::A<const DispatchEvent&>()))
693  .With(DispatchMatcher(method))
694  .WillRepeatedly(testing::Return(true));
695  }
696 }
697 
698 
699 template <typename PID, typename Method>
700 void ExpectNoFutureDispatches(PID pid, Method method)
701 {
702  TestsFilter* filter = FilterTestEventListener::instance()->install();
703  synchronized (filter->mutex) {
704  EXPECT_CALL(filter->mock, filter(pid, testing::A<const DispatchEvent&>()))
705  .With(DispatchMatcher(method))
706  .Times(0);
707  }
708 }
709 
710 
711 template <typename From, typename To>
712 Future<Nothing> FutureExited(From from, To to, bool drop = false)
713 {
714  TestsFilter* filter = FilterTestEventListener::instance()->install();
715  Future<Nothing> future;
716  synchronized (filter->mutex) {
717  EXPECT_CALL(filter->mock, filter(to, testing::A<const ExitedEvent&>()))
718  .With(ExitedMatcher(from))
719  .WillOnce(testing::DoAll(FutureSatisfy(&future),
720  testing::Return(drop)))
721  .RetiresOnSaturation(); // Don't impose any subsequent expectations.
722  }
723 
724  return future;
725 }
726 
727 } // namespace process {
728 
729 #endif // __PROCESS_GMOCK_HPP__
Definition: filter.hpp:20
Definition: path.hpp:29
Future< process::Message > FutureUnionMessage(Message message, UnionType unionType, From from, To to, bool drop=false)
Definition: gmock.hpp:518
MATCHER_P2(MessageMatcher, name, from,"")
Definition: gmock.hpp:375
Definition: nothing.hpp:16
PromiseArgActionP< index, process::Promise< T > * > FutureArg(process::Future< T > *future)
Definition: gmock.hpp:87
Definition: gmock.hpp:181
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
FutureResultAction(process::Future< R > *future, const A &action)
Definition: gmock.hpp:184
MATCHER_P3(HttpMatcher, message, path, deserializer,"")
Definition: gmock.hpp:414
Definition: check.hpp:33
MATCHER_P4(UnionHttpMatcher, message, unionType, path, deserializer,"")
Definition: gmock.hpp:429
void OnTestEnd(const ::testing::TestInfo &) override
Definition: gmock.hpp:354
Definition: event.hpp:142
void ExpectNoFutureUnionMessages(Message message, UnionType unionType, From from, To to)
Definition: gmock.hpp:675
Definition: message.hpp:22
PromiseSatisfyActionP2< process::Promise< T > *, T > FutureSatisfy(process::Future< T > *future, T t)
Definition: gmock.hpp:155
Future< Nothing > FutureExited(From from, To to, bool drop=false)
Definition: gmock.hpp:712
Definition: event.hpp:178
#define EXIT(status)
Definition: exit.hpp:31
void DropUnionHttpRequests(Message message, UnionType unionType, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:602
MockFilter mock
Definition: gmock.hpp:304
Definition: event.hpp:209
Future< Nothing > FutureDispatch(PID pid, Method method, bool drop=false)
Definition: gmock.hpp:540
PromiseArgNotPointerFieldActionP2< index, Field, process::Promise< T > * > FutureArgNotPointerField(Field field, process::Future< T > *future)
Definition: gmock.hpp:137
void DropHttpRequests(Message message, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:581
ACTION_P2(PromiseSatisfy, promise, value)
Definition: gmock.hpp:147
PromiseArgFieldActionP2< index, Field, process::Promise< T > * > FutureArgField(Field field, process::Future< T > *future)
Definition: gmock.hpp:111
MATCHER_P(ExitedMatcher, from,"")
Definition: gmock.hpp:407
void DropUnionMessages(Message message, UnionType unionType, From from, To to)
Definition: gmock.hpp:569
An "untyped" PID, used to encapsulate the process ID for lower-layer abstractions (eg...
Definition: pid.hpp:39
TestsFilter * install()
Definition: gmock.hpp:326
MockFilter()
Definition: gmock.hpp:243
bool filter(const UPID &process, const DispatchEvent &event) override
Definition: gmock.hpp:283
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:212
Definition: future.hpp:74
void OnTestProgramStart(const ::testing::UnitTest &) override
Definition: gmock.hpp:349
void DropDispatches(PID pid, Method method)
Definition: gmock.hpp:688
Protocol< PromiseRequest, PromiseResponse > promise
std::recursive_mutex mutex
Definition: gmock.hpp:311
Future< Message > FutureMessage(Name name, From from, To to, bool drop=false)
Definition: gmock.hpp:499
FutureResultAction< R, A > FutureResult(process::Future< R > *future, const A &action)
Definition: gmock.hpp:230
void ExpectNoFutureUnionHttpRequests(Message message, UnionType unionType, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:643
A "process identifier" used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:289
void ExpectNoFutureMessages(Name name, From from, To to)
Definition: gmock.hpp:663
Definition: executor.hpp:48
static FilterTestEventListener * instance()
Definition: gmock.hpp:319
Future< T > future() const
Definition: future.hpp:913
Future< http::Request > FutureUnionHttpRequest(Message message, UnionType unionType, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:473
Definition: event.hpp:103
bool filter(const UPID &process, const MessageEvent &event) override
Definition: gmock.hpp:279
bool filter(const UPID &process, const HttpEvent &event) override
Definition: gmock.hpp:287
Definition: gmock.hpp:240
Definition: gmock.hpp:315
void ExpectNoFutureDispatches(PID pid, Method method)
Definition: gmock.hpp:700
bool filter(const UPID &process, const ExitedEvent &event) override
Definition: gmock.hpp:291
Definition: gmock.hpp:274
ACTION_TEMPLATE(PromiseArg, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(promise))
Definition: gmock.hpp:72
void ExpectNoFutureHttpRequests(Message message, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:622
Future< http::Request > FutureHttpRequest(Message message, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:445
constexpr const char * name
Definition: shell.hpp:41
bool handle(const UPID &process, const T &t)
Definition: gmock.hpp:297
void filter(Filter *filter)
void DropMessages(Name name, From from, To to)
Definition: gmock.hpp:557
Definition: future.hpp:58