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

Unified Diff: remoting/host/mock_callback_unittest.cc

Issue 719983002: Reporting of policy errors via host-offline-reason: part 3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hor-nohoststatussender
Patch Set: Minor tweaks after end-to-end tests and self-review. Created 6 years, 1 month 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
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
+

Powered by Google App Engine
This is Rietveld 408576698