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

Unified Diff: media/base/mock_callback.h

Issue 6350001: Replace MockFilterCallback with MockCallback and simplify unit tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: forgot some files Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/composite_filter_unittest.cc ('k') | media/base/mock_callback.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/mock_callback.h
diff --git a/media/base/mock_callback.h b/media/base/mock_callback.h
new file mode 100644
index 0000000000000000000000000000000000000000..5526ee7256cb8af5d07e7a8ee1de3b1a418dc8b7
--- /dev/null
+++ b/media/base/mock_callback.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_MOCK_CALLBACK_H_
+#define MEDIA_BASE_MOCK_CALLBACK_H_
+
+#include "base/callback.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace media {
+
+// Helper class used to test that callbacks are executed.
+//
+// In most cases NewExpectedCallback() can be used but if need be you can
+// manually set expectations on an MockCallback object:
+//
+// StrictMock<MockCallback>* callback =
+// new StrictMock<MockCallback>();
+// EXPECT_CALL(*callback, RunWithParams(_));
+// EXPECT_CALL(*callback, Destructor());
+//
+// ...or if you don't care about verifying callback deletion:
+//
+// NiceMock<MockCallback>* callback =
+// new NiceMock<MockCallback>();
+// EXPECT_CALL(*callback, RunWithParams(_));
+class MockCallback : public CallbackRunner<Tuple0> {
+ public:
+ MockCallback();
+ virtual ~MockCallback();
+
+ MOCK_METHOD1(RunWithParams, void(const Tuple0& params));
+
+ // Can be used to verify the object is destroyed.
+ MOCK_METHOD0(Destructor, void());
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockCallback);
+};
+
+// Convenience function that automatically creates and sets an expectation for
+// the callback to run.
+MockCallback* NewExpectedCallback();
+
+} // namespace media
+
+#endif // MEDIA_BASE_MOCK_CALLBACK_H_
« no previous file with comments | « media/base/composite_filter_unittest.cc ('k') | media/base/mock_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698