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

Unified Diff: content/renderer/gpu/compositor_forwarding_message_filter_unittest.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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: content/renderer/gpu/compositor_forwarding_message_filter_unittest.cc
diff --git a/content/renderer/gpu/compositor_forwarding_message_filter_unittest.cc b/content/renderer/gpu/compositor_forwarding_message_filter_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6a21a84b1a6417037bb5dcf8dac1d177f4d9c72d
--- /dev/null
+++ b/content/renderer/gpu/compositor_forwarding_message_filter_unittest.cc
@@ -0,0 +1,81 @@
+// 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 "content/renderer/gpu/compositor_forwarding_message_filter.h"
+
+#include "base/bind.h"
+#include "base/test/test_simple_task_runner.h"
+#include "cc/test/begin_frame_args_test.h"
+#include "content/common/view_messages.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+class CompositorForwardingMessageFilterTestHandler
+ : public base::RefCounted<CompositorForwardingMessageFilterTestHandler> {
+ public:
+ CompositorForwardingMessageFilterTestHandler() : count_(0) {
+ }
+
+ void OnPlusMethod(const IPC::Message& msg) {
+ count_++;
+ }
+
+ void OnMinusMethod(const IPC::Message& msg) {
+ count_--;
+ }
+
+ int count() { return count_; }
+
+ void ResetCount() { count_ = 0; }
+
+ private:
+ friend class base::RefCounted<CompositorForwardingMessageFilterTestHandler>;
+ ~CompositorForwardingMessageFilterTestHandler() {}
+
+ int count_;
+};
+
+TEST(CompositorForwardingMessageFilterTest, BasicTest) {
+ scoped_refptr<CompositorForwardingMessageFilterTestHandler> handler =
+ new CompositorForwardingMessageFilterTestHandler;
+ scoped_refptr<base::TestSimpleTaskRunner> task_runner(
+ new base::TestSimpleTaskRunner);
+ int route_id = 0;
+
+ ViewMsg_BeginFrame msg(route_id, cc::CreateBeginFrameArgsForTesting());
+
+ CompositorForwardingMessageFilter::Handler plus_handler =
+ base::Bind(&CompositorForwardingMessageFilterTestHandler::OnPlusMethod,
+ handler);
+ CompositorForwardingMessageFilter::Handler minus_handler =
+ base::Bind(&CompositorForwardingMessageFilterTestHandler::OnMinusMethod,
+ handler);
+
+ scoped_refptr<CompositorForwardingMessageFilter> filter =
+ new CompositorForwardingMessageFilter(task_runner.get());
+
+ filter->AddHandlerOnCompositorThread(route_id, plus_handler);
+ filter->OnMessageReceived(msg);
+ task_runner->RunPendingTasks();
+ EXPECT_EQ(1, handler->count());
+
+ handler->ResetCount();
+ EXPECT_EQ(0, handler->count());
+
+ filter->AddHandlerOnCompositorThread(route_id, minus_handler);
+ filter->OnMessageReceived(msg);
+ task_runner->RunPendingTasks();
+ EXPECT_EQ(0, handler->count());
+
+ handler->ResetCount();
+ EXPECT_EQ(0, handler->count());
+
+ filter->RemoveHandlerOnCompositorThread(route_id, plus_handler);
+ filter->OnMessageReceived(msg);
+ task_runner->RunPendingTasks();
+ EXPECT_EQ(-1, handler->count());
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/gpu/compositor_forwarding_message_filter.cc ('k') | content/renderer/gpu/compositor_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698