Index: remoting/host/mock_callback_unittest.cc |
diff --git a/remoting/host/mock_callback_unittest.cc b/remoting/host/mock_callback_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..faad909a3f455dce87ad6e2535ede0e1c8a490a6 |
--- /dev/null |
+++ b/remoting/host/mock_callback_unittest.cc |
@@ -0,0 +1,40 @@ |
+// Copyright 2014 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. |
+ |
+#include "remoting/host/mock_callback.h" |
+ |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest-spi.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace remoting { |
+ |
+TEST(MockCallbackTest, SimpleExampleFromHeader) { |
+ EXPECT_NONFATAL_FAILURE({ |
+ MockCallback<void(int)> mock_callback; |
+ EXPECT_CALL(mock_callback, Run(123)).Times(2); |
+ base::Callback<void(int)> callback = mock_callback.GetCallback(); |
+ |
+ callback.Run(123); |
+ callback.Run(123); |
+ callback.Run(123); // Called too many times. |
+ }, |
+ "Mock function called more times than expected"); |
+} |
+ |
+TEST(MockCallbackTest, HasRemainingCallbacks) { |
+ MockCallback<int()> mock_callback; |
+ EXPECT_CALL(mock_callback, Run()).WillOnce(testing::Return(123)); |
+ |
+ { |
+ base::Callback<int()> callback = mock_callback.GetCallback(); |
+ EXPECT_TRUE(mock_callback.HasRemainingCallbacks()); |
+ EXPECT_EQ(123, callback.Run()); |
+ } |
+ |
+ EXPECT_FALSE(mock_callback.HasRemainingCallbacks()); |
+} |
+ |
+} // namespace remoting |
+ |