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

Unified Diff: content/renderer/scheduler_proxy_task_runner_browsertest.cc

Issue 363383002: Forward input tasks to the Blink scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only forward input tasks for now. Created 6 years, 3 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 | « content/renderer/scheduler_proxy_task_runner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/scheduler_proxy_task_runner_browsertest.cc
diff --git a/content/renderer/scheduler_proxy_task_runner_browsertest.cc b/content/renderer/scheduler_proxy_task_runner_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d67c54dbd21d13153cf06d1d327a9529a7b89002
--- /dev/null
+++ b/content/renderer/scheduler_proxy_task_runner_browsertest.cc
@@ -0,0 +1,85 @@
+// 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/public/browser/content_browser_client.h"
+#include "content/public/common/content_client.h"
+#include "content/public/renderer/content_renderer_client.h"
+#include "content/renderer/render_process_impl.h"
+#include "content/renderer/render_thread_impl.h"
+#include "content/renderer/scheduler_proxy_task_runner.h"
+#include "content/test/mock_render_process.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+namespace {
+
+void TestTask(int value, int* result) {
+ *result = (*result << 4) | value;
+}
+
+} // namespace
+
+class DummyListener : public IPC::Listener {
+ public:
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
+ return true;
+ }
+};
+
+TEST(SchedulerProxyTaskRunnerBrowserTest, TestTaskPosting) {
+ ContentClient content_client;
+ ContentBrowserClient content_browser_client;
+ ContentRendererClient content_renderer_client;
+ SetContentClient(&content_client);
+ SetBrowserClientForTesting(&content_browser_client);
+ SetRendererClientForTesting(&content_renderer_client);
+ base::MessageLoopForIO message_loop;
+
+ std::string channel_id =
+ IPC::Channel::GenerateVerifiedChannelID(std::string());
+ DummyListener dummy_listener;
+ scoped_ptr<IPC::Channel> channel(
+ IPC::Channel::CreateServer(channel_id, &dummy_listener));
+ EXPECT_TRUE(channel->Connect());
+
+ scoped_ptr<MockRenderProcess> mock_process(new MockRenderProcess);
+ // Owned by mock_process.
+ RenderThreadImpl* thread = new RenderThreadImpl(channel_id);
+ thread->EnsureWebKitInitialized();
+
+ scoped_refptr<base::SingleThreadTaskRunner> input_task_runner =
+ make_scoped_refptr(new SchedulerProxyTaskRunner<
+ &blink::WebSchedulerProxy::postInputTask>());
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner =
+ make_scoped_refptr(new SchedulerProxyTaskRunner<
+ &blink::WebSchedulerProxy::postCompositorTask>());
+
+ int input_order = 0;
+ int compositor_order = 0;
+
+ input_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 1, &input_order));
+ compositor_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 1, &compositor_order));
+ input_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 2, &input_order));
+ compositor_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 2, &compositor_order));
+
+ input_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 3, &input_order));
+ input_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 4, &input_order));
+ compositor_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 3, &compositor_order));
+ compositor_task_runner->PostTask(FROM_HERE,
+ base::Bind(&TestTask, 4, &compositor_order));
+
+ message_loop.RunUntilIdle();
+
+ EXPECT_EQ(0x1234, input_order);
+ EXPECT_EQ(0x1234, compositor_order);
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/scheduler_proxy_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698