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

Side by Side Diff: content/renderer/scheduler_proxy_task_runner_browsertest.cc

Issue 640803003: scheduler: Remove use of WebSchedulerProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
« 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> compositor_task_runner =
52 thread->main_thread_compositor_task_runner();
53
54 EXPECT_TRUE(compositor_task_runner->BelongsToCurrentThread());
55
56 int compositor_order = 0;
57 compositor_task_runner->PostTask(FROM_HERE,
58 base::Bind(&TestTask, 1, &compositor_order));
59 compositor_task_runner->PostTask(FROM_HERE,
60 base::Bind(&TestTask, 2, &compositor_order));
61 compositor_task_runner->PostTask(FROM_HERE,
62 base::Bind(&TestTask, 3, &compositor_order));
63 compositor_task_runner->PostTask(FROM_HERE,
64 base::Bind(&TestTask, 4, &compositor_order));
65
66 message_loop.RunUntilIdle();
67
68 EXPECT_EQ(0x1234, compositor_order);
69 }
70
71 } // 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