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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/scheduler_proxy_task_runner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/public/browser/content_browser_client.h"
6 #include "content/public/common/content_client.h"
7 #include "content/public/renderer/content_renderer_client.h"
8 #include "content/renderer/render_process_impl.h"
9 #include "content/renderer/render_thread_impl.h"
10 #include "content/renderer/scheduler_proxy_task_runner.h"
11 #include "content/test/mock_render_process.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace content {
15 namespace {
16
17 void TestTask(int value, int* result) {
18 *result = (*result << 4) | value;
19 }
20
21 } // namespace
22
23 class DummyListener : public IPC::Listener {
24 public:
25 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
26 return true;
27 }
28 };
29
30 TEST(SchedulerProxyTaskRunnerBrowserTest, TestTaskPosting) {
31 ContentClient content_client;
32 ContentBrowserClient content_browser_client;
33 ContentRendererClient content_renderer_client;
34 SetContentClient(&content_client);
35 SetBrowserClientForTesting(&content_browser_client);
36 SetRendererClientForTesting(&content_renderer_client);
37 base::MessageLoopForIO message_loop;
38
39 std::string channel_id =
40 IPC::Channel::GenerateVerifiedChannelID(std::string());
41 DummyListener dummy_listener;
42 scoped_ptr<IPC::Channel> channel(
43 IPC::Channel::CreateServer(channel_id, &dummy_listener));
44 EXPECT_TRUE(channel->Connect());
45
46 scoped_ptr<MockRenderProcess> mock_process(new MockRenderProcess);
47 // Owned by mock_process.
48 RenderThreadImpl* thread = new RenderThreadImpl(channel_id);
49 thread->EnsureWebKitInitialized();
50
51 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner =
52 make_scoped_refptr(new SchedulerProxyTaskRunner<
53 &blink::WebSchedulerProxy::postInputTask>());
54 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner =
55 make_scoped_refptr(new SchedulerProxyTaskRunner<
56 &blink::WebSchedulerProxy::postCompositorTask>());
57
58 int input_order = 0;
59 int compositor_order = 0;
60
61 input_task_runner->PostTask(FROM_HERE,
62 base::Bind(&TestTask, 1, &input_order));
63 compositor_task_runner->PostTask(FROM_HERE,
64 base::Bind(&TestTask, 1, &compositor_order));
65 input_task_runner->PostTask(FROM_HERE,
66 base::Bind(&TestTask, 2, &input_order));
67 compositor_task_runner->PostTask(FROM_HERE,
68 base::Bind(&TestTask, 2, &compositor_order));
69
70 input_task_runner->PostTask(FROM_HERE,
71 base::Bind(&TestTask, 3, &input_order));
72 input_task_runner->PostTask(FROM_HERE,
73 base::Bind(&TestTask, 4, &input_order));
74 compositor_task_runner->PostTask(FROM_HERE,
75 base::Bind(&TestTask, 3, &compositor_order));
76 compositor_task_runner->PostTask(FROM_HERE,
77 base::Bind(&TestTask, 4, &compositor_order));
78
79 message_loop.RunUntilIdle();
80
81 EXPECT_EQ(0x1234, input_order);
82 EXPECT_EQ(0x1234, compositor_order);
83 }
84
85 } // namespace content
OLDNEW
« 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